IPA ICF: add no_icf attribute.
[official-gcc.git] / gcc / doc / extend.texi
blobba921e914bdbf729450e6006dd929e134c78c2a1
1 @c Copyright (C) 1988-2015 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Label Attributes::    Specifying attributes on labels.
60 * Attribute Syntax::    Formal syntax for attributes.
61 * Function Prototypes:: Prototype declarations and old-style definitions.
62 * C++ Comments::        C++ comments are recognized.
63 * Dollar Signs::        Dollar sign is allowed in identifiers.
64 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
65 * Variable Attributes:: Specifying attributes of variables.
66 * Type Attributes::     Specifying attributes of types.
67 * Alignment::           Inquiring about the alignment of a type or variable.
68 * Inline::              Defining inline functions (as fast as macros).
69 * Volatiles::           What constitutes an access to a volatile object.
70 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
71 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
72 * Incomplete Enums::    @code{enum foo;}, with details to follow.
73 * Function Names::      Printable strings which are the name of the current
74                         function.
75 * Return Address::      Getting the return or frame address of a function.
76 * Vector Extensions::   Using vector instructions through built-in functions.
77 * Offsetof::            Special syntax for implementing @code{offsetof}.
78 * __sync Builtins::     Legacy built-in functions for atomic memory access.
79 * __atomic Builtins::   Atomic built-in functions with memory model.
80 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
81                         arithmetic overflow checking.
82 * x86 specific memory model extensions for transactional memory:: x86 memory models.
83 * Object Size Checking:: Built-in functions for limited buffer overflow
84                         checking.
85 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
86 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
87 * Other Builtins::      Other built-in functions.
88 * Target Builtins::     Built-in functions specific to particular targets.
89 * Target Format Checks:: Format checks specific to particular targets.
90 * Pragmas::             Pragmas accepted by GCC.
91 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
92 * Thread-Local::        Per-thread variables.
93 * Binary constants::    Binary constants using the @samp{0b} prefix.
94 @end menu
96 @node Statement Exprs
97 @section Statements and Declarations in Expressions
98 @cindex statements inside expressions
99 @cindex declarations inside expressions
100 @cindex expressions containing statements
101 @cindex macros, statements in expressions
103 @c the above section title wrapped and causes an underfull hbox.. i
104 @c changed it from "within" to "in". --mew 4feb93
105 A compound statement enclosed in parentheses may appear as an expression
106 in GNU C@.  This allows you to use loops, switches, and local variables
107 within an expression.
109 Recall that a compound statement is a sequence of statements surrounded
110 by braces; in this construct, parentheses go around the braces.  For
111 example:
113 @smallexample
114 (@{ int y = foo (); int z;
115    if (y > 0) z = y;
116    else z = - y;
117    z; @})
118 @end smallexample
120 @noindent
121 is a valid (though slightly more complex than necessary) expression
122 for the absolute value of @code{foo ()}.
124 The last thing in the compound statement should be an expression
125 followed by a semicolon; the value of this subexpression serves as the
126 value of the entire construct.  (If you use some other kind of statement
127 last within the braces, the construct has type @code{void}, and thus
128 effectively no value.)
130 This feature is especially useful in making macro definitions ``safe'' (so
131 that they evaluate each operand exactly once).  For example, the
132 ``maximum'' function is commonly defined as a macro in standard C as
133 follows:
135 @smallexample
136 #define max(a,b) ((a) > (b) ? (a) : (b))
137 @end smallexample
139 @noindent
140 @cindex side effects, macro argument
141 But this definition computes either @var{a} or @var{b} twice, with bad
142 results if the operand has side effects.  In GNU C, if you know the
143 type of the operands (here taken as @code{int}), you can define
144 the macro safely as follows:
146 @smallexample
147 #define maxint(a,b) \
148   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
149 @end smallexample
151 Embedded statements are not allowed in constant expressions, such as
152 the value of an enumeration constant, the width of a bit-field, or
153 the initial value of a static variable.
155 If you don't know the type of the operand, you can still do this, but you
156 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158 In G++, the result value of a statement expression undergoes array and
159 function pointer decay, and is returned by value to the enclosing
160 expression.  For instance, if @code{A} is a class, then
162 @smallexample
163         A a;
165         (@{a;@}).Foo ()
166 @end smallexample
168 @noindent
169 constructs a temporary @code{A} object to hold the result of the
170 statement expression, and that is used to invoke @code{Foo}.
171 Therefore the @code{this} pointer observed by @code{Foo} is not the
172 address of @code{a}.
174 In a statement expression, any temporaries created within a statement
175 are destroyed at that statement's end.  This makes statement
176 expressions inside macros slightly different from function calls.  In
177 the latter case temporaries introduced during argument evaluation are
178 destroyed at the end of the statement that includes the function
179 call.  In the statement expression case they are destroyed during
180 the statement expression.  For instance,
182 @smallexample
183 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
184 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186 void foo ()
188   macro (X ());
189   function (X ());
191 @end smallexample
193 @noindent
194 has different places where temporaries are destroyed.  For the
195 @code{macro} case, the temporary @code{X} is destroyed just after
196 the initialization of @code{b}.  In the @code{function} case that
197 temporary is destroyed when the function returns.
199 These considerations mean that it is probably a bad idea to use
200 statement expressions of this form in header files that are designed to
201 work with C++.  (Note that some versions of the GNU C Library contained
202 header files using statement expressions that lead to precisely this
203 bug.)
205 Jumping into a statement expression with @code{goto} or using a
206 @code{switch} statement outside the statement expression with a
207 @code{case} or @code{default} label inside the statement expression is
208 not permitted.  Jumping into a statement expression with a computed
209 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
210 Jumping out of a statement expression is permitted, but if the
211 statement expression is part of a larger expression then it is
212 unspecified which other subexpressions of that expression have been
213 evaluated except where the language definition requires certain
214 subexpressions to be evaluated before or after the statement
215 expression.  In any case, as with a function call, the evaluation of a
216 statement expression is not interleaved with the evaluation of other
217 parts of the containing expression.  For example,
219 @smallexample
220   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
221 @end smallexample
223 @noindent
224 calls @code{foo} and @code{bar1} and does not call @code{baz} but
225 may or may not call @code{bar2}.  If @code{bar2} is called, it is
226 called after @code{foo} and before @code{bar1}.
228 @node Local Labels
229 @section Locally Declared Labels
230 @cindex local labels
231 @cindex macros, local labels
233 GCC allows you to declare @dfn{local labels} in any nested block
234 scope.  A local label is just like an ordinary label, but you can
235 only reference it (with a @code{goto} statement, or by taking its
236 address) within the block in which it is declared.
238 A local label declaration looks like this:
240 @smallexample
241 __label__ @var{label};
242 @end smallexample
244 @noindent
247 @smallexample
248 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
249 @end smallexample
251 Local label declarations must come at the beginning of the block,
252 before any ordinary declarations or statements.
254 The label declaration defines the label @emph{name}, but does not define
255 the label itself.  You must do this in the usual way, with
256 @code{@var{label}:}, within the statements of the statement expression.
258 The local label feature is useful for complex macros.  If a macro
259 contains nested loops, a @code{goto} can be useful for breaking out of
260 them.  However, an ordinary label whose scope is the whole function
261 cannot be used: if the macro can be expanded several times in one
262 function, the label is multiply defined in that function.  A
263 local label avoids this problem.  For example:
265 @smallexample
266 #define SEARCH(value, array, target)              \
267 do @{                                              \
268   __label__ found;                                \
269   typeof (target) _SEARCH_target = (target);      \
270   typeof (*(array)) *_SEARCH_array = (array);     \
271   int i, j;                                       \
272   int value;                                      \
273   for (i = 0; i < max; i++)                       \
274     for (j = 0; j < max; j++)                     \
275       if (_SEARCH_array[i][j] == _SEARCH_target)  \
276         @{ (value) = i; goto found; @}              \
277   (value) = -1;                                   \
278  found:;                                          \
279 @} while (0)
280 @end smallexample
282 This could also be written using a statement expression:
284 @smallexample
285 #define SEARCH(array, target)                     \
286 (@{                                                \
287   __label__ found;                                \
288   typeof (target) _SEARCH_target = (target);      \
289   typeof (*(array)) *_SEARCH_array = (array);     \
290   int i, j;                                       \
291   int value;                                      \
292   for (i = 0; i < max; i++)                       \
293     for (j = 0; j < max; j++)                     \
294       if (_SEARCH_array[i][j] == _SEARCH_target)  \
295         @{ value = i; goto found; @}                \
296   value = -1;                                     \
297  found:                                           \
298   value;                                          \
300 @end smallexample
302 Local label declarations also make the labels they declare visible to
303 nested functions, if there are any.  @xref{Nested Functions}, for details.
305 @node Labels as Values
306 @section Labels as Values
307 @cindex labels as values
308 @cindex computed gotos
309 @cindex goto with computed label
310 @cindex address of a label
312 You can get the address of a label defined in the current function
313 (or a containing function) with the unary operator @samp{&&}.  The
314 value has type @code{void *}.  This value is a constant and can be used
315 wherever a constant of that type is valid.  For example:
317 @smallexample
318 void *ptr;
319 /* @r{@dots{}} */
320 ptr = &&foo;
321 @end smallexample
323 To use these values, you need to be able to jump to one.  This is done
324 with the computed goto statement@footnote{The analogous feature in
325 Fortran is called an assigned goto, but that name seems inappropriate in
326 C, where one can do more than simply store label addresses in label
327 variables.}, @code{goto *@var{exp};}.  For example,
329 @smallexample
330 goto *ptr;
331 @end smallexample
333 @noindent
334 Any expression of type @code{void *} is allowed.
336 One way of using these constants is in initializing a static array that
337 serves as a jump table:
339 @smallexample
340 static void *array[] = @{ &&foo, &&bar, &&hack @};
341 @end smallexample
343 @noindent
344 Then you can select a label with indexing, like this:
346 @smallexample
347 goto *array[i];
348 @end smallexample
350 @noindent
351 Note that this does not check whether the subscript is in bounds---array
352 indexing in C never does that.
354 Such an array of label values serves a purpose much like that of the
355 @code{switch} statement.  The @code{switch} statement is cleaner, so
356 use that rather than an array unless the problem does not fit a
357 @code{switch} statement very well.
359 Another use of label values is in an interpreter for threaded code.
360 The labels within the interpreter function can be stored in the
361 threaded code for super-fast dispatching.
363 You may not use this mechanism to jump to code in a different function.
364 If you do that, totally unpredictable things happen.  The best way to
365 avoid this is to store the label address only in automatic variables and
366 never pass it as an argument.
368 An alternate way to write the above example is
370 @smallexample
371 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
372                              &&hack - &&foo @};
373 goto *(&&foo + array[i]);
374 @end smallexample
376 @noindent
377 This is more friendly to code living in shared libraries, as it reduces
378 the number of dynamic relocations that are needed, and by consequence,
379 allows the data to be read-only.
380 This alternative with label differences is not supported for the AVR target,
381 please use the first approach for AVR programs.
383 The @code{&&foo} expressions for the same label might have different
384 values if the containing function is inlined or cloned.  If a program
385 relies on them being always the same,
386 @code{__attribute__((__noinline__,__noclone__))} should be used to
387 prevent inlining and cloning.  If @code{&&foo} is used in a static
388 variable initializer, inlining and cloning is forbidden.
390 @node Nested Functions
391 @section Nested Functions
392 @cindex nested functions
393 @cindex downward funargs
394 @cindex thunks
396 A @dfn{nested function} is a function defined inside another function.
397 Nested functions are supported as an extension in GNU C, but are not
398 supported by GNU C++.
400 The nested function's name is local to the block where it is defined.
401 For example, here we define a nested function named @code{square}, and
402 call it twice:
404 @smallexample
405 @group
406 foo (double a, double b)
408   double square (double z) @{ return z * z; @}
410   return square (a) + square (b);
412 @end group
413 @end smallexample
415 The nested function can access all the variables of the containing
416 function that are visible at the point of its definition.  This is
417 called @dfn{lexical scoping}.  For example, here we show a nested
418 function which uses an inherited variable named @code{offset}:
420 @smallexample
421 @group
422 bar (int *array, int offset, int size)
424   int access (int *array, int index)
425     @{ return array[index + offset]; @}
426   int i;
427   /* @r{@dots{}} */
428   for (i = 0; i < size; i++)
429     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @end group
432 @end smallexample
434 Nested function definitions are permitted within functions in the places
435 where variable definitions are allowed; that is, in any block, mixed
436 with the other declarations and statements in the block.
438 It is possible to call the nested function from outside the scope of its
439 name by storing its address or passing the address to another function:
441 @smallexample
442 hack (int *array, int size)
444   void store (int index, int value)
445     @{ array[index] = value; @}
447   intermediate (store, size);
449 @end smallexample
451 Here, the function @code{intermediate} receives the address of
452 @code{store} as an argument.  If @code{intermediate} calls @code{store},
453 the arguments given to @code{store} are used to store into @code{array}.
454 But this technique works only so long as the containing function
455 (@code{hack}, in this example) does not exit.
457 If you try to call the nested function through its address after the
458 containing function exits, all hell breaks loose.  If you try
459 to call it after a containing scope level exits, and if it refers
460 to some of the variables that are no longer in scope, you may be lucky,
461 but it's not wise to take the risk.  If, however, the nested function
462 does not refer to anything that has gone out of scope, you should be
463 safe.
465 GCC implements taking the address of a nested function using a technique
466 called @dfn{trampolines}.  This technique was described in
467 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
468 C++ Conference Proceedings, October 17-21, 1988).
470 A nested function can jump to a label inherited from a containing
471 function, provided the label is explicitly declared in the containing
472 function (@pxref{Local Labels}).  Such a jump returns instantly to the
473 containing function, exiting the nested function that did the
474 @code{goto} and any intermediate functions as well.  Here is an example:
476 @smallexample
477 @group
478 bar (int *array, int offset, int size)
480   __label__ failure;
481   int access (int *array, int index)
482     @{
483       if (index > size)
484         goto failure;
485       return array[index + offset];
486     @}
487   int i;
488   /* @r{@dots{}} */
489   for (i = 0; i < size; i++)
490     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
491   /* @r{@dots{}} */
492   return 0;
494  /* @r{Control comes here from @code{access}
495     if it detects an error.}  */
496  failure:
497   return -1;
499 @end group
500 @end smallexample
502 A nested function always has no linkage.  Declaring one with
503 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
504 before its definition, use @code{auto} (which is otherwise meaningless
505 for function declarations).
507 @smallexample
508 bar (int *array, int offset, int size)
510   __label__ failure;
511   auto int access (int *, int);
512   /* @r{@dots{}} */
513   int access (int *array, int index)
514     @{
515       if (index > size)
516         goto failure;
517       return array[index + offset];
518     @}
519   /* @r{@dots{}} */
521 @end smallexample
523 @node Constructing Calls
524 @section Constructing Function Calls
525 @cindex constructing calls
526 @cindex forwarding calls
528 Using the built-in functions described below, you can record
529 the arguments a function received, and call another function
530 with the same arguments, without knowing the number or types
531 of the arguments.
533 You can also record the return value of that function call,
534 and later return that value, without knowing what data type
535 the function tried to return (as long as your caller expects
536 that data type).
538 However, these built-in functions may interact badly with some
539 sophisticated features or other extensions of the language.  It
540 is, therefore, not recommended to use them outside very simple
541 functions acting as mere forwarders for their arguments.
543 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
544 This built-in function returns a pointer to data
545 describing how to perform a call with the same arguments as are passed
546 to the current function.
548 The function saves the arg pointer register, structure value address,
549 and all registers that might be used to pass arguments to a function
550 into a block of memory allocated on the stack.  Then it returns the
551 address of that block.
552 @end deftypefn
554 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
555 This built-in function invokes @var{function}
556 with a copy of the parameters described by @var{arguments}
557 and @var{size}.
559 The value of @var{arguments} should be the value returned by
560 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
561 of the stack argument data, in bytes.
563 This function returns a pointer to data describing
564 how to return whatever value is returned by @var{function}.  The data
565 is saved in a block of memory allocated on the stack.
567 It is not always simple to compute the proper value for @var{size}.  The
568 value is used by @code{__builtin_apply} to compute the amount of data
569 that should be pushed on the stack and copied from the incoming argument
570 area.
571 @end deftypefn
573 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
574 This built-in function returns the value described by @var{result} from
575 the containing function.  You should specify, for @var{result}, a value
576 returned by @code{__builtin_apply}.
577 @end deftypefn
579 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
580 This built-in function represents all anonymous arguments of an inline
581 function.  It can be used only in inline functions that are always
582 inlined, never compiled as a separate function, such as those using
583 @code{__attribute__ ((__always_inline__))} or
584 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
585 It must be only passed as last argument to some other function
586 with variable arguments.  This is useful for writing small wrapper
587 inlines for variable argument functions, when using preprocessor
588 macros is undesirable.  For example:
589 @smallexample
590 extern int myprintf (FILE *f, const char *format, ...);
591 extern inline __attribute__ ((__gnu_inline__)) int
592 myprintf (FILE *f, const char *format, ...)
594   int r = fprintf (f, "myprintf: ");
595   if (r < 0)
596     return r;
597   int s = fprintf (f, format, __builtin_va_arg_pack ());
598   if (s < 0)
599     return s;
600   return r + s;
602 @end smallexample
603 @end deftypefn
605 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
606 This built-in function returns the number of anonymous arguments of
607 an inline function.  It can be used only in inline functions that
608 are always inlined, never compiled as a separate function, such
609 as those using @code{__attribute__ ((__always_inline__))} or
610 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
611 For example following does link- or run-time checking of open
612 arguments for optimized code:
613 @smallexample
614 #ifdef __OPTIMIZE__
615 extern inline __attribute__((__gnu_inline__)) int
616 myopen (const char *path, int oflag, ...)
618   if (__builtin_va_arg_pack_len () > 1)
619     warn_open_too_many_arguments ();
621   if (__builtin_constant_p (oflag))
622     @{
623       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
624         @{
625           warn_open_missing_mode ();
626           return __open_2 (path, oflag);
627         @}
628       return open (path, oflag, __builtin_va_arg_pack ());
629     @}
631   if (__builtin_va_arg_pack_len () < 1)
632     return __open_2 (path, oflag);
634   return open (path, oflag, __builtin_va_arg_pack ());
636 #endif
637 @end smallexample
638 @end deftypefn
640 @node Typeof
641 @section Referring to a Type with @code{typeof}
642 @findex typeof
643 @findex sizeof
644 @cindex macros, types of arguments
646 Another way to refer to the type of an expression is with @code{typeof}.
647 The syntax of using of this keyword looks like @code{sizeof}, but the
648 construct acts semantically like a type name defined with @code{typedef}.
650 There are two ways of writing the argument to @code{typeof}: with an
651 expression or with a type.  Here is an example with an expression:
653 @smallexample
654 typeof (x[0](1))
655 @end smallexample
657 @noindent
658 This assumes that @code{x} is an array of pointers to functions;
659 the type described is that of the values of the functions.
661 Here is an example with a typename as the argument:
663 @smallexample
664 typeof (int *)
665 @end smallexample
667 @noindent
668 Here the type described is that of pointers to @code{int}.
670 If you are writing a header file that must work when included in ISO C
671 programs, write @code{__typeof__} instead of @code{typeof}.
672 @xref{Alternate Keywords}.
674 A @code{typeof} construct can be used anywhere a typedef name can be
675 used.  For example, you can use it in a declaration, in a cast, or inside
676 of @code{sizeof} or @code{typeof}.
678 The operand of @code{typeof} is evaluated for its side effects if and
679 only if it is an expression of variably modified type or the name of
680 such a type.
682 @code{typeof} is often useful in conjunction with
683 statement expressions (@pxref{Statement Exprs}).
684 Here is how the two together can
685 be used to define a safe ``maximum'' macro which operates on any
686 arithmetic type and evaluates each of its arguments exactly once:
688 @smallexample
689 #define max(a,b) \
690   (@{ typeof (a) _a = (a); \
691       typeof (b) _b = (b); \
692     _a > _b ? _a : _b; @})
693 @end smallexample
695 @cindex underscores in variables in macros
696 @cindex @samp{_} in variables in macros
697 @cindex local variables in macros
698 @cindex variables, local, in macros
699 @cindex macros, local variables in
701 The reason for using names that start with underscores for the local
702 variables is to avoid conflicts with variable names that occur within the
703 expressions that are substituted for @code{a} and @code{b}.  Eventually we
704 hope to design a new form of declaration syntax that allows you to declare
705 variables whose scopes start only after their initializers; this will be a
706 more reliable way to prevent such conflicts.
708 @noindent
709 Some more examples of the use of @code{typeof}:
711 @itemize @bullet
712 @item
713 This declares @code{y} with the type of what @code{x} points to.
715 @smallexample
716 typeof (*x) y;
717 @end smallexample
719 @item
720 This declares @code{y} as an array of such values.
722 @smallexample
723 typeof (*x) y[4];
724 @end smallexample
726 @item
727 This declares @code{y} as an array of pointers to characters:
729 @smallexample
730 typeof (typeof (char *)[4]) y;
731 @end smallexample
733 @noindent
734 It is equivalent to the following traditional C declaration:
736 @smallexample
737 char *y[4];
738 @end smallexample
740 To see the meaning of the declaration using @code{typeof}, and why it
741 might be a useful way to write, rewrite it with these macros:
743 @smallexample
744 #define pointer(T)  typeof(T *)
745 #define array(T, N) typeof(T [N])
746 @end smallexample
748 @noindent
749 Now the declaration can be rewritten this way:
751 @smallexample
752 array (pointer (char), 4) y;
753 @end smallexample
755 @noindent
756 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
757 pointers to @code{char}.
758 @end itemize
760 In GNU C, but not GNU C++, you may also declare the type of a variable
761 as @code{__auto_type}.  In that case, the declaration must declare
762 only one variable, whose declarator must just be an identifier, the
763 declaration must be initialized, and the type of the variable is
764 determined by the initializer; the name of the variable is not in
765 scope until after the initializer.  (In C++, you should use C++11
766 @code{auto} for this purpose.)  Using @code{__auto_type}, the
767 ``maximum'' macro above could be written as:
769 @smallexample
770 #define max(a,b) \
771   (@{ __auto_type _a = (a); \
772       __auto_type _b = (b); \
773     _a > _b ? _a : _b; @})
774 @end smallexample
776 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778 @itemize @bullet
779 @item Each argument to the macro appears only once in the expansion of
780 the macro.  This prevents the size of the macro expansion growing
781 exponentially when calls to such macros are nested inside arguments of
782 such macros.
784 @item If the argument to the macro has variably modified type, it is
785 evaluated only once when using @code{__auto_type}, but twice if
786 @code{typeof} is used.
787 @end itemize
789 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
790 a more limited extension that permitted one to write
792 @smallexample
793 typedef @var{T} = @var{expr};
794 @end smallexample
796 @noindent
797 with the effect of declaring @var{T} to have the type of the expression
798 @var{expr}.  This extension does not work with GCC 3 (versions between
799 3.0 and 3.2 crash; 3.2.1 and later give an error).  Code that
800 relies on it should be rewritten to use @code{typeof}:
802 @smallexample
803 typedef typeof(@var{expr}) @var{T};
804 @end smallexample
806 @noindent
807 This works with all versions of GCC@.
809 @node Conditionals
810 @section Conditionals with Omitted Operands
811 @cindex conditional expressions, extensions
812 @cindex omitted middle-operands
813 @cindex middle-operands, omitted
814 @cindex extensions, @code{?:}
815 @cindex @code{?:} extensions
817 The middle operand in a conditional expression may be omitted.  Then
818 if the first operand is nonzero, its value is the value of the conditional
819 expression.
821 Therefore, the expression
823 @smallexample
824 x ? : y
825 @end smallexample
827 @noindent
828 has the value of @code{x} if that is nonzero; otherwise, the value of
829 @code{y}.
831 This example is perfectly equivalent to
833 @smallexample
834 x ? x : y
835 @end smallexample
837 @cindex side effect in @code{?:}
838 @cindex @code{?:} side effect
839 @noindent
840 In this simple case, the ability to omit the middle operand is not
841 especially useful.  When it becomes useful is when the first operand does,
842 or may (if it is a macro argument), contain a side effect.  Then repeating
843 the operand in the middle would perform the side effect twice.  Omitting
844 the middle operand uses the value already computed without the undesirable
845 effects of recomputing it.
847 @node __int128
848 @section 128-bit integers
849 @cindex @code{__int128} data types
851 As an extension the integer scalar type @code{__int128} is supported for
852 targets which have an integer mode wide enough to hold 128 bits.
853 Simply write @code{__int128} for a signed 128-bit integer, or
854 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
855 support in GCC for expressing an integer constant of type @code{__int128}
856 for targets with @code{long long} integer less than 128 bits wide.
858 @node Long Long
859 @section Double-Word Integers
860 @cindex @code{long long} data types
861 @cindex double-word arithmetic
862 @cindex multiprecision arithmetic
863 @cindex @code{LL} integer suffix
864 @cindex @code{ULL} integer suffix
866 ISO C99 supports data types for integers that are at least 64 bits wide,
867 and as an extension GCC supports them in C90 mode and in C++.
868 Simply write @code{long long int} for a signed integer, or
869 @code{unsigned long long int} for an unsigned integer.  To make an
870 integer constant of type @code{long long int}, add the suffix @samp{LL}
871 to the integer.  To make an integer constant of type @code{unsigned long
872 long int}, add the suffix @samp{ULL} to the integer.
874 You can use these types in arithmetic like any other integer types.
875 Addition, subtraction, and bitwise boolean operations on these types
876 are open-coded on all types of machines.  Multiplication is open-coded
877 if the machine supports a fullword-to-doubleword widening multiply
878 instruction.  Division and shifts are open-coded only on machines that
879 provide special support.  The operations that are not open-coded use
880 special library routines that come with GCC@.
882 There may be pitfalls when you use @code{long long} types for function
883 arguments without function prototypes.  If a function
884 expects type @code{int} for its argument, and you pass a value of type
885 @code{long long int}, confusion results because the caller and the
886 subroutine disagree about the number of bytes for the argument.
887 Likewise, if the function expects @code{long long int} and you pass
888 @code{int}.  The best way to avoid such problems is to use prototypes.
890 @node Complex
891 @section Complex Numbers
892 @cindex complex numbers
893 @cindex @code{_Complex} keyword
894 @cindex @code{__complex__} keyword
896 ISO C99 supports complex floating data types, and as an extension GCC
897 supports them in C90 mode and in C++.  GCC also supports complex integer data
898 types which are not part of ISO C99.  You can declare complex types
899 using the keyword @code{_Complex}.  As an extension, the older GNU
900 keyword @code{__complex__} is also supported.
902 For example, @samp{_Complex double x;} declares @code{x} as a
903 variable whose real part and imaginary part are both of type
904 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
905 have real and imaginary parts of type @code{short int}; this is not
906 likely to be useful, but it shows that the set of complex types is
907 complete.
909 To write a constant with a complex data type, use the suffix @samp{i} or
910 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
911 has type @code{_Complex float} and @code{3i} has type
912 @code{_Complex int}.  Such a constant always has a pure imaginary
913 value, but you can form any complex value you like by adding one to a
914 real constant.  This is a GNU extension; if you have an ISO C99
915 conforming C library (such as the GNU C Library), and want to construct complex
916 constants of floating type, you should include @code{<complex.h>} and
917 use the macros @code{I} or @code{_Complex_I} instead.
919 @cindex @code{__real__} keyword
920 @cindex @code{__imag__} keyword
921 To extract the real part of a complex-valued expression @var{exp}, write
922 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
923 extract the imaginary part.  This is a GNU extension; for values of
924 floating type, you should use the ISO C99 functions @code{crealf},
925 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
926 @code{cimagl}, declared in @code{<complex.h>} and also provided as
927 built-in functions by GCC@.
929 @cindex complex conjugation
930 The operator @samp{~} performs complex conjugation when used on a value
931 with a complex type.  This is a GNU extension; for values of
932 floating type, you should use the ISO C99 functions @code{conjf},
933 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
934 provided as built-in functions by GCC@.
936 GCC can allocate complex automatic variables in a noncontiguous
937 fashion; it's even possible for the real part to be in a register while
938 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
939 debug info format can represent this, so use of DWARF 2 is recommended.
940 If you are using the stabs debug info format, GCC describes a noncontiguous
941 complex variable as if it were two separate variables of noncomplex type.
942 If the variable's actual name is @code{foo}, the two fictitious
943 variables are named @code{foo$real} and @code{foo$imag}.  You can
944 examine and set these two fictitious variables with your debugger.
946 @node Floating Types
947 @section Additional Floating Types
948 @cindex additional floating types
949 @cindex @code{__float80} data type
950 @cindex @code{__float128} data type
951 @cindex @code{w} floating point suffix
952 @cindex @code{q} floating point suffix
953 @cindex @code{W} floating point suffix
954 @cindex @code{Q} floating point suffix
956 As an extension, GNU C supports additional floating
957 types, @code{__float80} and @code{__float128} to support 80-bit
958 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
959 Support for additional types includes the arithmetic operators:
960 add, subtract, multiply, divide; unary arithmetic operators;
961 relational operators; equality operators; and conversions to and from
962 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
963 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
964 for @code{_float128}.  You can declare complex types using the
965 corresponding internal complex type, @code{XCmode} for @code{__float80}
966 type and @code{TCmode} for @code{__float128} type:
968 @smallexample
969 typedef _Complex float __attribute__((mode(TC))) _Complex128;
970 typedef _Complex float __attribute__((mode(XC))) _Complex80;
971 @end smallexample
973 Not all targets support additional floating-point types.  @code{__float80}
974 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
975 The @code{__float128} type is supported on hppa HP-UX targets.
977 @node Half-Precision
978 @section Half-Precision Floating Point
979 @cindex half-precision floating point
980 @cindex @code{__fp16} data type
982 On ARM targets, GCC supports half-precision (16-bit) floating point via
983 the @code{__fp16} type.  You must enable this type explicitly
984 with the @option{-mfp16-format} command-line option in order to use it.
986 ARM supports two incompatible representations for half-precision
987 floating-point values.  You must choose one of the representations and
988 use it consistently in your program.
990 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
991 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
992 There are 11 bits of significand precision, approximately 3
993 decimal digits.
995 Specifying @option{-mfp16-format=alternative} selects the ARM
996 alternative format.  This representation is similar to the IEEE
997 format, but does not support infinities or NaNs.  Instead, the range
998 of exponents is extended, so that this format can represent normalized
999 values in the range of @math{2^{-14}} to 131008.
1001 The @code{__fp16} type is a storage format only.  For purposes
1002 of arithmetic and other operations, @code{__fp16} values in C or C++
1003 expressions are automatically promoted to @code{float}.  In addition,
1004 you cannot declare a function with a return value or parameters
1005 of type @code{__fp16}.
1007 Note that conversions from @code{double} to @code{__fp16}
1008 involve an intermediate conversion to @code{float}.  Because
1009 of rounding, this can sometimes produce a different result than a
1010 direct conversion.
1012 ARM provides hardware support for conversions between
1013 @code{__fp16} and @code{float} values
1014 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
1015 code using these hardware instructions if you compile with
1016 options to select an FPU that provides them;
1017 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1018 in addition to the @option{-mfp16-format} option to select
1019 a half-precision format.
1021 Language-level support for the @code{__fp16} data type is
1022 independent of whether GCC generates code using hardware floating-point
1023 instructions.  In cases where hardware support is not specified, GCC
1024 implements conversions between @code{__fp16} and @code{float} values
1025 as library calls.
1027 @node Decimal Float
1028 @section Decimal Floating Types
1029 @cindex decimal floating types
1030 @cindex @code{_Decimal32} data type
1031 @cindex @code{_Decimal64} data type
1032 @cindex @code{_Decimal128} data type
1033 @cindex @code{df} integer suffix
1034 @cindex @code{dd} integer suffix
1035 @cindex @code{dl} integer suffix
1036 @cindex @code{DF} integer suffix
1037 @cindex @code{DD} integer suffix
1038 @cindex @code{DL} integer suffix
1040 As an extension, GNU C supports decimal floating types as
1041 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1042 floating types in GCC will evolve as the draft technical report changes.
1043 Calling conventions for any target might also change.  Not all targets
1044 support decimal floating types.
1046 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1047 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1048 @code{float}, @code{double}, and @code{long double} whose radix is not
1049 specified by the C standard but is usually two.
1051 Support for decimal floating types includes the arithmetic operators
1052 add, subtract, multiply, divide; unary arithmetic operators;
1053 relational operators; equality operators; and conversions to and from
1054 integer and other floating types.  Use a suffix @samp{df} or
1055 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1056 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1057 @code{_Decimal128}.
1059 GCC support of decimal float as specified by the draft technical report
1060 is incomplete:
1062 @itemize @bullet
1063 @item
1064 When the value of a decimal floating type cannot be represented in the
1065 integer type to which it is being converted, the result is undefined
1066 rather than the result value specified by the draft technical report.
1068 @item
1069 GCC does not provide the C library functionality associated with
1070 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1071 @file{wchar.h}, which must come from a separate C library implementation.
1072 Because of this the GNU C compiler does not define macro
1073 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1074 the technical report.
1075 @end itemize
1077 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1078 are supported by the DWARF 2 debug information format.
1080 @node Hex Floats
1081 @section Hex Floats
1082 @cindex hex floats
1084 ISO C99 supports floating-point numbers written not only in the usual
1085 decimal notation, such as @code{1.55e1}, but also numbers such as
1086 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1087 supports this in C90 mode (except in some cases when strictly
1088 conforming) and in C++.  In that format the
1089 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1090 mandatory.  The exponent is a decimal number that indicates the power of
1091 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1092 @tex
1093 $1 {15\over16}$,
1094 @end tex
1095 @ifnottex
1096 1 15/16,
1097 @end ifnottex
1098 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1099 is the same as @code{1.55e1}.
1101 Unlike for floating-point numbers in the decimal notation the exponent
1102 is always required in the hexadecimal notation.  Otherwise the compiler
1103 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1104 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1105 extension for floating-point constants of type @code{float}.
1107 @node Fixed-Point
1108 @section Fixed-Point Types
1109 @cindex fixed-point types
1110 @cindex @code{_Fract} data type
1111 @cindex @code{_Accum} data type
1112 @cindex @code{_Sat} data type
1113 @cindex @code{hr} fixed-suffix
1114 @cindex @code{r} fixed-suffix
1115 @cindex @code{lr} fixed-suffix
1116 @cindex @code{llr} fixed-suffix
1117 @cindex @code{uhr} fixed-suffix
1118 @cindex @code{ur} fixed-suffix
1119 @cindex @code{ulr} fixed-suffix
1120 @cindex @code{ullr} fixed-suffix
1121 @cindex @code{hk} fixed-suffix
1122 @cindex @code{k} fixed-suffix
1123 @cindex @code{lk} fixed-suffix
1124 @cindex @code{llk} fixed-suffix
1125 @cindex @code{uhk} fixed-suffix
1126 @cindex @code{uk} fixed-suffix
1127 @cindex @code{ulk} fixed-suffix
1128 @cindex @code{ullk} fixed-suffix
1129 @cindex @code{HR} fixed-suffix
1130 @cindex @code{R} fixed-suffix
1131 @cindex @code{LR} fixed-suffix
1132 @cindex @code{LLR} fixed-suffix
1133 @cindex @code{UHR} fixed-suffix
1134 @cindex @code{UR} fixed-suffix
1135 @cindex @code{ULR} fixed-suffix
1136 @cindex @code{ULLR} fixed-suffix
1137 @cindex @code{HK} fixed-suffix
1138 @cindex @code{K} fixed-suffix
1139 @cindex @code{LK} fixed-suffix
1140 @cindex @code{LLK} fixed-suffix
1141 @cindex @code{UHK} fixed-suffix
1142 @cindex @code{UK} fixed-suffix
1143 @cindex @code{ULK} fixed-suffix
1144 @cindex @code{ULLK} fixed-suffix
1146 As an extension, GNU C supports fixed-point types as
1147 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1148 types in GCC will evolve as the draft technical report changes.
1149 Calling conventions for any target might also change.  Not all targets
1150 support fixed-point types.
1152 The fixed-point types are
1153 @code{short _Fract},
1154 @code{_Fract},
1155 @code{long _Fract},
1156 @code{long long _Fract},
1157 @code{unsigned short _Fract},
1158 @code{unsigned _Fract},
1159 @code{unsigned long _Fract},
1160 @code{unsigned long long _Fract},
1161 @code{_Sat short _Fract},
1162 @code{_Sat _Fract},
1163 @code{_Sat long _Fract},
1164 @code{_Sat long long _Fract},
1165 @code{_Sat unsigned short _Fract},
1166 @code{_Sat unsigned _Fract},
1167 @code{_Sat unsigned long _Fract},
1168 @code{_Sat unsigned long long _Fract},
1169 @code{short _Accum},
1170 @code{_Accum},
1171 @code{long _Accum},
1172 @code{long long _Accum},
1173 @code{unsigned short _Accum},
1174 @code{unsigned _Accum},
1175 @code{unsigned long _Accum},
1176 @code{unsigned long long _Accum},
1177 @code{_Sat short _Accum},
1178 @code{_Sat _Accum},
1179 @code{_Sat long _Accum},
1180 @code{_Sat long long _Accum},
1181 @code{_Sat unsigned short _Accum},
1182 @code{_Sat unsigned _Accum},
1183 @code{_Sat unsigned long _Accum},
1184 @code{_Sat unsigned long long _Accum}.
1186 Fixed-point data values contain fractional and optional integral parts.
1187 The format of fixed-point data varies and depends on the target machine.
1189 Support for fixed-point types includes:
1190 @itemize @bullet
1191 @item
1192 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1193 @item
1194 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1195 @item
1196 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1197 @item
1198 binary shift operators (@code{<<}, @code{>>})
1199 @item
1200 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1201 @item
1202 equality operators (@code{==}, @code{!=})
1203 @item
1204 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1205 @code{<<=}, @code{>>=})
1206 @item
1207 conversions to and from integer, floating-point, or fixed-point types
1208 @end itemize
1210 Use a suffix in a fixed-point literal constant:
1211 @itemize
1212 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1213 @code{_Sat short _Fract}
1214 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1215 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1216 @code{_Sat long _Fract}
1217 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1218 @code{_Sat long long _Fract}
1219 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1220 @code{_Sat unsigned short _Fract}
1221 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1222 @code{_Sat unsigned _Fract}
1223 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1224 @code{_Sat unsigned long _Fract}
1225 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1226 and @code{_Sat unsigned long long _Fract}
1227 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1228 @code{_Sat short _Accum}
1229 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1230 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1231 @code{_Sat long _Accum}
1232 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1233 @code{_Sat long long _Accum}
1234 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1235 @code{_Sat unsigned short _Accum}
1236 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1237 @code{_Sat unsigned _Accum}
1238 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1239 @code{_Sat unsigned long _Accum}
1240 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1241 and @code{_Sat unsigned long long _Accum}
1242 @end itemize
1244 GCC support of fixed-point types as specified by the draft technical report
1245 is incomplete:
1247 @itemize @bullet
1248 @item
1249 Pragmas to control overflow and rounding behaviors are not implemented.
1250 @end itemize
1252 Fixed-point types are supported by the DWARF 2 debug information format.
1254 @node Named Address Spaces
1255 @section Named Address Spaces
1256 @cindex Named Address Spaces
1258 As an extension, GNU C supports named address spaces as
1259 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1260 address spaces in GCC will evolve as the draft technical report
1261 changes.  Calling conventions for any target might also change.  At
1262 present, only the AVR, SPU, M32C, and RL78 targets support address
1263 spaces other than the generic address space.
1265 Address space identifiers may be used exactly like any other C type
1266 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1267 document for more details.
1269 @anchor{AVR Named Address Spaces}
1270 @subsection AVR Named Address Spaces
1272 On the AVR target, there are several address spaces that can be used
1273 in order to put read-only data into the flash memory and access that
1274 data by means of the special instructions @code{LPM} or @code{ELPM}
1275 needed to read from flash.
1277 Per default, any data including read-only data is located in RAM
1278 (the generic address space) so that non-generic address spaces are
1279 needed to locate read-only data in flash memory
1280 @emph{and} to generate the right instructions to access this data
1281 without using (inline) assembler code.
1283 @table @code
1284 @item __flash
1285 @cindex @code{__flash} AVR Named Address Spaces
1286 The @code{__flash} qualifier locates data in the
1287 @code{.progmem.data} section. Data is read using the @code{LPM}
1288 instruction. Pointers to this address space are 16 bits wide.
1290 @item __flash1
1291 @itemx __flash2
1292 @itemx __flash3
1293 @itemx __flash4
1294 @itemx __flash5
1295 @cindex @code{__flash1} AVR Named Address Spaces
1296 @cindex @code{__flash2} AVR Named Address Spaces
1297 @cindex @code{__flash3} AVR Named Address Spaces
1298 @cindex @code{__flash4} AVR Named Address Spaces
1299 @cindex @code{__flash5} AVR Named Address Spaces
1300 These are 16-bit address spaces locating data in section
1301 @code{.progmem@var{N}.data} where @var{N} refers to
1302 address space @code{__flash@var{N}}.
1303 The compiler sets the @code{RAMPZ} segment register appropriately 
1304 before reading data by means of the @code{ELPM} instruction.
1306 @item __memx
1307 @cindex @code{__memx} AVR Named Address Spaces
1308 This is a 24-bit address space that linearizes flash and RAM:
1309 If the high bit of the address is set, data is read from
1310 RAM using the lower two bytes as RAM address.
1311 If the high bit of the address is clear, data is read from flash
1312 with @code{RAMPZ} set according to the high byte of the address.
1313 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1315 Objects in this address space are located in @code{.progmemx.data}.
1316 @end table
1318 @b{Example}
1320 @smallexample
1321 char my_read (const __flash char ** p)
1323     /* p is a pointer to RAM that points to a pointer to flash.
1324        The first indirection of p reads that flash pointer
1325        from RAM and the second indirection reads a char from this
1326        flash address.  */
1328     return **p;
1331 /* Locate array[] in flash memory */
1332 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1334 int i = 1;
1336 int main (void)
1338    /* Return 17 by reading from flash memory */
1339    return array[array[i]];
1341 @end smallexample
1343 @noindent
1344 For each named address space supported by avr-gcc there is an equally
1345 named but uppercase built-in macro defined. 
1346 The purpose is to facilitate testing if respective address space
1347 support is available or not:
1349 @smallexample
1350 #ifdef __FLASH
1351 const __flash int var = 1;
1353 int read_var (void)
1355     return var;
1357 #else
1358 #include <avr/pgmspace.h> /* From AVR-LibC */
1360 const int var PROGMEM = 1;
1362 int read_var (void)
1364     return (int) pgm_read_word (&var);
1366 #endif /* __FLASH */
1367 @end smallexample
1369 @noindent
1370 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1371 locates data in flash but
1372 accesses to these data read from generic address space, i.e.@:
1373 from RAM,
1374 so that you need special accessors like @code{pgm_read_byte}
1375 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1376 together with attribute @code{progmem}.
1378 @noindent
1379 @b{Limitations and caveats}
1381 @itemize
1382 @item
1383 Reading across the 64@tie{}KiB section boundary of
1384 the @code{__flash} or @code{__flash@var{N}} address spaces
1385 shows undefined behavior. The only address space that
1386 supports reading across the 64@tie{}KiB flash segment boundaries is
1387 @code{__memx}.
1389 @item
1390 If you use one of the @code{__flash@var{N}} address spaces
1391 you must arrange your linker script to locate the
1392 @code{.progmem@var{N}.data} sections according to your needs.
1394 @item
1395 Any data or pointers to the non-generic address spaces must
1396 be qualified as @code{const}, i.e.@: as read-only data.
1397 This still applies if the data in one of these address
1398 spaces like software version number or calibration lookup table are intended to
1399 be changed after load time by, say, a boot loader. In this case
1400 the right qualification is @code{const} @code{volatile} so that the compiler
1401 must not optimize away known values or insert them
1402 as immediates into operands of instructions.
1404 @item
1405 The following code initializes a variable @code{pfoo}
1406 located in static storage with a 24-bit address:
1407 @smallexample
1408 extern const __memx char foo;
1409 const __memx void *pfoo = &foo;
1410 @end smallexample
1412 @noindent
1413 Such code requires at least binutils 2.23, see
1414 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1416 @end itemize
1418 @subsection M32C Named Address Spaces
1419 @cindex @code{__far} M32C Named Address Spaces
1421 On the M32C target, with the R8C and M16C CPU variants, variables
1422 qualified with @code{__far} are accessed using 32-bit addresses in
1423 order to access memory beyond the first 64@tie{}Ki bytes.  If
1424 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1425 effect.
1427 @subsection RL78 Named Address Spaces
1428 @cindex @code{__far} RL78 Named Address Spaces
1430 On the RL78 target, variables qualified with @code{__far} are accessed
1431 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1432 addresses.  Non-far variables are assumed to appear in the topmost
1433 64@tie{}KiB of the address space.
1435 @subsection SPU Named Address Spaces
1436 @cindex @code{__ea} SPU Named Address Spaces
1438 On the SPU target variables may be declared as
1439 belonging to another address space by qualifying the type with the
1440 @code{__ea} address space identifier:
1442 @smallexample
1443 extern int __ea i;
1444 @end smallexample
1446 @noindent 
1447 The compiler generates special code to access the variable @code{i}.
1448 It may use runtime library
1449 support, or generate special machine instructions to access that address
1450 space.
1452 @node Zero Length
1453 @section Arrays of Length Zero
1454 @cindex arrays of length zero
1455 @cindex zero-length arrays
1456 @cindex length-zero arrays
1457 @cindex flexible array members
1459 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1460 last element of a structure that is really a header for a variable-length
1461 object:
1463 @smallexample
1464 struct line @{
1465   int length;
1466   char contents[0];
1469 struct line *thisline = (struct line *)
1470   malloc (sizeof (struct line) + this_length);
1471 thisline->length = this_length;
1472 @end smallexample
1474 In ISO C90, you would have to give @code{contents} a length of 1, which
1475 means either you waste space or complicate the argument to @code{malloc}.
1477 In ISO C99, you would use a @dfn{flexible array member}, which is
1478 slightly different in syntax and semantics:
1480 @itemize @bullet
1481 @item
1482 Flexible array members are written as @code{contents[]} without
1483 the @code{0}.
1485 @item
1486 Flexible array members have incomplete type, and so the @code{sizeof}
1487 operator may not be applied.  As a quirk of the original implementation
1488 of zero-length arrays, @code{sizeof} evaluates to zero.
1490 @item
1491 Flexible array members may only appear as the last member of a
1492 @code{struct} that is otherwise non-empty.
1494 @item
1495 A structure containing a flexible array member, or a union containing
1496 such a structure (possibly recursively), may not be a member of a
1497 structure or an element of an array.  (However, these uses are
1498 permitted by GCC as extensions.)
1499 @end itemize
1501 GCC versions before 3.0 allowed zero-length arrays to be statically
1502 initialized, as if they were flexible arrays.  In addition to those
1503 cases that were useful, it also allowed initializations in situations
1504 that would corrupt later data.  Non-empty initialization of zero-length
1505 arrays is now treated like any case where there are more initializer
1506 elements than the array holds, in that a suitable warning about ``excess
1507 elements in array'' is given, and the excess elements (all of them, in
1508 this case) are ignored.
1510 Instead GCC allows static initialization of flexible array members.
1511 This is equivalent to defining a new structure containing the original
1512 structure followed by an array of sufficient size to contain the data.
1513 E.g.@: in the following, @code{f1} is constructed as if it were declared
1514 like @code{f2}.
1516 @smallexample
1517 struct f1 @{
1518   int x; int y[];
1519 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1521 struct f2 @{
1522   struct f1 f1; int data[3];
1523 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1524 @end smallexample
1526 @noindent
1527 The convenience of this extension is that @code{f1} has the desired
1528 type, eliminating the need to consistently refer to @code{f2.f1}.
1530 This has symmetry with normal static arrays, in that an array of
1531 unknown size is also written with @code{[]}.
1533 Of course, this extension only makes sense if the extra data comes at
1534 the end of a top-level object, as otherwise we would be overwriting
1535 data at subsequent offsets.  To avoid undue complication and confusion
1536 with initialization of deeply nested arrays, we simply disallow any
1537 non-empty initialization except when the structure is the top-level
1538 object.  For example:
1540 @smallexample
1541 struct foo @{ int x; int y[]; @};
1542 struct bar @{ struct foo z; @};
1544 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1545 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1546 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1547 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1548 @end smallexample
1550 @node Empty Structures
1551 @section Structures With No Members
1552 @cindex empty structures
1553 @cindex zero-size structures
1555 GCC permits a C structure to have no members:
1557 @smallexample
1558 struct empty @{
1560 @end smallexample
1562 The structure has size zero.  In C++, empty structures are part
1563 of the language.  G++ treats empty structures as if they had a single
1564 member of type @code{char}.
1566 @node Variable Length
1567 @section Arrays of Variable Length
1568 @cindex variable-length arrays
1569 @cindex arrays of variable length
1570 @cindex VLAs
1572 Variable-length automatic arrays are allowed in ISO C99, and as an
1573 extension GCC accepts them in C90 mode and in C++.  These arrays are
1574 declared like any other automatic arrays, but with a length that is not
1575 a constant expression.  The storage is allocated at the point of
1576 declaration and deallocated when the block scope containing the declaration
1577 exits.  For
1578 example:
1580 @smallexample
1581 FILE *
1582 concat_fopen (char *s1, char *s2, char *mode)
1584   char str[strlen (s1) + strlen (s2) + 1];
1585   strcpy (str, s1);
1586   strcat (str, s2);
1587   return fopen (str, mode);
1589 @end smallexample
1591 @cindex scope of a variable length array
1592 @cindex variable-length array scope
1593 @cindex deallocating variable length arrays
1594 Jumping or breaking out of the scope of the array name deallocates the
1595 storage.  Jumping into the scope is not allowed; you get an error
1596 message for it.
1598 @cindex variable-length array in a structure
1599 As an extension, GCC accepts variable-length arrays as a member of
1600 a structure or a union.  For example:
1602 @smallexample
1603 void
1604 foo (int n)
1606   struct S @{ int x[n]; @};
1608 @end smallexample
1610 @cindex @code{alloca} vs variable-length arrays
1611 You can use the function @code{alloca} to get an effect much like
1612 variable-length arrays.  The function @code{alloca} is available in
1613 many other C implementations (but not in all).  On the other hand,
1614 variable-length arrays are more elegant.
1616 There are other differences between these two methods.  Space allocated
1617 with @code{alloca} exists until the containing @emph{function} returns.
1618 The space for a variable-length array is deallocated as soon as the array
1619 name's scope ends.  (If you use both variable-length arrays and
1620 @code{alloca} in the same function, deallocation of a variable-length array
1621 also deallocates anything more recently allocated with @code{alloca}.)
1623 You can also use variable-length arrays as arguments to functions:
1625 @smallexample
1626 struct entry
1627 tester (int len, char data[len][len])
1629   /* @r{@dots{}} */
1631 @end smallexample
1633 The length of an array is computed once when the storage is allocated
1634 and is remembered for the scope of the array in case you access it with
1635 @code{sizeof}.
1637 If you want to pass the array first and the length afterward, you can
1638 use a forward declaration in the parameter list---another GNU extension.
1640 @smallexample
1641 struct entry
1642 tester (int len; char data[len][len], int len)
1644   /* @r{@dots{}} */
1646 @end smallexample
1648 @cindex parameter forward declaration
1649 The @samp{int len} before the semicolon is a @dfn{parameter forward
1650 declaration}, and it serves the purpose of making the name @code{len}
1651 known when the declaration of @code{data} is parsed.
1653 You can write any number of such parameter forward declarations in the
1654 parameter list.  They can be separated by commas or semicolons, but the
1655 last one must end with a semicolon, which is followed by the ``real''
1656 parameter declarations.  Each forward declaration must match a ``real''
1657 declaration in parameter name and data type.  ISO C99 does not support
1658 parameter forward declarations.
1660 @node Variadic Macros
1661 @section Macros with a Variable Number of Arguments.
1662 @cindex variable number of arguments
1663 @cindex macro with variable arguments
1664 @cindex rest argument (in macro)
1665 @cindex variadic macros
1667 In the ISO C standard of 1999, a macro can be declared to accept a
1668 variable number of arguments much as a function can.  The syntax for
1669 defining the macro is similar to that of a function.  Here is an
1670 example:
1672 @smallexample
1673 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1674 @end smallexample
1676 @noindent
1677 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1678 such a macro, it represents the zero or more tokens until the closing
1679 parenthesis that ends the invocation, including any commas.  This set of
1680 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1681 wherever it appears.  See the CPP manual for more information.
1683 GCC has long supported variadic macros, and used a different syntax that
1684 allowed you to give a name to the variable arguments just like any other
1685 argument.  Here is an example:
1687 @smallexample
1688 #define debug(format, args...) fprintf (stderr, format, args)
1689 @end smallexample
1691 @noindent
1692 This is in all ways equivalent to the ISO C example above, but arguably
1693 more readable and descriptive.
1695 GNU CPP has two further variadic macro extensions, and permits them to
1696 be used with either of the above forms of macro definition.
1698 In standard C, you are not allowed to leave the variable argument out
1699 entirely; but you are allowed to pass an empty argument.  For example,
1700 this invocation is invalid in ISO C, because there is no comma after
1701 the string:
1703 @smallexample
1704 debug ("A message")
1705 @end smallexample
1707 GNU CPP permits you to completely omit the variable arguments in this
1708 way.  In the above examples, the compiler would complain, though since
1709 the expansion of the macro still has the extra comma after the format
1710 string.
1712 To help solve this problem, CPP behaves specially for variable arguments
1713 used with the token paste operator, @samp{##}.  If instead you write
1715 @smallexample
1716 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1717 @end smallexample
1719 @noindent
1720 and if the variable arguments are omitted or empty, the @samp{##}
1721 operator causes the preprocessor to remove the comma before it.  If you
1722 do provide some variable arguments in your macro invocation, GNU CPP
1723 does not complain about the paste operation and instead places the
1724 variable arguments after the comma.  Just like any other pasted macro
1725 argument, these arguments are not macro expanded.
1727 @node Escaped Newlines
1728 @section Slightly Looser Rules for Escaped Newlines
1729 @cindex escaped newlines
1730 @cindex newlines (escaped)
1732 Recently, the preprocessor has relaxed its treatment of escaped
1733 newlines.  Previously, the newline had to immediately follow a
1734 backslash.  The current implementation allows whitespace in the form
1735 of spaces, horizontal and vertical tabs, and form feeds between the
1736 backslash and the subsequent newline.  The preprocessor issues a
1737 warning, but treats it as a valid escaped newline and combines the two
1738 lines to form a single logical line.  This works within comments and
1739 tokens, as well as between tokens.  Comments are @emph{not} treated as
1740 whitespace for the purposes of this relaxation, since they have not
1741 yet been replaced with spaces.
1743 @node Subscripting
1744 @section Non-Lvalue Arrays May Have Subscripts
1745 @cindex subscripting
1746 @cindex arrays, non-lvalue
1748 @cindex subscripting and function values
1749 In ISO C99, arrays that are not lvalues still decay to pointers, and
1750 may be subscripted, although they may not be modified or used after
1751 the next sequence point and the unary @samp{&} operator may not be
1752 applied to them.  As an extension, GNU C allows such arrays to be
1753 subscripted in C90 mode, though otherwise they do not decay to
1754 pointers outside C99 mode.  For example,
1755 this is valid in GNU C though not valid in C90:
1757 @smallexample
1758 @group
1759 struct foo @{int a[4];@};
1761 struct foo f();
1763 bar (int index)
1765   return f().a[index];
1767 @end group
1768 @end smallexample
1770 @node Pointer Arith
1771 @section Arithmetic on @code{void}- and Function-Pointers
1772 @cindex void pointers, arithmetic
1773 @cindex void, size of pointer to
1774 @cindex function pointers, arithmetic
1775 @cindex function, size of pointer to
1777 In GNU C, addition and subtraction operations are supported on pointers to
1778 @code{void} and on pointers to functions.  This is done by treating the
1779 size of a @code{void} or of a function as 1.
1781 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1782 and on function types, and returns 1.
1784 @opindex Wpointer-arith
1785 The option @option{-Wpointer-arith} requests a warning if these extensions
1786 are used.
1788 @node Pointers to Arrays
1789 @section Pointers to arrays with qualifiers work as expected
1790 @cindex pointers to arrays
1791 @cindex const qualifier
1793 In GNU C, pointers to arrays with qualifiers work similar to pointers
1794 to other qualified types. For example, a value of type @code{int (*)[5]}
1795 can be used to initialize a variable of type @code{const int (*)[5]}.
1796 These types are incompatible in ISO C because the @code{const} qualifier
1797 is formally attached to the element type of the array and not the
1798 array itself.
1800 @smallexample
1801 extern void
1802 transpose (int N, int M, double out[M][N], const double in[N][M]);
1803 double x[3][2];
1804 double y[2][3];
1805 @r{@dots{}}
1806 transpose(3, 2, y, x);
1807 @end smallexample
1809 @node Initializers
1810 @section Non-Constant Initializers
1811 @cindex initializers, non-constant
1812 @cindex non-constant initializers
1814 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1815 automatic variable are not required to be constant expressions in GNU C@.
1816 Here is an example of an initializer with run-time varying elements:
1818 @smallexample
1819 foo (float f, float g)
1821   float beat_freqs[2] = @{ f-g, f+g @};
1822   /* @r{@dots{}} */
1824 @end smallexample
1826 @node Compound Literals
1827 @section Compound Literals
1828 @cindex constructor expressions
1829 @cindex initializations in expressions
1830 @cindex structures, constructor expression
1831 @cindex expressions, constructor
1832 @cindex compound literals
1833 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1835 ISO C99 supports compound literals.  A compound literal looks like
1836 a cast containing an initializer.  Its value is an object of the
1837 type specified in the cast, containing the elements specified in
1838 the initializer; it is an lvalue.  As an extension, GCC supports
1839 compound literals in C90 mode and in C++, though the semantics are
1840 somewhat different in C++.
1842 Usually, the specified type is a structure.  Assume that
1843 @code{struct foo} and @code{structure} are declared as shown:
1845 @smallexample
1846 struct foo @{int a; char b[2];@} structure;
1847 @end smallexample
1849 @noindent
1850 Here is an example of constructing a @code{struct foo} with a compound literal:
1852 @smallexample
1853 structure = ((struct foo) @{x + y, 'a', 0@});
1854 @end smallexample
1856 @noindent
1857 This is equivalent to writing the following:
1859 @smallexample
1861   struct foo temp = @{x + y, 'a', 0@};
1862   structure = temp;
1864 @end smallexample
1866 You can also construct an array, though this is dangerous in C++, as
1867 explained below.  If all the elements of the compound literal are
1868 (made up of) simple constant expressions, suitable for use in
1869 initializers of objects of static storage duration, then the compound
1870 literal can be coerced to a pointer to its first element and used in
1871 such an initializer, as shown here:
1873 @smallexample
1874 char **foo = (char *[]) @{ "x", "y", "z" @};
1875 @end smallexample
1877 Compound literals for scalar types and union types are
1878 also allowed, but then the compound literal is equivalent
1879 to a cast.
1881 As a GNU extension, GCC allows initialization of objects with static storage
1882 duration by compound literals (which is not possible in ISO C99, because
1883 the initializer is not a constant).
1884 It is handled as if the object is initialized only with the bracket
1885 enclosed list if the types of the compound literal and the object match.
1886 The initializer list of the compound literal must be constant.
1887 If the object being initialized has array type of unknown size, the size is
1888 determined by compound literal size.
1890 @smallexample
1891 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1892 static int y[] = (int []) @{1, 2, 3@};
1893 static int z[] = (int [3]) @{1@};
1894 @end smallexample
1896 @noindent
1897 The above lines are equivalent to the following:
1898 @smallexample
1899 static struct foo x = @{1, 'a', 'b'@};
1900 static int y[] = @{1, 2, 3@};
1901 static int z[] = @{1, 0, 0@};
1902 @end smallexample
1904 In C, a compound literal designates an unnamed object with static or
1905 automatic storage duration.  In C++, a compound literal designates a
1906 temporary object, which only lives until the end of its
1907 full-expression.  As a result, well-defined C code that takes the
1908 address of a subobject of a compound literal can be undefined in C++.
1909 For instance, if the array compound literal example above appeared
1910 inside a function, any subsequent use of @samp{foo} in C++ has
1911 undefined behavior because the lifetime of the array ends after the
1912 declaration of @samp{foo}.  As a result, the C++ compiler now rejects
1913 the conversion of a temporary array to a pointer.
1915 As an optimization, the C++ compiler sometimes gives array compound
1916 literals longer lifetimes: when the array either appears outside a
1917 function or has const-qualified type.  If @samp{foo} and its
1918 initializer had elements of @samp{char *const} type rather than
1919 @samp{char *}, or if @samp{foo} were a global variable, the array
1920 would have static storage duration.  But it is probably safest just to
1921 avoid the use of array compound literals in code compiled as C++.
1923 @node Designated Inits
1924 @section Designated Initializers
1925 @cindex initializers with labeled elements
1926 @cindex labeled elements in initializers
1927 @cindex case labels in initializers
1928 @cindex designated initializers
1930 Standard C90 requires the elements of an initializer to appear in a fixed
1931 order, the same as the order of the elements in the array or structure
1932 being initialized.
1934 In ISO C99 you can give the elements in any order, specifying the array
1935 indices or structure field names they apply to, and GNU C allows this as
1936 an extension in C90 mode as well.  This extension is not
1937 implemented in GNU C++.
1939 To specify an array index, write
1940 @samp{[@var{index}] =} before the element value.  For example,
1942 @smallexample
1943 int a[6] = @{ [4] = 29, [2] = 15 @};
1944 @end smallexample
1946 @noindent
1947 is equivalent to
1949 @smallexample
1950 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1951 @end smallexample
1953 @noindent
1954 The index values must be constant expressions, even if the array being
1955 initialized is automatic.
1957 An alternative syntax for this that has been obsolete since GCC 2.5 but
1958 GCC still accepts is to write @samp{[@var{index}]} before the element
1959 value, with no @samp{=}.
1961 To initialize a range of elements to the same value, write
1962 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1963 extension.  For example,
1965 @smallexample
1966 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1967 @end smallexample
1969 @noindent
1970 If the value in it has side-effects, the side-effects happen only once,
1971 not for each initialized field by the range initializer.
1973 @noindent
1974 Note that the length of the array is the highest value specified
1975 plus one.
1977 In a structure initializer, specify the name of a field to initialize
1978 with @samp{.@var{fieldname} =} before the element value.  For example,
1979 given the following structure,
1981 @smallexample
1982 struct point @{ int x, y; @};
1983 @end smallexample
1985 @noindent
1986 the following initialization
1988 @smallexample
1989 struct point p = @{ .y = yvalue, .x = xvalue @};
1990 @end smallexample
1992 @noindent
1993 is equivalent to
1995 @smallexample
1996 struct point p = @{ xvalue, yvalue @};
1997 @end smallexample
1999 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2000 @samp{@var{fieldname}:}, as shown here:
2002 @smallexample
2003 struct point p = @{ y: yvalue, x: xvalue @};
2004 @end smallexample
2006 Omitted field members are implicitly initialized the same as objects
2007 that have static storage duration.
2009 @cindex designators
2010 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2011 @dfn{designator}.  You can also use a designator (or the obsolete colon
2012 syntax) when initializing a union, to specify which element of the union
2013 should be used.  For example,
2015 @smallexample
2016 union foo @{ int i; double d; @};
2018 union foo f = @{ .d = 4 @};
2019 @end smallexample
2021 @noindent
2022 converts 4 to a @code{double} to store it in the union using
2023 the second element.  By contrast, casting 4 to type @code{union foo}
2024 stores it into the union as the integer @code{i}, since it is
2025 an integer.  (@xref{Cast to Union}.)
2027 You can combine this technique of naming elements with ordinary C
2028 initialization of successive elements.  Each initializer element that
2029 does not have a designator applies to the next consecutive element of the
2030 array or structure.  For example,
2032 @smallexample
2033 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2034 @end smallexample
2036 @noindent
2037 is equivalent to
2039 @smallexample
2040 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2041 @end smallexample
2043 Labeling the elements of an array initializer is especially useful
2044 when the indices are characters or belong to an @code{enum} type.
2045 For example:
2047 @smallexample
2048 int whitespace[256]
2049   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2050       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2051 @end smallexample
2053 @cindex designator lists
2054 You can also write a series of @samp{.@var{fieldname}} and
2055 @samp{[@var{index}]} designators before an @samp{=} to specify a
2056 nested subobject to initialize; the list is taken relative to the
2057 subobject corresponding to the closest surrounding brace pair.  For
2058 example, with the @samp{struct point} declaration above:
2060 @smallexample
2061 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2062 @end smallexample
2064 @noindent
2065 If the same field is initialized multiple times, it has the value from
2066 the last initialization.  If any such overridden initialization has
2067 side-effect, it is unspecified whether the side-effect happens or not.
2068 Currently, GCC discards them and issues a warning.
2070 @node Case Ranges
2071 @section Case Ranges
2072 @cindex case ranges
2073 @cindex ranges in case statements
2075 You can specify a range of consecutive values in a single @code{case} label,
2076 like this:
2078 @smallexample
2079 case @var{low} ... @var{high}:
2080 @end smallexample
2082 @noindent
2083 This has the same effect as the proper number of individual @code{case}
2084 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2086 This feature is especially useful for ranges of ASCII character codes:
2088 @smallexample
2089 case 'A' ... 'Z':
2090 @end smallexample
2092 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2093 it may be parsed wrong when you use it with integer values.  For example,
2094 write this:
2096 @smallexample
2097 case 1 ... 5:
2098 @end smallexample
2100 @noindent
2101 rather than this:
2103 @smallexample
2104 case 1...5:
2105 @end smallexample
2107 @node Cast to Union
2108 @section Cast to a Union Type
2109 @cindex cast to a union
2110 @cindex union, casting to a
2112 A cast to union type is similar to other casts, except that the type
2113 specified is a union type.  You can specify the type either with
2114 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2115 a constructor, not a cast, and hence does not yield an lvalue like
2116 normal casts.  (@xref{Compound Literals}.)
2118 The types that may be cast to the union type are those of the members
2119 of the union.  Thus, given the following union and variables:
2121 @smallexample
2122 union foo @{ int i; double d; @};
2123 int x;
2124 double y;
2125 @end smallexample
2127 @noindent
2128 both @code{x} and @code{y} can be cast to type @code{union foo}.
2130 Using the cast as the right-hand side of an assignment to a variable of
2131 union type is equivalent to storing in a member of the union:
2133 @smallexample
2134 union foo u;
2135 /* @r{@dots{}} */
2136 u = (union foo) x  @equiv{}  u.i = x
2137 u = (union foo) y  @equiv{}  u.d = y
2138 @end smallexample
2140 You can also use the union cast as a function argument:
2142 @smallexample
2143 void hack (union foo);
2144 /* @r{@dots{}} */
2145 hack ((union foo) x);
2146 @end smallexample
2148 @node Mixed Declarations
2149 @section Mixed Declarations and Code
2150 @cindex mixed declarations and code
2151 @cindex declarations, mixed with code
2152 @cindex code, mixed with declarations
2154 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2155 within compound statements.  As an extension, GNU C also allows this in
2156 C90 mode.  For example, you could do:
2158 @smallexample
2159 int i;
2160 /* @r{@dots{}} */
2161 i++;
2162 int j = i + 2;
2163 @end smallexample
2165 Each identifier is visible from where it is declared until the end of
2166 the enclosing block.
2168 @node Function Attributes
2169 @section Declaring Attributes of Functions
2170 @cindex function attributes
2171 @cindex declaring attributes of functions
2172 @cindex functions that never return
2173 @cindex functions that return more than once
2174 @cindex functions that have no side effects
2175 @cindex functions in arbitrary sections
2176 @cindex functions that behave like malloc
2177 @cindex @code{volatile} applied to function
2178 @cindex @code{const} applied to function
2179 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2180 @cindex functions with non-null pointer arguments
2181 @cindex functions that are passed arguments in registers on the 386
2182 @cindex functions that pop the argument stack on the 386
2183 @cindex functions that do not pop the argument stack on the 386
2184 @cindex functions that have different compilation options on the 386
2185 @cindex functions that have different optimization options
2186 @cindex functions that are dynamically resolved
2188 In GNU C, you declare certain things about functions called in your program
2189 which help the compiler optimize function calls and check your code more
2190 carefully.
2192 The keyword @code{__attribute__} allows you to specify special
2193 attributes when making a declaration.  This keyword is followed by an
2194 attribute specification inside double parentheses.  The following
2195 attributes are currently defined for functions on all targets:
2196 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2197 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2198 @code{no_icf},
2199 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2200 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2201 @code{no_instrument_function}, @code{no_split_stack},
2202 @code{section}, @code{constructor},
2203 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2204 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2205 @code{warn_unused_result}, @code{nonnull},
2206 @code{returns_nonnull}, @code{gnu_inline},
2207 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2208 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2209 @code{no_sanitize_thread},
2210 @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
2211 @code{bnd_instrument}, @code{stack_protect},
2212 @code{error} and @code{warning}.
2213 Several other attributes are defined for functions on particular
2214 target systems.  Other attributes, including @code{section} are
2215 supported for variables declarations (@pxref{Variable Attributes}),
2216 labels (@pxref{Label Attributes})
2217 and for types (@pxref{Type Attributes}).
2219 GCC plugins may provide their own attributes.
2221 You may also specify attributes with @samp{__} preceding and following
2222 each keyword.  This allows you to use them in header files without
2223 being concerned about a possible macro of the same name.  For example,
2224 you may use @code{__noreturn__} instead of @code{noreturn}.
2226 @xref{Attribute Syntax}, for details of the exact syntax for using
2227 attributes.
2229 @table @code
2230 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2232 @item alias ("@var{target}")
2233 @cindex @code{alias} attribute
2234 The @code{alias} attribute causes the declaration to be emitted as an
2235 alias for another symbol, which must be specified.  For instance,
2237 @smallexample
2238 void __f () @{ /* @r{Do something.} */; @}
2239 void f () __attribute__ ((weak, alias ("__f")));
2240 @end smallexample
2242 @noindent
2243 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2244 mangled name for the target must be used.  It is an error if @samp{__f}
2245 is not defined in the same translation unit.
2247 Not all target machines support this attribute.
2249 @item aligned (@var{alignment})
2250 @cindex @code{aligned} attribute
2251 This attribute specifies a minimum alignment for the function,
2252 measured in bytes.
2254 You cannot use this attribute to decrease the alignment of a function,
2255 only to increase it.  However, when you explicitly specify a function
2256 alignment this overrides the effect of the
2257 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2258 function.
2260 Note that the effectiveness of @code{aligned} attributes may be
2261 limited by inherent limitations in your linker.  On many systems, the
2262 linker is only able to arrange for functions to be aligned up to a
2263 certain maximum alignment.  (For some linkers, the maximum supported
2264 alignment may be very very small.)  See your linker documentation for
2265 further information.
2267 The @code{aligned} attribute can also be used for variables and fields
2268 (@pxref{Variable Attributes}.)
2270 @item alloc_size
2271 @cindex @code{alloc_size} attribute
2272 The @code{alloc_size} attribute is used to tell the compiler that the
2273 function return value points to memory, where the size is given by
2274 one or two of the functions parameters.  GCC uses this
2275 information to improve the correctness of @code{__builtin_object_size}.
2277 The function parameter(s) denoting the allocated size are specified by
2278 one or two integer arguments supplied to the attribute.  The allocated size
2279 is either the value of the single function argument specified or the product
2280 of the two function arguments specified.  Argument numbering starts at
2281 one.
2283 For instance,
2285 @smallexample
2286 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2287 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2288 @end smallexample
2290 @noindent
2291 declares that @code{my_calloc} returns memory of the size given by
2292 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2293 of the size given by parameter 2.
2295 @item alloc_align
2296 @cindex @code{alloc_align} attribute
2297 The @code{alloc_align} attribute is used to tell the compiler that the
2298 function return value points to memory, where the returned pointer minimum
2299 alignment is given by one of the functions parameters.  GCC uses this
2300 information to improve pointer alignment analysis.
2302 The function parameter denoting the allocated alignment is specified by
2303 one integer argument, whose number is the argument of the attribute.
2304 Argument numbering starts at one.
2306 For instance,
2308 @smallexample
2309 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2310 @end smallexample
2312 @noindent
2313 declares that @code{my_memalign} returns memory with minimum alignment
2314 given by parameter 1.
2316 @item assume_aligned
2317 @cindex @code{assume_aligned} attribute
2318 The @code{assume_aligned} attribute is used to tell the compiler that the
2319 function return value points to memory, where the returned pointer minimum
2320 alignment is given by the first argument.
2321 If the attribute has two arguments, the second argument is misalignment offset.
2323 For instance
2325 @smallexample
2326 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2327 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2328 @end smallexample
2330 @noindent
2331 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2332 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2333 to 8.
2335 @item always_inline
2336 @cindex @code{always_inline} function attribute
2337 Generally, functions are not inlined unless optimization is specified.
2338 For functions declared inline, this attribute inlines the function
2339 independent of any restrictions that otherwise apply to inlining.
2340 Failure to inline such a function is diagnosed as an error.
2341 Note that if such a function is called indirectly the compiler may
2342 or may not inline it depending on optimization level and a failure
2343 to inline an indirect call may or may not be diagnosed.
2345 @item gnu_inline
2346 @cindex @code{gnu_inline} function attribute
2347 This attribute should be used with a function that is also declared
2348 with the @code{inline} keyword.  It directs GCC to treat the function
2349 as if it were defined in gnu90 mode even when compiling in C99 or
2350 gnu99 mode.
2352 If the function is declared @code{extern}, then this definition of the
2353 function is used only for inlining.  In no case is the function
2354 compiled as a standalone function, not even if you take its address
2355 explicitly.  Such an address becomes an external reference, as if you
2356 had only declared the function, and had not defined it.  This has
2357 almost the effect of a macro.  The way to use this is to put a
2358 function definition in a header file with this attribute, and put
2359 another copy of the function, without @code{extern}, in a library
2360 file.  The definition in the header file causes most calls to the
2361 function to be inlined.  If any uses of the function remain, they
2362 refer to the single copy in the library.  Note that the two
2363 definitions of the functions need not be precisely the same, although
2364 if they do not have the same effect your program may behave oddly.
2366 In C, if the function is neither @code{extern} nor @code{static}, then
2367 the function is compiled as a standalone function, as well as being
2368 inlined where possible.
2370 This is how GCC traditionally handled functions declared
2371 @code{inline}.  Since ISO C99 specifies a different semantics for
2372 @code{inline}, this function attribute is provided as a transition
2373 measure and as a useful feature in its own right.  This attribute is
2374 available in GCC 4.1.3 and later.  It is available if either of the
2375 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2376 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2377 Function is As Fast As a Macro}.
2379 In C++, this attribute does not depend on @code{extern} in any way,
2380 but it still requires the @code{inline} keyword to enable its special
2381 behavior.
2383 @item artificial
2384 @cindex @code{artificial} function attribute
2385 This attribute is useful for small inline wrappers that if possible
2386 should appear during debugging as a unit.  Depending on the debug
2387 info format it either means marking the function as artificial
2388 or using the caller location for all instructions within the inlined
2389 body.
2391 @item bank_switch
2392 @cindex interrupt handler functions
2393 When added to an interrupt handler with the M32C port, causes the
2394 prologue and epilogue to use bank switching to preserve the registers
2395 rather than saving them on the stack.
2397 @item flatten
2398 @cindex @code{flatten} function attribute
2399 Generally, inlining into a function is limited.  For a function marked with
2400 this attribute, every call inside this function is inlined, if possible.
2401 Whether the function itself is considered for inlining depends on its size and
2402 the current inlining parameters.
2404 @item error ("@var{message}")
2405 @cindex @code{error} function attribute
2406 If this attribute is used on a function declaration and a call to such a function
2407 is not eliminated through dead code elimination or other optimizations, an error
2408 that includes @var{message} is diagnosed.  This is useful
2409 for compile-time checking, especially together with @code{__builtin_constant_p}
2410 and inline functions where checking the inline function arguments is not
2411 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2412 While it is possible to leave the function undefined and thus invoke
2413 a link failure, when using this attribute the problem is diagnosed
2414 earlier and with exact location of the call even in presence of inline
2415 functions or when not emitting debugging information.
2417 @item warning ("@var{message}")
2418 @cindex @code{warning} function attribute
2419 If this attribute is used on a function declaration and a call to such a function
2420 is not eliminated through dead code elimination or other optimizations, a warning
2421 that includes @var{message} is diagnosed.  This is useful
2422 for compile-time checking, especially together with @code{__builtin_constant_p}
2423 and inline functions.  While it is possible to define the function with
2424 a message in @code{.gnu.warning*} section, when using this attribute the problem
2425 is diagnosed earlier and with exact location of the call even in presence
2426 of inline functions or when not emitting debugging information.
2428 @item cdecl
2429 @cindex functions that do pop the argument stack on the 386
2430 @opindex mrtd
2431 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2432 assume that the calling function pops off the stack space used to
2433 pass arguments.  This is
2434 useful to override the effects of the @option{-mrtd} switch.
2436 @item const
2437 @cindex @code{const} function attribute
2438 Many functions do not examine any values except their arguments, and
2439 have no effects except the return value.  Basically this is just slightly
2440 more strict class than the @code{pure} attribute below, since function is not
2441 allowed to read global memory.
2443 @cindex pointer arguments
2444 Note that a function that has pointer arguments and examines the data
2445 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2446 function that calls a non-@code{const} function usually must not be
2447 @code{const}.  It does not make sense for a @code{const} function to
2448 return @code{void}.
2450 The attribute @code{const} is not implemented in GCC versions earlier
2451 than 2.5.  An alternative way to declare that a function has no side
2452 effects, which works in the current version and in some older versions,
2453 is as follows:
2455 @smallexample
2456 typedef int intfn ();
2458 extern const intfn square;
2459 @end smallexample
2461 @noindent
2462 This approach does not work in GNU C++ from 2.6.0 on, since the language
2463 specifies that the @samp{const} must be attached to the return value.
2465 @item constructor
2466 @itemx destructor
2467 @itemx constructor (@var{priority})
2468 @itemx destructor (@var{priority})
2469 @cindex @code{constructor} function attribute
2470 @cindex @code{destructor} function attribute
2471 The @code{constructor} attribute causes the function to be called
2472 automatically before execution enters @code{main ()}.  Similarly, the
2473 @code{destructor} attribute causes the function to be called
2474 automatically after @code{main ()} completes or @code{exit ()} is
2475 called.  Functions with these attributes are useful for
2476 initializing data that is used implicitly during the execution of
2477 the program.
2479 You may provide an optional integer priority to control the order in
2480 which constructor and destructor functions are run.  A constructor
2481 with a smaller priority number runs before a constructor with a larger
2482 priority number; the opposite relationship holds for destructors.  So,
2483 if you have a constructor that allocates a resource and a destructor
2484 that deallocates the same resource, both functions typically have the
2485 same priority.  The priorities for constructor and destructor
2486 functions are the same as those specified for namespace-scope C++
2487 objects (@pxref{C++ Attributes}).
2489 These attributes are not currently implemented for Objective-C@.
2491 @item deprecated
2492 @itemx deprecated (@var{msg})
2493 @cindex @code{deprecated} attribute.
2494 The @code{deprecated} attribute results in a warning if the function
2495 is used anywhere in the source file.  This is useful when identifying
2496 functions that are expected to be removed in a future version of a
2497 program.  The warning also includes the location of the declaration
2498 of the deprecated function, to enable users to easily find further
2499 information about why the function is deprecated, or what they should
2500 do instead.  Note that the warnings only occurs for uses:
2502 @smallexample
2503 int old_fn () __attribute__ ((deprecated));
2504 int old_fn ();
2505 int (*fn_ptr)() = old_fn;
2506 @end smallexample
2508 @noindent
2509 results in a warning on line 3 but not line 2.  The optional @var{msg}
2510 argument, which must be a string, is printed in the warning if
2511 present.
2513 The @code{deprecated} attribute can also be used for variables and
2514 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2516 @item disinterrupt
2517 @cindex @code{disinterrupt} attribute
2518 On Epiphany and MeP targets, this attribute causes the compiler to emit
2519 instructions to disable interrupts for the duration of the given
2520 function.
2522 @item dllexport
2523 @cindex @code{__declspec(dllexport)}
2524 On Microsoft Windows targets and Symbian OS targets the
2525 @code{dllexport} attribute causes the compiler to provide a global
2526 pointer to a pointer in a DLL, so that it can be referenced with the
2527 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2528 name is formed by combining @code{_imp__} and the function or variable
2529 name.
2531 You can use @code{__declspec(dllexport)} as a synonym for
2532 @code{__attribute__ ((dllexport))} for compatibility with other
2533 compilers.
2535 On systems that support the @code{visibility} attribute, this
2536 attribute also implies ``default'' visibility.  It is an error to
2537 explicitly specify any other visibility.
2539 In previous versions of GCC, the @code{dllexport} attribute was ignored
2540 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2541 had been used.  The default behavior now is to emit all dllexported
2542 inline functions; however, this can cause object file-size bloat, in
2543 which case the old behavior can be restored by using
2544 @option{-fno-keep-inline-dllexport}.
2546 The attribute is also ignored for undefined symbols.
2548 When applied to C++ classes, the attribute marks defined non-inlined
2549 member functions and static data members as exports.  Static consts
2550 initialized in-class are not marked unless they are also defined
2551 out-of-class.
2553 For Microsoft Windows targets there are alternative methods for
2554 including the symbol in the DLL's export table such as using a
2555 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2556 the @option{--export-all} linker flag.
2558 @item dllimport
2559 @cindex @code{__declspec(dllimport)}
2560 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2561 attribute causes the compiler to reference a function or variable via
2562 a global pointer to a pointer that is set up by the DLL exporting the
2563 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2564 targets, the pointer name is formed by combining @code{_imp__} and the
2565 function or variable name.
2567 You can use @code{__declspec(dllimport)} as a synonym for
2568 @code{__attribute__ ((dllimport))} for compatibility with other
2569 compilers.
2571 On systems that support the @code{visibility} attribute, this
2572 attribute also implies ``default'' visibility.  It is an error to
2573 explicitly specify any other visibility.
2575 Currently, the attribute is ignored for inlined functions.  If the
2576 attribute is applied to a symbol @emph{definition}, an error is reported.
2577 If a symbol previously declared @code{dllimport} is later defined, the
2578 attribute is ignored in subsequent references, and a warning is emitted.
2579 The attribute is also overridden by a subsequent declaration as
2580 @code{dllexport}.
2582 When applied to C++ classes, the attribute marks non-inlined
2583 member functions and static data members as imports.  However, the
2584 attribute is ignored for virtual methods to allow creation of vtables
2585 using thunks.
2587 On the SH Symbian OS target the @code{dllimport} attribute also has
2588 another affect---it can cause the vtable and run-time type information
2589 for a class to be exported.  This happens when the class has a
2590 dllimported constructor or a non-inline, non-pure virtual function
2591 and, for either of those two conditions, the class also has an inline
2592 constructor or destructor and has a key function that is defined in
2593 the current translation unit.
2595 For Microsoft Windows targets the use of the @code{dllimport}
2596 attribute on functions is not necessary, but provides a small
2597 performance benefit by eliminating a thunk in the DLL@.  The use of the
2598 @code{dllimport} attribute on imported variables was required on older
2599 versions of the GNU linker, but can now be avoided by passing the
2600 @option{--enable-auto-import} switch to the GNU linker.  As with
2601 functions, using the attribute for a variable eliminates a thunk in
2602 the DLL@.
2604 One drawback to using this attribute is that a pointer to a
2605 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2606 address. However, a pointer to a @emph{function} with the
2607 @code{dllimport} attribute can be used as a constant initializer; in
2608 this case, the address of a stub function in the import lib is
2609 referenced.  On Microsoft Windows targets, the attribute can be disabled
2610 for functions by setting the @option{-mnop-fun-dllimport} flag.
2612 @item eightbit_data
2613 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2614 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2615 variable should be placed into the eight-bit data section.
2616 The compiler generates more efficient code for certain operations
2617 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2618 256 bytes of data.
2620 You must use GAS and GLD from GNU binutils version 2.7 or later for
2621 this attribute to work correctly.
2623 @item exception
2624 @cindex exception handler functions
2625 Use this attribute on the NDS32 target to indicate that the specified function
2626 is an exception handler.  The compiler will generate corresponding sections
2627 for use in an exception handler.
2629 @item exception_handler
2630 @cindex exception handler functions on the Blackfin processor
2631 Use this attribute on the Blackfin to indicate that the specified function
2632 is an exception handler.  The compiler generates function entry and
2633 exit sequences suitable for use in an exception handler when this
2634 attribute is present.
2636 @item externally_visible
2637 @cindex @code{externally_visible} attribute.
2638 This attribute, attached to a global variable or function, nullifies
2639 the effect of the @option{-fwhole-program} command-line option, so the
2640 object remains visible outside the current compilation unit.
2642 If @option{-fwhole-program} is used together with @option{-flto} and 
2643 @command{gold} is used as the linker plugin, 
2644 @code{externally_visible} attributes are automatically added to functions 
2645 (not variable yet due to a current @command{gold} issue) 
2646 that are accessed outside of LTO objects according to resolution file
2647 produced by @command{gold}.
2648 For other linkers that cannot generate resolution file,
2649 explicit @code{externally_visible} attributes are still necessary.
2651 @item far
2652 @cindex functions that handle memory bank switching
2653 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2654 use a calling convention that takes care of switching memory banks when
2655 entering and leaving a function.  This calling convention is also the
2656 default when using the @option{-mlong-calls} option.
2658 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2659 to call and return from a function.
2661 On 68HC11 the compiler generates a sequence of instructions
2662 to invoke a board-specific routine to switch the memory bank and call the
2663 real function.  The board-specific routine simulates a @code{call}.
2664 At the end of a function, it jumps to a board-specific routine
2665 instead of using @code{rts}.  The board-specific return routine simulates
2666 the @code{rtc}.
2668 On MeP targets this causes the compiler to use a calling convention
2669 that assumes the called function is too far away for the built-in
2670 addressing modes.
2672 @item fast_interrupt
2673 @cindex interrupt handler functions
2674 Use this attribute on the M32C and RX ports to indicate that the specified
2675 function is a fast interrupt handler.  This is just like the
2676 @code{interrupt} attribute, except that @code{freit} is used to return
2677 instead of @code{reit}.
2679 @item fastcall
2680 @cindex functions that pop the argument stack on the 386
2681 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2682 pass the first argument (if of integral type) in the register ECX and
2683 the second argument (if of integral type) in the register EDX@.  Subsequent
2684 and other typed arguments are passed on the stack.  The called function
2685 pops the arguments off the stack.  If the number of arguments is variable all
2686 arguments are pushed on the stack.
2688 @item thiscall
2689 @cindex functions that pop the argument stack on the 386
2690 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2691 pass the first argument (if of integral type) in the register ECX.
2692 Subsequent and other typed arguments are passed on the stack. The called
2693 function pops the arguments off the stack.
2694 If the number of arguments is variable all arguments are pushed on the
2695 stack.
2696 The @code{thiscall} attribute is intended for C++ non-static member functions.
2697 As a GCC extension, this calling convention can be used for C functions
2698 and for static member methods.
2700 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2701 @cindex @code{format} function attribute
2702 @opindex Wformat
2703 The @code{format} attribute specifies that a function takes @code{printf},
2704 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2705 should be type-checked against a format string.  For example, the
2706 declaration:
2708 @smallexample
2709 extern int
2710 my_printf (void *my_object, const char *my_format, ...)
2711       __attribute__ ((format (printf, 2, 3)));
2712 @end smallexample
2714 @noindent
2715 causes the compiler to check the arguments in calls to @code{my_printf}
2716 for consistency with the @code{printf} style format string argument
2717 @code{my_format}.
2719 The parameter @var{archetype} determines how the format string is
2720 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2721 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2722 @code{strfmon}.  (You can also use @code{__printf__},
2723 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2724 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2725 @code{ms_strftime} are also present.
2726 @var{archetype} values such as @code{printf} refer to the formats accepted
2727 by the system's C runtime library,
2728 while values prefixed with @samp{gnu_} always refer
2729 to the formats accepted by the GNU C Library.  On Microsoft Windows
2730 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2731 @file{msvcrt.dll} library.
2732 The parameter @var{string-index}
2733 specifies which argument is the format string argument (starting
2734 from 1), while @var{first-to-check} is the number of the first
2735 argument to check against the format string.  For functions
2736 where the arguments are not available to be checked (such as
2737 @code{vprintf}), specify the third parameter as zero.  In this case the
2738 compiler only checks the format string for consistency.  For
2739 @code{strftime} formats, the third parameter is required to be zero.
2740 Since non-static C++ methods have an implicit @code{this} argument, the
2741 arguments of such methods should be counted from two, not one, when
2742 giving values for @var{string-index} and @var{first-to-check}.
2744 In the example above, the format string (@code{my_format}) is the second
2745 argument of the function @code{my_print}, and the arguments to check
2746 start with the third argument, so the correct parameters for the format
2747 attribute are 2 and 3.
2749 @opindex ffreestanding
2750 @opindex fno-builtin
2751 The @code{format} attribute allows you to identify your own functions
2752 that take format strings as arguments, so that GCC can check the
2753 calls to these functions for errors.  The compiler always (unless
2754 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2755 for the standard library functions @code{printf}, @code{fprintf},
2756 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2757 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2758 warnings are requested (using @option{-Wformat}), so there is no need to
2759 modify the header file @file{stdio.h}.  In C99 mode, the functions
2760 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2761 @code{vsscanf} are also checked.  Except in strictly conforming C
2762 standard modes, the X/Open function @code{strfmon} is also checked as
2763 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2764 @xref{C Dialect Options,,Options Controlling C Dialect}.
2766 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2767 recognized in the same context.  Declarations including these format attributes
2768 are parsed for correct syntax, however the result of checking of such format
2769 strings is not yet defined, and is not carried out by this version of the
2770 compiler.
2772 The target may also provide additional types of format checks.
2773 @xref{Target Format Checks,,Format Checks Specific to Particular
2774 Target Machines}.
2776 @item format_arg (@var{string-index})
2777 @cindex @code{format_arg} function attribute
2778 @opindex Wformat-nonliteral
2779 The @code{format_arg} attribute specifies that a function takes a format
2780 string for a @code{printf}, @code{scanf}, @code{strftime} or
2781 @code{strfmon} style function and modifies it (for example, to translate
2782 it into another language), so the result can be passed to a
2783 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2784 function (with the remaining arguments to the format function the same
2785 as they would have been for the unmodified string).  For example, the
2786 declaration:
2788 @smallexample
2789 extern char *
2790 my_dgettext (char *my_domain, const char *my_format)
2791       __attribute__ ((format_arg (2)));
2792 @end smallexample
2794 @noindent
2795 causes the compiler to check the arguments in calls to a @code{printf},
2796 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2797 format string argument is a call to the @code{my_dgettext} function, for
2798 consistency with the format string argument @code{my_format}.  If the
2799 @code{format_arg} attribute had not been specified, all the compiler
2800 could tell in such calls to format functions would be that the format
2801 string argument is not constant; this would generate a warning when
2802 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2803 without the attribute.
2805 The parameter @var{string-index} specifies which argument is the format
2806 string argument (starting from one).  Since non-static C++ methods have
2807 an implicit @code{this} argument, the arguments of such methods should
2808 be counted from two.
2810 The @code{format_arg} attribute allows you to identify your own
2811 functions that modify format strings, so that GCC can check the
2812 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2813 type function whose operands are a call to one of your own function.
2814 The compiler always treats @code{gettext}, @code{dgettext}, and
2815 @code{dcgettext} in this manner except when strict ISO C support is
2816 requested by @option{-ansi} or an appropriate @option{-std} option, or
2817 @option{-ffreestanding} or @option{-fno-builtin}
2818 is used.  @xref{C Dialect Options,,Options
2819 Controlling C Dialect}.
2821 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2822 @code{NSString} reference for compatibility with the @code{format} attribute
2823 above.
2825 The target may also allow additional types in @code{format-arg} attributes.
2826 @xref{Target Format Checks,,Format Checks Specific to Particular
2827 Target Machines}.
2829 @item function_vector
2830 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2831 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2832 function should be called through the function vector.  Calling a
2833 function through the function vector reduces code size, however;
2834 the function vector has a limited size (maximum 128 entries on the H8/300
2835 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2837 On SH2A targets, this attribute declares a function to be called using the
2838 TBR relative addressing mode.  The argument to this attribute is the entry
2839 number of the same function in a vector table containing all the TBR
2840 relative addressable functions.  For correct operation the TBR must be setup
2841 accordingly to point to the start of the vector table before any functions with
2842 this attribute are invoked.  Usually a good place to do the initialization is
2843 the startup routine.  The TBR relative vector table can have at max 256 function
2844 entries.  The jumps to these functions are generated using a SH2A specific,
2845 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2846 from GNU binutils version 2.7 or later for this attribute to work correctly.
2848 Please refer the example of M16C target, to see the use of this
2849 attribute while declaring a function,
2851 In an application, for a function being called once, this attribute
2852 saves at least 8 bytes of code; and if other successive calls are being
2853 made to the same function, it saves 2 bytes of code per each of these
2854 calls.
2856 On M16C/M32C targets, the @code{function_vector} attribute declares a
2857 special page subroutine call function. Use of this attribute reduces
2858 the code size by 2 bytes for each call generated to the
2859 subroutine. The argument to the attribute is the vector number entry
2860 from the special page vector table which contains the 16 low-order
2861 bits of the subroutine's entry address. Each vector table has special
2862 page number (18 to 255) that is used in @code{jsrs} instructions.
2863 Jump addresses of the routines are generated by adding 0x0F0000 (in
2864 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2865 2-byte addresses set in the vector table. Therefore you need to ensure
2866 that all the special page vector routines should get mapped within the
2867 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2868 (for M32C).
2870 In the following example 2 bytes are saved for each call to
2871 function @code{foo}.
2873 @smallexample
2874 void foo (void) __attribute__((function_vector(0x18)));
2875 void foo (void)
2879 void bar (void)
2881     foo();
2883 @end smallexample
2885 If functions are defined in one file and are called in another file,
2886 then be sure to write this declaration in both files.
2888 This attribute is ignored for R8C target.
2890 @item ifunc ("@var{resolver}")
2891 @cindex @code{ifunc} attribute
2892 The @code{ifunc} attribute is used to mark a function as an indirect
2893 function using the STT_GNU_IFUNC symbol type extension to the ELF
2894 standard.  This allows the resolution of the symbol value to be
2895 determined dynamically at load time, and an optimized version of the
2896 routine can be selected for the particular processor or other system
2897 characteristics determined then.  To use this attribute, first define
2898 the implementation functions available, and a resolver function that
2899 returns a pointer to the selected implementation function.  The
2900 implementation functions' declarations must match the API of the
2901 function being implemented, the resolver's declaration is be a
2902 function returning pointer to void function returning void:
2904 @smallexample
2905 void *my_memcpy (void *dst, const void *src, size_t len)
2907   @dots{}
2910 static void (*resolve_memcpy (void)) (void)
2912   return my_memcpy; // we'll just always select this routine
2914 @end smallexample
2916 @noindent
2917 The exported header file declaring the function the user calls would
2918 contain:
2920 @smallexample
2921 extern void *memcpy (void *, const void *, size_t);
2922 @end smallexample
2924 @noindent
2925 allowing the user to call this as a regular function, unaware of the
2926 implementation.  Finally, the indirect function needs to be defined in
2927 the same translation unit as the resolver function:
2929 @smallexample
2930 void *memcpy (void *, const void *, size_t)
2931      __attribute__ ((ifunc ("resolve_memcpy")));
2932 @end smallexample
2934 Indirect functions cannot be weak, and require a recent binutils (at
2935 least version 2.20.1), and GNU C library (at least version 2.11.1).
2937 @item interrupt
2938 @cindex interrupt handler functions
2939 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2940 m68k, MeP, MIPS, MSP430, RL78, RX, Visium and Xstormy16 ports to indicate
2941 that the specified function is an interrupt handler.  The compiler generates
2942 function entry and exit sequences suitable for use in an interrupt handler
2943 when this attribute is present.  With Epiphany targets it may also generate
2944 a special section with code to initialize the interrupt vector table.
2946 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2947 and SH processors can be specified via the @code{interrupt_handler} attribute.
2949 Note, on the ARC, you must specify the kind of interrupt to be handled
2950 in a parameter to the interrupt attribute like this:
2952 @smallexample
2953 void f () __attribute__ ((interrupt ("ilink1")));
2954 @end smallexample
2956 Permissible values for this parameter are: @w{@code{ilink1}} and
2957 @w{@code{ilink2}}.
2959 Note, on the AVR, the hardware globally disables interrupts when an
2960 interrupt is executed.  The first instruction of an interrupt handler
2961 declared with this attribute is a @code{SEI} instruction to
2962 re-enable interrupts.  See also the @code{signal} function attribute
2963 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2964 @code{interrupt} are specified for the same function, @code{signal}
2965 is silently ignored.
2967 Note, for the ARM, you can specify the kind of interrupt to be handled by
2968 adding an optional parameter to the interrupt attribute like this:
2970 @smallexample
2971 void f () __attribute__ ((interrupt ("IRQ")));
2972 @end smallexample
2974 @noindent
2975 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2976 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2978 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2979 may be called with a word-aligned stack pointer.
2981 Note, for the MSP430 you can provide an argument to the interrupt
2982 attribute which specifies a name or number.  If the argument is a
2983 number it indicates the slot in the interrupt vector table (0 - 31) to
2984 which this handler should be assigned.  If the argument is a name it
2985 is treated as a symbolic name for the vector slot.  These names should
2986 match up with appropriate entries in the linker script.  By default
2987 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2988 @code{reset} for vector 31 are recognised.
2990 You can also use the following function attributes to modify how
2991 normal functions interact with interrupt functions:
2993 @table @code
2994 @item critical
2995 @cindex @code{critical} attribute
2996 Critical functions disable interrupts upon entry and restore the
2997 previous interrupt state upon exit.  Critical functions cannot also
2998 have the @code{naked} or @code{reentrant} attributes.  They can have
2999 the @code{interrupt} attribute.
3001 @item reentrant
3002 @cindex @code{reentrant} attribute
3003 Reentrant functions disable interrupts upon entry and enable them
3004 upon exit.  Reentrant functions cannot also have the @code{naked}
3005 or @code{critical} attributes.  They can have the @code{interrupt}
3006 attribute.
3008 @item wakeup
3009 @cindex @code{wakeup} attribute
3010 This attribute only applies to interrupt functions.  It is silently
3011 ignored if applied to a non-interrupt function.  A wakeup interrupt
3012 function will rouse the processor from any low-power state that it
3013 might be in when the function exits.
3015 @end table
3017 On Epiphany targets one or more optional parameters can be added like this:
3019 @smallexample
3020 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3021 @end smallexample
3023 Permissible values for these parameters are: @w{@code{reset}},
3024 @w{@code{software_exception}}, @w{@code{page_miss}},
3025 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3026 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3027 Multiple parameters indicate that multiple entries in the interrupt
3028 vector table should be initialized for this function, i.e.@: for each
3029 parameter @w{@var{name}}, a jump to the function is emitted in
3030 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3031 entirely, in which case no interrupt vector table entry is provided.
3033 Note, on Epiphany targets, interrupts are enabled inside the function
3034 unless the @code{disinterrupt} attribute is also specified.
3036 On Epiphany targets, you can also use the following attribute to
3037 modify the behavior of an interrupt handler:
3038 @table @code
3039 @item forwarder_section
3040 @cindex @code{forwarder_section} attribute
3041 The interrupt handler may be in external memory which cannot be
3042 reached by a branch instruction, so generate a local memory trampoline
3043 to transfer control.  The single parameter identifies the section where
3044 the trampoline is placed.
3045 @end table
3047 The following examples are all valid uses of these attributes on
3048 Epiphany targets:
3049 @smallexample
3050 void __attribute__ ((interrupt)) universal_handler ();
3051 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3052 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3053 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3054   fast_timer_handler ();
3055 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3056   external_dma_handler ();
3057 @end smallexample
3059 On MIPS targets, you can use the following attributes to modify the behavior
3060 of an interrupt handler:
3061 @table @code
3062 @item use_shadow_register_set
3063 @cindex @code{use_shadow_register_set} attribute
3064 Assume that the handler uses a shadow register set, instead of
3065 the main general-purpose registers.
3067 @item keep_interrupts_masked
3068 @cindex @code{keep_interrupts_masked} attribute
3069 Keep interrupts masked for the whole function.  Without this attribute,
3070 GCC tries to reenable interrupts for as much of the function as it can.
3072 @item use_debug_exception_return
3073 @cindex @code{use_debug_exception_return} attribute
3074 Return using the @code{deret} instruction.  Interrupt handlers that don't
3075 have this attribute return using @code{eret} instead.
3076 @end table
3078 You can use any combination of these attributes, as shown below:
3079 @smallexample
3080 void __attribute__ ((interrupt)) v0 ();
3081 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3082 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3083 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3084 void __attribute__ ((interrupt, use_shadow_register_set,
3085                      keep_interrupts_masked)) v4 ();
3086 void __attribute__ ((interrupt, use_shadow_register_set,
3087                      use_debug_exception_return)) v5 ();
3088 void __attribute__ ((interrupt, keep_interrupts_masked,
3089                      use_debug_exception_return)) v6 ();
3090 void __attribute__ ((interrupt, use_shadow_register_set,
3091                      keep_interrupts_masked,
3092                      use_debug_exception_return)) v7 ();
3093 @end smallexample
3095 On NDS32 target, this attribute is to indicate that the specified function
3096 is an interrupt handler.  The compiler will generate corresponding sections
3097 for use in an interrupt handler.  You can use the following attributes
3098 to modify the behavior:
3099 @table @code
3100 @item nested
3101 @cindex @code{nested} attribute
3102 This interrupt service routine is interruptible.
3103 @item not_nested
3104 @cindex @code{not_nested} attribute
3105 This interrupt service routine is not interruptible.
3106 @item nested_ready
3107 @cindex @code{nested_ready} attribute
3108 This interrupt service routine is interruptible after @code{PSW.GIE}
3109 (global interrupt enable) is set.  This allows interrupt service routine to
3110 finish some short critical code before enabling interrupts.
3111 @item save_all
3112 @cindex @code{save_all} attribute
3113 The system will help save all registers into stack before entering
3114 interrupt handler.
3115 @item partial_save
3116 @cindex @code{partial_save} attribute
3117 The system will help save caller registers into stack before entering
3118 interrupt handler.
3119 @end table
3121 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3122 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3123 that must end with @code{RETB} instead of @code{RETI}).
3125 On RX targets, you may specify one or more vector numbers as arguments
3126 to the attribute, as well as naming an alternate table name.
3127 Parameters are handled sequentially, so one handler can be assigned to
3128 multiple entries in multiple tables.  One may also pass the magic
3129 string @code{"$default"} which causes the function to be used for any
3130 unfilled slots in the current table.
3132 This example shows a simple assignment of a function to one vector in
3133 the default table (note that preprocessor macros may be used for
3134 chip-specific symbolic vector names):
3135 @smallexample
3136 void __attribute__ ((interrupt (5))) txd1_handler ();
3137 @end smallexample
3139 This example assigns a function to two slots in the default table
3140 (using preprocessor macros defined elsewhere) and makes it the default
3141 for the @code{dct} table:
3142 @smallexample
3143 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3144         txd1_handler ();
3145 @end smallexample
3147 @item interrupt_handler
3148 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3149 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3150 indicate that the specified function is an interrupt handler.  The compiler
3151 generates function entry and exit sequences suitable for use in an
3152 interrupt handler when this attribute is present.
3154 @item interrupt_thread
3155 @cindex interrupt thread functions on fido
3156 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3157 that the specified function is an interrupt handler that is designed
3158 to run as a thread.  The compiler omits generate prologue/epilogue
3159 sequences and replaces the return instruction with a @code{sleep}
3160 instruction.  This attribute is available only on fido.
3162 @item isr
3163 @cindex interrupt service routines on ARM
3164 Use this attribute on ARM to write Interrupt Service Routines. This is an
3165 alias to the @code{interrupt} attribute above.
3167 @item kspisusp
3168 @cindex User stack pointer in interrupts on the Blackfin
3169 When used together with @code{interrupt_handler}, @code{exception_handler}
3170 or @code{nmi_handler}, code is generated to load the stack pointer
3171 from the USP register in the function prologue.
3173 @item l1_text
3174 @cindex @code{l1_text} function attribute
3175 This attribute specifies a function to be placed into L1 Instruction
3176 SRAM@. The function is put into a specific section named @code{.l1.text}.
3177 With @option{-mfdpic}, function calls with a such function as the callee
3178 or caller uses inlined PLT.
3180 @item l2
3181 @cindex @code{l2} function attribute
3182 On the Blackfin, this attribute specifies a function to be placed into L2
3183 SRAM. The function is put into a specific section named
3184 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3185 an inlined PLT.
3187 @item leaf
3188 @cindex @code{leaf} function attribute
3189 Calls to external functions with this attribute must return to the current
3190 compilation unit only by return or by exception handling.  In particular, leaf
3191 functions are not allowed to call callback function passed to it from the current
3192 compilation unit or directly call functions exported by the unit or longjmp
3193 into the unit.  Leaf function might still call functions from other compilation
3194 units and thus they are not necessarily leaf in the sense that they contain no
3195 function calls at all.
3197 The attribute is intended for library functions to improve dataflow analysis.
3198 The compiler takes the hint that any data not escaping the current compilation unit can
3199 not be used or modified by the leaf function.  For example, the @code{sin} function
3200 is a leaf function, but @code{qsort} is not.
3202 Note that leaf functions might invoke signals and signal handlers might be
3203 defined in the current compilation unit and use static variables.  The only
3204 compliant way to write such a signal handler is to declare such variables
3205 @code{volatile}.
3207 The attribute has no effect on functions defined within the current compilation
3208 unit.  This is to allow easy merging of multiple compilation units into one,
3209 for example, by using the link-time optimization.  For this reason the
3210 attribute is not allowed on types to annotate indirect calls.
3212 @item long_call/medium_call/short_call
3213 @cindex indirect calls on ARC
3214 @cindex indirect calls on ARM
3215 @cindex indirect calls on Epiphany
3216 These attributes specify how a particular function is called on
3217 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3218 These attributes override the
3219 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3220 and @option{-mmedium-calls} (@pxref{ARC Options})
3221 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3222 @code{long_call} attribute indicates that the function might be far
3223 away from the call site and require a different (more expensive)
3224 calling sequence.   The @code{short_call} attribute always places
3225 the offset to the function from the call site into the @samp{BL}
3226 instruction directly.
3228 For ARC, a function marked with the @code{long_call} attribute is
3229 always called using register-indirect jump-and-link instructions,
3230 thereby enabling the called function to be placed anywhere within the
3231 32-bit address space.  A function marked with the @code{medium_call}
3232 attribute will always be close enough to be called with an unconditional
3233 branch-and-link instruction, which has a 25-bit offset from
3234 the call site.  A function marked with the @code{short_call}
3235 attribute will always be close enough to be called with a conditional
3236 branch-and-link instruction, which has a 21-bit offset from
3237 the call site.
3239 @item longcall/shortcall
3240 @cindex functions called via pointer on the RS/6000 and PowerPC
3241 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3242 indicates that the function might be far away from the call site and
3243 require a different (more expensive) calling sequence.  The
3244 @code{shortcall} attribute indicates that the function is always close
3245 enough for the shorter calling sequence to be used.  These attributes
3246 override both the @option{-mlongcall} switch and, on the RS/6000 and
3247 PowerPC, the @code{#pragma longcall} setting.
3249 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3250 calls are necessary.
3252 @item long_call/near/far
3253 @cindex indirect calls on MIPS
3254 These attributes specify how a particular function is called on MIPS@.
3255 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3256 command-line switch.  The @code{long_call} and @code{far} attributes are
3257 synonyms, and cause the compiler to always call
3258 the function by first loading its address into a register, and then using
3259 the contents of that register.  The @code{near} attribute has the opposite
3260 effect; it specifies that non-PIC calls should be made using the more
3261 efficient @code{jal} instruction.
3263 @item malloc
3264 @cindex @code{malloc} attribute
3265 This tells the compiler that a function is @code{malloc}-like, i.e.,
3266 that the pointer @var{P} returned by the function cannot alias any
3267 other pointer valid when the function returns, and moreover no
3268 pointers to valid objects occur in any storage addressed by @var{P}.
3270 Using this attribute can improve optimization.  Functions like
3271 @code{malloc} and @code{calloc} have this property because they return
3272 a pointer to uninitialized or zeroed-out storage.  However, functions
3273 like @code{realloc} do not have this property, as they can return a
3274 pointer to storage containing pointers.
3276 @item mips16/nomips16
3277 @cindex @code{mips16} attribute
3278 @cindex @code{nomips16} attribute
3280 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3281 function attributes to locally select or turn off MIPS16 code generation.
3282 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3283 while MIPS16 code generation is disabled for functions with the
3284 @code{nomips16} attribute.  These attributes override the
3285 @option{-mips16} and @option{-mno-mips16} options on the command line
3286 (@pxref{MIPS Options}).
3288 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3289 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3290 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3291 may interact badly with some GCC extensions such as @code{__builtin_apply}
3292 (@pxref{Constructing Calls}).
3294 @item micromips/nomicromips
3295 @cindex @code{micromips} attribute
3296 @cindex @code{nomicromips} attribute
3298 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3299 function attributes to locally select or turn off microMIPS code generation.
3300 A function with the @code{micromips} attribute is emitted as microMIPS code,
3301 while microMIPS code generation is disabled for functions with the
3302 @code{nomicromips} attribute.  These attributes override the
3303 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3304 (@pxref{MIPS Options}).
3306 When compiling files containing mixed microMIPS and non-microMIPS code, the
3307 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3308 command line,
3309 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3310 may interact badly with some GCC extensions such as @code{__builtin_apply}
3311 (@pxref{Constructing Calls}).
3313 @item model (@var{model-name})
3314 @cindex function addressability on the M32R/D
3315 @cindex variable addressability on the IA-64
3317 On the M32R/D, use this attribute to set the addressability of an
3318 object, and of the code generated for a function.  The identifier
3319 @var{model-name} is one of @code{small}, @code{medium}, or
3320 @code{large}, representing each of the code models.
3322 Small model objects live in the lower 16MB of memory (so that their
3323 addresses can be loaded with the @code{ld24} instruction), and are
3324 callable with the @code{bl} instruction.
3326 Medium model objects may live anywhere in the 32-bit address space (the
3327 compiler generates @code{seth/add3} instructions to load their addresses),
3328 and are callable with the @code{bl} instruction.
3330 Large model objects may live anywhere in the 32-bit address space (the
3331 compiler generates @code{seth/add3} instructions to load their addresses),
3332 and may not be reachable with the @code{bl} instruction (the compiler
3333 generates the much slower @code{seth/add3/jl} instruction sequence).
3335 On IA-64, use this attribute to set the addressability of an object.
3336 At present, the only supported identifier for @var{model-name} is
3337 @code{small}, indicating addressability via ``small'' (22-bit)
3338 addresses (so that their addresses can be loaded with the @code{addl}
3339 instruction).  Caveat: such addressing is by definition not position
3340 independent and hence this attribute must not be used for objects
3341 defined by shared libraries.
3343 @item ms_abi/sysv_abi
3344 @cindex @code{ms_abi} attribute
3345 @cindex @code{sysv_abi} attribute
3347 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3348 to indicate which calling convention should be used for a function.  The
3349 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3350 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3351 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3352 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3354 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3355 requires the @option{-maccumulate-outgoing-args} option.
3357 @item callee_pop_aggregate_return (@var{number})
3358 @cindex @code{callee_pop_aggregate_return} attribute
3360 On 32-bit i?86-*-* targets, you can use this attribute to control how
3361 aggregates are returned in memory.  If the caller is responsible for
3362 popping the hidden pointer together with the rest of the arguments, specify
3363 @var{number} equal to zero.  If callee is responsible for popping the
3364 hidden pointer, specify @var{number} equal to one.  
3366 The default i386 ABI assumes that the callee pops the
3367 stack for hidden pointer.  However, on 32-bit i386 Microsoft Windows targets,
3368 the compiler assumes that the
3369 caller pops the stack for hidden pointer.
3371 @item ms_hook_prologue
3372 @cindex @code{ms_hook_prologue} attribute
3374 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3375 this function attribute to make GCC generate the ``hot-patching'' function
3376 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3377 and newer.
3379 @item hotpatch [(@var{prologue-halfwords})]
3380 @cindex @code{hotpatch} attribute
3382 On S/390 System z targets, you can use this function attribute to
3383 make GCC generate a ``hot-patching'' function prologue.  The
3384 @code{hotpatch} has no effect on funtions that are explicitly
3385 inline.  If the @option{-mhotpatch} or @option{-mno-hotpatch}
3386 command-line option is used at the same time, the @code{hotpatch}
3387 attribute takes precedence.  If an argument is given, the maximum
3388 allowed value is 1000000.
3390 @item naked
3391 @cindex function without a prologue/epilogue code
3392 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3393 RL78, RX and SPU ports.  It allows the compiler to construct the
3394 requisite function declaration, while allowing the body of the
3395 function to be assembly code. The specified function will not have
3396 prologue/epilogue sequences generated by the compiler. Only Basic
3397 @code{asm} statements can safely be included in naked functions
3398 (@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
3399 Basic @code{asm} and ``C'' code may appear to work, they cannot be
3400 depended upon to work reliably and are not supported.
3402 @item near
3403 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3404 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3405 use the normal calling convention based on @code{jsr} and @code{rts}.
3406 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3407 option.
3409 On MeP targets this attribute causes the compiler to assume the called
3410 function is close enough to use the normal calling convention,
3411 overriding the @option{-mtf} command-line option.
3413 @item nesting
3414 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3415 Use this attribute together with @code{interrupt_handler},
3416 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3417 entry code should enable nested interrupts or exceptions.
3419 @item nmi_handler
3420 @cindex NMI handler functions on the Blackfin processor
3421 Use this attribute on the Blackfin to indicate that the specified function
3422 is an NMI handler.  The compiler generates function entry and
3423 exit sequences suitable for use in an NMI handler when this
3424 attribute is present.
3426 @item nocompression
3427 @cindex @code{nocompression} attribute
3428 On MIPS targets, you can use the @code{nocompression} function attribute
3429 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3430 overrides the @option{-mips16} and @option{-mmicromips} options on the
3431 command line (@pxref{MIPS Options}).
3433 @item no_instrument_function
3434 @cindex @code{no_instrument_function} function attribute
3435 @opindex finstrument-functions
3436 If @option{-finstrument-functions} is given, profiling function calls are
3437 generated at entry and exit of most user-compiled functions.
3438 Functions with this attribute are not so instrumented.
3440 @item no_split_stack
3441 @cindex @code{no_split_stack} function attribute
3442 @opindex fsplit-stack
3443 If @option{-fsplit-stack} is given, functions have a small
3444 prologue which decides whether to split the stack.  Functions with the
3445 @code{no_split_stack} attribute do not have that prologue, and thus
3446 may run with only a small amount of stack space available.
3448 @item stack_protect
3449 @cindex @code{stack_protect} function attribute
3450 This function attribute make a stack protection of the function if 
3451 flags @option{fstack-protector} or @option{fstack-protector-strong}
3452 or @option{fstack-protector-explicit} are set.
3454 @item noinline
3455 @cindex @code{noinline} function attribute
3456 This function attribute prevents a function from being considered for
3457 inlining.
3458 @c Don't enumerate the optimizations by name here; we try to be
3459 @c future-compatible with this mechanism.
3460 If the function does not have side-effects, there are optimizations
3461 other than inlining that cause function calls to be optimized away,
3462 although the function call is live.  To keep such calls from being
3463 optimized away, put
3464 @smallexample
3465 asm ("");
3466 @end smallexample
3468 @noindent
3469 (@pxref{Extended Asm}) in the called function, to serve as a special
3470 side-effect.
3472 @item noclone
3473 @cindex @code{noclone} function attribute
3474 This function attribute prevents a function from being considered for
3475 cloning---a mechanism that produces specialized copies of functions
3476 and which is (currently) performed by interprocedural constant
3477 propagation.
3479 @item no_icf
3480 @cindex @code{no_icf} function attribute
3481 This function attribute prevents a functions from being merged with another
3482 semantically equivalent function.
3484 @item nonnull (@var{arg-index}, @dots{})
3485 @cindex @code{nonnull} function attribute
3486 The @code{nonnull} attribute specifies that some function parameters should
3487 be non-null pointers.  For instance, the declaration:
3489 @smallexample
3490 extern void *
3491 my_memcpy (void *dest, const void *src, size_t len)
3492         __attribute__((nonnull (1, 2)));
3493 @end smallexample
3495 @noindent
3496 causes the compiler to check that, in calls to @code{my_memcpy},
3497 arguments @var{dest} and @var{src} are non-null.  If the compiler
3498 determines that a null pointer is passed in an argument slot marked
3499 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3500 is issued.  The compiler may also choose to make optimizations based
3501 on the knowledge that certain function arguments will never be null.
3503 If no argument index list is given to the @code{nonnull} attribute,
3504 all pointer arguments are marked as non-null.  To illustrate, the
3505 following declaration is equivalent to the previous example:
3507 @smallexample
3508 extern void *
3509 my_memcpy (void *dest, const void *src, size_t len)
3510         __attribute__((nonnull));
3511 @end smallexample
3513 @item no_reorder
3514 @cindex @code{no_reorder} function or variable attribute
3515 Do not reorder functions or variables marked @code{no_reorder}
3516 against each other or top level assembler statements the executable.
3517 The actual order in the program will depend on the linker command
3518 line. Static variables marked like this are also not removed.
3519 This has a similar effect
3520 as the @option{-fno-toplevel-reorder} option, but only applies to the
3521 marked symbols.
3523 @item returns_nonnull
3524 @cindex @code{returns_nonnull} function attribute
3525 The @code{returns_nonnull} attribute specifies that the function
3526 return value should be a non-null pointer.  For instance, the declaration:
3528 @smallexample
3529 extern void *
3530 mymalloc (size_t len) __attribute__((returns_nonnull));
3531 @end smallexample
3533 @noindent
3534 lets the compiler optimize callers based on the knowledge
3535 that the return value will never be null.
3537 @item noreturn
3538 @cindex @code{noreturn} function attribute
3539 A few standard library functions, such as @code{abort} and @code{exit},
3540 cannot return.  GCC knows this automatically.  Some programs define
3541 their own functions that never return.  You can declare them
3542 @code{noreturn} to tell the compiler this fact.  For example,
3544 @smallexample
3545 @group
3546 void fatal () __attribute__ ((noreturn));
3548 void
3549 fatal (/* @r{@dots{}} */)
3551   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3552   exit (1);
3554 @end group
3555 @end smallexample
3557 The @code{noreturn} keyword tells the compiler to assume that
3558 @code{fatal} cannot return.  It can then optimize without regard to what
3559 would happen if @code{fatal} ever did return.  This makes slightly
3560 better code.  More importantly, it helps avoid spurious warnings of
3561 uninitialized variables.
3563 The @code{noreturn} keyword does not affect the exceptional path when that
3564 applies: a @code{noreturn}-marked function may still return to the caller
3565 by throwing an exception or calling @code{longjmp}.
3567 Do not assume that registers saved by the calling function are
3568 restored before calling the @code{noreturn} function.
3570 It does not make sense for a @code{noreturn} function to have a return
3571 type other than @code{void}.
3573 The attribute @code{noreturn} is not implemented in GCC versions
3574 earlier than 2.5.  An alternative way to declare that a function does
3575 not return, which works in the current version and in some older
3576 versions, is as follows:
3578 @smallexample
3579 typedef void voidfn ();
3581 volatile voidfn fatal;
3582 @end smallexample
3584 @noindent
3585 This approach does not work in GNU C++.
3587 @item nothrow
3588 @cindex @code{nothrow} function attribute
3589 The @code{nothrow} attribute is used to inform the compiler that a
3590 function cannot throw an exception.  For example, most functions in
3591 the standard C library can be guaranteed not to throw an exception
3592 with the notable exceptions of @code{qsort} and @code{bsearch} that
3593 take function pointer arguments.  The @code{nothrow} attribute is not
3594 implemented in GCC versions earlier than 3.3.
3596 @item nosave_low_regs
3597 @cindex @code{nosave_low_regs} attribute
3598 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3599 function should not save and restore registers R0..R7.  This can be used on SH3*
3600 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3601 interrupt handlers.
3603 @item optimize
3604 @cindex @code{optimize} function attribute
3605 The @code{optimize} attribute is used to specify that a function is to
3606 be compiled with different optimization options than specified on the
3607 command line.  Arguments can either be numbers or strings.  Numbers
3608 are assumed to be an optimization level.  Strings that begin with
3609 @code{O} are assumed to be an optimization option, while other options
3610 are assumed to be used with a @code{-f} prefix.  You can also use the
3611 @samp{#pragma GCC optimize} pragma to set the optimization options
3612 that affect more than one function.
3613 @xref{Function Specific Option Pragmas}, for details about the
3614 @samp{#pragma GCC optimize} pragma.
3616 This can be used for instance to have frequently-executed functions
3617 compiled with more aggressive optimization options that produce faster
3618 and larger code, while other functions can be compiled with less
3619 aggressive options.
3621 @item OS_main/OS_task
3622 @cindex @code{OS_main} AVR function attribute
3623 @cindex @code{OS_task} AVR function attribute
3624 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3625 do not save/restore any call-saved register in their prologue/epilogue.
3627 The @code{OS_main} attribute can be used when there @emph{is
3628 guarantee} that interrupts are disabled at the time when the function
3629 is entered.  This saves resources when the stack pointer has to be
3630 changed to set up a frame for local variables.
3632 The @code{OS_task} attribute can be used when there is @emph{no
3633 guarantee} that interrupts are disabled at that time when the function
3634 is entered like for, e@.g@. task functions in a multi-threading operating
3635 system. In that case, changing the stack pointer register is
3636 guarded by save/clear/restore of the global interrupt enable flag.
3638 The differences to the @code{naked} function attribute are:
3639 @itemize @bullet
3640 @item @code{naked} functions do not have a return instruction whereas 
3641 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3642 @code{RETI} return instruction.
3643 @item @code{naked} functions do not set up a frame for local variables
3644 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3645 as needed.
3646 @end itemize
3648 @item pcs
3649 @cindex @code{pcs} function attribute
3651 The @code{pcs} attribute can be used to control the calling convention
3652 used for a function on ARM.  The attribute takes an argument that specifies
3653 the calling convention to use.
3655 When compiling using the AAPCS ABI (or a variant of it) then valid
3656 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3657 order to use a variant other than @code{"aapcs"} then the compiler must
3658 be permitted to use the appropriate co-processor registers (i.e., the
3659 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3660 For example,
3662 @smallexample
3663 /* Argument passed in r0, and result returned in r0+r1.  */
3664 double f2d (float) __attribute__((pcs("aapcs")));
3665 @end smallexample
3667 Variadic functions always use the @code{"aapcs"} calling convention and
3668 the compiler rejects attempts to specify an alternative.
3670 @item pure
3671 @cindex @code{pure} function attribute
3672 Many functions have no effects except the return value and their
3673 return value depends only on the parameters and/or global variables.
3674 Such a function can be subject
3675 to common subexpression elimination and loop optimization just as an
3676 arithmetic operator would be.  These functions should be declared
3677 with the attribute @code{pure}.  For example,
3679 @smallexample
3680 int square (int) __attribute__ ((pure));
3681 @end smallexample
3683 @noindent
3684 says that the hypothetical function @code{square} is safe to call
3685 fewer times than the program says.
3687 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3688 Interesting non-pure functions are functions with infinite loops or those
3689 depending on volatile memory or other system resource, that may change between
3690 two consecutive calls (such as @code{feof} in a multithreading environment).
3692 The attribute @code{pure} is not implemented in GCC versions earlier
3693 than 2.96.
3695 @item hot
3696 @cindex @code{hot} function attribute
3697 The @code{hot} attribute on a function is used to inform the compiler that
3698 the function is a hot spot of the compiled program.  The function is
3699 optimized more aggressively and on many targets it is placed into a special
3700 subsection of the text section so all hot functions appear close together,
3701 improving locality.
3703 When profile feedback is available, via @option{-fprofile-use}, hot functions
3704 are automatically detected and this attribute is ignored.
3706 The @code{hot} attribute on functions is not implemented in GCC versions
3707 earlier than 4.3.
3709 @item cold
3710 @cindex @code{cold} function attribute
3711 The @code{cold} attribute on functions is used to inform the compiler that
3712 the function is unlikely to be executed.  The function is optimized for
3713 size rather than speed and on many targets it is placed into a special
3714 subsection of the text section so all cold functions appear close together,
3715 improving code locality of non-cold parts of program.  The paths leading
3716 to calls of cold functions within code are marked as unlikely by the branch
3717 prediction mechanism.  It is thus useful to mark functions used to handle
3718 unlikely conditions, such as @code{perror}, as cold to improve optimization
3719 of hot functions that do call marked functions in rare occasions.
3721 When profile feedback is available, via @option{-fprofile-use}, cold functions
3722 are automatically detected and this attribute is ignored.
3724 The @code{cold} attribute on functions is not implemented in GCC versions
3725 earlier than 4.3.
3727 @item no_sanitize_address
3728 @itemx no_address_safety_analysis
3729 @cindex @code{no_sanitize_address} function attribute
3730 The @code{no_sanitize_address} attribute on functions is used
3731 to inform the compiler that it should not instrument memory accesses
3732 in the function when compiling with the @option{-fsanitize=address} option.
3733 The @code{no_address_safety_analysis} is a deprecated alias of the
3734 @code{no_sanitize_address} attribute, new code should use
3735 @code{no_sanitize_address}.
3737 @item no_sanitize_thread
3738 @cindex @code{no_sanitize_thread} function attribute
3739 The @code{no_sanitize_thread} attribute on functions is used
3740 to inform the compiler that it should not instrument memory accesses
3741 in the function when compiling with the @option{-fsanitize=thread} option.
3743 @item no_sanitize_undefined
3744 @cindex @code{no_sanitize_undefined} function attribute
3745 The @code{no_sanitize_undefined} attribute on functions is used
3746 to inform the compiler that it should not check for undefined behavior
3747 in the function when compiling with the @option{-fsanitize=undefined} option.
3749 @item bnd_legacy
3750 @cindex @code{bnd_legacy} function attribute
3751 The @code{bnd_legacy} attribute on functions is used to inform
3752 compiler that function should not be instrumented when compiled
3753 with @option{-fcheck-pointer-bounds} option.
3755 @item bnd_instrument
3756 @cindex @code{bnd_instrument} function attribute
3757 The @code{bnd_instrument} attribute on functions is used to inform
3758 compiler that function should be instrumented when compiled
3759 with @option{-fchkp-instrument-marked-only} option.
3761 @item regparm (@var{number})
3762 @cindex @code{regparm} attribute
3763 @cindex functions that are passed arguments in registers on the 386
3764 On the Intel 386, the @code{regparm} attribute causes the compiler to
3765 pass arguments number one to @var{number} if they are of integral type
3766 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3767 take a variable number of arguments continue to be passed all of their
3768 arguments on the stack.
3770 Beware that on some ELF systems this attribute is unsuitable for
3771 global functions in shared libraries with lazy binding (which is the
3772 default).  Lazy binding sends the first call via resolving code in
3773 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3774 per the standard calling conventions.  Solaris 8 is affected by this.
3775 Systems with the GNU C Library version 2.1 or higher
3776 and FreeBSD are believed to be
3777 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3778 disabled with the linker or the loader if desired, to avoid the
3779 problem.)
3781 @item reset
3782 @cindex reset handler functions
3783 Use this attribute on the NDS32 target to indicate that the specified function
3784 is a reset handler.  The compiler will generate corresponding sections
3785 for use in a reset handler.  You can use the following attributes
3786 to provide extra exception handling:
3787 @table @code
3788 @item nmi
3789 @cindex @code{nmi} attribute
3790 Provide a user-defined function to handle NMI exception.
3791 @item warm
3792 @cindex @code{warm} attribute
3793 Provide a user-defined function to handle warm reset exception.
3794 @end table
3796 @item sseregparm
3797 @cindex @code{sseregparm} attribute
3798 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3799 causes the compiler to pass up to 3 floating-point arguments in
3800 SSE registers instead of on the stack.  Functions that take a
3801 variable number of arguments continue to pass all of their
3802 floating-point arguments on the stack.
3804 @item force_align_arg_pointer
3805 @cindex @code{force_align_arg_pointer} attribute
3806 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3807 applied to individual function definitions, generating an alternate
3808 prologue and epilogue that realigns the run-time stack if necessary.
3809 This supports mixing legacy codes that run with a 4-byte aligned stack
3810 with modern codes that keep a 16-byte stack for SSE compatibility.
3812 @item renesas
3813 @cindex @code{renesas} attribute
3814 On SH targets this attribute specifies that the function or struct follows the
3815 Renesas ABI.
3817 @item resbank
3818 @cindex @code{resbank} attribute
3819 On the SH2A target, this attribute enables the high-speed register
3820 saving and restoration using a register bank for @code{interrupt_handler}
3821 routines.  Saving to the bank is performed automatically after the CPU
3822 accepts an interrupt that uses a register bank.
3824 The nineteen 32-bit registers comprising general register R0 to R14,
3825 control register GBR, and system registers MACH, MACL, and PR and the
3826 vector table address offset are saved into a register bank.  Register
3827 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3828 from the bank is executed by issuing a RESBANK instruction.
3830 @item returns_twice
3831 @cindex @code{returns_twice} attribute
3832 The @code{returns_twice} attribute tells the compiler that a function may
3833 return more than one time.  The compiler ensures that all registers
3834 are dead before calling such a function and emits a warning about
3835 the variables that may be clobbered after the second return from the
3836 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3837 The @code{longjmp}-like counterpart of such function, if any, might need
3838 to be marked with the @code{noreturn} attribute.
3840 @item saveall
3841 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3842 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3843 all registers except the stack pointer should be saved in the prologue
3844 regardless of whether they are used or not.
3846 @item save_volatiles
3847 @cindex save volatile registers on the MicroBlaze
3848 Use this attribute on the MicroBlaze to indicate that the function is
3849 an interrupt handler.  All volatile registers (in addition to non-volatile
3850 registers) are saved in the function prologue.  If the function is a leaf
3851 function, only volatiles used by the function are saved.  A normal function
3852 return is generated instead of a return from interrupt.
3854 @item break_handler
3855 @cindex break handler functions
3856 Use this attribute on the MicroBlaze ports to indicate that
3857 the specified function is an break handler.  The compiler generates function
3858 entry and exit sequences suitable for use in an break handler when this
3859 attribute is present. The return from @code{break_handler} is done through
3860 the @code{rtbd} instead of @code{rtsd}.
3862 @smallexample
3863 void f () __attribute__ ((break_handler));
3864 @end smallexample
3866 @item section ("@var{section-name}")
3867 @cindex @code{section} function attribute
3868 Normally, the compiler places the code it generates in the @code{text} section.
3869 Sometimes, however, you need additional sections, or you need certain
3870 particular functions to appear in special sections.  The @code{section}
3871 attribute specifies that a function lives in a particular section.
3872 For example, the declaration:
3874 @smallexample
3875 extern void foobar (void) __attribute__ ((section ("bar")));
3876 @end smallexample
3878 @noindent
3879 puts the function @code{foobar} in the @code{bar} section.
3881 Some file formats do not support arbitrary sections so the @code{section}
3882 attribute is not available on all platforms.
3883 If you need to map the entire contents of a module to a particular
3884 section, consider using the facilities of the linker instead.
3886 @item sentinel
3887 @cindex @code{sentinel} function attribute
3888 This function attribute ensures that a parameter in a function call is
3889 an explicit @code{NULL}.  The attribute is only valid on variadic
3890 functions.  By default, the sentinel is located at position zero, the
3891 last parameter of the function call.  If an optional integer position
3892 argument P is supplied to the attribute, the sentinel must be located at
3893 position P counting backwards from the end of the argument list.
3895 @smallexample
3896 __attribute__ ((sentinel))
3897 is equivalent to
3898 __attribute__ ((sentinel(0)))
3899 @end smallexample
3901 The attribute is automatically set with a position of 0 for the built-in
3902 functions @code{execl} and @code{execlp}.  The built-in function
3903 @code{execle} has the attribute set with a position of 1.
3905 A valid @code{NULL} in this context is defined as zero with any pointer
3906 type.  If your system defines the @code{NULL} macro with an integer type
3907 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3908 with a copy that redefines NULL appropriately.
3910 The warnings for missing or incorrect sentinels are enabled with
3911 @option{-Wformat}.
3913 @item short_call
3914 See @code{long_call/short_call}.
3916 @item shortcall
3917 See @code{longcall/shortcall}.
3919 @item signal
3920 @cindex interrupt handler functions on the AVR processors
3921 Use this attribute on the AVR to indicate that the specified
3922 function is an interrupt handler.  The compiler generates function
3923 entry and exit sequences suitable for use in an interrupt handler when this
3924 attribute is present.
3926 See also the @code{interrupt} function attribute. 
3928 The AVR hardware globally disables interrupts when an interrupt is executed.
3929 Interrupt handler functions defined with the @code{signal} attribute
3930 do not re-enable interrupts.  It is save to enable interrupts in a
3931 @code{signal} handler.  This ``save'' only applies to the code
3932 generated by the compiler and not to the IRQ layout of the
3933 application which is responsibility of the application.
3935 If both @code{signal} and @code{interrupt} are specified for the same
3936 function, @code{signal} is silently ignored.
3938 @item sp_switch
3939 @cindex @code{sp_switch} attribute
3940 Use this attribute on the SH to indicate an @code{interrupt_handler}
3941 function should switch to an alternate stack.  It expects a string
3942 argument that names a global variable holding the address of the
3943 alternate stack.
3945 @smallexample
3946 void *alt_stack;
3947 void f () __attribute__ ((interrupt_handler,
3948                           sp_switch ("alt_stack")));
3949 @end smallexample
3951 @item stdcall
3952 @cindex functions that pop the argument stack on the 386
3953 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3954 assume that the called function pops off the stack space used to
3955 pass arguments, unless it takes a variable number of arguments.
3957 @item syscall_linkage
3958 @cindex @code{syscall_linkage} attribute
3959 This attribute is used to modify the IA-64 calling convention by marking
3960 all input registers as live at all function exits.  This makes it possible
3961 to restart a system call after an interrupt without having to save/restore
3962 the input registers.  This also prevents kernel data from leaking into
3963 application code.
3965 @item target
3966 @cindex @code{target} function attribute
3967 The @code{target} attribute is used to specify that a function is to
3968 be compiled with different target options than specified on the
3969 command line.  This can be used for instance to have functions
3970 compiled with a different ISA (instruction set architecture) than the
3971 default.  You can also use the @samp{#pragma GCC target} pragma to set
3972 more than one function to be compiled with specific target options.
3973 @xref{Function Specific Option Pragmas}, for details about the
3974 @samp{#pragma GCC target} pragma.
3976 For instance on a 386, you could compile one function with
3977 @code{target("sse4.1,arch=core2")} and another with
3978 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3979 compiling the first function with @option{-msse4.1} and
3980 @option{-march=core2} options, and the second function with
3981 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3982 user to make sure that a function is only invoked on a machine that
3983 supports the particular ISA it is compiled for (for example by using
3984 @code{cpuid} on 386 to determine what feature bits and architecture
3985 family are used).
3987 @smallexample
3988 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3989 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3990 @end smallexample
3992 You can either use multiple
3993 strings to specify multiple options, or separate the options
3994 with a comma (@samp{,}).
3996 The @code{target} attribute is presently implemented for
3997 i386/x86_64, PowerPC, and Nios II targets only.
3998 The options supported are specific to each target.
4000 On the 386, the following options are allowed:
4002 @table @samp
4003 @item abm
4004 @itemx no-abm
4005 @cindex @code{target("abm")} attribute
4006 Enable/disable the generation of the advanced bit instructions.
4008 @item aes
4009 @itemx no-aes
4010 @cindex @code{target("aes")} attribute
4011 Enable/disable the generation of the AES instructions.
4013 @item default
4014 @cindex @code{target("default")} attribute
4015 @xref{Function Multiversioning}, where it is used to specify the
4016 default function version.
4018 @item mmx
4019 @itemx no-mmx
4020 @cindex @code{target("mmx")} attribute
4021 Enable/disable the generation of the MMX instructions.
4023 @item pclmul
4024 @itemx no-pclmul
4025 @cindex @code{target("pclmul")} attribute
4026 Enable/disable the generation of the PCLMUL instructions.
4028 @item popcnt
4029 @itemx no-popcnt
4030 @cindex @code{target("popcnt")} attribute
4031 Enable/disable the generation of the POPCNT instruction.
4033 @item sse
4034 @itemx no-sse
4035 @cindex @code{target("sse")} attribute
4036 Enable/disable the generation of the SSE instructions.
4038 @item sse2
4039 @itemx no-sse2
4040 @cindex @code{target("sse2")} attribute
4041 Enable/disable the generation of the SSE2 instructions.
4043 @item sse3
4044 @itemx no-sse3
4045 @cindex @code{target("sse3")} attribute
4046 Enable/disable the generation of the SSE3 instructions.
4048 @item sse4
4049 @itemx no-sse4
4050 @cindex @code{target("sse4")} attribute
4051 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4052 and SSE4.2).
4054 @item sse4.1
4055 @itemx no-sse4.1
4056 @cindex @code{target("sse4.1")} attribute
4057 Enable/disable the generation of the sse4.1 instructions.
4059 @item sse4.2
4060 @itemx no-sse4.2
4061 @cindex @code{target("sse4.2")} attribute
4062 Enable/disable the generation of the sse4.2 instructions.
4064 @item sse4a
4065 @itemx no-sse4a
4066 @cindex @code{target("sse4a")} attribute
4067 Enable/disable the generation of the SSE4A instructions.
4069 @item fma4
4070 @itemx no-fma4
4071 @cindex @code{target("fma4")} attribute
4072 Enable/disable the generation of the FMA4 instructions.
4074 @item xop
4075 @itemx no-xop
4076 @cindex @code{target("xop")} attribute
4077 Enable/disable the generation of the XOP instructions.
4079 @item lwp
4080 @itemx no-lwp
4081 @cindex @code{target("lwp")} attribute
4082 Enable/disable the generation of the LWP instructions.
4084 @item ssse3
4085 @itemx no-ssse3
4086 @cindex @code{target("ssse3")} attribute
4087 Enable/disable the generation of the SSSE3 instructions.
4089 @item cld
4090 @itemx no-cld
4091 @cindex @code{target("cld")} attribute
4092 Enable/disable the generation of the CLD before string moves.
4094 @item fancy-math-387
4095 @itemx no-fancy-math-387
4096 @cindex @code{target("fancy-math-387")} attribute
4097 Enable/disable the generation of the @code{sin}, @code{cos}, and
4098 @code{sqrt} instructions on the 387 floating-point unit.
4100 @item fused-madd
4101 @itemx no-fused-madd
4102 @cindex @code{target("fused-madd")} attribute
4103 Enable/disable the generation of the fused multiply/add instructions.
4105 @item ieee-fp
4106 @itemx no-ieee-fp
4107 @cindex @code{target("ieee-fp")} attribute
4108 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4110 @item inline-all-stringops
4111 @itemx no-inline-all-stringops
4112 @cindex @code{target("inline-all-stringops")} attribute
4113 Enable/disable inlining of string operations.
4115 @item inline-stringops-dynamically
4116 @itemx no-inline-stringops-dynamically
4117 @cindex @code{target("inline-stringops-dynamically")} attribute
4118 Enable/disable the generation of the inline code to do small string
4119 operations and calling the library routines for large operations.
4121 @item align-stringops
4122 @itemx no-align-stringops
4123 @cindex @code{target("align-stringops")} attribute
4124 Do/do not align destination of inlined string operations.
4126 @item recip
4127 @itemx no-recip
4128 @cindex @code{target("recip")} attribute
4129 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4130 instructions followed an additional Newton-Raphson step instead of
4131 doing a floating-point division.
4133 @item arch=@var{ARCH}
4134 @cindex @code{target("arch=@var{ARCH}")} attribute
4135 Specify the architecture to generate code for in compiling the function.
4137 @item tune=@var{TUNE}
4138 @cindex @code{target("tune=@var{TUNE}")} attribute
4139 Specify the architecture to tune for in compiling the function.
4141 @item fpmath=@var{FPMATH}
4142 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4143 Specify which floating-point unit to use.  The
4144 @code{target("fpmath=sse,387")} option must be specified as
4145 @code{target("fpmath=sse+387")} because the comma would separate
4146 different options.
4147 @end table
4149 On the PowerPC, the following options are allowed:
4151 @table @samp
4152 @item altivec
4153 @itemx no-altivec
4154 @cindex @code{target("altivec")} attribute
4155 Generate code that uses (does not use) AltiVec instructions.  In
4156 32-bit code, you cannot enable AltiVec instructions unless
4157 @option{-mabi=altivec} is used on the command line.
4159 @item cmpb
4160 @itemx no-cmpb
4161 @cindex @code{target("cmpb")} attribute
4162 Generate code that uses (does not use) the compare bytes instruction
4163 implemented on the POWER6 processor and other processors that support
4164 the PowerPC V2.05 architecture.
4166 @item dlmzb
4167 @itemx no-dlmzb
4168 @cindex @code{target("dlmzb")} attribute
4169 Generate code that uses (does not use) the string-search @samp{dlmzb}
4170 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4171 generated by default when targeting those processors.
4173 @item fprnd
4174 @itemx no-fprnd
4175 @cindex @code{target("fprnd")} attribute
4176 Generate code that uses (does not use) the FP round to integer
4177 instructions implemented on the POWER5+ processor and other processors
4178 that support the PowerPC V2.03 architecture.
4180 @item hard-dfp
4181 @itemx no-hard-dfp
4182 @cindex @code{target("hard-dfp")} attribute
4183 Generate code that uses (does not use) the decimal floating-point
4184 instructions implemented on some POWER processors.
4186 @item isel
4187 @itemx no-isel
4188 @cindex @code{target("isel")} attribute
4189 Generate code that uses (does not use) ISEL instruction.
4191 @item mfcrf
4192 @itemx no-mfcrf
4193 @cindex @code{target("mfcrf")} attribute
4194 Generate code that uses (does not use) the move from condition
4195 register field instruction implemented on the POWER4 processor and
4196 other processors that support the PowerPC V2.01 architecture.
4198 @item mfpgpr
4199 @itemx no-mfpgpr
4200 @cindex @code{target("mfpgpr")} attribute
4201 Generate code that uses (does not use) the FP move to/from general
4202 purpose register instructions implemented on the POWER6X processor and
4203 other processors that support the extended PowerPC V2.05 architecture.
4205 @item mulhw
4206 @itemx no-mulhw
4207 @cindex @code{target("mulhw")} attribute
4208 Generate code that uses (does not use) the half-word multiply and
4209 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4210 These instructions are generated by default when targeting those
4211 processors.
4213 @item multiple
4214 @itemx no-multiple
4215 @cindex @code{target("multiple")} attribute
4216 Generate code that uses (does not use) the load multiple word
4217 instructions and the store multiple word instructions.
4219 @item update
4220 @itemx no-update
4221 @cindex @code{target("update")} attribute
4222 Generate code that uses (does not use) the load or store instructions
4223 that update the base register to the address of the calculated memory
4224 location.
4226 @item popcntb
4227 @itemx no-popcntb
4228 @cindex @code{target("popcntb")} attribute
4229 Generate code that uses (does not use) the popcount and double-precision
4230 FP reciprocal estimate instruction implemented on the POWER5
4231 processor and other processors that support the PowerPC V2.02
4232 architecture.
4234 @item popcntd
4235 @itemx no-popcntd
4236 @cindex @code{target("popcntd")} attribute
4237 Generate code that uses (does not use) the popcount instruction
4238 implemented on the POWER7 processor and other processors that support
4239 the PowerPC V2.06 architecture.
4241 @item powerpc-gfxopt
4242 @itemx no-powerpc-gfxopt
4243 @cindex @code{target("powerpc-gfxopt")} attribute
4244 Generate code that uses (does not use) the optional PowerPC
4245 architecture instructions in the Graphics group, including
4246 floating-point select.
4248 @item powerpc-gpopt
4249 @itemx no-powerpc-gpopt
4250 @cindex @code{target("powerpc-gpopt")} attribute
4251 Generate code that uses (does not use) the optional PowerPC
4252 architecture instructions in the General Purpose group, including
4253 floating-point square root.
4255 @item recip-precision
4256 @itemx no-recip-precision
4257 @cindex @code{target("recip-precision")} attribute
4258 Assume (do not assume) that the reciprocal estimate instructions
4259 provide higher-precision estimates than is mandated by the powerpc
4260 ABI.
4262 @item string
4263 @itemx no-string
4264 @cindex @code{target("string")} attribute
4265 Generate code that uses (does not use) the load string instructions
4266 and the store string word instructions to save multiple registers and
4267 do small block moves.
4269 @item vsx
4270 @itemx no-vsx
4271 @cindex @code{target("vsx")} attribute
4272 Generate code that uses (does not use) vector/scalar (VSX)
4273 instructions, and also enable the use of built-in functions that allow
4274 more direct access to the VSX instruction set.  In 32-bit code, you
4275 cannot enable VSX or AltiVec instructions unless
4276 @option{-mabi=altivec} is used on the command line.
4278 @item friz
4279 @itemx no-friz
4280 @cindex @code{target("friz")} attribute
4281 Generate (do not generate) the @code{friz} instruction when the
4282 @option{-funsafe-math-optimizations} option is used to optimize
4283 rounding a floating-point value to 64-bit integer and back to floating
4284 point.  The @code{friz} instruction does not return the same value if
4285 the floating-point number is too large to fit in an integer.
4287 @item avoid-indexed-addresses
4288 @itemx no-avoid-indexed-addresses
4289 @cindex @code{target("avoid-indexed-addresses")} attribute
4290 Generate code that tries to avoid (not avoid) the use of indexed load
4291 or store instructions.
4293 @item paired
4294 @itemx no-paired
4295 @cindex @code{target("paired")} attribute
4296 Generate code that uses (does not use) the generation of PAIRED simd
4297 instructions.
4299 @item longcall
4300 @itemx no-longcall
4301 @cindex @code{target("longcall")} attribute
4302 Generate code that assumes (does not assume) that all calls are far
4303 away so that a longer more expensive calling sequence is required.
4305 @item cpu=@var{CPU}
4306 @cindex @code{target("cpu=@var{CPU}")} attribute
4307 Specify the architecture to generate code for when compiling the
4308 function.  If you select the @code{target("cpu=power7")} attribute when
4309 generating 32-bit code, VSX and AltiVec instructions are not generated
4310 unless you use the @option{-mabi=altivec} option on the command line.
4312 @item tune=@var{TUNE}
4313 @cindex @code{target("tune=@var{TUNE}")} attribute
4314 Specify the architecture to tune for when compiling the function.  If
4315 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4316 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4317 compilation tunes for the @var{CPU} architecture, and not the
4318 default tuning specified on the command line.
4319 @end table
4321 When compiling for Nios II, the following options are allowed:
4323 @table @samp
4324 @item custom-@var{insn}=@var{N}
4325 @itemx no-custom-@var{insn}
4326 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4327 @cindex @code{target("no-custom-@var{insn}")} attribute
4328 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4329 custom instruction with encoding @var{N} when generating code that uses 
4330 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4331 the custom instruction @var{insn}.
4332 These target attributes correspond to the
4333 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4334 command-line options, and support the same set of @var{insn} keywords.
4335 @xref{Nios II Options}, for more information.
4337 @item custom-fpu-cfg=@var{name}
4338 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4339 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4340 command-line option, to select a predefined set of custom instructions
4341 named @var{name}.
4342 @xref{Nios II Options}, for more information.
4343 @end table
4345 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4346 function that has different target options than the caller, unless the
4347 callee has a subset of the target options of the caller.  For example
4348 a function declared with @code{target("sse3")} can inline a function
4349 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4351 @item tiny_data
4352 @cindex tiny data section on the H8/300H and H8S
4353 Use this attribute on the H8/300H and H8S to indicate that the specified
4354 variable should be placed into the tiny data section.
4355 The compiler generates more efficient code for loads and stores
4356 on data in the tiny data section.  Note the tiny data area is limited to
4357 slightly under 32KB of data.
4359 @item trap_exit
4360 @cindex @code{trap_exit} attribute
4361 Use this attribute on the SH for an @code{interrupt_handler} to return using
4362 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4363 argument specifying the trap number to be used.
4365 @item trapa_handler
4366 @cindex @code{trapa_handler} attribute
4367 On SH targets this function attribute is similar to @code{interrupt_handler}
4368 but it does not save and restore all registers.
4370 @item unused
4371 @cindex @code{unused} attribute.
4372 This attribute, attached to a function, means that the function is meant
4373 to be possibly unused.  GCC does not produce a warning for this
4374 function.
4376 @item used
4377 @cindex @code{used} attribute.
4378 This attribute, attached to a function, means that code must be emitted
4379 for the function even if it appears that the function is not referenced.
4380 This is useful, for example, when the function is referenced only in
4381 inline assembly.
4383 When applied to a member function of a C++ class template, the
4384 attribute also means that the function is instantiated if the
4385 class itself is instantiated.
4387 @item vector
4388 @cindex @code{vector} attribute
4389 This RX attribute is similar to the @code{interrupt} attribute, including its
4390 parameters, but does not make the function an interrupt-handler type
4391 function (i.e. it retains the normal C function calling ABI).  See the
4392 @code{interrupt} attribute for a description of its arguments.
4394 @item version_id
4395 @cindex @code{version_id} attribute
4396 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4397 symbol to contain a version string, thus allowing for function level
4398 versioning.  HP-UX system header files may use function level versioning
4399 for some system calls.
4401 @smallexample
4402 extern int foo () __attribute__((version_id ("20040821")));
4403 @end smallexample
4405 @noindent
4406 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4408 @item visibility ("@var{visibility_type}")
4409 @cindex @code{visibility} attribute
4410 This attribute affects the linkage of the declaration to which it is attached.
4411 There are four supported @var{visibility_type} values: default,
4412 hidden, protected or internal visibility.
4414 @smallexample
4415 void __attribute__ ((visibility ("protected")))
4416 f () @{ /* @r{Do something.} */; @}
4417 int i __attribute__ ((visibility ("hidden")));
4418 @end smallexample
4420 The possible values of @var{visibility_type} correspond to the
4421 visibility settings in the ELF gABI.
4423 @table @dfn
4424 @c keep this list of visibilities in alphabetical order.
4426 @item default
4427 Default visibility is the normal case for the object file format.
4428 This value is available for the visibility attribute to override other
4429 options that may change the assumed visibility of entities.
4431 On ELF, default visibility means that the declaration is visible to other
4432 modules and, in shared libraries, means that the declared entity may be
4433 overridden.
4435 On Darwin, default visibility means that the declaration is visible to
4436 other modules.
4438 Default visibility corresponds to ``external linkage'' in the language.
4440 @item hidden
4441 Hidden visibility indicates that the entity declared has a new
4442 form of linkage, which we call ``hidden linkage''.  Two
4443 declarations of an object with hidden linkage refer to the same object
4444 if they are in the same shared object.
4446 @item internal
4447 Internal visibility is like hidden visibility, but with additional
4448 processor specific semantics.  Unless otherwise specified by the
4449 psABI, GCC defines internal visibility to mean that a function is
4450 @emph{never} called from another module.  Compare this with hidden
4451 functions which, while they cannot be referenced directly by other
4452 modules, can be referenced indirectly via function pointers.  By
4453 indicating that a function cannot be called from outside the module,
4454 GCC may for instance omit the load of a PIC register since it is known
4455 that the calling function loaded the correct value.
4457 @item protected
4458 Protected visibility is like default visibility except that it
4459 indicates that references within the defining module bind to the
4460 definition in that module.  That is, the declared entity cannot be
4461 overridden by another module.
4463 @end table
4465 All visibilities are supported on many, but not all, ELF targets
4466 (supported when the assembler supports the @samp{.visibility}
4467 pseudo-op).  Default visibility is supported everywhere.  Hidden
4468 visibility is supported on Darwin targets.
4470 The visibility attribute should be applied only to declarations that
4471 would otherwise have external linkage.  The attribute should be applied
4472 consistently, so that the same entity should not be declared with
4473 different settings of the attribute.
4475 In C++, the visibility attribute applies to types as well as functions
4476 and objects, because in C++ types have linkage.  A class must not have
4477 greater visibility than its non-static data member types and bases,
4478 and class members default to the visibility of their class.  Also, a
4479 declaration without explicit visibility is limited to the visibility
4480 of its type.
4482 In C++, you can mark member functions and static member variables of a
4483 class with the visibility attribute.  This is useful if you know a
4484 particular method or static member variable should only be used from
4485 one shared object; then you can mark it hidden while the rest of the
4486 class has default visibility.  Care must be taken to avoid breaking
4487 the One Definition Rule; for example, it is usually not useful to mark
4488 an inline method as hidden without marking the whole class as hidden.
4490 A C++ namespace declaration can also have the visibility attribute.
4492 @smallexample
4493 namespace nspace1 __attribute__ ((visibility ("protected")))
4494 @{ /* @r{Do something.} */; @}
4495 @end smallexample
4497 This attribute applies only to the particular namespace body, not to
4498 other definitions of the same namespace; it is equivalent to using
4499 @samp{#pragma GCC visibility} before and after the namespace
4500 definition (@pxref{Visibility Pragmas}).
4502 In C++, if a template argument has limited visibility, this
4503 restriction is implicitly propagated to the template instantiation.
4504 Otherwise, template instantiations and specializations default to the
4505 visibility of their template.
4507 If both the template and enclosing class have explicit visibility, the
4508 visibility from the template is used.
4510 @item vliw
4511 @cindex @code{vliw} attribute
4512 On MeP, the @code{vliw} attribute tells the compiler to emit
4513 instructions in VLIW mode instead of core mode.  Note that this
4514 attribute is not allowed unless a VLIW coprocessor has been configured
4515 and enabled through command-line options.
4517 @item warn_unused_result
4518 @cindex @code{warn_unused_result} attribute
4519 The @code{warn_unused_result} attribute causes a warning to be emitted
4520 if a caller of the function with this attribute does not use its
4521 return value.  This is useful for functions where not checking
4522 the result is either a security problem or always a bug, such as
4523 @code{realloc}.
4525 @smallexample
4526 int fn () __attribute__ ((warn_unused_result));
4527 int foo ()
4529   if (fn () < 0) return -1;
4530   fn ();
4531   return 0;
4533 @end smallexample
4535 @noindent
4536 results in warning on line 5.
4538 @item weak
4539 @cindex @code{weak} attribute
4540 The @code{weak} attribute causes the declaration to be emitted as a weak
4541 symbol rather than a global.  This is primarily useful in defining
4542 library functions that can be overridden in user code, though it can
4543 also be used with non-function declarations.  Weak symbols are supported
4544 for ELF targets, and also for a.out targets when using the GNU assembler
4545 and linker.
4547 @item weakref
4548 @itemx weakref ("@var{target}")
4549 @cindex @code{weakref} attribute
4550 The @code{weakref} attribute marks a declaration as a weak reference.
4551 Without arguments, it should be accompanied by an @code{alias} attribute
4552 naming the target symbol.  Optionally, the @var{target} may be given as
4553 an argument to @code{weakref} itself.  In either case, @code{weakref}
4554 implicitly marks the declaration as @code{weak}.  Without a
4555 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4556 @code{weakref} is equivalent to @code{weak}.
4558 @smallexample
4559 static int x() __attribute__ ((weakref ("y")));
4560 /* is equivalent to... */
4561 static int x() __attribute__ ((weak, weakref, alias ("y")));
4562 /* and to... */
4563 static int x() __attribute__ ((weakref));
4564 static int x() __attribute__ ((alias ("y")));
4565 @end smallexample
4567 A weak reference is an alias that does not by itself require a
4568 definition to be given for the target symbol.  If the target symbol is
4569 only referenced through weak references, then it becomes a @code{weak}
4570 undefined symbol.  If it is directly referenced, however, then such
4571 strong references prevail, and a definition is required for the
4572 symbol, not necessarily in the same translation unit.
4574 The effect is equivalent to moving all references to the alias to a
4575 separate translation unit, renaming the alias to the aliased symbol,
4576 declaring it as weak, compiling the two separate translation units and
4577 performing a reloadable link on them.
4579 At present, a declaration to which @code{weakref} is attached can
4580 only be @code{static}.
4582 @end table
4584 You can specify multiple attributes in a declaration by separating them
4585 by commas within the double parentheses or by immediately following an
4586 attribute declaration with another attribute declaration.
4588 @cindex @code{#pragma}, reason for not using
4589 @cindex pragma, reason for not using
4590 Some people object to the @code{__attribute__} feature, suggesting that
4591 ISO C's @code{#pragma} should be used instead.  At the time
4592 @code{__attribute__} was designed, there were two reasons for not doing
4593 this.
4595 @enumerate
4596 @item
4597 It is impossible to generate @code{#pragma} commands from a macro.
4599 @item
4600 There is no telling what the same @code{#pragma} might mean in another
4601 compiler.
4602 @end enumerate
4604 These two reasons applied to almost any application that might have been
4605 proposed for @code{#pragma}.  It was basically a mistake to use
4606 @code{#pragma} for @emph{anything}.
4608 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4609 to be generated from macros.  In addition, a @code{#pragma GCC}
4610 namespace is now in use for GCC-specific pragmas.  However, it has been
4611 found convenient to use @code{__attribute__} to achieve a natural
4612 attachment of attributes to their corresponding declarations, whereas
4613 @code{#pragma GCC} is of use for constructs that do not naturally form
4614 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4616 @node Label Attributes
4617 @section Label Attributes
4618 @cindex Label Attributes
4620 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
4621 details of the exact syntax for using attributes.  Other attributes are 
4622 available for functions (@pxref{Function Attributes}), variables 
4623 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4625 This example uses the @code{cold} label attribute to indicate the 
4626 @code{ErrorHandling} branch is unlikely to be taken and that the
4627 @code{ErrorHandling} label is unused:
4629 @smallexample
4631    asm goto ("some asm" : : : : NoError);
4633 /* This branch (the fallthru from the asm) is less commonly used */
4634 ErrorHandling: 
4635    __attribute__((cold, unused)); /* Semi-colon is required here */
4636    printf("error\n");
4637    return 0;
4639 NoError:
4640    printf("no error\n");
4641    return 1;
4642 @end smallexample
4644 @table @code
4645 @item unused
4646 @cindex @code{unused} label attribute
4647 This feature is intended for program-generated code that may contain 
4648 unused labels, but which is compiled with @option{-Wall}.  It is
4649 not normally appropriate to use in it human-written code, though it
4650 could be useful in cases where the code that jumps to the label is
4651 contained within an @code{#ifdef} conditional.
4653 @item hot
4654 @cindex @code{hot} label attribute
4655 The @code{hot} attribute on a label is used to inform the compiler that
4656 the path following the label is more likely than paths that are not so
4657 annotated.  This attribute is used in cases where @code{__builtin_expect}
4658 cannot be used, for instance with computed goto or @code{asm goto}.
4660 The @code{hot} attribute on labels is not implemented in GCC versions
4661 earlier than 4.8.
4663 @item cold
4664 @cindex @code{cold} label attribute
4665 The @code{cold} attribute on labels is used to inform the compiler that
4666 the path following the label is unlikely to be executed.  This attribute
4667 is used in cases where @code{__builtin_expect} cannot be used, for instance
4668 with computed goto or @code{asm goto}.
4670 The @code{cold} attribute on labels is not implemented in GCC versions
4671 earlier than 4.8.
4673 @end table
4675 @node Attribute Syntax
4676 @section Attribute Syntax
4677 @cindex attribute syntax
4679 This section describes the syntax with which @code{__attribute__} may be
4680 used, and the constructs to which attribute specifiers bind, for the C
4681 language.  Some details may vary for C++ and Objective-C@.  Because of
4682 infelicities in the grammar for attributes, some forms described here
4683 may not be successfully parsed in all cases.
4685 There are some problems with the semantics of attributes in C++.  For
4686 example, there are no manglings for attributes, although they may affect
4687 code generation, so problems may arise when attributed types are used in
4688 conjunction with templates or overloading.  Similarly, @code{typeid}
4689 does not distinguish between types with different attributes.  Support
4690 for attributes in C++ may be restricted in future to attributes on
4691 declarations only, but not on nested declarators.
4693 @xref{Function Attributes}, for details of the semantics of attributes
4694 applying to functions.  @xref{Variable Attributes}, for details of the
4695 semantics of attributes applying to variables.  @xref{Type Attributes},
4696 for details of the semantics of attributes applying to structure, union
4697 and enumerated types.
4698 @xref{Label Attributes}, for details of the semantics of attributes 
4699 applying to labels.
4701 An @dfn{attribute specifier} is of the form
4702 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4703 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4704 each attribute is one of the following:
4706 @itemize @bullet
4707 @item
4708 Empty.  Empty attributes are ignored.
4710 @item
4711 A word (which may be an identifier such as @code{unused}, or a reserved
4712 word such as @code{const}).
4714 @item
4715 A word, followed by, in parentheses, parameters for the attribute.
4716 These parameters take one of the following forms:
4718 @itemize @bullet
4719 @item
4720 An identifier.  For example, @code{mode} attributes use this form.
4722 @item
4723 An identifier followed by a comma and a non-empty comma-separated list
4724 of expressions.  For example, @code{format} attributes use this form.
4726 @item
4727 A possibly empty comma-separated list of expressions.  For example,
4728 @code{format_arg} attributes use this form with the list being a single
4729 integer constant expression, and @code{alias} attributes use this form
4730 with the list being a single string constant.
4731 @end itemize
4732 @end itemize
4734 An @dfn{attribute specifier list} is a sequence of one or more attribute
4735 specifiers, not separated by any other tokens.
4737 @subsubheading Label Attributes
4739 In GNU C, an attribute specifier list may appear after the colon following a
4740 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
4741 attributes on labels if the attribute specifier is immediately
4742 followed by a semicolon (i.e., the label applies to an empty
4743 statement).  If the semicolon is missing, C++ label attributes are
4744 ambiguous, as it is permissible for a declaration, which could begin
4745 with an attribute list, to be labelled in C++.  Declarations cannot be
4746 labelled in C90 or C99, so the ambiguity does not arise there.
4748 @subsubheading Type Attributes
4750 An attribute specifier list may appear as part of a @code{struct},
4751 @code{union} or @code{enum} specifier.  It may go either immediately
4752 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4753 the closing brace.  The former syntax is preferred.
4754 Where attribute specifiers follow the closing brace, they are considered
4755 to relate to the structure, union or enumerated type defined, not to any
4756 enclosing declaration the type specifier appears in, and the type
4757 defined is not complete until after the attribute specifiers.
4758 @c Otherwise, there would be the following problems: a shift/reduce
4759 @c conflict between attributes binding the struct/union/enum and
4760 @c binding to the list of specifiers/qualifiers; and "aligned"
4761 @c attributes could use sizeof for the structure, but the size could be
4762 @c changed later by "packed" attributes.
4765 @subsubheading All other attributes
4767 Otherwise, an attribute specifier appears as part of a declaration,
4768 counting declarations of unnamed parameters and type names, and relates
4769 to that declaration (which may be nested in another declaration, for
4770 example in the case of a parameter declaration), or to a particular declarator
4771 within a declaration.  Where an
4772 attribute specifier is applied to a parameter declared as a function or
4773 an array, it should apply to the function or array rather than the
4774 pointer to which the parameter is implicitly converted, but this is not
4775 yet correctly implemented.
4777 Any list of specifiers and qualifiers at the start of a declaration may
4778 contain attribute specifiers, whether or not such a list may in that
4779 context contain storage class specifiers.  (Some attributes, however,
4780 are essentially in the nature of storage class specifiers, and only make
4781 sense where storage class specifiers may be used; for example,
4782 @code{section}.)  There is one necessary limitation to this syntax: the
4783 first old-style parameter declaration in a function definition cannot
4784 begin with an attribute specifier, because such an attribute applies to
4785 the function instead by syntax described below (which, however, is not
4786 yet implemented in this case).  In some other cases, attribute
4787 specifiers are permitted by this grammar but not yet supported by the
4788 compiler.  All attribute specifiers in this place relate to the
4789 declaration as a whole.  In the obsolescent usage where a type of
4790 @code{int} is implied by the absence of type specifiers, such a list of
4791 specifiers and qualifiers may be an attribute specifier list with no
4792 other specifiers or qualifiers.
4794 At present, the first parameter in a function prototype must have some
4795 type specifier that is not an attribute specifier; this resolves an
4796 ambiguity in the interpretation of @code{void f(int
4797 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4798 the parentheses of a function declarator contain only attributes then
4799 those attributes are ignored, rather than yielding an error or warning
4800 or implying a single parameter of type int, but this is subject to
4801 change.
4803 An attribute specifier list may appear immediately before a declarator
4804 (other than the first) in a comma-separated list of declarators in a
4805 declaration of more than one identifier using a single list of
4806 specifiers and qualifiers.  Such attribute specifiers apply
4807 only to the identifier before whose declarator they appear.  For
4808 example, in
4810 @smallexample
4811 __attribute__((noreturn)) void d0 (void),
4812     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4813      d2 (void)
4814 @end smallexample
4816 @noindent
4817 the @code{noreturn} attribute applies to all the functions
4818 declared; the @code{format} attribute only applies to @code{d1}.
4820 An attribute specifier list may appear immediately before the comma,
4821 @code{=} or semicolon terminating the declaration of an identifier other
4822 than a function definition.  Such attribute specifiers apply
4823 to the declared object or function.  Where an
4824 assembler name for an object or function is specified (@pxref{Asm
4825 Labels}), the attribute must follow the @code{asm}
4826 specification.
4828 An attribute specifier list may, in future, be permitted to appear after
4829 the declarator in a function definition (before any old-style parameter
4830 declarations or the function body).
4832 Attribute specifiers may be mixed with type qualifiers appearing inside
4833 the @code{[]} of a parameter array declarator, in the C99 construct by
4834 which such qualifiers are applied to the pointer to which the array is
4835 implicitly converted.  Such attribute specifiers apply to the pointer,
4836 not to the array, but at present this is not implemented and they are
4837 ignored.
4839 An attribute specifier list may appear at the start of a nested
4840 declarator.  At present, there are some limitations in this usage: the
4841 attributes correctly apply to the declarator, but for most individual
4842 attributes the semantics this implies are not implemented.
4843 When attribute specifiers follow the @code{*} of a pointer
4844 declarator, they may be mixed with any type qualifiers present.
4845 The following describes the formal semantics of this syntax.  It makes the
4846 most sense if you are familiar with the formal specification of
4847 declarators in the ISO C standard.
4849 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4850 D1}, where @code{T} contains declaration specifiers that specify a type
4851 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4852 contains an identifier @var{ident}.  The type specified for @var{ident}
4853 for derived declarators whose type does not include an attribute
4854 specifier is as in the ISO C standard.
4856 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4857 and the declaration @code{T D} specifies the type
4858 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4859 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4860 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4862 If @code{D1} has the form @code{*
4863 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4864 declaration @code{T D} specifies the type
4865 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4866 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4867 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4868 @var{ident}.
4870 For example,
4872 @smallexample
4873 void (__attribute__((noreturn)) ****f) (void);
4874 @end smallexample
4876 @noindent
4877 specifies the type ``pointer to pointer to pointer to pointer to
4878 non-returning function returning @code{void}''.  As another example,
4880 @smallexample
4881 char *__attribute__((aligned(8))) *f;
4882 @end smallexample
4884 @noindent
4885 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4886 Note again that this does not work with most attributes; for example,
4887 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4888 is not yet supported.
4890 For compatibility with existing code written for compiler versions that
4891 did not implement attributes on nested declarators, some laxity is
4892 allowed in the placing of attributes.  If an attribute that only applies
4893 to types is applied to a declaration, it is treated as applying to
4894 the type of that declaration.  If an attribute that only applies to
4895 declarations is applied to the type of a declaration, it is treated
4896 as applying to that declaration; and, for compatibility with code
4897 placing the attributes immediately before the identifier declared, such
4898 an attribute applied to a function return type is treated as
4899 applying to the function type, and such an attribute applied to an array
4900 element type is treated as applying to the array type.  If an
4901 attribute that only applies to function types is applied to a
4902 pointer-to-function type, it is treated as applying to the pointer
4903 target type; if such an attribute is applied to a function return type
4904 that is not a pointer-to-function type, it is treated as applying
4905 to the function type.
4907 @node Function Prototypes
4908 @section Prototypes and Old-Style Function Definitions
4909 @cindex function prototype declarations
4910 @cindex old-style function definitions
4911 @cindex promotion of formal parameters
4913 GNU C extends ISO C to allow a function prototype to override a later
4914 old-style non-prototype definition.  Consider the following example:
4916 @smallexample
4917 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4918 #ifdef __STDC__
4919 #define P(x) x
4920 #else
4921 #define P(x) ()
4922 #endif
4924 /* @r{Prototype function declaration.}  */
4925 int isroot P((uid_t));
4927 /* @r{Old-style function definition.}  */
4929 isroot (x)   /* @r{??? lossage here ???} */
4930      uid_t x;
4932   return x == 0;
4934 @end smallexample
4936 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4937 not allow this example, because subword arguments in old-style
4938 non-prototype definitions are promoted.  Therefore in this example the
4939 function definition's argument is really an @code{int}, which does not
4940 match the prototype argument type of @code{short}.
4942 This restriction of ISO C makes it hard to write code that is portable
4943 to traditional C compilers, because the programmer does not know
4944 whether the @code{uid_t} type is @code{short}, @code{int}, or
4945 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4946 to override a later old-style definition.  More precisely, in GNU C, a
4947 function prototype argument type overrides the argument type specified
4948 by a later old-style definition if the former type is the same as the
4949 latter type before promotion.  Thus in GNU C the above example is
4950 equivalent to the following:
4952 @smallexample
4953 int isroot (uid_t);
4956 isroot (uid_t x)
4958   return x == 0;
4960 @end smallexample
4962 @noindent
4963 GNU C++ does not support old-style function definitions, so this
4964 extension is irrelevant.
4966 @node C++ Comments
4967 @section C++ Style Comments
4968 @cindex @code{//}
4969 @cindex C++ comments
4970 @cindex comments, C++ style
4972 In GNU C, you may use C++ style comments, which start with @samp{//} and
4973 continue until the end of the line.  Many other C implementations allow
4974 such comments, and they are included in the 1999 C standard.  However,
4975 C++ style comments are not recognized if you specify an @option{-std}
4976 option specifying a version of ISO C before C99, or @option{-ansi}
4977 (equivalent to @option{-std=c90}).
4979 @node Dollar Signs
4980 @section Dollar Signs in Identifier Names
4981 @cindex $
4982 @cindex dollar signs in identifier names
4983 @cindex identifier names, dollar signs in
4985 In GNU C, you may normally use dollar signs in identifier names.
4986 This is because many traditional C implementations allow such identifiers.
4987 However, dollar signs in identifiers are not supported on a few target
4988 machines, typically because the target assembler does not allow them.
4990 @node Character Escapes
4991 @section The Character @key{ESC} in Constants
4993 You can use the sequence @samp{\e} in a string or character constant to
4994 stand for the ASCII character @key{ESC}.
4996 @node Variable Attributes
4997 @section Specifying Attributes of Variables
4998 @cindex attribute of variables
4999 @cindex variable attributes
5001 The keyword @code{__attribute__} allows you to specify special
5002 attributes of variables or structure fields.  This keyword is followed
5003 by an attribute specification inside double parentheses.  Some
5004 attributes are currently defined generically for variables.
5005 Other attributes are defined for variables on particular target
5006 systems.  Other attributes are available for functions
5007 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
5008 types (@pxref{Type Attributes}).
5009 Other front ends might define more attributes
5010 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5012 You may also specify attributes with @samp{__} preceding and following
5013 each keyword.  This allows you to use them in header files without
5014 being concerned about a possible macro of the same name.  For example,
5015 you may use @code{__aligned__} instead of @code{aligned}.
5017 @xref{Attribute Syntax}, for details of the exact syntax for using
5018 attributes.
5020 @table @code
5021 @cindex @code{aligned} attribute
5022 @item aligned (@var{alignment})
5023 This attribute specifies a minimum alignment for the variable or
5024 structure field, measured in bytes.  For example, the declaration:
5026 @smallexample
5027 int x __attribute__ ((aligned (16))) = 0;
5028 @end smallexample
5030 @noindent
5031 causes the compiler to allocate the global variable @code{x} on a
5032 16-byte boundary.  On a 68040, this could be used in conjunction with
5033 an @code{asm} expression to access the @code{move16} instruction which
5034 requires 16-byte aligned operands.
5036 You can also specify the alignment of structure fields.  For example, to
5037 create a double-word aligned @code{int} pair, you could write:
5039 @smallexample
5040 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5041 @end smallexample
5043 @noindent
5044 This is an alternative to creating a union with a @code{double} member,
5045 which forces the union to be double-word aligned.
5047 As in the preceding examples, you can explicitly specify the alignment
5048 (in bytes) that you wish the compiler to use for a given variable or
5049 structure field.  Alternatively, you can leave out the alignment factor
5050 and just ask the compiler to align a variable or field to the
5051 default alignment for the target architecture you are compiling for.
5052 The default alignment is sufficient for all scalar types, but may not be
5053 enough for all vector types on a target that supports vector operations.
5054 The default alignment is fixed for a particular target ABI.
5056 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5057 which is the largest alignment ever used for any data type on the
5058 target machine you are compiling for.  For example, you could write:
5060 @smallexample
5061 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5062 @end smallexample
5064 The compiler automatically sets the alignment for the declared
5065 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5066 often make copy operations more efficient, because the compiler can
5067 use whatever instructions copy the biggest chunks of memory when
5068 performing copies to or from the variables or fields that you have
5069 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5070 may change depending on command-line options.
5072 When used on a struct, or struct member, the @code{aligned} attribute can
5073 only increase the alignment; in order to decrease it, the @code{packed}
5074 attribute must be specified as well.  When used as part of a typedef, the
5075 @code{aligned} attribute can both increase and decrease alignment, and
5076 specifying the @code{packed} attribute generates a warning.
5078 Note that the effectiveness of @code{aligned} attributes may be limited
5079 by inherent limitations in your linker.  On many systems, the linker is
5080 only able to arrange for variables to be aligned up to a certain maximum
5081 alignment.  (For some linkers, the maximum supported alignment may
5082 be very very small.)  If your linker is only able to align variables
5083 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5084 in an @code{__attribute__} still only provides you with 8-byte
5085 alignment.  See your linker documentation for further information.
5087 The @code{aligned} attribute can also be used for functions
5088 (@pxref{Function Attributes}.)
5090 @item cleanup (@var{cleanup_function})
5091 @cindex @code{cleanup} attribute
5092 The @code{cleanup} attribute runs a function when the variable goes
5093 out of scope.  This attribute can only be applied to auto function
5094 scope variables; it may not be applied to parameters or variables
5095 with static storage duration.  The function must take one parameter,
5096 a pointer to a type compatible with the variable.  The return value
5097 of the function (if any) is ignored.
5099 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5100 is run during the stack unwinding that happens during the
5101 processing of the exception.  Note that the @code{cleanup} attribute
5102 does not allow the exception to be caught, only to perform an action.
5103 It is undefined what happens if @var{cleanup_function} does not
5104 return normally.
5106 @item common
5107 @itemx nocommon
5108 @cindex @code{common} attribute
5109 @cindex @code{nocommon} attribute
5110 @opindex fcommon
5111 @opindex fno-common
5112 The @code{common} attribute requests GCC to place a variable in
5113 ``common'' storage.  The @code{nocommon} attribute requests the
5114 opposite---to allocate space for it directly.
5116 These attributes override the default chosen by the
5117 @option{-fno-common} and @option{-fcommon} flags respectively.
5119 @item deprecated
5120 @itemx deprecated (@var{msg})
5121 @cindex @code{deprecated} attribute
5122 The @code{deprecated} attribute results in a warning if the variable
5123 is used anywhere in the source file.  This is useful when identifying
5124 variables that are expected to be removed in a future version of a
5125 program.  The warning also includes the location of the declaration
5126 of the deprecated variable, to enable users to easily find further
5127 information about why the variable is deprecated, or what they should
5128 do instead.  Note that the warning only occurs for uses:
5130 @smallexample
5131 extern int old_var __attribute__ ((deprecated));
5132 extern int old_var;
5133 int new_fn () @{ return old_var; @}
5134 @end smallexample
5136 @noindent
5137 results in a warning on line 3 but not line 2.  The optional @var{msg}
5138 argument, which must be a string, is printed in the warning if
5139 present.
5141 The @code{deprecated} attribute can also be used for functions and
5142 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5144 @item mode (@var{mode})
5145 @cindex @code{mode} attribute
5146 This attribute specifies the data type for the declaration---whichever
5147 type corresponds to the mode @var{mode}.  This in effect lets you
5148 request an integer or floating-point type according to its width.
5150 You may also specify a mode of @code{byte} or @code{__byte__} to
5151 indicate the mode corresponding to a one-byte integer, @code{word} or
5152 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5153 or @code{__pointer__} for the mode used to represent pointers.
5155 @item packed
5156 @cindex @code{packed} attribute
5157 The @code{packed} attribute specifies that a variable or structure field
5158 should have the smallest possible alignment---one byte for a variable,
5159 and one bit for a field, unless you specify a larger value with the
5160 @code{aligned} attribute.
5162 Here is a structure in which the field @code{x} is packed, so that it
5163 immediately follows @code{a}:
5165 @smallexample
5166 struct foo
5168   char a;
5169   int x[2] __attribute__ ((packed));
5171 @end smallexample
5173 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5174 @code{packed} attribute on bit-fields of type @code{char}.  This has
5175 been fixed in GCC 4.4 but the change can lead to differences in the
5176 structure layout.  See the documentation of
5177 @option{-Wpacked-bitfield-compat} for more information.
5179 @item section ("@var{section-name}")
5180 @cindex @code{section} variable attribute
5181 Normally, the compiler places the objects it generates in sections like
5182 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5183 or you need certain particular variables to appear in special sections,
5184 for example to map to special hardware.  The @code{section}
5185 attribute specifies that a variable (or function) lives in a particular
5186 section.  For example, this small program uses several specific section names:
5188 @smallexample
5189 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5190 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5191 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5192 int init_data __attribute__ ((section ("INITDATA")));
5194 main()
5196   /* @r{Initialize stack pointer} */
5197   init_sp (stack + sizeof (stack));
5199   /* @r{Initialize initialized data} */
5200   memcpy (&init_data, &data, &edata - &data);
5202   /* @r{Turn on the serial ports} */
5203   init_duart (&a);
5204   init_duart (&b);
5206 @end smallexample
5208 @noindent
5209 Use the @code{section} attribute with
5210 @emph{global} variables and not @emph{local} variables,
5211 as shown in the example.
5213 You may use the @code{section} attribute with initialized or
5214 uninitialized global variables but the linker requires
5215 each object be defined once, with the exception that uninitialized
5216 variables tentatively go in the @code{common} (or @code{bss}) section
5217 and can be multiply ``defined''.  Using the @code{section} attribute
5218 changes what section the variable goes into and may cause the
5219 linker to issue an error if an uninitialized variable has multiple
5220 definitions.  You can force a variable to be initialized with the
5221 @option{-fno-common} flag or the @code{nocommon} attribute.
5223 Some file formats do not support arbitrary sections so the @code{section}
5224 attribute is not available on all platforms.
5225 If you need to map the entire contents of a module to a particular
5226 section, consider using the facilities of the linker instead.
5228 @item shared
5229 @cindex @code{shared} variable attribute
5230 On Microsoft Windows, in addition to putting variable definitions in a named
5231 section, the section can also be shared among all running copies of an
5232 executable or DLL@.  For example, this small program defines shared data
5233 by putting it in a named section @code{shared} and marking the section
5234 shareable:
5236 @smallexample
5237 int foo __attribute__((section ("shared"), shared)) = 0;
5240 main()
5242   /* @r{Read and write foo.  All running
5243      copies see the same value.}  */
5244   return 0;
5246 @end smallexample
5248 @noindent
5249 You may only use the @code{shared} attribute along with @code{section}
5250 attribute with a fully-initialized global definition because of the way
5251 linkers work.  See @code{section} attribute for more information.
5253 The @code{shared} attribute is only available on Microsoft Windows@.
5255 @item tls_model ("@var{tls_model}")
5256 @cindex @code{tls_model} attribute
5257 The @code{tls_model} attribute sets thread-local storage model
5258 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5259 overriding @option{-ftls-model=} command-line switch on a per-variable
5260 basis.
5261 The @var{tls_model} argument should be one of @code{global-dynamic},
5262 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5264 Not all targets support this attribute.
5266 @item unused
5267 This attribute, attached to a variable, means that the variable is meant
5268 to be possibly unused.  GCC does not produce a warning for this
5269 variable.
5271 @item used
5272 This attribute, attached to a variable with the static storage, means that
5273 the variable must be emitted even if it appears that the variable is not
5274 referenced.
5276 When applied to a static data member of a C++ class template, the
5277 attribute also means that the member is instantiated if the
5278 class itself is instantiated.
5280 @item vector_size (@var{bytes})
5281 This attribute specifies the vector size for the variable, measured in
5282 bytes.  For example, the declaration:
5284 @smallexample
5285 int foo __attribute__ ((vector_size (16)));
5286 @end smallexample
5288 @noindent
5289 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5290 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5291 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5293 This attribute is only applicable to integral and float scalars,
5294 although arrays, pointers, and function return values are allowed in
5295 conjunction with this construct.
5297 Aggregates with this attribute are invalid, even if they are of the same
5298 size as a corresponding scalar.  For example, the declaration:
5300 @smallexample
5301 struct S @{ int a; @};
5302 struct S  __attribute__ ((vector_size (16))) foo;
5303 @end smallexample
5305 @noindent
5306 is invalid even if the size of the structure is the same as the size of
5307 the @code{int}.
5309 @item selectany
5310 The @code{selectany} attribute causes an initialized global variable to
5311 have link-once semantics.  When multiple definitions of the variable are
5312 encountered by the linker, the first is selected and the remainder are
5313 discarded.  Following usage by the Microsoft compiler, the linker is told
5314 @emph{not} to warn about size or content differences of the multiple
5315 definitions.
5317 Although the primary usage of this attribute is for POD types, the
5318 attribute can also be applied to global C++ objects that are initialized
5319 by a constructor.  In this case, the static initialization and destruction
5320 code for the object is emitted in each translation defining the object,
5321 but the calls to the constructor and destructor are protected by a
5322 link-once guard variable.
5324 The @code{selectany} attribute is only available on Microsoft Windows
5325 targets.  You can use @code{__declspec (selectany)} as a synonym for
5326 @code{__attribute__ ((selectany))} for compatibility with other
5327 compilers.
5329 @item weak
5330 The @code{weak} attribute is described in @ref{Function Attributes}.
5332 @item dllimport
5333 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5335 @item dllexport
5336 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5338 @end table
5340 @anchor{AVR Variable Attributes}
5341 @subsection AVR Variable Attributes
5343 @table @code
5344 @item progmem
5345 @cindex @code{progmem} AVR variable attribute
5346 The @code{progmem} attribute is used on the AVR to place read-only
5347 data in the non-volatile program memory (flash). The @code{progmem}
5348 attribute accomplishes this by putting respective variables into a
5349 section whose name starts with @code{.progmem}.
5351 This attribute works similar to the @code{section} attribute
5352 but adds additional checking. Notice that just like the
5353 @code{section} attribute, @code{progmem} affects the location
5354 of the data but not how this data is accessed.
5356 In order to read data located with the @code{progmem} attribute
5357 (inline) assembler must be used.
5358 @smallexample
5359 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5360 #include <avr/pgmspace.h> 
5362 /* Locate var in flash memory */
5363 const int var[2] PROGMEM = @{ 1, 2 @};
5365 int read_var (int i)
5367     /* Access var[] by accessor macro from avr/pgmspace.h */
5368     return (int) pgm_read_word (& var[i]);
5370 @end smallexample
5372 AVR is a Harvard architecture processor and data and read-only data
5373 normally resides in the data memory (RAM).
5375 See also the @ref{AVR Named Address Spaces} section for
5376 an alternate way to locate and access data in flash memory.
5378 @item io
5379 @itemx io (@var{addr})
5380 Variables with the @code{io} attribute are used to address
5381 memory-mapped peripherals in the io address range.
5382 If an address is specified, the variable
5383 is assigned that address, and the value is interpreted as an
5384 address in the data address space.
5385 Example:
5387 @smallexample
5388 volatile int porta __attribute__((io (0x22)));
5389 @end smallexample
5391 The address specified in the address in the data address range.
5393 Otherwise, the variable it is not assigned an address, but the
5394 compiler will still use in/out instructions where applicable,
5395 assuming some other module assigns an address in the io address range.
5396 Example:
5398 @smallexample
5399 extern volatile int porta __attribute__((io));
5400 @end smallexample
5402 @item io_low
5403 @itemx io_low (@var{addr})
5404 This is like the @code{io} attribute, but additionally it informs the
5405 compiler that the object lies in the lower half of the I/O area,
5406 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5407 instructions.
5409 @item address
5410 @itemx address (@var{addr})
5411 Variables with the @code{address} attribute are used to address
5412 memory-mapped peripherals that may lie outside the io address range.
5414 @smallexample
5415 volatile int porta __attribute__((address (0x600)));
5416 @end smallexample
5418 @end table
5420 @subsection Blackfin Variable Attributes
5422 Three attributes are currently defined for the Blackfin.
5424 @table @code
5425 @item l1_data
5426 @itemx l1_data_A
5427 @itemx l1_data_B
5428 @cindex @code{l1_data} variable attribute
5429 @cindex @code{l1_data_A} variable attribute
5430 @cindex @code{l1_data_B} variable attribute
5431 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5432 Variables with @code{l1_data} attribute are put into the specific section
5433 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5434 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5435 attribute are put into the specific section named @code{.l1.data.B}.
5437 @item l2
5438 @cindex @code{l2} variable attribute
5439 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5440 Variables with @code{l2} attribute are put into the specific section
5441 named @code{.l2.data}.
5442 @end table
5444 @subsection M32R/D Variable Attributes
5446 One attribute is currently defined for the M32R/D@.
5448 @table @code
5449 @item model (@var{model-name})
5450 @cindex variable addressability on the M32R/D
5451 Use this attribute on the M32R/D to set the addressability of an object.
5452 The identifier @var{model-name} is one of @code{small}, @code{medium},
5453 or @code{large}, representing each of the code models.
5455 Small model objects live in the lower 16MB of memory (so that their
5456 addresses can be loaded with the @code{ld24} instruction).
5458 Medium and large model objects may live anywhere in the 32-bit address space
5459 (the compiler generates @code{seth/add3} instructions to load their
5460 addresses).
5461 @end table
5463 @anchor{MeP Variable Attributes}
5464 @subsection MeP Variable Attributes
5466 The MeP target has a number of addressing modes and busses.  The
5467 @code{near} space spans the standard memory space's first 16 megabytes
5468 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5469 The @code{based} space is a 128-byte region in the memory space that
5470 is addressed relative to the @code{$tp} register.  The @code{tiny}
5471 space is a 65536-byte region relative to the @code{$gp} register.  In
5472 addition to these memory regions, the MeP target has a separate 16-bit
5473 control bus which is specified with @code{cb} attributes.
5475 @table @code
5477 @item based
5478 Any variable with the @code{based} attribute is assigned to the
5479 @code{.based} section, and is accessed with relative to the
5480 @code{$tp} register.
5482 @item tiny
5483 Likewise, the @code{tiny} attribute assigned variables to the
5484 @code{.tiny} section, relative to the @code{$gp} register.
5486 @item near
5487 Variables with the @code{near} attribute are assumed to have addresses
5488 that fit in a 24-bit addressing mode.  This is the default for large
5489 variables (@code{-mtiny=4} is the default) but this attribute can
5490 override @code{-mtiny=} for small variables, or override @code{-ml}.
5492 @item far
5493 Variables with the @code{far} attribute are addressed using a full
5494 32-bit address.  Since this covers the entire memory space, this
5495 allows modules to make no assumptions about where variables might be
5496 stored.
5498 @item io
5499 @itemx io (@var{addr})
5500 Variables with the @code{io} attribute are used to address
5501 memory-mapped peripherals.  If an address is specified, the variable
5502 is assigned that address, else it is not assigned an address (it is
5503 assumed some other module assigns an address).  Example:
5505 @smallexample
5506 int timer_count __attribute__((io(0x123)));
5507 @end smallexample
5509 @item cb
5510 @itemx cb (@var{addr})
5511 Variables with the @code{cb} attribute are used to access the control
5512 bus, using special instructions.  @code{addr} indicates the control bus
5513 address.  Example:
5515 @smallexample
5516 int cpu_clock __attribute__((cb(0x123)));
5517 @end smallexample
5519 @end table
5521 @anchor{i386 Variable Attributes}
5522 @subsection i386 Variable Attributes
5524 Two attributes are currently defined for i386 configurations:
5525 @code{ms_struct} and @code{gcc_struct}
5527 @table @code
5528 @item ms_struct
5529 @itemx gcc_struct
5530 @cindex @code{ms_struct} attribute
5531 @cindex @code{gcc_struct} attribute
5533 If @code{packed} is used on a structure, or if bit-fields are used,
5534 it may be that the Microsoft ABI lays out the structure differently
5535 than the way GCC normally does.  Particularly when moving packed
5536 data between functions compiled with GCC and the native Microsoft compiler
5537 (either via function call or as data in a file), it may be necessary to access
5538 either format.
5540 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5541 compilers to match the native Microsoft compiler.
5543 The Microsoft structure layout algorithm is fairly simple with the exception
5544 of the bit-field packing.  
5545 The padding and alignment of members of structures and whether a bit-field 
5546 can straddle a storage-unit boundary are determine by these rules:
5548 @enumerate
5549 @item Structure members are stored sequentially in the order in which they are
5550 declared: the first member has the lowest memory address and the last member
5551 the highest.
5553 @item Every data object has an alignment requirement.  The alignment requirement
5554 for all data except structures, unions, and arrays is either the size of the
5555 object or the current packing size (specified with either the
5556 @code{aligned} attribute or the @code{pack} pragma),
5557 whichever is less.  For structures, unions, and arrays,
5558 the alignment requirement is the largest alignment requirement of its members.
5559 Every object is allocated an offset so that:
5561 @smallexample
5562 offset % alignment_requirement == 0
5563 @end smallexample
5565 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5566 unit if the integral types are the same size and if the next bit-field fits
5567 into the current allocation unit without crossing the boundary imposed by the
5568 common alignment requirements of the bit-fields.
5569 @end enumerate
5571 MSVC interprets zero-length bit-fields in the following ways:
5573 @enumerate
5574 @item If a zero-length bit-field is inserted between two bit-fields that
5575 are normally coalesced, the bit-fields are not coalesced.
5577 For example:
5579 @smallexample
5580 struct
5581  @{
5582    unsigned long bf_1 : 12;
5583    unsigned long : 0;
5584    unsigned long bf_2 : 12;
5585  @} t1;
5586 @end smallexample
5588 @noindent
5589 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5590 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5592 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5593 alignment of the zero-length bit-field is greater than the member that follows it,
5594 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5596 For example:
5598 @smallexample
5599 struct
5600  @{
5601    char foo : 4;
5602    short : 0;
5603    char bar;
5604  @} t2;
5606 struct
5607  @{
5608    char foo : 4;
5609    short : 0;
5610    double bar;
5611  @} t3;
5612 @end smallexample
5614 @noindent
5615 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5616 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5617 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5618 of the structure.
5620 Taking this into account, it is important to note the following:
5622 @enumerate
5623 @item If a zero-length bit-field follows a normal bit-field, the type of the
5624 zero-length bit-field may affect the alignment of the structure as whole. For
5625 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5626 normal bit-field, and is of type short.
5628 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5629 still affect the alignment of the structure:
5631 @smallexample
5632 struct
5633  @{
5634    char foo : 6;
5635    long : 0;
5636  @} t4;
5637 @end smallexample
5639 @noindent
5640 Here, @code{t4} takes up 4 bytes.
5641 @end enumerate
5643 @item Zero-length bit-fields following non-bit-field members are ignored:
5645 @smallexample
5646 struct
5647  @{
5648    char foo;
5649    long : 0;
5650    char bar;
5651  @} t5;
5652 @end smallexample
5654 @noindent
5655 Here, @code{t5} takes up 2 bytes.
5656 @end enumerate
5657 @end table
5659 @subsection PowerPC Variable Attributes
5661 Three attributes currently are defined for PowerPC configurations:
5662 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5664 For full documentation of the struct attributes please see the
5665 documentation in @ref{i386 Variable Attributes}.
5667 For documentation of @code{altivec} attribute please see the
5668 documentation in @ref{PowerPC Type Attributes}.
5670 @subsection SPU Variable Attributes
5672 The SPU supports the @code{spu_vector} attribute for variables.  For
5673 documentation of this attribute please see the documentation in
5674 @ref{SPU Type Attributes}.
5676 @subsection Xstormy16 Variable Attributes
5678 One attribute is currently defined for xstormy16 configurations:
5679 @code{below100}.
5681 @table @code
5682 @item below100
5683 @cindex @code{below100} attribute
5685 If a variable has the @code{below100} attribute (@code{BELOW100} is
5686 allowed also), GCC places the variable in the first 0x100 bytes of
5687 memory and use special opcodes to access it.  Such variables are
5688 placed in either the @code{.bss_below100} section or the
5689 @code{.data_below100} section.
5691 @end table
5693 @node Type Attributes
5694 @section Specifying Attributes of Types
5695 @cindex attribute of types
5696 @cindex type attributes
5698 The keyword @code{__attribute__} allows you to specify special
5699 attributes of @code{struct} and @code{union} types when you define
5700 such types.  This keyword is followed by an attribute specification
5701 inside double parentheses.  Eight attributes are currently defined for
5702 types: @code{aligned}, @code{packed}, @code{transparent_union},
5703 @code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias}
5704 and @code{bnd_variable_size}.  Other attributes are defined for
5705 functions (@pxref{Function Attributes}), labels (@pxref{Label 
5706 Attributes}) and for variables (@pxref{Variable Attributes}).
5708 You may also specify any one of these attributes with @samp{__}
5709 preceding and following its keyword.  This allows you to use these
5710 attributes in header files without being concerned about a possible
5711 macro of the same name.  For example, you may use @code{__aligned__}
5712 instead of @code{aligned}.
5714 You may specify type attributes in an enum, struct or union type
5715 declaration or definition, or for other types in a @code{typedef}
5716 declaration.
5718 For an enum, struct or union type, you may specify attributes either
5719 between the enum, struct or union tag and the name of the type, or
5720 just past the closing curly brace of the @emph{definition}.  The
5721 former syntax is preferred.
5723 @xref{Attribute Syntax}, for details of the exact syntax for using
5724 attributes.
5726 @table @code
5727 @cindex @code{aligned} attribute
5728 @item aligned (@var{alignment})
5729 This attribute specifies a minimum alignment (in bytes) for variables
5730 of the specified type.  For example, the declarations:
5732 @smallexample
5733 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5734 typedef int more_aligned_int __attribute__ ((aligned (8)));
5735 @end smallexample
5737 @noindent
5738 force the compiler to ensure (as far as it can) that each variable whose
5739 type is @code{struct S} or @code{more_aligned_int} is allocated and
5740 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5741 variables of type @code{struct S} aligned to 8-byte boundaries allows
5742 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5743 store) instructions when copying one variable of type @code{struct S} to
5744 another, thus improving run-time efficiency.
5746 Note that the alignment of any given @code{struct} or @code{union} type
5747 is required by the ISO C standard to be at least a perfect multiple of
5748 the lowest common multiple of the alignments of all of the members of
5749 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5750 effectively adjust the alignment of a @code{struct} or @code{union}
5751 type by attaching an @code{aligned} attribute to any one of the members
5752 of such a type, but the notation illustrated in the example above is a
5753 more obvious, intuitive, and readable way to request the compiler to
5754 adjust the alignment of an entire @code{struct} or @code{union} type.
5756 As in the preceding example, you can explicitly specify the alignment
5757 (in bytes) that you wish the compiler to use for a given @code{struct}
5758 or @code{union} type.  Alternatively, you can leave out the alignment factor
5759 and just ask the compiler to align a type to the maximum
5760 useful alignment for the target machine you are compiling for.  For
5761 example, you could write:
5763 @smallexample
5764 struct S @{ short f[3]; @} __attribute__ ((aligned));
5765 @end smallexample
5767 Whenever you leave out the alignment factor in an @code{aligned}
5768 attribute specification, the compiler automatically sets the alignment
5769 for the type to the largest alignment that is ever used for any data
5770 type on the target machine you are compiling for.  Doing this can often
5771 make copy operations more efficient, because the compiler can use
5772 whatever instructions copy the biggest chunks of memory when performing
5773 copies to or from the variables that have types that you have aligned
5774 this way.
5776 In the example above, if the size of each @code{short} is 2 bytes, then
5777 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5778 power of two that is greater than or equal to that is 8, so the
5779 compiler sets the alignment for the entire @code{struct S} type to 8
5780 bytes.
5782 Note that although you can ask the compiler to select a time-efficient
5783 alignment for a given type and then declare only individual stand-alone
5784 objects of that type, the compiler's ability to select a time-efficient
5785 alignment is primarily useful only when you plan to create arrays of
5786 variables having the relevant (efficiently aligned) type.  If you
5787 declare or use arrays of variables of an efficiently-aligned type, then
5788 it is likely that your program also does pointer arithmetic (or
5789 subscripting, which amounts to the same thing) on pointers to the
5790 relevant type, and the code that the compiler generates for these
5791 pointer arithmetic operations is often more efficient for
5792 efficiently-aligned types than for other types.
5794 The @code{aligned} attribute can only increase the alignment; but you
5795 can decrease it by specifying @code{packed} as well.  See below.
5797 Note that the effectiveness of @code{aligned} attributes may be limited
5798 by inherent limitations in your linker.  On many systems, the linker is
5799 only able to arrange for variables to be aligned up to a certain maximum
5800 alignment.  (For some linkers, the maximum supported alignment may
5801 be very very small.)  If your linker is only able to align variables
5802 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5803 in an @code{__attribute__} still only provides you with 8-byte
5804 alignment.  See your linker documentation for further information.
5806 @item packed
5807 This attribute, attached to @code{struct} or @code{union} type
5808 definition, specifies that each member (other than zero-width bit-fields)
5809 of the structure or union is placed to minimize the memory required.  When
5810 attached to an @code{enum} definition, it indicates that the smallest
5811 integral type should be used.
5813 @opindex fshort-enums
5814 Specifying this attribute for @code{struct} and @code{union} types is
5815 equivalent to specifying the @code{packed} attribute on each of the
5816 structure or union members.  Specifying the @option{-fshort-enums}
5817 flag on the line is equivalent to specifying the @code{packed}
5818 attribute on all @code{enum} definitions.
5820 In the following example @code{struct my_packed_struct}'s members are
5821 packed closely together, but the internal layout of its @code{s} member
5822 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5823 be packed too.
5825 @smallexample
5826 struct my_unpacked_struct
5827  @{
5828     char c;
5829     int i;
5830  @};
5832 struct __attribute__ ((__packed__)) my_packed_struct
5833   @{
5834      char c;
5835      int  i;
5836      struct my_unpacked_struct s;
5837   @};
5838 @end smallexample
5840 You may only specify this attribute on the definition of an @code{enum},
5841 @code{struct} or @code{union}, not on a @code{typedef} that does not
5842 also define the enumerated type, structure or union.
5844 @item transparent_union
5845 @cindex @code{transparent_union} attribute
5847 This attribute, attached to a @code{union} type definition, indicates
5848 that any function parameter having that union type causes calls to that
5849 function to be treated in a special way.
5851 First, the argument corresponding to a transparent union type can be of
5852 any type in the union; no cast is required.  Also, if the union contains
5853 a pointer type, the corresponding argument can be a null pointer
5854 constant or a void pointer expression; and if the union contains a void
5855 pointer type, the corresponding argument can be any pointer expression.
5856 If the union member type is a pointer, qualifiers like @code{const} on
5857 the referenced type must be respected, just as with normal pointer
5858 conversions.
5860 Second, the argument is passed to the function using the calling
5861 conventions of the first member of the transparent union, not the calling
5862 conventions of the union itself.  All members of the union must have the
5863 same machine representation; this is necessary for this argument passing
5864 to work properly.
5866 Transparent unions are designed for library functions that have multiple
5867 interfaces for compatibility reasons.  For example, suppose the
5868 @code{wait} function must accept either a value of type @code{int *} to
5869 comply with POSIX, or a value of type @code{union wait *} to comply with
5870 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5871 @code{wait} would accept both kinds of arguments, but it would also
5872 accept any other pointer type and this would make argument type checking
5873 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5874 as follows:
5876 @smallexample
5877 typedef union __attribute__ ((__transparent_union__))
5878   @{
5879     int *__ip;
5880     union wait *__up;
5881   @} wait_status_ptr_t;
5883 pid_t wait (wait_status_ptr_t);
5884 @end smallexample
5886 @noindent
5887 This interface allows either @code{int *} or @code{union wait *}
5888 arguments to be passed, using the @code{int *} calling convention.
5889 The program can call @code{wait} with arguments of either type:
5891 @smallexample
5892 int w1 () @{ int w; return wait (&w); @}
5893 int w2 () @{ union wait w; return wait (&w); @}
5894 @end smallexample
5896 @noindent
5897 With this interface, @code{wait}'s implementation might look like this:
5899 @smallexample
5900 pid_t wait (wait_status_ptr_t p)
5902   return waitpid (-1, p.__ip, 0);
5904 @end smallexample
5906 @item unused
5907 When attached to a type (including a @code{union} or a @code{struct}),
5908 this attribute means that variables of that type are meant to appear
5909 possibly unused.  GCC does not produce a warning for any variables of
5910 that type, even if the variable appears to do nothing.  This is often
5911 the case with lock or thread classes, which are usually defined and then
5912 not referenced, but contain constructors and destructors that have
5913 nontrivial bookkeeping functions.
5915 @item deprecated
5916 @itemx deprecated (@var{msg})
5917 The @code{deprecated} attribute results in a warning if the type
5918 is used anywhere in the source file.  This is useful when identifying
5919 types that are expected to be removed in a future version of a program.
5920 If possible, the warning also includes the location of the declaration
5921 of the deprecated type, to enable users to easily find further
5922 information about why the type is deprecated, or what they should do
5923 instead.  Note that the warnings only occur for uses and then only
5924 if the type is being applied to an identifier that itself is not being
5925 declared as deprecated.
5927 @smallexample
5928 typedef int T1 __attribute__ ((deprecated));
5929 T1 x;
5930 typedef T1 T2;
5931 T2 y;
5932 typedef T1 T3 __attribute__ ((deprecated));
5933 T3 z __attribute__ ((deprecated));
5934 @end smallexample
5936 @noindent
5937 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5938 warning is issued for line 4 because T2 is not explicitly
5939 deprecated.  Line 5 has no warning because T3 is explicitly
5940 deprecated.  Similarly for line 6.  The optional @var{msg}
5941 argument, which must be a string, is printed in the warning if
5942 present.
5944 The @code{deprecated} attribute can also be used for functions and
5945 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5947 @item may_alias
5948 Accesses through pointers to types with this attribute are not subject
5949 to type-based alias analysis, but are instead assumed to be able to alias
5950 any other type of objects.
5951 In the context of section 6.5 paragraph 7 of the C99 standard,
5952 an lvalue expression
5953 dereferencing such a pointer is treated like having a character type.
5954 See @option{-fstrict-aliasing} for more information on aliasing issues.
5955 This extension exists to support some vector APIs, in which pointers to
5956 one vector type are permitted to alias pointers to a different vector type.
5958 Note that an object of a type with this attribute does not have any
5959 special semantics.
5961 Example of use:
5963 @smallexample
5964 typedef short __attribute__((__may_alias__)) short_a;
5967 main (void)
5969   int a = 0x12345678;
5970   short_a *b = (short_a *) &a;
5972   b[1] = 0;
5974   if (a == 0x12345678)
5975     abort();
5977   exit(0);
5979 @end smallexample
5981 @noindent
5982 If you replaced @code{short_a} with @code{short} in the variable
5983 declaration, the above program would abort when compiled with
5984 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5985 above in recent GCC versions.
5987 @item visibility
5988 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5989 applied to class, struct, union and enum types.  Unlike other type
5990 attributes, the attribute must appear between the initial keyword and
5991 the name of the type; it cannot appear after the body of the type.
5993 Note that the type visibility is applied to vague linkage entities
5994 associated with the class (vtable, typeinfo node, etc.).  In
5995 particular, if a class is thrown as an exception in one shared object
5996 and caught in another, the class must have default visibility.
5997 Otherwise the two shared objects are unable to use the same
5998 typeinfo node and exception handling will break.
6000 @item designated_init
6001 This attribute may only be applied to structure types.  It indicates
6002 that any initialization of an object of this type must use designated
6003 initializers rather than positional initializers.  The intent of this
6004 attribute is to allow the programmer to indicate that a structure's
6005 layout may change, and that therefore relying on positional
6006 initialization will result in future breakage.
6008 GCC emits warnings based on this attribute by default; use
6009 @option{-Wno-designated-init} to suppress them.
6011 @item bnd_variable_size
6012 When applied to a structure field, this attribute tells Pointer
6013 Bounds Checker that the size of this field should not be computed
6014 using static type information.  It may be used to mark variable
6015 sized static array fields placed at the end of a structure.
6017 @smallexample
6018 struct S
6020   int size;
6021   char data[1];
6023 S *p = (S *)malloc (sizeof(S) + 100);
6024 p->data[10] = 0; //Bounds violation
6025 @end smallexample
6027 By using an attribute for a field we may avoid bound violation
6028 we most probably do not want to see:
6030 @smallexample
6031 struct S
6033   int size;
6034   char data[1] __attribute__((bnd_variable_size));
6036 S *p = (S *)malloc (sizeof(S) + 100);
6037 p->data[10] = 0; //OK
6038 @end smallexample
6040 @end table
6042 To specify multiple attributes, separate them by commas within the
6043 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6044 packed))}.
6046 @subsection ARM Type Attributes
6048 On those ARM targets that support @code{dllimport} (such as Symbian
6049 OS), you can use the @code{notshared} attribute to indicate that the
6050 virtual table and other similar data for a class should not be
6051 exported from a DLL@.  For example:
6053 @smallexample
6054 class __declspec(notshared) C @{
6055 public:
6056   __declspec(dllimport) C();
6057   virtual void f();
6060 __declspec(dllexport)
6061 C::C() @{@}
6062 @end smallexample
6064 @noindent
6065 In this code, @code{C::C} is exported from the current DLL, but the
6066 virtual table for @code{C} is not exported.  (You can use
6067 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6068 most Symbian OS code uses @code{__declspec}.)
6070 @anchor{MeP Type Attributes}
6071 @subsection MeP Type Attributes
6073 Many of the MeP variable attributes may be applied to types as well.
6074 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6075 @code{far} attributes may be applied to either.  The @code{io} and
6076 @code{cb} attributes may not be applied to types.
6078 @anchor{i386 Type Attributes}
6079 @subsection i386 Type Attributes
6081 Two attributes are currently defined for i386 configurations:
6082 @code{ms_struct} and @code{gcc_struct}.
6084 @table @code
6086 @item ms_struct
6087 @itemx gcc_struct
6088 @cindex @code{ms_struct}
6089 @cindex @code{gcc_struct}
6091 If @code{packed} is used on a structure, or if bit-fields are used
6092 it may be that the Microsoft ABI packs them differently
6093 than GCC normally packs them.  Particularly when moving packed
6094 data between functions compiled with GCC and the native Microsoft compiler
6095 (either via function call or as data in a file), it may be necessary to access
6096 either format.
6098 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
6099 compilers to match the native Microsoft compiler.
6100 @end table
6102 @anchor{PowerPC Type Attributes}
6103 @subsection PowerPC Type Attributes
6105 Three attributes currently are defined for PowerPC configurations:
6106 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6108 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6109 attributes please see the documentation in @ref{i386 Type Attributes}.
6111 The @code{altivec} attribute allows one to declare AltiVec vector data
6112 types supported by the AltiVec Programming Interface Manual.  The
6113 attribute requires an argument to specify one of three vector types:
6114 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6115 and @code{bool__} (always followed by unsigned).
6117 @smallexample
6118 __attribute__((altivec(vector__)))
6119 __attribute__((altivec(pixel__))) unsigned short
6120 __attribute__((altivec(bool__))) unsigned
6121 @end smallexample
6123 These attributes mainly are intended to support the @code{__vector},
6124 @code{__pixel}, and @code{__bool} AltiVec keywords.
6126 @anchor{SPU Type Attributes}
6127 @subsection SPU Type Attributes
6129 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6130 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6131 Language Extensions Specification.  It is intended to support the
6132 @code{__vector} keyword.
6134 @node Alignment
6135 @section Inquiring on Alignment of Types or Variables
6136 @cindex alignment
6137 @cindex type alignment
6138 @cindex variable alignment
6140 The keyword @code{__alignof__} allows you to inquire about how an object
6141 is aligned, or the minimum alignment usually required by a type.  Its
6142 syntax is just like @code{sizeof}.
6144 For example, if the target machine requires a @code{double} value to be
6145 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6146 This is true on many RISC machines.  On more traditional machine
6147 designs, @code{__alignof__ (double)} is 4 or even 2.
6149 Some machines never actually require alignment; they allow reference to any
6150 data type even at an odd address.  For these machines, @code{__alignof__}
6151 reports the smallest alignment that GCC gives the data type, usually as
6152 mandated by the target ABI.
6154 If the operand of @code{__alignof__} is an lvalue rather than a type,
6155 its value is the required alignment for its type, taking into account
6156 any minimum alignment specified with GCC's @code{__attribute__}
6157 extension (@pxref{Variable Attributes}).  For example, after this
6158 declaration:
6160 @smallexample
6161 struct foo @{ int x; char y; @} foo1;
6162 @end smallexample
6164 @noindent
6165 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6166 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6168 It is an error to ask for the alignment of an incomplete type.
6171 @node Inline
6172 @section An Inline Function is As Fast As a Macro
6173 @cindex inline functions
6174 @cindex integrating function code
6175 @cindex open coding
6176 @cindex macros, inline alternative
6178 By declaring a function inline, you can direct GCC to make
6179 calls to that function faster.  One way GCC can achieve this is to
6180 integrate that function's code into the code for its callers.  This
6181 makes execution faster by eliminating the function-call overhead; in
6182 addition, if any of the actual argument values are constant, their
6183 known values may permit simplifications at compile time so that not
6184 all of the inline function's code needs to be included.  The effect on
6185 code size is less predictable; object code may be larger or smaller
6186 with function inlining, depending on the particular case.  You can
6187 also direct GCC to try to integrate all ``simple enough'' functions
6188 into their callers with the option @option{-finline-functions}.
6190 GCC implements three different semantics of declaring a function
6191 inline.  One is available with @option{-std=gnu89} or
6192 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6193 on all inline declarations, another when
6194 @option{-std=c99}, @option{-std=c11},
6195 @option{-std=gnu99} or @option{-std=gnu11}
6196 (without @option{-fgnu89-inline}), and the third
6197 is used when compiling C++.
6199 To declare a function inline, use the @code{inline} keyword in its
6200 declaration, like this:
6202 @smallexample
6203 static inline int
6204 inc (int *a)
6206   return (*a)++;
6208 @end smallexample
6210 If you are writing a header file to be included in ISO C90 programs, write
6211 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6213 The three types of inlining behave similarly in two important cases:
6214 when the @code{inline} keyword is used on a @code{static} function,
6215 like the example above, and when a function is first declared without
6216 using the @code{inline} keyword and then is defined with
6217 @code{inline}, like this:
6219 @smallexample
6220 extern int inc (int *a);
6221 inline int
6222 inc (int *a)
6224   return (*a)++;
6226 @end smallexample
6228 In both of these common cases, the program behaves the same as if you
6229 had not used the @code{inline} keyword, except for its speed.
6231 @cindex inline functions, omission of
6232 @opindex fkeep-inline-functions
6233 When a function is both inline and @code{static}, if all calls to the
6234 function are integrated into the caller, and the function's address is
6235 never used, then the function's own assembler code is never referenced.
6236 In this case, GCC does not actually output assembler code for the
6237 function, unless you specify the option @option{-fkeep-inline-functions}.
6238 Some calls cannot be integrated for various reasons (in particular,
6239 calls that precede the function's definition cannot be integrated, and
6240 neither can recursive calls within the definition).  If there is a
6241 nonintegrated call, then the function is compiled to assembler code as
6242 usual.  The function must also be compiled as usual if the program
6243 refers to its address, because that can't be inlined.
6245 @opindex Winline
6246 Note that certain usages in a function definition can make it unsuitable
6247 for inline substitution.  Among these usages are: variadic functions, use of
6248 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6249 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6250 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6251 warns when a function marked @code{inline} could not be substituted,
6252 and gives the reason for the failure.
6254 @cindex automatic @code{inline} for C++ member fns
6255 @cindex @code{inline} automatic for C++ member fns
6256 @cindex member fns, automatically @code{inline}
6257 @cindex C++ member fns, automatically @code{inline}
6258 @opindex fno-default-inline
6259 As required by ISO C++, GCC considers member functions defined within
6260 the body of a class to be marked inline even if they are
6261 not explicitly declared with the @code{inline} keyword.  You can
6262 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6263 Options,,Options Controlling C++ Dialect}.
6265 GCC does not inline any functions when not optimizing unless you specify
6266 the @samp{always_inline} attribute for the function, like this:
6268 @smallexample
6269 /* @r{Prototype.}  */
6270 inline void foo (const char) __attribute__((always_inline));
6271 @end smallexample
6273 The remainder of this section is specific to GNU C90 inlining.
6275 @cindex non-static inline function
6276 When an inline function is not @code{static}, then the compiler must assume
6277 that there may be calls from other source files; since a global symbol can
6278 be defined only once in any program, the function must not be defined in
6279 the other source files, so the calls therein cannot be integrated.
6280 Therefore, a non-@code{static} inline function is always compiled on its
6281 own in the usual fashion.
6283 If you specify both @code{inline} and @code{extern} in the function
6284 definition, then the definition is used only for inlining.  In no case
6285 is the function compiled on its own, not even if you refer to its
6286 address explicitly.  Such an address becomes an external reference, as
6287 if you had only declared the function, and had not defined it.
6289 This combination of @code{inline} and @code{extern} has almost the
6290 effect of a macro.  The way to use it is to put a function definition in
6291 a header file with these keywords, and put another copy of the
6292 definition (lacking @code{inline} and @code{extern}) in a library file.
6293 The definition in the header file causes most calls to the function
6294 to be inlined.  If any uses of the function remain, they refer to
6295 the single copy in the library.
6297 @node Volatiles
6298 @section When is a Volatile Object Accessed?
6299 @cindex accessing volatiles
6300 @cindex volatile read
6301 @cindex volatile write
6302 @cindex volatile access
6304 C has the concept of volatile objects.  These are normally accessed by
6305 pointers and used for accessing hardware or inter-thread
6306 communication.  The standard encourages compilers to refrain from
6307 optimizations concerning accesses to volatile objects, but leaves it
6308 implementation defined as to what constitutes a volatile access.  The
6309 minimum requirement is that at a sequence point all previous accesses
6310 to volatile objects have stabilized and no subsequent accesses have
6311 occurred.  Thus an implementation is free to reorder and combine
6312 volatile accesses that occur between sequence points, but cannot do
6313 so for accesses across a sequence point.  The use of volatile does
6314 not allow you to violate the restriction on updating objects multiple
6315 times between two sequence points.
6317 Accesses to non-volatile objects are not ordered with respect to
6318 volatile accesses.  You cannot use a volatile object as a memory
6319 barrier to order a sequence of writes to non-volatile memory.  For
6320 instance:
6322 @smallexample
6323 int *ptr = @var{something};
6324 volatile int vobj;
6325 *ptr = @var{something};
6326 vobj = 1;
6327 @end smallexample
6329 @noindent
6330 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6331 that the write to @var{*ptr} occurs by the time the update
6332 of @var{vobj} happens.  If you need this guarantee, you must use
6333 a stronger memory barrier such as:
6335 @smallexample
6336 int *ptr = @var{something};
6337 volatile int vobj;
6338 *ptr = @var{something};
6339 asm volatile ("" : : : "memory");
6340 vobj = 1;
6341 @end smallexample
6343 A scalar volatile object is read when it is accessed in a void context:
6345 @smallexample
6346 volatile int *src = @var{somevalue};
6347 *src;
6348 @end smallexample
6350 Such expressions are rvalues, and GCC implements this as a
6351 read of the volatile object being pointed to.
6353 Assignments are also expressions and have an rvalue.  However when
6354 assigning to a scalar volatile, the volatile object is not reread,
6355 regardless of whether the assignment expression's rvalue is used or
6356 not.  If the assignment's rvalue is used, the value is that assigned
6357 to the volatile object.  For instance, there is no read of @var{vobj}
6358 in all the following cases:
6360 @smallexample
6361 int obj;
6362 volatile int vobj;
6363 vobj = @var{something};
6364 obj = vobj = @var{something};
6365 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6366 obj = (@var{something}, vobj = @var{anotherthing});
6367 @end smallexample
6369 If you need to read the volatile object after an assignment has
6370 occurred, you must use a separate expression with an intervening
6371 sequence point.
6373 As bit-fields are not individually addressable, volatile bit-fields may
6374 be implicitly read when written to, or when adjacent bit-fields are
6375 accessed.  Bit-field operations may be optimized such that adjacent
6376 bit-fields are only partially accessed, if they straddle a storage unit
6377 boundary.  For these reasons it is unwise to use volatile bit-fields to
6378 access hardware.
6380 @node Using Assembly Language with C
6381 @section How to Use Inline Assembly Language in C Code
6383 GCC provides various extensions that allow you to embed assembler within 
6384 C code.
6386 @menu
6387 * Basic Asm::          Inline assembler with no operands.
6388 * Extended Asm::       Inline assembler with operands.
6389 * Constraints::        Constraints for @code{asm} operands
6390 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6391 * Explicit Reg Vars::  Defining variables residing in specified registers.
6392 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6393 @end menu
6395 @node Basic Asm
6396 @subsection Basic Asm --- Assembler Instructions with No Operands
6397 @cindex basic @code{asm}
6399 The @code{asm} keyword allows you to embed assembler instructions within 
6400 C code.
6402 @example
6403 asm [ volatile ] ( AssemblerInstructions )
6404 @end example
6406 To create headers compatible with ISO C, write @code{__asm__} instead of 
6407 @code{asm} (@pxref{Alternate Keywords}).
6409 By definition, a Basic @code{asm} statement is one with no operands. 
6410 @code{asm} statements that contain one or more colons (used to delineate 
6411 operands) are considered to be Extended (for example, @code{asm("int $3")} 
6412 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6414 @subsubheading Qualifiers
6415 @emph{volatile}
6417 This optional qualifier has no effect. All Basic @code{asm} blocks are 
6418 implicitly volatile.
6420 @subsubheading Parameters
6421 @emph{AssemblerInstructions}
6423 This is a literal string that specifies the assembler code. The string can 
6424 contain any instructions recognized by the assembler, including directives. 
6425 GCC does not parse the assembler instructions themselves and 
6426 does not know what they mean or even whether they are valid assembler input. 
6427 The compiler copies it verbatim to the assembly language output file, without 
6428 processing dialects or any of the "%" operators that are available with
6429 Extended @code{asm}. This results in minor differences between Basic 
6430 @code{asm} strings and Extended @code{asm} templates. For example, to refer to 
6431 registers you might use %%eax in Extended @code{asm} and %eax in Basic 
6432 @code{asm}.
6434 You may place multiple assembler instructions together in a single @code{asm} 
6435 string, separated by the characters normally used in assembly code for the 
6436 system. A combination that works in most places is a newline to break the 
6437 line, plus a tab character (written as "\n\t").
6438 Some assemblers allow semicolons as a line separator. However, 
6439 note that some assembler dialects use semicolons to start a comment. 
6441 Do not expect a sequence of @code{asm} statements to remain perfectly 
6442 consecutive after compilation. If certain instructions need to remain 
6443 consecutive in the output, put them in a single multi-instruction asm 
6444 statement. Note that GCC's optimizers can move @code{asm} statements 
6445 relative to other code, including across jumps.
6447 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6448 GCC does not know about these jumps, and therefore cannot take 
6449 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6450 labels are only supported in Extended @code{asm}.
6452 @subsubheading Remarks
6453 Using Extended @code{asm} will typically produce smaller, safer, and more 
6454 efficient code, and in most cases it is a better solution. When writing 
6455 inline assembly language outside of C functions, however, you must use Basic 
6456 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6457 Functions declared with the @code{naked} attribute also require Basic 
6458 @code{asm} (@pxref{Function Attributes}).
6460 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6461 assembly code when optimizing. This can lead to unexpected duplicate 
6462 symbol errors during compilation if your assembly code defines symbols or 
6463 labels.
6465 Safely accessing C data and calling functions from Basic @code{asm} is more 
6466 complex than it may appear. To access C data, it is better to use Extended 
6467 @code{asm}.
6469 Since GCC does not parse the AssemblerInstructions, it has no 
6470 visibility of any symbols it references. This may result in GCC discarding 
6471 those symbols as unreferenced.
6473 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly 
6474 volatile. @xref{Volatile}.  Similarly, Basic @code{asm} blocks are not treated 
6475 as though they used a "memory" clobber (@pxref{Clobbers}).
6477 All Basic @code{asm} blocks use the assembler dialect specified by the 
6478 @option{-masm} command-line option. Basic @code{asm} provides no
6479 mechanism to provide different assembler strings for different dialects.
6481 Here is an example of Basic @code{asm} for i386:
6483 @example
6484 /* Note that this code will not compile with -masm=intel */
6485 #define DebugBreak() asm("int $3")
6486 @end example
6488 @node Extended Asm
6489 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6490 @cindex @code{asm} keyword
6491 @cindex extended @code{asm}
6492 @cindex assembler instructions
6494 The @code{asm} keyword allows you to embed assembler instructions within C 
6495 code. With Extended @code{asm} you can read and write C variables from 
6496 assembler and perform jumps from assembler code to C labels.
6498 @example
6499 @ifhtml
6500 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6502 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6503 @end ifhtml
6504 @ifnothtml
6505 asm [volatile] ( AssemblerTemplate 
6506                  : [OutputOperands] 
6507                  [ : [InputOperands] 
6508                  [ : [Clobbers] ] ])
6510 asm [volatile] goto ( AssemblerTemplate 
6511                       : 
6512                       : [InputOperands] 
6513                       : [Clobbers] 
6514                       : GotoLabels)
6515 @end ifnothtml
6516 @end example
6518 To create headers compatible with ISO C, write @code{__asm__} instead of 
6519 @code{asm} and @code{__volatile__} instead of @code{volatile} 
6520 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6522 By definition, Extended @code{asm} is an @code{asm} statement that contains 
6523 operands. To separate the classes of operands, you use colons. Basic 
6524 @code{asm} statements contain no colons. (So, for example, 
6525 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is 
6526 Extended @code{asm}. @pxref{Basic Asm}.)
6528 @subsubheading Qualifiers
6529 @emph{volatile}
6531 The typical use of Extended @code{asm} statements is to manipulate input 
6532 values to produce output values. However, your @code{asm} statements may 
6533 also produce side effects. If so, you may need to use the @code{volatile} 
6534 qualifier to disable certain optimizations. @xref{Volatile}.
6536 @emph{goto}
6538 This qualifier informs the compiler that the @code{asm} statement may 
6539 perform a jump to one of the labels listed in the GotoLabels section. 
6540 @xref{GotoLabels}.
6542 @subsubheading Parameters
6543 @emph{AssemblerTemplate}
6545 This is a literal string that contains the assembler code. It is a 
6546 combination of fixed text and tokens that refer to the input, output, 
6547 and goto parameters. @xref{AssemblerTemplate}.
6549 @emph{OutputOperands}
6551 A comma-separated list of the C variables modified by the instructions in the 
6552 AssemblerTemplate. @xref{OutputOperands}.
6554 @emph{InputOperands}
6556 A comma-separated list of C expressions read by the instructions in the 
6557 AssemblerTemplate. @xref{InputOperands}.
6559 @emph{Clobbers}
6561 A comma-separated list of registers or other values changed by the 
6562 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6564 @emph{GotoLabels}
6566 When you are using the @code{goto} form of @code{asm}, this section contains 
6567 the list of all C labels to which the AssemblerTemplate may jump. 
6568 @xref{GotoLabels}.
6570 @subsubheading Remarks
6571 The @code{asm} statement allows you to include assembly instructions directly 
6572 within C code. This may help you to maximize performance in time-sensitive 
6573 code or to access assembly instructions that are not readily available to C 
6574 programs.
6576 Note that Extended @code{asm} statements must be inside a function. Only 
6577 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6578 Functions declared with the @code{naked} attribute also require Basic 
6579 @code{asm} (@pxref{Function Attributes}).
6581 While the uses of @code{asm} are many and varied, it may help to think of an 
6582 @code{asm} statement as a series of low-level instructions that convert input 
6583 parameters to output parameters. So a simple (if not particularly useful) 
6584 example for i386 using @code{asm} might look like this:
6586 @example
6587 int src = 1;
6588 int dst;   
6590 asm ("mov %1, %0\n\t"
6591     "add $1, %0"
6592     : "=r" (dst) 
6593     : "r" (src));
6595 printf("%d\n", dst);
6596 @end example
6598 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6600 @anchor{Volatile}
6601 @subsubsection Volatile
6602 @cindex volatile @code{asm}
6603 @cindex @code{asm} volatile
6605 GCC's optimizers sometimes discard @code{asm} statements if they determine 
6606 there is no need for the output variables. Also, the optimizers may move 
6607 code out of loops if they believe that the code will always return the same 
6608 result (i.e. none of its input values change between calls). Using the 
6609 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
6610 that have no output operands are implicitly volatile.
6612 Examples:
6614 This i386 code demonstrates a case that does not use (or require) the 
6615 @code{volatile} qualifier. If it is performing assertion checking, this code 
6616 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is 
6617 unreferenced by any code. As a result, the optimizers can discard the 
6618 @code{asm} statement, which in turn removes the need for the entire 
6619 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
6620 isn't needed you allow the optimizers to produce the most efficient code 
6621 possible.
6623 @example
6624 void DoCheck(uint32_t dwSomeValue)
6626    uint32_t dwRes;
6628    // Assumes dwSomeValue is not zero.
6629    asm ("bsfl %1,%0"
6630      : "=r" (dwRes)
6631      : "r" (dwSomeValue)
6632      : "cc");
6634    assert(dwRes > 3);
6636 @end example
6638 The next example shows a case where the optimizers can recognize that the input 
6639 (@var{dwSomeValue}) never changes during the execution of the function and can 
6640 therefore move the @code{asm} outside the loop to produce more efficient code. 
6641 Again, using @code{volatile} disables this type of optimization.
6643 @example
6644 void do_print(uint32_t dwSomeValue)
6646    uint32_t dwRes;
6648    for (uint32_t x=0; x < 5; x++)
6649    @{
6650       // Assumes dwSomeValue is not zero.
6651       asm ("bsfl %1,%0"
6652         : "=r" (dwRes)
6653         : "r" (dwSomeValue)
6654         : "cc");
6656       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6657    @}
6659 @end example
6661 The following example demonstrates a case where you need to use the 
6662 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads 
6663 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
6664 the optimizers might assume that the @code{asm} block will always return the 
6665 same value and therefore optimize away the second call.
6667 @example
6668 uint64_t msr;
6670 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6671         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6672         "or %%rdx, %0"        // 'Or' in the lower bits.
6673         : "=a" (msr)
6674         : 
6675         : "rdx");
6677 printf("msr: %llx\n", msr);
6679 // Do other work...
6681 // Reprint the timestamp
6682 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6683         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6684         "or %%rdx, %0"        // 'Or' in the lower bits.
6685         : "=a" (msr)
6686         : 
6687         : "rdx");
6689 printf("msr: %llx\n", msr);
6690 @end example
6692 GCC's optimizers will not treat this code like the non-volatile code in the 
6693 earlier examples. They do not move it out of loops or omit it on the 
6694 assumption that the result from a previous call is still valid.
6696 Note that the compiler can move even volatile @code{asm} instructions relative 
6697 to other code, including across jump instructions. For example, on many 
6698 targets there is a system register that controls the rounding mode of 
6699 floating-point operations. Setting it with a volatile @code{asm}, as in the 
6700 following PowerPC example, will not work reliably.
6702 @example
6703 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6704 sum = x + y;
6705 @end example
6707 The compiler may move the addition back before the volatile @code{asm}. To 
6708 make it work as expected, add an artificial dependency to the @code{asm} by 
6709 referencing a variable in the subsequent code, for example: 
6711 @example
6712 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6713 sum = x + y;
6714 @end example
6716 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6717 assembly code when optimizing. This can lead to unexpected duplicate symbol 
6718 errors during compilation if your asm code defines symbols or labels. Using %= 
6719 (@pxref{AssemblerTemplate}) may help resolve this problem.
6721 @anchor{AssemblerTemplate}
6722 @subsubsection Assembler Template
6723 @cindex @code{asm} assembler template
6725 An assembler template is a literal string containing assembler instructions. 
6726 The compiler will replace any references to inputs, outputs, and goto labels 
6727 in the template, and then output the resulting string to the assembler. The 
6728 string can contain any instructions recognized by the assembler, including 
6729 directives. GCC does not parse the assembler instructions 
6730 themselves and does not know what they mean or even whether they are valid 
6731 assembler input. However, it does count the statements 
6732 (@pxref{Size of an asm}).
6734 You may place multiple assembler instructions together in a single @code{asm} 
6735 string, separated by the characters normally used in assembly code for the 
6736 system. A combination that works in most places is a newline to break the 
6737 line, plus a tab character to move to the instruction field (written as 
6738 "\n\t"). Some assemblers allow semicolons as a line separator. However, note 
6739 that some assembler dialects use semicolons to start a comment. 
6741 Do not expect a sequence of @code{asm} statements to remain perfectly 
6742 consecutive after compilation, even when you are using the @code{volatile} 
6743 qualifier. If certain instructions need to remain consecutive in the output, 
6744 put them in a single multi-instruction asm statement.
6746 Accessing data from C programs without using input/output operands (such as 
6747 by using global symbols directly from the assembler template) may not work as 
6748 expected. Similarly, calling functions directly from an assembler template 
6749 requires a detailed understanding of the target assembler and ABI.
6751 Since GCC does not parse the AssemblerTemplate, it has no visibility of any 
6752 symbols it references. This may result in GCC discarding those symbols as 
6753 unreferenced unless they are also listed as input, output, or goto operands.
6755 GCC can support multiple assembler dialects (for example, GCC for i386 
6756 supports "att" and "intel" dialects) for inline assembler. In builds that 
6757 support this capability, the @option{-masm} option controls which dialect 
6758 GCC uses as its default. The hardware-specific documentation for the 
6759 @option{-masm} option contains the list of supported dialects, as well as the 
6760 default dialect if the option is not specified. This information may be 
6761 important to understand, since assembler code that works correctly when 
6762 compiled using one dialect will likely fail if compiled using another.
6764 @subsubheading Using braces in @code{asm} templates
6766 If your code needs to support multiple assembler dialects (for example, if 
6767 you are writing public headers that need to support a variety of compilation 
6768 options), use constructs of this form:
6770 @example
6771 @{ dialect0 | dialect1 | dialect2... @}
6772 @end example
6774 This construct outputs 'dialect0' when using dialect #0 to compile the code, 
6775 'dialect1' for dialect #1, etc. If there are fewer alternatives within the 
6776 braces than the number of dialects the compiler supports, the construct 
6777 outputs nothing.
6779 For example, if an i386 compiler supports two dialects (att, intel), an 
6780 assembler template such as this:
6782 @example
6783 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6784 @end example
6786 would produce the output:
6788 @example
6789 For att: "btl %[Offset],%[Base] ; jc %l2"
6790 For intel: "bt %[Base],%[Offset]; jc %l2"
6791 @end example
6793 Using that same compiler, this code:
6795 @example
6796 "xchg@{l@}\t@{%%@}ebx, %1"
6797 @end example
6799 would produce 
6801 @example
6802 For att: "xchgl\t%%ebx, %1"
6803 For intel: "xchg\tebx, %1"
6804 @end example
6806 There is no support for nesting dialect alternatives. Also, there is no 
6807 ``escape'' for an open brace (@{), so do not use open braces in an Extended 
6808 @code{asm} template other than as a dialect indicator.
6810 @subsubheading Other format strings
6812 In addition to the tokens described by the input, output, and goto operands, 
6813 there are a few special cases:
6815 @itemize
6816 @item
6817 "%%" outputs a single "%" into the assembler code.
6819 @item
6820 "%=" outputs a number that is unique to each instance of the @code{asm} 
6821 statement in the entire compilation. This option is useful when creating local 
6822 labels and referring to them multiple times in a single template that 
6823 generates multiple assembler instructions. 
6825 @end itemize
6827 @anchor{OutputOperands}
6828 @subsubsection Output Operands
6829 @cindex @code{asm} output operands
6831 An @code{asm} statement has zero or more output operands indicating the names
6832 of C variables modified by the assembler code.
6834 In this i386 example, @var{old} (referred to in the template string as 
6835 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset} 
6836 (@code{%2}) is an input:
6838 @example
6839 bool old;
6841 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6842          "sbb %0,%0"      // Use the CF to calculate old.
6843    : "=r" (old), "+rm" (*Base)
6844    : "Ir" (Offset)
6845    : "cc");
6847 return old;
6848 @end example
6850 Operands use this format:
6852 @example
6853 [ [asmSymbolicName] ] "constraint" (cvariablename)
6854 @end example
6856 @emph{asmSymbolicName}
6859 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6860 in the list of operands in the assembler template. For example if there are 
6861 three output operands, use @code{%0} in the template to refer to the first, 
6862 @code{%1} for the second, and @code{%2} for the third. When using an 
6863 asmSymbolicName, reference it by enclosing the name in square brackets 
6864 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement 
6865 that contains the definition. Any valid C variable name is acceptable, 
6866 including names already defined in the surrounding code. No two operands 
6867 within the same @code{asm} statement can use the same symbolic name.
6869 @emph{constraint}
6871 Output constraints must begin with either @code{"="} (a variable overwriting an 
6872 existing value) or @code{"+"} (when reading and writing). When using 
6873 @code{"="}, do not assume the location will contain the existing value (except 
6874 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6876 After the prefix, there must be one or more additional constraints 
6877 (@pxref{Constraints}) that describe where the value resides. Common 
6878 constraints include @code{"r"} for register and @code{"m"} for memory. 
6879 When you list more than one possible location (for example @code{"=rm"}), the 
6880 compiler chooses the most efficient one based on the current context. If you 
6881 list as many alternates as the @code{asm} statement allows, you will permit 
6882 the optimizers to produce the best possible code. If you must use a specific
6883 register, but your Machine Constraints do not provide sufficient 
6884 control to select the specific register you want, Local Reg Vars may provide 
6885 a solution (@pxref{Local Reg Vars}).
6887 @emph{cvariablename}
6889 Specifies the C variable name of the output (enclosed by parentheses). Accepts 
6890 any (non-constant) variable within scope.
6892 Remarks:
6894 The total number of input + output + goto operands has a limit of 30. Commas 
6895 separate the operands. When the compiler selects the registers to use to 
6896 represent the output operands, it will not use any of the clobbered registers 
6897 (@pxref{Clobbers}).
6899 Output operand expressions must be lvalues. The compiler cannot check whether 
6900 the operands have data types that are reasonable for the instruction being 
6901 executed. For output expressions that are not directly addressable (for 
6902 example a bit-field), the constraint must allow a register. In that case, GCC 
6903 uses the register as the output of the @code{asm}, and then stores that 
6904 register into the output. 
6906 Unless an output operand has the '@code{&}' constraint modifier 
6907 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated 
6908 input operand, on the assumption that the assembler code will consume its 
6909 inputs before producing outputs. This assumption may be false if the assembler 
6910 code actually consists of more than one instruction. In this case, use 
6911 '@code{&}' on each output operand that must not overlap an input.
6913 The same problem can occur if one output parameter (@var{a}) allows a register 
6914 constraint and another output parameter (@var{b}) allows a memory constraint.
6915 The code generated by GCC to access the memory address in @var{b} can contain
6916 registers which @emph{might} be shared by @var{a}, and GCC considers those 
6917 registers to be inputs to the asm. As above, GCC assumes that such input
6918 registers are consumed before any outputs are written. This assumption may 
6919 result in incorrect behavior if the asm writes to @var{a} before using 
6920 @var{b}. Combining the `@code{&}' constraint with the register constraint 
6921 ensures that modifying @var{a} will not affect what address is referenced by 
6922 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b} 
6923 will be undefined if @var{a} is modified before using @var{b}.
6925 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6926 instead of simply @code{%2}). Typically these qualifiers are hardware 
6927 dependent. The list of supported modifiers for i386 is found at 
6928 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6930 If the C code that follows the @code{asm} makes no use of any of the output 
6931 operands, use @code{volatile} for the @code{asm} statement to prevent the 
6932 optimizers from discarding the @code{asm} statement as unneeded 
6933 (see @ref{Volatile}).
6935 Examples:
6937 This code makes no use of the optional asmSymbolicName. Therefore it 
6938 references the first output operand as @code{%0} (were there a second, it 
6939 would be @code{%1}, etc). The number of the first input operand is one greater 
6940 than that of the last output operand. In this i386 example, that makes 
6941 @var{Mask} @code{%1}:
6943 @example
6944 uint32_t Mask = 1234;
6945 uint32_t Index;
6947   asm ("bsfl %1, %0"
6948      : "=r" (Index)
6949      : "r" (Mask)
6950      : "cc");
6951 @end example
6953 That code overwrites the variable Index ("="), placing the value in a register 
6954 ("r"). The generic "r" constraint instead of a constraint for a specific 
6955 register allows the compiler to pick the register to use, which can result 
6956 in more efficient code. This may not be possible if an assembler instruction 
6957 requires a specific register.
6959 The following i386 example uses the asmSymbolicName operand. It produces the 
6960 same result as the code above, but some may consider it more readable or more 
6961 maintainable since reordering index numbers is not necessary when adding or 
6962 removing operands. The names aIndex and aMask are only used to emphasize which 
6963 names get used where. It is acceptable to reuse the names Index and Mask.
6965 @example
6966 uint32_t Mask = 1234;
6967 uint32_t Index;
6969   asm ("bsfl %[aMask], %[aIndex]"
6970      : [aIndex] "=r" (Index)
6971      : [aMask] "r" (Mask)
6972      : "cc");
6973 @end example
6975 Here are some more examples of output operands.
6977 @example
6978 uint32_t c = 1;
6979 uint32_t d;
6980 uint32_t *e = &c;
6982 asm ("mov %[e], %[d]"
6983    : [d] "=rm" (d)
6984    : [e] "rm" (*e));
6985 @end example
6987 Here, @var{d} may either be in a register or in memory. Since the compiler 
6988 might already have the current value of the uint32_t pointed to by @var{e} 
6989 in a register, you can enable it to choose the best location
6990 for @var{d} by specifying both constraints.
6992 @anchor{InputOperands}
6993 @subsubsection Input Operands
6994 @cindex @code{asm} input operands
6995 @cindex @code{asm} expressions
6997 Input operands make inputs from C variables and expressions available to the 
6998 assembly code.
7000 Specify input operands by using the format:
7002 @example
7003 [ [asmSymbolicName] ] "constraint" (cexpression)
7004 @end example
7006 @emph{asmSymbolicName}
7008 When not using asmSymbolicNames, use the (zero-based) position of the operand 
7009 in the list of operands, including outputs, in the assembler template. For 
7010 example, if there are two output parameters and three inputs, @code{%2} refers 
7011 to the first input, @code{%3} to the second, and @code{%4} to the third.
7012 When using an asmSymbolicName, reference it by enclosing the name in square 
7013 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm} 
7014 statement that contains the definition. Any valid C variable name is 
7015 acceptable, including names already defined in the surrounding code. No two 
7016 operands within the same @code{asm} statement can use the same symbolic name.
7018 @emph{constraint}
7020 Input constraints must be a string containing one or more constraints 
7021 (@pxref{Constraints}). When you give more than one possible constraint 
7022 (for example, @code{"irm"}), the compiler will choose the most efficient 
7023 method based on the current context. Input constraints may not begin with 
7024 either "=" or "+". If you must use a specific register, but your Machine
7025 Constraints do not provide sufficient control to select the specific 
7026 register you want, Local Reg Vars may provide a solution 
7027 (@pxref{Local Reg Vars}).
7029 Input constraints can also be digits (for example, @code{"0"}). This indicates 
7030 that the specified input will be in the same place as the output constraint 
7031 at the (zero-based) index in the output constraint list. When using 
7032 asmSymbolicNames for the output operands, you may use these names (enclosed 
7033 in brackets []) instead of digits.
7035 @emph{cexpression}
7037 This is the C variable or expression being passed to the @code{asm} statement 
7038 as input.
7040 When the compiler selects the registers to use to represent the input 
7041 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
7043 If there are no output operands but there are input operands, place two 
7044 consecutive colons where the output operands would go:
7046 @example
7047 __asm__ ("some instructions"
7048    : /* No outputs. */
7049    : "r" (Offset / 8);
7050 @end example
7052 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7053 (except for inputs tied to outputs). The compiler assumes that on exit from 
7054 the @code{asm} statement these operands will contain the same values as they 
7055 had before executing the assembler. It is @emph{not} possible to use Clobbers 
7056 to inform the compiler that the values in these inputs are changing. One 
7057 common work-around is to tie the changing input variable to an output variable 
7058 that never gets used. Note, however, that if the code that follows the 
7059 @code{asm} statement makes no use of any of the output operands, the GCC 
7060 optimizers may discard the @code{asm} statement as unneeded 
7061 (see @ref{Volatile}).
7063 Remarks:
7065 The total number of input + output + goto operands has a limit of 30.
7067 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
7068 instead of simply @code{%2}). Typically these qualifiers are hardware 
7069 dependent. The list of supported modifiers for i386 is found at 
7070 @ref{i386Operandmodifiers,i386 Operand modifiers}.
7072 Examples:
7074 In this example using the fictitious @code{combine} instruction, the 
7075 constraint @code{"0"} for input operand 1 says that it must occupy the same 
7076 location as output operand 0. Only input operands may use numbers in 
7077 constraints, and they must each refer to an output operand. Only a number (or 
7078 the symbolic assembler name) in the constraint can guarantee that one operand 
7079 is in the same place as another. The mere fact that @var{foo} is the value of 
7080 both operands is not enough to guarantee that they are in the same place in 
7081 the generated assembler code.
7083 @example
7084 asm ("combine %2, %0" 
7085    : "=r" (foo) 
7086    : "0" (foo), "g" (bar));
7087 @end example
7089 Here is an example using symbolic names.
7091 @example
7092 asm ("cmoveq %1, %2, %[result]" 
7093    : [result] "=r"(result) 
7094    : "r" (test), "r" (new), "[result]" (old));
7095 @end example
7097 @anchor{Clobbers}
7098 @subsubsection Clobbers
7099 @cindex @code{asm} clobbers
7101 While the compiler is aware of changes to entries listed in the output 
7102 operands, the assembler code may modify more than just the outputs. For 
7103 example, calculations may require additional registers, or the processor may 
7104 overwrite a register as a side effect of a particular assembler instruction. 
7105 In order to inform the compiler of these changes, list them in the clobber 
7106 list. Clobber list items are either register names or the special clobbers 
7107 (listed below). Each clobber list item is enclosed in double quotes and 
7108 separated by commas.
7110 Clobber descriptions may not in any way overlap with an input or output 
7111 operand. For example, you may not have an operand describing a register class 
7112 with one member when listing that register in the clobber list. Variables 
7113 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used 
7114 as @code{asm} input or output operands, must have no part mentioned in the 
7115 clobber description. In particular, there is no way to specify that input 
7116 operands get modified without also specifying them as output operands.
7118 When the compiler selects which registers to use to represent input and output 
7119 operands, it will not use any of the clobbered registers. As a result, 
7120 clobbered registers are available for any use in the assembler code.
7122 Here is a realistic example for the VAX showing the use of clobbered 
7123 registers: 
7125 @example
7126 asm volatile ("movc3 %0, %1, %2"
7127                    : /* No outputs. */
7128                    : "g" (from), "g" (to), "g" (count)
7129                    : "r0", "r1", "r2", "r3", "r4", "r5");
7130 @end example
7132 Also, there are two special clobber arguments:
7134 @enumerate
7135 @item
7136 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7137 register. On some machines, GCC represents the condition codes as a specific 
7138 hardware register; "cc" serves to name this register. On other machines, 
7139 condition code handling is different, and specifying "cc" has no effect. But 
7140 it is valid no matter what the machine.
7142 @item
7143 The "memory" clobber tells the compiler that the assembly code performs memory 
7144 reads or writes to items other than those listed in the input and output 
7145 operands (for example accessing the memory pointed to by one of the input 
7146 parameters). To ensure memory contains correct values, GCC may need to flush 
7147 specific register values to memory before executing the @code{asm}. Further, 
7148 the compiler will not assume that any values read from memory before an 
7149 @code{asm} will remain unchanged after that @code{asm}; it will reload them as 
7150 needed. This effectively forms a read/write memory barrier for the compiler.
7152 Note that this clobber does not prevent the @emph{processor} from doing 
7153 speculative reads past the @code{asm} statement. To prevent that, you need 
7154 processor-specific fence instructions.
7156 Flushing registers to memory has performance implications and may be an issue 
7157 for time-sensitive code. One trick to avoid this is available if the size of 
7158 the memory being accessed is known at compile time. For example, if accessing 
7159 ten bytes of a string, use a memory input like: 
7161 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7163 @end enumerate
7165 @anchor{GotoLabels}
7166 @subsubsection Goto Labels
7167 @cindex @code{asm} goto labels
7169 @code{asm goto} allows assembly code to jump to one or more C labels. The 
7170 GotoLabels section in an @code{asm goto} statement contains a comma-separated 
7171 list of all C labels to which the assembler code may jump. GCC assumes that 
7172 @code{asm} execution falls through to the next statement (if this is not the 
7173 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7174 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7175 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7176 Attributes}). The total number of input + output + goto operands has 
7177 a limit of 30.
7179 An @code{asm goto} statement can not have outputs (which means that the 
7180 statement is implicitly volatile). This is due to an internal restriction of 
7181 the compiler: control transfer instructions cannot have outputs. If the 
7182 assembler code does modify anything, use the "memory" clobber to force the 
7183 optimizers to flush all register values to memory, and reload them if 
7184 necessary, after the @code{asm} statement.
7186 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed 
7187 by its (zero-based) position in GotoLabels plus the number of input 
7188 arguments.  For example, if the @code{asm} has three inputs and references two 
7189 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7191 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7192 GCC's optimizers do not know about these jumps; therefore they cannot take 
7193 account of them when deciding how to optimize.
7195 Example code for i386 might look like:
7197 @example
7198 asm goto (
7199     "btl %1, %0\n\t"
7200     "jc %l2"
7201     : /* No outputs. */
7202     : "r" (p1), "r" (p2) 
7203     : "cc" 
7204     : carry);
7206 return 0;
7208 carry:
7209 return 1;
7210 @end example
7212 The following example shows an @code{asm goto} that uses the memory clobber.
7214 @example
7215 int frob(int x)
7217   int y;
7218   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7219             : /* No outputs. */
7220             : "r"(x), "r"(&y)
7221             : "r5", "memory" 
7222             : error);
7223   return y;
7224 error:
7225   return -1;
7227 @end example
7229 @anchor{i386Operandmodifiers}
7230 @subsubsection i386 Operand modifiers
7232 Input, output, and goto operands for extended @code{asm} statements can use 
7233 modifiers to affect the code output to the assembler. For example, the 
7234 following code uses the "h" and "b" modifiers for i386:
7236 @example
7237 uint16_t  num;
7238 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7239 @end example
7241 These modifiers generate this assembler code:
7243 @example
7244 xchg %ah, %al
7245 @end example
7247 The rest of this discussion uses the following code for illustrative purposes.
7249 @example
7250 int main()
7252    int iInt = 1;
7254 top:
7256    asm volatile goto ("some assembler instructions here"
7257    : /* No outputs. */
7258    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7259    : /* No clobbers. */
7260    : top);
7262 @end example
7264 With no modifiers, this is what the output from the operands would be for the 
7265 att and intel dialects of assembler:
7267 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7268 @headitem Operand @tab masm=att @tab masm=intel
7269 @item @code{%0}
7270 @tab @code{%eax}
7271 @tab @code{eax}
7272 @item @code{%1}
7273 @tab @code{$2}
7274 @tab @code{2}
7275 @item @code{%2}
7276 @tab @code{$.L2}
7277 @tab @code{OFFSET FLAT:.L2}
7278 @end multitable
7280 The table below shows the list of supported modifiers and their effects.
7282 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7283 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7284 @item @code{z}
7285 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7286 @tab @code{%z0}
7287 @tab @code{l}
7288 @tab 
7289 @item @code{b}
7290 @tab Print the QImode name of the register.
7291 @tab @code{%b0}
7292 @tab @code{%al}
7293 @tab @code{al}
7294 @item @code{h}
7295 @tab Print the QImode name for a ``high'' register.
7296 @tab @code{%h0}
7297 @tab @code{%ah}
7298 @tab @code{ah}
7299 @item @code{w}
7300 @tab Print the HImode name of the register.
7301 @tab @code{%w0}
7302 @tab @code{%ax}
7303 @tab @code{ax}
7304 @item @code{k}
7305 @tab Print the SImode name of the register.
7306 @tab @code{%k0}
7307 @tab @code{%eax}
7308 @tab @code{eax}
7309 @item @code{q}
7310 @tab Print the DImode name of the register.
7311 @tab @code{%q0}
7312 @tab @code{%rax}
7313 @tab @code{rax}
7314 @item @code{l}
7315 @tab Print the label name with no punctuation.
7316 @tab @code{%l2}
7317 @tab @code{.L2}
7318 @tab @code{.L2}
7319 @item @code{c}
7320 @tab Require a constant operand and print the constant expression with no punctuation.
7321 @tab @code{%c1}
7322 @tab @code{2}
7323 @tab @code{2}
7324 @end multitable
7326 @anchor{i386floatingpointasmoperands}
7327 @subsubsection i386 floating-point asm operands
7329 On i386 targets, there are several rules on the usage of stack-like registers
7330 in the operands of an @code{asm}.  These rules apply only to the operands
7331 that are stack-like registers:
7333 @enumerate
7334 @item
7335 Given a set of input registers that die in an @code{asm}, it is
7336 necessary to know which are implicitly popped by the @code{asm}, and
7337 which must be explicitly popped by GCC@.
7339 An input register that is implicitly popped by the @code{asm} must be
7340 explicitly clobbered, unless it is constrained to match an
7341 output operand.
7343 @item
7344 For any input register that is implicitly popped by an @code{asm}, it is
7345 necessary to know how to adjust the stack to compensate for the pop.
7346 If any non-popped input is closer to the top of the reg-stack than
7347 the implicitly popped register, it would not be possible to know what the
7348 stack looked like---it's not clear how the rest of the stack ``slides
7349 up''.
7351 All implicitly popped input registers must be closer to the top of
7352 the reg-stack than any input that is not implicitly popped.
7354 It is possible that if an input dies in an @code{asm}, the compiler might
7355 use the input register for an output reload.  Consider this example:
7357 @smallexample
7358 asm ("foo" : "=t" (a) : "f" (b));
7359 @end smallexample
7361 @noindent
7362 This code says that input @code{b} is not popped by the @code{asm}, and that
7363 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7364 deeper after the @code{asm} than it was before.  But, it is possible that
7365 reload may think that it can use the same register for both the input and
7366 the output.
7368 To prevent this from happening,
7369 if any input operand uses the @code{f} constraint, all output register
7370 constraints must use the @code{&} early-clobber modifier.
7372 The example above would be correctly written as:
7374 @smallexample
7375 asm ("foo" : "=&t" (a) : "f" (b));
7376 @end smallexample
7378 @item
7379 Some operands need to be in particular places on the stack.  All
7380 output operands fall in this category---GCC has no other way to
7381 know which registers the outputs appear in unless you indicate
7382 this in the constraints.
7384 Output operands must specifically indicate which register an output
7385 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
7386 constraints must select a class with a single register.
7388 @item
7389 Output operands may not be ``inserted'' between existing stack registers.
7390 Since no 387 opcode uses a read/write operand, all output operands
7391 are dead before the @code{asm}, and are pushed by the @code{asm}.
7392 It makes no sense to push anywhere but the top of the reg-stack.
7394 Output operands must start at the top of the reg-stack: output
7395 operands may not ``skip'' a register.
7397 @item
7398 Some @code{asm} statements may need extra stack space for internal
7399 calculations.  This can be guaranteed by clobbering stack registers
7400 unrelated to the inputs and outputs.
7402 @end enumerate
7404 Here are a couple of reasonable @code{asm}s to want to write.  This
7405 @code{asm}
7406 takes one input, which is internally popped, and produces two outputs.
7408 @smallexample
7409 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7410 @end smallexample
7412 @noindent
7413 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7414 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7415 for the compiler to know that @code{fyl2xp1} pops both inputs.
7417 @smallexample
7418 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7419 @end smallexample
7421 @lowersections
7422 @include md.texi
7423 @raisesections
7425 @node Asm Labels
7426 @subsection Controlling Names Used in Assembler Code
7427 @cindex assembler names for identifiers
7428 @cindex names used in assembler code
7429 @cindex identifiers, names in assembler code
7431 You can specify the name to be used in the assembler code for a C
7432 function or variable by writing the @code{asm} (or @code{__asm__})
7433 keyword after the declarator as follows:
7435 @smallexample
7436 int foo asm ("myfoo") = 2;
7437 @end smallexample
7439 @noindent
7440 This specifies that the name to be used for the variable @code{foo} in
7441 the assembler code should be @samp{myfoo} rather than the usual
7442 @samp{_foo}.
7444 On systems where an underscore is normally prepended to the name of a C
7445 function or variable, this feature allows you to define names for the
7446 linker that do not start with an underscore.
7448 It does not make sense to use this feature with a non-static local
7449 variable since such variables do not have assembler names.  If you are
7450 trying to put the variable in a particular register, see @ref{Explicit
7451 Reg Vars}.  GCC presently accepts such code with a warning, but will
7452 probably be changed to issue an error, rather than a warning, in the
7453 future.
7455 You cannot use @code{asm} in this way in a function @emph{definition}; but
7456 you can get the same effect by writing a declaration for the function
7457 before its definition and putting @code{asm} there, like this:
7459 @smallexample
7460 extern func () asm ("FUNC");
7462 func (x, y)
7463      int x, y;
7464 /* @r{@dots{}} */
7465 @end smallexample
7467 It is up to you to make sure that the assembler names you choose do not
7468 conflict with any other assembler symbols.  Also, you must not use a
7469 register name; that would produce completely invalid assembler code.  GCC
7470 does not as yet have the ability to store static variables in registers.
7471 Perhaps that will be added.
7473 @node Explicit Reg Vars
7474 @subsection Variables in Specified Registers
7475 @cindex explicit register variables
7476 @cindex variables in specified registers
7477 @cindex specified registers
7478 @cindex registers, global allocation
7480 GNU C allows you to put a few global variables into specified hardware
7481 registers.  You can also specify the register in which an ordinary
7482 register variable should be allocated.
7484 @itemize @bullet
7485 @item
7486 Global register variables reserve registers throughout the program.
7487 This may be useful in programs such as programming language
7488 interpreters that have a couple of global variables that are accessed
7489 very often.
7491 @item
7492 Local register variables in specific registers do not reserve the
7493 registers, except at the point where they are used as input or output
7494 operands in an @code{asm} statement and the @code{asm} statement itself is
7495 not deleted.  The compiler's data flow analysis is capable of determining
7496 where the specified registers contain live values, and where they are
7497 available for other uses.  Stores into local register variables may be deleted
7498 when they appear to be dead according to dataflow analysis.  References
7499 to local register variables may be deleted or moved or simplified.
7501 These local variables are sometimes convenient for use with the extended
7502 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7503 output of the assembler instruction directly into a particular register.
7504 (This works provided the register you specify fits the constraints
7505 specified for that operand in the @code{asm}.)
7506 @end itemize
7508 @menu
7509 * Global Reg Vars::
7510 * Local Reg Vars::
7511 @end menu
7513 @node Global Reg Vars
7514 @subsubsection Defining Global Register Variables
7515 @cindex global register variables
7516 @cindex registers, global variables in
7518 You can define a global register variable in GNU C like this:
7520 @smallexample
7521 register int *foo asm ("a5");
7522 @end smallexample
7524 @noindent
7525 Here @code{a5} is the name of the register that should be used.  Choose a
7526 register that is normally saved and restored by function calls on your
7527 machine, so that library routines will not clobber it.
7529 Naturally the register name is cpu-dependent, so you need to
7530 conditionalize your program according to cpu type.  The register
7531 @code{a5} is a good choice on a 68000 for a variable of pointer
7532 type.  On machines with register windows, be sure to choose a ``global''
7533 register that is not affected magically by the function call mechanism.
7535 In addition, different operating systems on the same CPU may differ in how they
7536 name the registers; then you need additional conditionals.  For
7537 example, some 68000 operating systems call this register @code{%a5}.
7539 Eventually there may be a way of asking the compiler to choose a register
7540 automatically, but first we need to figure out how it should choose and
7541 how to enable you to guide the choice.  No solution is evident.
7543 Defining a global register variable in a certain register reserves that
7544 register entirely for this use, at least within the current compilation.
7545 The register is not allocated for any other purpose in the functions
7546 in the current compilation, and is not saved and restored by
7547 these functions.  Stores into this register are never deleted even if they
7548 appear to be dead, but references may be deleted or moved or
7549 simplified.
7551 It is not safe to access the global register variables from signal
7552 handlers, or from more than one thread of control, because the system
7553 library routines may temporarily use the register for other things (unless
7554 you recompile them specially for the task at hand).
7556 @cindex @code{qsort}, and global register variables
7557 It is not safe for one function that uses a global register variable to
7558 call another such function @code{foo} by way of a third function
7559 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7560 different source file in which the variable isn't declared).  This is
7561 because @code{lose} might save the register and put some other value there.
7562 For example, you can't expect a global register variable to be available in
7563 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7564 might have put something else in that register.  (If you are prepared to
7565 recompile @code{qsort} with the same global register variable, you can
7566 solve this problem.)
7568 If you want to recompile @code{qsort} or other source files that do not
7569 actually use your global register variable, so that they do not use that
7570 register for any other purpose, then it suffices to specify the compiler
7571 option @option{-ffixed-@var{reg}}.  You need not actually add a global
7572 register declaration to their source code.
7574 A function that can alter the value of a global register variable cannot
7575 safely be called from a function compiled without this variable, because it
7576 could clobber the value the caller expects to find there on return.
7577 Therefore, the function that is the entry point into the part of the
7578 program that uses the global register variable must explicitly save and
7579 restore the value that belongs to its caller.
7581 @cindex register variable after @code{longjmp}
7582 @cindex global register after @code{longjmp}
7583 @cindex value after @code{longjmp}
7584 @findex longjmp
7585 @findex setjmp
7586 On most machines, @code{longjmp} restores to each global register
7587 variable the value it had at the time of the @code{setjmp}.  On some
7588 machines, however, @code{longjmp} does not change the value of global
7589 register variables.  To be portable, the function that called @code{setjmp}
7590 should make other arrangements to save the values of the global register
7591 variables, and to restore them in a @code{longjmp}.  This way, the same
7592 thing happens regardless of what @code{longjmp} does.
7594 All global register variable declarations must precede all function
7595 definitions.  If such a declaration could appear after function
7596 definitions, the declaration would be too late to prevent the register from
7597 being used for other purposes in the preceding functions.
7599 Global register variables may not have initial values, because an
7600 executable file has no means to supply initial contents for a register.
7602 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7603 registers, but certain library functions, such as @code{getwd}, as well
7604 as the subroutines for division and remainder, modify g3 and g4.  g1 and
7605 g2 are local temporaries.
7607 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7608 Of course, it does not do to use more than a few of those.
7610 @node Local Reg Vars
7611 @subsubsection Specifying Registers for Local Variables
7612 @cindex local variables, specifying registers
7613 @cindex specifying registers for local variables
7614 @cindex registers for local variables
7616 You can define a local register variable with a specified register
7617 like this:
7619 @smallexample
7620 register int *foo asm ("a5");
7621 @end smallexample
7623 @noindent
7624 Here @code{a5} is the name of the register that should be used.  Note
7625 that this is the same syntax used for defining global register
7626 variables, but for a local variable it appears within a function.
7628 Naturally the register name is cpu-dependent, but this is not a
7629 problem, since specific registers are most often useful with explicit
7630 assembler instructions (@pxref{Extended Asm}).  Both of these things
7631 generally require that you conditionalize your program according to
7632 cpu type.
7634 In addition, operating systems on one type of cpu may differ in how they
7635 name the registers; then you need additional conditionals.  For
7636 example, some 68000 operating systems call this register @code{%a5}.
7638 Defining such a register variable does not reserve the register; it
7639 remains available for other uses in places where flow control determines
7640 the variable's value is not live.
7642 This option does not guarantee that GCC generates code that has
7643 this variable in the register you specify at all times.  You may not
7644 code an explicit reference to this register in the @emph{assembler
7645 instruction template} part of an @code{asm} statement and assume it
7646 always refers to this variable.  However, using the variable as an
7647 @code{asm} @emph{operand} guarantees that the specified register is used
7648 for the operand.
7650 Stores into local register variables may be deleted when they appear to be dead
7651 according to dataflow analysis.  References to local register variables may
7652 be deleted or moved or simplified.
7654 As with global register variables, it is recommended that you choose a
7655 register that is normally saved and restored by function calls on
7656 your machine, so that library routines will not clobber it.  
7658 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
7659 specific register, but there's no matching constraint letter for that 
7660 register. To force the operand into that register, create a local variable 
7661 and specify the register in the variable's declaration. Then use the local 
7662 variable for the asm operand and specify any constraint letter that matches 
7663 the register:
7665 @smallexample
7666 register int *p1 asm ("r0") = @dots{};
7667 register int *p2 asm ("r1") = @dots{};
7668 register int *result asm ("r0");
7669 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7670 @end smallexample
7672 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
7673 call-clobbered by subsequent code, including function calls and library calls 
7674 for arithmetic operators on other variables (for example the initialization 
7675 of p2). In this case, use temporary variables for expressions between the 
7676 register assignments:
7678 @smallexample
7679 int t1 = @dots{};
7680 register int *p1 asm ("r0") = @dots{};
7681 register int *p2 asm ("r1") = t1;
7682 register int *result asm ("r0");
7683 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7684 @end smallexample
7686 @node Size of an asm
7687 @subsection Size of an @code{asm}
7689 Some targets require that GCC track the size of each instruction used
7690 in order to generate correct code.  Because the final length of the
7691 code produced by an @code{asm} statement is only known by the
7692 assembler, GCC must make an estimate as to how big it will be.  It
7693 does this by counting the number of instructions in the pattern of the
7694 @code{asm} and multiplying that by the length of the longest
7695 instruction supported by that processor.  (When working out the number
7696 of instructions, it assumes that any occurrence of a newline or of
7697 whatever statement separator character is supported by the assembler --
7698 typically @samp{;} --- indicates the end of an instruction.)
7700 Normally, GCC's estimate is adequate to ensure that correct
7701 code is generated, but it is possible to confuse the compiler if you use
7702 pseudo instructions or assembler macros that expand into multiple real
7703 instructions, or if you use assembler directives that expand to more
7704 space in the object file than is needed for a single instruction.
7705 If this happens then the assembler may produce a diagnostic saying that
7706 a label is unreachable.
7708 @node Alternate Keywords
7709 @section Alternate Keywords
7710 @cindex alternate keywords
7711 @cindex keywords, alternate
7713 @option{-ansi} and the various @option{-std} options disable certain
7714 keywords.  This causes trouble when you want to use GNU C extensions, or
7715 a general-purpose header file that should be usable by all programs,
7716 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
7717 @code{inline} are not available in programs compiled with
7718 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7719 program compiled with @option{-std=c99} or @option{-std=c11}).  The
7720 ISO C99 keyword
7721 @code{restrict} is only available when @option{-std=gnu99} (which will
7722 eventually be the default) or @option{-std=c99} (or the equivalent
7723 @option{-std=iso9899:1999}), or an option for a later standard
7724 version, is used.
7726 The way to solve these problems is to put @samp{__} at the beginning and
7727 end of each problematical keyword.  For example, use @code{__asm__}
7728 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7730 Other C compilers won't accept these alternative keywords; if you want to
7731 compile with another compiler, you can define the alternate keywords as
7732 macros to replace them with the customary keywords.  It looks like this:
7734 @smallexample
7735 #ifndef __GNUC__
7736 #define __asm__ asm
7737 #endif
7738 @end smallexample
7740 @findex __extension__
7741 @opindex pedantic
7742 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7743 You can
7744 prevent such warnings within one expression by writing
7745 @code{__extension__} before the expression.  @code{__extension__} has no
7746 effect aside from this.
7748 @node Incomplete Enums
7749 @section Incomplete @code{enum} Types
7751 You can define an @code{enum} tag without specifying its possible values.
7752 This results in an incomplete type, much like what you get if you write
7753 @code{struct foo} without describing the elements.  A later declaration
7754 that does specify the possible values completes the type.
7756 You can't allocate variables or storage using the type while it is
7757 incomplete.  However, you can work with pointers to that type.
7759 This extension may not be very useful, but it makes the handling of
7760 @code{enum} more consistent with the way @code{struct} and @code{union}
7761 are handled.
7763 This extension is not supported by GNU C++.
7765 @node Function Names
7766 @section Function Names as Strings
7767 @cindex @code{__func__} identifier
7768 @cindex @code{__FUNCTION__} identifier
7769 @cindex @code{__PRETTY_FUNCTION__} identifier
7771 GCC provides three magic variables that hold the name of the current
7772 function, as a string.  The first of these is @code{__func__}, which
7773 is part of the C99 standard:
7775 The identifier @code{__func__} is implicitly declared by the translator
7776 as if, immediately following the opening brace of each function
7777 definition, the declaration
7779 @smallexample
7780 static const char __func__[] = "function-name";
7781 @end smallexample
7783 @noindent
7784 appeared, where function-name is the name of the lexically-enclosing
7785 function.  This name is the unadorned name of the function.
7787 @code{__FUNCTION__} is another name for @code{__func__}.  Older
7788 versions of GCC recognize only this name.  However, it is not
7789 standardized.  For maximum portability, we recommend you use
7790 @code{__func__}, but provide a fallback definition with the
7791 preprocessor:
7793 @smallexample
7794 #if __STDC_VERSION__ < 199901L
7795 # if __GNUC__ >= 2
7796 #  define __func__ __FUNCTION__
7797 # else
7798 #  define __func__ "<unknown>"
7799 # endif
7800 #endif
7801 @end smallexample
7803 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7804 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
7805 the type signature of the function as well as its bare name.  For
7806 example, this program:
7808 @smallexample
7809 extern "C" @{
7810 extern int printf (char *, ...);
7813 class a @{
7814  public:
7815   void sub (int i)
7816     @{
7817       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7818       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7819     @}
7823 main (void)
7825   a ax;
7826   ax.sub (0);
7827   return 0;
7829 @end smallexample
7831 @noindent
7832 gives this output:
7834 @smallexample
7835 __FUNCTION__ = sub
7836 __PRETTY_FUNCTION__ = void a::sub(int)
7837 @end smallexample
7839 These identifiers are not preprocessor macros.  In GCC 3.3 and
7840 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7841 were treated as string literals; they could be used to initialize
7842 @code{char} arrays, and they could be concatenated with other string
7843 literals.  GCC 3.4 and later treat them as variables, like
7844 @code{__func__}.  In C++, @code{__FUNCTION__} and
7845 @code{__PRETTY_FUNCTION__} have always been variables.
7847 @node Return Address
7848 @section Getting the Return or Frame Address of a Function
7850 These functions may be used to get information about the callers of a
7851 function.
7853 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7854 This function returns the return address of the current function, or of
7855 one of its callers.  The @var{level} argument is number of frames to
7856 scan up the call stack.  A value of @code{0} yields the return address
7857 of the current function, a value of @code{1} yields the return address
7858 of the caller of the current function, and so forth.  When inlining
7859 the expected behavior is that the function returns the address of
7860 the function that is returned to.  To work around this behavior use
7861 the @code{noinline} function attribute.
7863 The @var{level} argument must be a constant integer.
7865 On some machines it may be impossible to determine the return address of
7866 any function other than the current one; in such cases, or when the top
7867 of the stack has been reached, this function returns @code{0} or a
7868 random value.  In addition, @code{__builtin_frame_address} may be used
7869 to determine if the top of the stack has been reached.
7871 Additional post-processing of the returned value may be needed, see
7872 @code{__builtin_extract_return_addr}.
7874 This function should only be used with a nonzero argument for debugging
7875 purposes.
7876 @end deftypefn
7878 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7879 The address as returned by @code{__builtin_return_address} may have to be fed
7880 through this function to get the actual encoded address.  For example, on the
7881 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7882 platforms an offset has to be added for the true next instruction to be
7883 executed.
7885 If no fixup is needed, this function simply passes through @var{addr}.
7886 @end deftypefn
7888 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7889 This function does the reverse of @code{__builtin_extract_return_addr}.
7890 @end deftypefn
7892 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7893 This function is similar to @code{__builtin_return_address}, but it
7894 returns the address of the function frame rather than the return address
7895 of the function.  Calling @code{__builtin_frame_address} with a value of
7896 @code{0} yields the frame address of the current function, a value of
7897 @code{1} yields the frame address of the caller of the current function,
7898 and so forth.
7900 The frame is the area on the stack that holds local variables and saved
7901 registers.  The frame address is normally the address of the first word
7902 pushed on to the stack by the function.  However, the exact definition
7903 depends upon the processor and the calling convention.  If the processor
7904 has a dedicated frame pointer register, and the function has a frame,
7905 then @code{__builtin_frame_address} returns the value of the frame
7906 pointer register.
7908 On some machines it may be impossible to determine the frame address of
7909 any function other than the current one; in such cases, or when the top
7910 of the stack has been reached, this function returns @code{0} if
7911 the first frame pointer is properly initialized by the startup code.
7913 This function should only be used with a nonzero argument for debugging
7914 purposes.
7915 @end deftypefn
7917 @node Vector Extensions
7918 @section Using Vector Instructions through Built-in Functions
7920 On some targets, the instruction set contains SIMD vector instructions which
7921 operate on multiple values contained in one large register at the same time.
7922 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7923 this way.
7925 The first step in using these extensions is to provide the necessary data
7926 types.  This should be done using an appropriate @code{typedef}:
7928 @smallexample
7929 typedef int v4si __attribute__ ((vector_size (16)));
7930 @end smallexample
7932 @noindent
7933 The @code{int} type specifies the base type, while the attribute specifies
7934 the vector size for the variable, measured in bytes.  For example, the
7935 declaration above causes the compiler to set the mode for the @code{v4si}
7936 type to be 16 bytes wide and divided into @code{int} sized units.  For
7937 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7938 corresponding mode of @code{foo} is @acronym{V4SI}.
7940 The @code{vector_size} attribute is only applicable to integral and
7941 float scalars, although arrays, pointers, and function return values
7942 are allowed in conjunction with this construct. Only sizes that are
7943 a power of two are currently allowed.
7945 All the basic integer types can be used as base types, both as signed
7946 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7947 @code{long long}.  In addition, @code{float} and @code{double} can be
7948 used to build floating-point vector types.
7950 Specifying a combination that is not valid for the current architecture
7951 causes GCC to synthesize the instructions using a narrower mode.
7952 For example, if you specify a variable of type @code{V4SI} and your
7953 architecture does not allow for this specific SIMD type, GCC
7954 produces code that uses 4 @code{SIs}.
7956 The types defined in this manner can be used with a subset of normal C
7957 operations.  Currently, GCC allows using the following operators
7958 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7960 The operations behave like C++ @code{valarrays}.  Addition is defined as
7961 the addition of the corresponding elements of the operands.  For
7962 example, in the code below, each of the 4 elements in @var{a} is
7963 added to the corresponding 4 elements in @var{b} and the resulting
7964 vector is stored in @var{c}.
7966 @smallexample
7967 typedef int v4si __attribute__ ((vector_size (16)));
7969 v4si a, b, c;
7971 c = a + b;
7972 @end smallexample
7974 Subtraction, multiplication, division, and the logical operations
7975 operate in a similar manner.  Likewise, the result of using the unary
7976 minus or complement operators on a vector type is a vector whose
7977 elements are the negative or complemented values of the corresponding
7978 elements in the operand.
7980 It is possible to use shifting operators @code{<<}, @code{>>} on
7981 integer-type vectors. The operation is defined as following: @code{@{a0,
7982 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7983 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7984 elements. 
7986 For convenience, it is allowed to use a binary vector operation
7987 where one operand is a scalar. In that case the compiler transforms
7988 the scalar operand into a vector where each element is the scalar from
7989 the operation. The transformation happens only if the scalar could be
7990 safely converted to the vector-element type.
7991 Consider the following code.
7993 @smallexample
7994 typedef int v4si __attribute__ ((vector_size (16)));
7996 v4si a, b, c;
7997 long l;
7999 a = b + 1;    /* a = b + @{1,1,1,1@}; */
8000 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
8002 a = l + a;    /* Error, cannot convert long to int. */
8003 @end smallexample
8005 Vectors can be subscripted as if the vector were an array with
8006 the same number of elements and base type.  Out of bound accesses
8007 invoke undefined behavior at run time.  Warnings for out of bound
8008 accesses for vector subscription can be enabled with
8009 @option{-Warray-bounds}.
8011 Vector comparison is supported with standard comparison
8012 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
8013 vector expressions of integer-type or real-type. Comparison between
8014 integer-type vectors and real-type vectors are not supported.  The
8015 result of the comparison is a vector of the same width and number of
8016 elements as the comparison operands with a signed integral element
8017 type.
8019 Vectors are compared element-wise producing 0 when comparison is false
8020 and -1 (constant of the appropriate type where all bits are set)
8021 otherwise. Consider the following example.
8023 @smallexample
8024 typedef int v4si __attribute__ ((vector_size (16)));
8026 v4si a = @{1,2,3,4@};
8027 v4si b = @{3,2,1,4@};
8028 v4si c;
8030 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
8031 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
8032 @end smallexample
8034 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8035 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8036 integer vector with the same number of elements of the same size as @code{b}
8037 and @code{c}, computes all three arguments and creates a vector
8038 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
8039 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8040 As in the case of binary operations, this syntax is also accepted when
8041 one of @code{b} or @code{c} is a scalar that is then transformed into a
8042 vector. If both @code{b} and @code{c} are scalars and the type of
8043 @code{true?b:c} has the same size as the element type of @code{a}, then
8044 @code{b} and @code{c} are converted to a vector type whose elements have
8045 this type and with the same number of elements as @code{a}.
8047 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8048 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8049 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8050 For mixed operations between a scalar @code{s} and a vector @code{v},
8051 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8052 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8054 Vector shuffling is available using functions
8055 @code{__builtin_shuffle (vec, mask)} and
8056 @code{__builtin_shuffle (vec0, vec1, mask)}.
8057 Both functions construct a permutation of elements from one or two
8058 vectors and return a vector of the same type as the input vector(s).
8059 The @var{mask} is an integral vector with the same width (@var{W})
8060 and element count (@var{N}) as the output vector.
8062 The elements of the input vectors are numbered in memory ordering of
8063 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8064 elements of @var{mask} are considered modulo @var{N} in the single-operand
8065 case and modulo @math{2*@var{N}} in the two-operand case.
8067 Consider the following example,
8069 @smallexample
8070 typedef int v4si __attribute__ ((vector_size (16)));
8072 v4si a = @{1,2,3,4@};
8073 v4si b = @{5,6,7,8@};
8074 v4si mask1 = @{0,1,1,3@};
8075 v4si mask2 = @{0,4,2,5@};
8076 v4si res;
8078 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
8079 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
8080 @end smallexample
8082 Note that @code{__builtin_shuffle} is intentionally semantically
8083 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8085 You can declare variables and use them in function calls and returns, as
8086 well as in assignments and some casts.  You can specify a vector type as
8087 a return type for a function.  Vector types can also be used as function
8088 arguments.  It is possible to cast from one vector type to another,
8089 provided they are of the same size (in fact, you can also cast vectors
8090 to and from other datatypes of the same size).
8092 You cannot operate between vectors of different lengths or different
8093 signedness without a cast.
8095 @node Offsetof
8096 @section Offsetof
8097 @findex __builtin_offsetof
8099 GCC implements for both C and C++ a syntactic extension to implement
8100 the @code{offsetof} macro.
8102 @smallexample
8103 primary:
8104         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8106 offsetof_member_designator:
8107           @code{identifier}
8108         | offsetof_member_designator "." @code{identifier}
8109         | offsetof_member_designator "[" @code{expr} "]"
8110 @end smallexample
8112 This extension is sufficient such that
8114 @smallexample
8115 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8116 @end smallexample
8118 @noindent
8119 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8120 may be dependent.  In either case, @var{member} may consist of a single
8121 identifier, or a sequence of member accesses and array references.
8123 @node __sync Builtins
8124 @section Legacy __sync Built-in Functions for Atomic Memory Access
8126 The following built-in functions
8127 are intended to be compatible with those described
8128 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8129 section 7.4.  As such, they depart from the normal GCC practice of using
8130 the @samp{__builtin_} prefix, and further that they are overloaded such that
8131 they work on multiple types.
8133 The definition given in the Intel documentation allows only for the use of
8134 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
8135 counterparts.  GCC allows any integral scalar or pointer type that is
8136 1, 2, 4 or 8 bytes in length.
8138 Not all operations are supported by all target processors.  If a particular
8139 operation cannot be implemented on the target processor, a warning is
8140 generated and a call an external function is generated.  The external
8141 function carries the same name as the built-in version,
8142 with an additional suffix
8143 @samp{_@var{n}} where @var{n} is the size of the data type.
8145 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8146 @c useful for implementing the operation under the control of an external
8147 @c mutex.
8149 In most cases, these built-in functions are considered a @dfn{full barrier}.
8150 That is,
8151 no memory operand is moved across the operation, either forward or
8152 backward.  Further, instructions are issued as necessary to prevent the
8153 processor from speculating loads across the operation and from queuing stores
8154 after the operation.
8156 All of the routines are described in the Intel documentation to take
8157 ``an optional list of variables protected by the memory barrier''.  It's
8158 not clear what is meant by that; it could mean that @emph{only} the
8159 following variables are protected, or it could mean that these variables
8160 should in addition be protected.  At present GCC ignores this list and
8161 protects all variables that are globally accessible.  If in the future
8162 we make some use of this list, an empty list will continue to mean all
8163 globally accessible variables.
8165 @table @code
8166 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8167 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8168 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8169 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8170 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8171 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8172 @findex __sync_fetch_and_add
8173 @findex __sync_fetch_and_sub
8174 @findex __sync_fetch_and_or
8175 @findex __sync_fetch_and_and
8176 @findex __sync_fetch_and_xor
8177 @findex __sync_fetch_and_nand
8178 These built-in functions perform the operation suggested by the name, and
8179 returns the value that had previously been in memory.  That is,
8181 @smallexample
8182 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8183 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8184 @end smallexample
8186 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8187 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8189 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8190 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8191 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8192 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8193 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8194 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8195 @findex __sync_add_and_fetch
8196 @findex __sync_sub_and_fetch
8197 @findex __sync_or_and_fetch
8198 @findex __sync_and_and_fetch
8199 @findex __sync_xor_and_fetch
8200 @findex __sync_nand_and_fetch
8201 These built-in functions perform the operation suggested by the name, and
8202 return the new value.  That is,
8204 @smallexample
8205 @{ *ptr @var{op}= value; return *ptr; @}
8206 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8207 @end smallexample
8209 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8210 as @code{*ptr = ~(*ptr & value)} instead of
8211 @code{*ptr = ~*ptr & value}.
8213 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8214 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8215 @findex __sync_bool_compare_and_swap
8216 @findex __sync_val_compare_and_swap
8217 These built-in functions perform an atomic compare and swap.
8218 That is, if the current
8219 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8220 @code{*@var{ptr}}.
8222 The ``bool'' version returns true if the comparison is successful and
8223 @var{newval} is written.  The ``val'' version returns the contents
8224 of @code{*@var{ptr}} before the operation.
8226 @item __sync_synchronize (...)
8227 @findex __sync_synchronize
8228 This built-in function issues a full memory barrier.
8230 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8231 @findex __sync_lock_test_and_set
8232 This built-in function, as described by Intel, is not a traditional test-and-set
8233 operation, but rather an atomic exchange operation.  It writes @var{value}
8234 into @code{*@var{ptr}}, and returns the previous contents of
8235 @code{*@var{ptr}}.
8237 Many targets have only minimal support for such locks, and do not support
8238 a full exchange operation.  In this case, a target may support reduced
8239 functionality here by which the @emph{only} valid value to store is the
8240 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8241 is implementation defined.
8243 This built-in function is not a full barrier,
8244 but rather an @dfn{acquire barrier}.
8245 This means that references after the operation cannot move to (or be
8246 speculated to) before the operation, but previous memory stores may not
8247 be globally visible yet, and previous memory loads may not yet be
8248 satisfied.
8250 @item void __sync_lock_release (@var{type} *ptr, ...)
8251 @findex __sync_lock_release
8252 This built-in function releases the lock acquired by
8253 @code{__sync_lock_test_and_set}.
8254 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8256 This built-in function is not a full barrier,
8257 but rather a @dfn{release barrier}.
8258 This means that all previous memory stores are globally visible, and all
8259 previous memory loads have been satisfied, but following memory reads
8260 are not prevented from being speculated to before the barrier.
8261 @end table
8263 @node __atomic Builtins
8264 @section Built-in functions for memory model aware atomic operations
8266 The following built-in functions approximately match the requirements for
8267 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8268 functions, but all also have a memory model parameter.  These are all
8269 identified by being prefixed with @samp{__atomic}, and most are overloaded
8270 such that they work with multiple types.
8272 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8273 bytes in length. 16-byte integral types are also allowed if
8274 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8276 Target architectures are encouraged to provide their own patterns for
8277 each of these built-in functions.  If no target is provided, the original 
8278 non-memory model set of @samp{__sync} atomic built-in functions are
8279 utilized, along with any required synchronization fences surrounding it in
8280 order to achieve the proper behavior.  Execution in this case is subject
8281 to the same restrictions as those built-in functions.
8283 If there is no pattern or mechanism to provide a lock free instruction
8284 sequence, a call is made to an external routine with the same parameters
8285 to be resolved at run time.
8287 The four non-arithmetic functions (load, store, exchange, and 
8288 compare_exchange) all have a generic version as well.  This generic
8289 version works on any data type.  If the data type size maps to one
8290 of the integral sizes that may have lock free support, the generic
8291 version utilizes the lock free built-in function.  Otherwise an
8292 external call is left to be resolved at run time.  This external call is
8293 the same format with the addition of a @samp{size_t} parameter inserted
8294 as the first parameter indicating the size of the object being pointed to.
8295 All objects must be the same size.
8297 There are 6 different memory models that can be specified.  These map
8298 to the same names in the C++11 standard.  Refer there or to the
8299 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8300 atomic synchronization} for more detailed definitions.  These memory
8301 models integrate both barriers to code motion as well as synchronization
8302 requirements with other threads. These are listed in approximately
8303 ascending order of strength. It is also possible to use target specific
8304 flags for memory model flags, like Hardware Lock Elision.
8306 @table  @code
8307 @item __ATOMIC_RELAXED
8308 No barriers or synchronization.
8309 @item __ATOMIC_CONSUME
8310 Data dependency only for both barrier and synchronization with another
8311 thread.
8312 @item __ATOMIC_ACQUIRE
8313 Barrier to hoisting of code and synchronizes with release (or stronger)
8314 semantic stores from another thread.
8315 @item __ATOMIC_RELEASE
8316 Barrier to sinking of code and synchronizes with acquire (or stronger)
8317 semantic loads from another thread.
8318 @item __ATOMIC_ACQ_REL
8319 Full barrier in both directions and synchronizes with acquire loads and
8320 release stores in another thread.
8321 @item __ATOMIC_SEQ_CST
8322 Full barrier in both directions and synchronizes with acquire loads and
8323 release stores in all threads.
8324 @end table
8326 When implementing patterns for these built-in functions, the memory model
8327 parameter can be ignored as long as the pattern implements the most
8328 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8329 execute correctly with this memory model but they may not execute as
8330 efficiently as they could with a more appropriate implementation of the
8331 relaxed requirements.
8333 Note that the C++11 standard allows for the memory model parameter to be
8334 determined at run time rather than at compile time.  These built-in
8335 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8336 than invoke a runtime library call or inline a switch statement.  This is
8337 standard compliant, safe, and the simplest approach for now.
8339 The memory model parameter is a signed int, but only the lower 8 bits are
8340 reserved for the memory model.  The remainder of the signed int is reserved
8341 for future use and should be 0.  Use of the predefined atomic values
8342 ensures proper usage.
8344 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8345 This built-in function implements an atomic load operation.  It returns the
8346 contents of @code{*@var{ptr}}.
8348 The valid memory model variants are
8349 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8350 and @code{__ATOMIC_CONSUME}.
8352 @end deftypefn
8354 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8355 This is the generic version of an atomic load.  It returns the
8356 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8358 @end deftypefn
8360 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8361 This built-in function implements an atomic store operation.  It writes 
8362 @code{@var{val}} into @code{*@var{ptr}}.  
8364 The valid memory model variants are
8365 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8367 @end deftypefn
8369 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8370 This is the generic version of an atomic store.  It stores the value
8371 of @code{*@var{val}} into @code{*@var{ptr}}.
8373 @end deftypefn
8375 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8376 This built-in function implements an atomic exchange operation.  It writes
8377 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8378 @code{*@var{ptr}}.
8380 The valid memory model variants are
8381 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8382 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8384 @end deftypefn
8386 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8387 This is the generic version of an atomic exchange.  It stores the
8388 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8389 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8391 @end deftypefn
8393 @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)
8394 This built-in function implements an atomic compare and exchange operation.
8395 This compares the contents of @code{*@var{ptr}} with the contents of
8396 @code{*@var{expected}} and if equal, writes @var{desired} into
8397 @code{*@var{ptr}}.  If they are not equal, the current contents of
8398 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8399 for weak compare_exchange, and false for the strong variation.  Many targets 
8400 only offer the strong variation and ignore the parameter.  When in doubt, use
8401 the strong variation.
8403 True is returned if @var{desired} is written into
8404 @code{*@var{ptr}} and the execution is considered to conform to the
8405 memory model specified by @var{success_memmodel}.  There are no
8406 restrictions on what memory model can be used here.
8408 False is returned otherwise, and the execution is considered to conform
8409 to @var{failure_memmodel}. This memory model cannot be
8410 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8411 stronger model than that specified by @var{success_memmodel}.
8413 @end deftypefn
8415 @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)
8416 This built-in function implements the generic version of
8417 @code{__atomic_compare_exchange}.  The function is virtually identical to
8418 @code{__atomic_compare_exchange_n}, except the desired value is also a
8419 pointer.
8421 @end deftypefn
8423 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8424 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8425 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8426 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8427 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8428 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8429 These built-in functions perform the operation suggested by the name, and
8430 return the result of the operation. That is,
8432 @smallexample
8433 @{ *ptr @var{op}= val; return *ptr; @}
8434 @end smallexample
8436 All memory models are valid.
8438 @end deftypefn
8440 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8441 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8442 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8443 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8444 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8445 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8446 These built-in functions perform the operation suggested by the name, and
8447 return the value that had previously been in @code{*@var{ptr}}.  That is,
8449 @smallexample
8450 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8451 @end smallexample
8453 All memory models are valid.
8455 @end deftypefn
8457 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8459 This built-in function performs an atomic test-and-set operation on
8460 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
8461 defined nonzero ``set'' value and the return value is @code{true} if and only
8462 if the previous contents were ``set''.
8463 It should be only used for operands of type @code{bool} or @code{char}. For 
8464 other types only part of the value may be set.
8466 All memory models are valid.
8468 @end deftypefn
8470 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8472 This built-in function performs an atomic clear operation on
8473 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
8474 It should be only used for operands of type @code{bool} or @code{char} and 
8475 in conjunction with @code{__atomic_test_and_set}.
8476 For other types it may only clear partially. If the type is not @code{bool}
8477 prefer using @code{__atomic_store}.
8479 The valid memory model variants are
8480 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8481 @code{__ATOMIC_RELEASE}.
8483 @end deftypefn
8485 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8487 This built-in function acts as a synchronization fence between threads
8488 based on the specified memory model.
8490 All memory orders are valid.
8492 @end deftypefn
8494 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8496 This built-in function acts as a synchronization fence between a thread
8497 and signal handlers based in the same thread.
8499 All memory orders are valid.
8501 @end deftypefn
8503 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
8505 This built-in function returns true if objects of @var{size} bytes always
8506 generate lock free atomic instructions for the target architecture.  
8507 @var{size} must resolve to a compile-time constant and the result also
8508 resolves to a compile-time constant.
8510 @var{ptr} is an optional pointer to the object that may be used to determine
8511 alignment.  A value of 0 indicates typical alignment should be used.  The 
8512 compiler may also ignore this parameter.
8514 @smallexample
8515 if (_atomic_always_lock_free (sizeof (long long), 0))
8516 @end smallexample
8518 @end deftypefn
8520 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8522 This built-in function returns true if objects of @var{size} bytes always
8523 generate lock free atomic instructions for the target architecture.  If
8524 it is not known to be lock free a call is made to a runtime routine named
8525 @code{__atomic_is_lock_free}.
8527 @var{ptr} is an optional pointer to the object that may be used to determine
8528 alignment.  A value of 0 indicates typical alignment should be used.  The 
8529 compiler may also ignore this parameter.
8530 @end deftypefn
8532 @node Integer Overflow Builtins
8533 @section Built-in functions to perform arithmetics and arithmetic overflow checking.
8535 The following built-in functions allow performing simple arithmetic operations
8536 together with checking whether the operations overflowed.
8538 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8539 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
8540 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
8541 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
8542 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
8543 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8544 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8546 These built-in functions promote the first two operands into infinite precision signed
8547 type and perform addition on those promoted operands.  The result is then
8548 cast to the type the third pointer argument points to and stored there.
8549 If the stored result is equal to the infinite precision result, the built-in
8550 functions return false, otherwise they return true.  As the addition is
8551 performed in infinite signed precision, these built-in functions have fully defined
8552 behavior for all argument values.
8554 The first built-in function allows arbitrary integral types for operands and
8555 the result type must be pointer to some integer type, the rest of the built-in
8556 functions have explicit integer types.
8558 The compiler will attempt to use hardware instructions to implement
8559 these built-in functions where possible, like conditional jump on overflow
8560 after addition, conditional jump on carry etc.
8562 @end deftypefn
8564 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8565 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
8566 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
8567 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
8568 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
8569 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8570 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8572 These built-in functions are similar to the add overflow checking built-in
8573 functions above, except they perform subtraction, subtract the second argument
8574 from the first one, instead of addition.
8576 @end deftypefn
8578 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8579 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
8580 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
8581 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
8582 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
8583 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8584 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8586 These built-in functions are similar to the add overflow checking built-in
8587 functions above, except they perform multiplication, instead of addition.
8589 @end deftypefn
8591 @node x86 specific memory model extensions for transactional memory
8592 @section x86 specific memory model extensions for transactional memory
8594 The i386 architecture supports additional memory ordering flags
8595 to mark lock critical sections for hardware lock elision. 
8596 These must be specified in addition to an existing memory model to 
8597 atomic intrinsics.
8599 @table @code
8600 @item __ATOMIC_HLE_ACQUIRE
8601 Start lock elision on a lock variable.
8602 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8603 @item __ATOMIC_HLE_RELEASE
8604 End lock elision on a lock variable.
8605 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8606 @end table
8608 When a lock acquire fails it is required for good performance to abort
8609 the transaction quickly. This can be done with a @code{_mm_pause}
8611 @smallexample
8612 #include <immintrin.h> // For _mm_pause
8614 int lockvar;
8616 /* Acquire lock with lock elision */
8617 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8618     _mm_pause(); /* Abort failed transaction */
8620 /* Free lock with lock elision */
8621 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8622 @end smallexample
8624 @node Object Size Checking
8625 @section Object Size Checking Built-in Functions
8626 @findex __builtin_object_size
8627 @findex __builtin___memcpy_chk
8628 @findex __builtin___mempcpy_chk
8629 @findex __builtin___memmove_chk
8630 @findex __builtin___memset_chk
8631 @findex __builtin___strcpy_chk
8632 @findex __builtin___stpcpy_chk
8633 @findex __builtin___strncpy_chk
8634 @findex __builtin___strcat_chk
8635 @findex __builtin___strncat_chk
8636 @findex __builtin___sprintf_chk
8637 @findex __builtin___snprintf_chk
8638 @findex __builtin___vsprintf_chk
8639 @findex __builtin___vsnprintf_chk
8640 @findex __builtin___printf_chk
8641 @findex __builtin___vprintf_chk
8642 @findex __builtin___fprintf_chk
8643 @findex __builtin___vfprintf_chk
8645 GCC implements a limited buffer overflow protection mechanism
8646 that can prevent some buffer overflow attacks.
8648 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8649 is a built-in construct that returns a constant number of bytes from
8650 @var{ptr} to the end of the object @var{ptr} pointer points to
8651 (if known at compile time).  @code{__builtin_object_size} never evaluates
8652 its arguments for side-effects.  If there are any side-effects in them, it
8653 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8654 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
8655 point to and all of them are known at compile time, the returned number
8656 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8657 0 and minimum if nonzero.  If it is not possible to determine which objects
8658 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8659 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8660 for @var{type} 2 or 3.
8662 @var{type} is an integer constant from 0 to 3.  If the least significant
8663 bit is clear, objects are whole variables, if it is set, a closest
8664 surrounding subobject is considered the object a pointer points to.
8665 The second bit determines if maximum or minimum of remaining bytes
8666 is computed.
8668 @smallexample
8669 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8670 char *p = &var.buf1[1], *q = &var.b;
8672 /* Here the object p points to is var.  */
8673 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8674 /* The subobject p points to is var.buf1.  */
8675 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8676 /* The object q points to is var.  */
8677 assert (__builtin_object_size (q, 0)
8678         == (char *) (&var + 1) - (char *) &var.b);
8679 /* The subobject q points to is var.b.  */
8680 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8681 @end smallexample
8682 @end deftypefn
8684 There are built-in functions added for many common string operation
8685 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8686 built-in is provided.  This built-in has an additional last argument,
8687 which is the number of bytes remaining in object the @var{dest}
8688 argument points to or @code{(size_t) -1} if the size is not known.
8690 The built-in functions are optimized into the normal string functions
8691 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8692 it is known at compile time that the destination object will not
8693 be overflown.  If the compiler can determine at compile time the
8694 object will be always overflown, it issues a warning.
8696 The intended use can be e.g.@:
8698 @smallexample
8699 #undef memcpy
8700 #define bos0(dest) __builtin_object_size (dest, 0)
8701 #define memcpy(dest, src, n) \
8702   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8704 char *volatile p;
8705 char buf[10];
8706 /* It is unknown what object p points to, so this is optimized
8707    into plain memcpy - no checking is possible.  */
8708 memcpy (p, "abcde", n);
8709 /* Destination is known and length too.  It is known at compile
8710    time there will be no overflow.  */
8711 memcpy (&buf[5], "abcde", 5);
8712 /* Destination is known, but the length is not known at compile time.
8713    This will result in __memcpy_chk call that can check for overflow
8714    at run time.  */
8715 memcpy (&buf[5], "abcde", n);
8716 /* Destination is known and it is known at compile time there will
8717    be overflow.  There will be a warning and __memcpy_chk call that
8718    will abort the program at run time.  */
8719 memcpy (&buf[6], "abcde", 5);
8720 @end smallexample
8722 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8723 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8724 @code{strcat} and @code{strncat}.
8726 There are also checking built-in functions for formatted output functions.
8727 @smallexample
8728 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8729 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8730                               const char *fmt, ...);
8731 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8732                               va_list ap);
8733 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8734                                const char *fmt, va_list ap);
8735 @end smallexample
8737 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8738 etc.@: functions and can contain implementation specific flags on what
8739 additional security measures the checking function might take, such as
8740 handling @code{%n} differently.
8742 The @var{os} argument is the object size @var{s} points to, like in the
8743 other built-in functions.  There is a small difference in the behavior
8744 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8745 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8746 the checking function is called with @var{os} argument set to
8747 @code{(size_t) -1}.
8749 In addition to this, there are checking built-in functions
8750 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8751 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8752 These have just one additional argument, @var{flag}, right before
8753 format string @var{fmt}.  If the compiler is able to optimize them to
8754 @code{fputc} etc.@: functions, it does, otherwise the checking function
8755 is called and the @var{flag} argument passed to it.
8757 @node Pointer Bounds Checker builtins
8758 @section Pointer Bounds Checker Built-in Functions
8759 @findex __builtin___bnd_set_ptr_bounds
8760 @findex __builtin___bnd_narrow_ptr_bounds
8761 @findex __builtin___bnd_copy_ptr_bounds
8762 @findex __builtin___bnd_init_ptr_bounds
8763 @findex __builtin___bnd_null_ptr_bounds
8764 @findex __builtin___bnd_store_ptr_bounds
8765 @findex __builtin___bnd_chk_ptr_lbounds
8766 @findex __builtin___bnd_chk_ptr_ubounds
8767 @findex __builtin___bnd_chk_ptr_bounds
8768 @findex __builtin___bnd_get_ptr_lbound
8769 @findex __builtin___bnd_get_ptr_ubound
8771 GCC provides a set of built-in functions to control Pointer Bounds Checker
8772 instrumentation.  Note that all Pointer Bounds Checker builtins are allowed
8773 to use even if you compile with Pointer Bounds Checker off.  The builtins
8774 behavior may differ in such case as documented below.
8776 @deftypefn {Built-in Function} void * __builtin___bnd_set_ptr_bounds (const void * @var{q}, size_t @var{size})
8778 This built-in function returns a new pointer with the value of @var{q}, and
8779 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
8780 Bounds Checker off built-in function just returns the first argument.
8782 @smallexample
8783 extern void *__wrap_malloc (size_t n)
8785   void *p = (void *)__real_malloc (n);
8786   if (!p) return __builtin___bnd_null_ptr_bounds (p);
8787   return __builtin___bnd_set_ptr_bounds (p, n);
8789 @end smallexample
8791 @end deftypefn
8793 @deftypefn {Built-in Function} void * __builtin___bnd_narrow_ptr_bounds (const void * @var{p}, const void * @var{q}, size_t  @var{size})
8795 This built-in function returns a new pointer with the value of @var{p}
8796 and associate it with the narrowed bounds formed by the intersection
8797 of bounds associated with @var{q} and the [@var{p}, @var{p} + @var{size} - 1].
8798 With Pointer Bounds Checker off built-in function just returns the first
8799 argument.
8801 @smallexample
8802 void init_objects (object *objs, size_t size)
8804   size_t i;
8805   /* Initialize objects one-by-one passing pointers with bounds of an object,
8806      not the full array of objects.  */
8807   for (i = 0; i < size; i++)
8808     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, sizeof(object)));
8810 @end smallexample
8812 @end deftypefn
8814 @deftypefn {Built-in Function} void * __builtin___bnd_copy_ptr_bounds (const void * @var{q}, const void * @var{r})
8816 This built-in function returns a new pointer with the value of @var{q},
8817 and associate it with the bounds already associated with pointer @var{r}.
8818 With Pointer Bounds Checker off built-in function just returns the first
8819 argument.
8821 @smallexample
8822 /* Here is a way to get pointer to object's field but
8823    still with the full object's bounds.  */
8824 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_filed, objptr);
8825 @end smallexample
8827 @end deftypefn
8829 @deftypefn {Built-in Function} void * __builtin___bnd_init_ptr_bounds (const void * @var{q})
8831 This built-in function returns a new pointer with the value of @var{q}, and
8832 associate it with INIT (allowing full memory access) bounds. With Pointer
8833 Bounds Checker off built-in function just returns the first argument.
8835 @end deftypefn
8837 @deftypefn {Built-in Function} void * __builtin___bnd_null_ptr_bounds (const void * @var{q})
8839 This built-in function returns a new pointer with the value of @var{q}, and
8840 associate it with NULL (allowing no memory access) bounds. With Pointer
8841 Bounds Checker off built-in function just returns the first argument.
8843 @end deftypefn
8845 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void ** @var{ptr_addr}, const void * @var{ptr_val})
8847 This built-in function stores the bounds associated with pointer @var{ptr_val}
8848 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
8849 bounds from legacy code without touching the associated pointer's memory when
8850 pointers were copied as integers.  With Pointer Bounds Checker off built-in
8851 function call is ignored.
8853 @end deftypefn
8855 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void * @var{q})
8857 This built-in function checks if the pointer @var{q} is within the lower
8858 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8859 function call is ignored.
8861 @smallexample
8862 extern void *__wrap_memset (void *dst, int c, size_t len)
8864   if (len > 0)
8865     @{
8866       __builtin___bnd_chk_ptr_lbounds (dst);
8867       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
8868       __real_memset (dst, c, len);
8869     @}
8870   return dst;
8872 @end smallexample
8874 @end deftypefn
8876 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void * @var{q})
8878 This built-in function checks if the pointer @var{q} is within the upper
8879 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8880 function call is ignored.
8882 @end deftypefn
8884 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void * @var{q}, size_t @var{size})
8886 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
8887 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
8888 off built-in function call is ignored.
8890 @smallexample
8891 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
8893   if (n > 0)
8894     @{
8895       __bnd_chk_ptr_bounds (dst, n);
8896       __bnd_chk_ptr_bounds (src, n);
8897       __real_memcpy (dst, src, n);
8898     @}
8899   return dst;
8901 @end smallexample
8903 @end deftypefn
8905 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_lbound (const void * @var{q})
8907 This built-in function returns the lower bound (which is a pointer) associated
8908 with the pointer @var{q}.  This is at least useful for debugging using printf.
8909 With Pointer Bounds Checker off built-in function returns 0.
8911 @smallexample
8912 void *lb = __builtin___bnd_get_ptr_lbound (q);
8913 void *ub = __builtin___bnd_get_ptr_ubound (q);
8914 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
8915 @end smallexample
8917 @end deftypefn
8919 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_ubound (const void * @var{q})
8921 This built-in function returns the upper bound (which is a pointer) associated
8922 with the pointer @var{q}.  With Pointer Bounds Checker off built-in function
8923 returns -1.
8925 @end deftypefn
8927 @node Cilk Plus Builtins
8928 @section Cilk Plus C/C++ language extension Built-in Functions.
8930 GCC provides support for the following built-in reduction funtions if Cilk Plus
8931 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8933 @itemize @bullet
8934 @item __sec_implicit_index
8935 @item __sec_reduce
8936 @item __sec_reduce_add
8937 @item __sec_reduce_all_nonzero
8938 @item __sec_reduce_all_zero
8939 @item __sec_reduce_any_nonzero
8940 @item __sec_reduce_any_zero
8941 @item __sec_reduce_max
8942 @item __sec_reduce_min
8943 @item __sec_reduce_max_ind
8944 @item __sec_reduce_min_ind
8945 @item __sec_reduce_mul
8946 @item __sec_reduce_mutating
8947 @end itemize
8949 Further details and examples about these built-in functions are described 
8950 in the Cilk Plus language manual which can be found at 
8951 @uref{http://www.cilkplus.org}.
8953 @node Other Builtins
8954 @section Other Built-in Functions Provided by GCC
8955 @cindex built-in functions
8956 @findex __builtin_call_with_static_chain
8957 @findex __builtin_fpclassify
8958 @findex __builtin_isfinite
8959 @findex __builtin_isnormal
8960 @findex __builtin_isgreater
8961 @findex __builtin_isgreaterequal
8962 @findex __builtin_isinf_sign
8963 @findex __builtin_isless
8964 @findex __builtin_islessequal
8965 @findex __builtin_islessgreater
8966 @findex __builtin_isunordered
8967 @findex __builtin_powi
8968 @findex __builtin_powif
8969 @findex __builtin_powil
8970 @findex _Exit
8971 @findex _exit
8972 @findex abort
8973 @findex abs
8974 @findex acos
8975 @findex acosf
8976 @findex acosh
8977 @findex acoshf
8978 @findex acoshl
8979 @findex acosl
8980 @findex alloca
8981 @findex asin
8982 @findex asinf
8983 @findex asinh
8984 @findex asinhf
8985 @findex asinhl
8986 @findex asinl
8987 @findex atan
8988 @findex atan2
8989 @findex atan2f
8990 @findex atan2l
8991 @findex atanf
8992 @findex atanh
8993 @findex atanhf
8994 @findex atanhl
8995 @findex atanl
8996 @findex bcmp
8997 @findex bzero
8998 @findex cabs
8999 @findex cabsf
9000 @findex cabsl
9001 @findex cacos
9002 @findex cacosf
9003 @findex cacosh
9004 @findex cacoshf
9005 @findex cacoshl
9006 @findex cacosl
9007 @findex calloc
9008 @findex carg
9009 @findex cargf
9010 @findex cargl
9011 @findex casin
9012 @findex casinf
9013 @findex casinh
9014 @findex casinhf
9015 @findex casinhl
9016 @findex casinl
9017 @findex catan
9018 @findex catanf
9019 @findex catanh
9020 @findex catanhf
9021 @findex catanhl
9022 @findex catanl
9023 @findex cbrt
9024 @findex cbrtf
9025 @findex cbrtl
9026 @findex ccos
9027 @findex ccosf
9028 @findex ccosh
9029 @findex ccoshf
9030 @findex ccoshl
9031 @findex ccosl
9032 @findex ceil
9033 @findex ceilf
9034 @findex ceill
9035 @findex cexp
9036 @findex cexpf
9037 @findex cexpl
9038 @findex cimag
9039 @findex cimagf
9040 @findex cimagl
9041 @findex clog
9042 @findex clogf
9043 @findex clogl
9044 @findex conj
9045 @findex conjf
9046 @findex conjl
9047 @findex copysign
9048 @findex copysignf
9049 @findex copysignl
9050 @findex cos
9051 @findex cosf
9052 @findex cosh
9053 @findex coshf
9054 @findex coshl
9055 @findex cosl
9056 @findex cpow
9057 @findex cpowf
9058 @findex cpowl
9059 @findex cproj
9060 @findex cprojf
9061 @findex cprojl
9062 @findex creal
9063 @findex crealf
9064 @findex creall
9065 @findex csin
9066 @findex csinf
9067 @findex csinh
9068 @findex csinhf
9069 @findex csinhl
9070 @findex csinl
9071 @findex csqrt
9072 @findex csqrtf
9073 @findex csqrtl
9074 @findex ctan
9075 @findex ctanf
9076 @findex ctanh
9077 @findex ctanhf
9078 @findex ctanhl
9079 @findex ctanl
9080 @findex dcgettext
9081 @findex dgettext
9082 @findex drem
9083 @findex dremf
9084 @findex dreml
9085 @findex erf
9086 @findex erfc
9087 @findex erfcf
9088 @findex erfcl
9089 @findex erff
9090 @findex erfl
9091 @findex exit
9092 @findex exp
9093 @findex exp10
9094 @findex exp10f
9095 @findex exp10l
9096 @findex exp2
9097 @findex exp2f
9098 @findex exp2l
9099 @findex expf
9100 @findex expl
9101 @findex expm1
9102 @findex expm1f
9103 @findex expm1l
9104 @findex fabs
9105 @findex fabsf
9106 @findex fabsl
9107 @findex fdim
9108 @findex fdimf
9109 @findex fdiml
9110 @findex ffs
9111 @findex floor
9112 @findex floorf
9113 @findex floorl
9114 @findex fma
9115 @findex fmaf
9116 @findex fmal
9117 @findex fmax
9118 @findex fmaxf
9119 @findex fmaxl
9120 @findex fmin
9121 @findex fminf
9122 @findex fminl
9123 @findex fmod
9124 @findex fmodf
9125 @findex fmodl
9126 @findex fprintf
9127 @findex fprintf_unlocked
9128 @findex fputs
9129 @findex fputs_unlocked
9130 @findex frexp
9131 @findex frexpf
9132 @findex frexpl
9133 @findex fscanf
9134 @findex gamma
9135 @findex gammaf
9136 @findex gammal
9137 @findex gamma_r
9138 @findex gammaf_r
9139 @findex gammal_r
9140 @findex gettext
9141 @findex hypot
9142 @findex hypotf
9143 @findex hypotl
9144 @findex ilogb
9145 @findex ilogbf
9146 @findex ilogbl
9147 @findex imaxabs
9148 @findex index
9149 @findex isalnum
9150 @findex isalpha
9151 @findex isascii
9152 @findex isblank
9153 @findex iscntrl
9154 @findex isdigit
9155 @findex isgraph
9156 @findex islower
9157 @findex isprint
9158 @findex ispunct
9159 @findex isspace
9160 @findex isupper
9161 @findex iswalnum
9162 @findex iswalpha
9163 @findex iswblank
9164 @findex iswcntrl
9165 @findex iswdigit
9166 @findex iswgraph
9167 @findex iswlower
9168 @findex iswprint
9169 @findex iswpunct
9170 @findex iswspace
9171 @findex iswupper
9172 @findex iswxdigit
9173 @findex isxdigit
9174 @findex j0
9175 @findex j0f
9176 @findex j0l
9177 @findex j1
9178 @findex j1f
9179 @findex j1l
9180 @findex jn
9181 @findex jnf
9182 @findex jnl
9183 @findex labs
9184 @findex ldexp
9185 @findex ldexpf
9186 @findex ldexpl
9187 @findex lgamma
9188 @findex lgammaf
9189 @findex lgammal
9190 @findex lgamma_r
9191 @findex lgammaf_r
9192 @findex lgammal_r
9193 @findex llabs
9194 @findex llrint
9195 @findex llrintf
9196 @findex llrintl
9197 @findex llround
9198 @findex llroundf
9199 @findex llroundl
9200 @findex log
9201 @findex log10
9202 @findex log10f
9203 @findex log10l
9204 @findex log1p
9205 @findex log1pf
9206 @findex log1pl
9207 @findex log2
9208 @findex log2f
9209 @findex log2l
9210 @findex logb
9211 @findex logbf
9212 @findex logbl
9213 @findex logf
9214 @findex logl
9215 @findex lrint
9216 @findex lrintf
9217 @findex lrintl
9218 @findex lround
9219 @findex lroundf
9220 @findex lroundl
9221 @findex malloc
9222 @findex memchr
9223 @findex memcmp
9224 @findex memcpy
9225 @findex mempcpy
9226 @findex memset
9227 @findex modf
9228 @findex modff
9229 @findex modfl
9230 @findex nearbyint
9231 @findex nearbyintf
9232 @findex nearbyintl
9233 @findex nextafter
9234 @findex nextafterf
9235 @findex nextafterl
9236 @findex nexttoward
9237 @findex nexttowardf
9238 @findex nexttowardl
9239 @findex pow
9240 @findex pow10
9241 @findex pow10f
9242 @findex pow10l
9243 @findex powf
9244 @findex powl
9245 @findex printf
9246 @findex printf_unlocked
9247 @findex putchar
9248 @findex puts
9249 @findex remainder
9250 @findex remainderf
9251 @findex remainderl
9252 @findex remquo
9253 @findex remquof
9254 @findex remquol
9255 @findex rindex
9256 @findex rint
9257 @findex rintf
9258 @findex rintl
9259 @findex round
9260 @findex roundf
9261 @findex roundl
9262 @findex scalb
9263 @findex scalbf
9264 @findex scalbl
9265 @findex scalbln
9266 @findex scalblnf
9267 @findex scalblnf
9268 @findex scalbn
9269 @findex scalbnf
9270 @findex scanfnl
9271 @findex signbit
9272 @findex signbitf
9273 @findex signbitl
9274 @findex signbitd32
9275 @findex signbitd64
9276 @findex signbitd128
9277 @findex significand
9278 @findex significandf
9279 @findex significandl
9280 @findex sin
9281 @findex sincos
9282 @findex sincosf
9283 @findex sincosl
9284 @findex sinf
9285 @findex sinh
9286 @findex sinhf
9287 @findex sinhl
9288 @findex sinl
9289 @findex snprintf
9290 @findex sprintf
9291 @findex sqrt
9292 @findex sqrtf
9293 @findex sqrtl
9294 @findex sscanf
9295 @findex stpcpy
9296 @findex stpncpy
9297 @findex strcasecmp
9298 @findex strcat
9299 @findex strchr
9300 @findex strcmp
9301 @findex strcpy
9302 @findex strcspn
9303 @findex strdup
9304 @findex strfmon
9305 @findex strftime
9306 @findex strlen
9307 @findex strncasecmp
9308 @findex strncat
9309 @findex strncmp
9310 @findex strncpy
9311 @findex strndup
9312 @findex strpbrk
9313 @findex strrchr
9314 @findex strspn
9315 @findex strstr
9316 @findex tan
9317 @findex tanf
9318 @findex tanh
9319 @findex tanhf
9320 @findex tanhl
9321 @findex tanl
9322 @findex tgamma
9323 @findex tgammaf
9324 @findex tgammal
9325 @findex toascii
9326 @findex tolower
9327 @findex toupper
9328 @findex towlower
9329 @findex towupper
9330 @findex trunc
9331 @findex truncf
9332 @findex truncl
9333 @findex vfprintf
9334 @findex vfscanf
9335 @findex vprintf
9336 @findex vscanf
9337 @findex vsnprintf
9338 @findex vsprintf
9339 @findex vsscanf
9340 @findex y0
9341 @findex y0f
9342 @findex y0l
9343 @findex y1
9344 @findex y1f
9345 @findex y1l
9346 @findex yn
9347 @findex ynf
9348 @findex ynl
9350 GCC provides a large number of built-in functions other than the ones
9351 mentioned above.  Some of these are for internal use in the processing
9352 of exceptions or variable-length argument lists and are not
9353 documented here because they may change from time to time; we do not
9354 recommend general use of these functions.
9356 The remaining functions are provided for optimization purposes.
9358 @opindex fno-builtin
9359 GCC includes built-in versions of many of the functions in the standard
9360 C library.  The versions prefixed with @code{__builtin_} are always
9361 treated as having the same meaning as the C library function even if you
9362 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
9363 Many of these functions are only optimized in certain cases; if they are
9364 not optimized in a particular case, a call to the library function is
9365 emitted.
9367 @opindex ansi
9368 @opindex std
9369 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9370 @option{-std=c99} or @option{-std=c11}), the functions
9371 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9372 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9373 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9374 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9375 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9376 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9377 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9378 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9379 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9380 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9381 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9382 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9383 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9384 @code{significandl}, @code{significand}, @code{sincosf},
9385 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9386 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9387 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9388 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9389 @code{yn}
9390 may be handled as built-in functions.
9391 All these functions have corresponding versions
9392 prefixed with @code{__builtin_}, which may be used even in strict C90
9393 mode.
9395 The ISO C99 functions
9396 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9397 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9398 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9399 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9400 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9401 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9402 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9403 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9404 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9405 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9406 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9407 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9408 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9409 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9410 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9411 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9412 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9413 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9414 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9415 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9416 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9417 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9418 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9419 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9420 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9421 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9422 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9423 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9424 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9425 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9426 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9427 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9428 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9429 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9430 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9431 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9432 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9433 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9434 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9435 are handled as built-in functions
9436 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9438 There are also built-in versions of the ISO C99 functions
9439 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9440 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9441 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9442 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9443 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9444 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9445 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9446 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9447 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9448 that are recognized in any mode since ISO C90 reserves these names for
9449 the purpose to which ISO C99 puts them.  All these functions have
9450 corresponding versions prefixed with @code{__builtin_}.
9452 The ISO C94 functions
9453 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9454 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9455 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9456 @code{towupper}
9457 are handled as built-in functions
9458 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9460 The ISO C90 functions
9461 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9462 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9463 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9464 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9465 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9466 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9467 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9468 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9469 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9470 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9471 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9472 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9473 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9474 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9475 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9476 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9477 are all recognized as built-in functions unless
9478 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9479 is specified for an individual function).  All of these functions have
9480 corresponding versions prefixed with @code{__builtin_}.
9482 GCC provides built-in versions of the ISO C99 floating-point comparison
9483 macros that avoid raising exceptions for unordered operands.  They have
9484 the same names as the standard macros ( @code{isgreater},
9485 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9486 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9487 prefixed.  We intend for a library implementor to be able to simply
9488 @code{#define} each standard macro to its built-in equivalent.
9489 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9490 @code{isinf_sign} and @code{isnormal} built-ins used with
9491 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
9492 built-in functions appear both with and without the @code{__builtin_} prefix.
9494 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9496 You can use the built-in function @code{__builtin_types_compatible_p} to
9497 determine whether two types are the same.
9499 This built-in function returns 1 if the unqualified versions of the
9500 types @var{type1} and @var{type2} (which are types, not expressions) are
9501 compatible, 0 otherwise.  The result of this built-in function can be
9502 used in integer constant expressions.
9504 This built-in function ignores top level qualifiers (e.g., @code{const},
9505 @code{volatile}).  For example, @code{int} is equivalent to @code{const
9506 int}.
9508 The type @code{int[]} and @code{int[5]} are compatible.  On the other
9509 hand, @code{int} and @code{char *} are not compatible, even if the size
9510 of their types, on the particular architecture are the same.  Also, the
9511 amount of pointer indirection is taken into account when determining
9512 similarity.  Consequently, @code{short *} is not similar to
9513 @code{short **}.  Furthermore, two types that are typedefed are
9514 considered compatible if their underlying types are compatible.
9516 An @code{enum} type is not considered to be compatible with another
9517 @code{enum} type even if both are compatible with the same integer
9518 type; this is what the C standard specifies.
9519 For example, @code{enum @{foo, bar@}} is not similar to
9520 @code{enum @{hot, dog@}}.
9522 You typically use this function in code whose execution varies
9523 depending on the arguments' types.  For example:
9525 @smallexample
9526 #define foo(x)                                                  \
9527   (@{                                                           \
9528     typeof (x) tmp = (x);                                       \
9529     if (__builtin_types_compatible_p (typeof (x), long double)) \
9530       tmp = foo_long_double (tmp);                              \
9531     else if (__builtin_types_compatible_p (typeof (x), double)) \
9532       tmp = foo_double (tmp);                                   \
9533     else if (__builtin_types_compatible_p (typeof (x), float))  \
9534       tmp = foo_float (tmp);                                    \
9535     else                                                        \
9536       abort ();                                                 \
9537     tmp;                                                        \
9538   @})
9539 @end smallexample
9541 @emph{Note:} This construct is only available for C@.
9543 @end deftypefn
9545 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
9547 The @var{call_exp} expression must be a function call, and the
9548 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
9549 is passed to the function call in the target's static chain location.
9550 The result of builtin is the result of the function call.
9552 @emph{Note:} This builtin is only available for C@.
9553 This builtin can be used to call Go closures from C.
9555 @end deftypefn
9557 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9559 You can use the built-in function @code{__builtin_choose_expr} to
9560 evaluate code depending on the value of a constant expression.  This
9561 built-in function returns @var{exp1} if @var{const_exp}, which is an
9562 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
9564 This built-in function is analogous to the @samp{? :} operator in C,
9565 except that the expression returned has its type unaltered by promotion
9566 rules.  Also, the built-in function does not evaluate the expression
9567 that is not chosen.  For example, if @var{const_exp} evaluates to true,
9568 @var{exp2} is not evaluated even if it has side-effects.
9570 This built-in function can return an lvalue if the chosen argument is an
9571 lvalue.
9573 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9574 type.  Similarly, if @var{exp2} is returned, its return type is the same
9575 as @var{exp2}.
9577 Example:
9579 @smallexample
9580 #define foo(x)                                                    \
9581   __builtin_choose_expr (                                         \
9582     __builtin_types_compatible_p (typeof (x), double),            \
9583     foo_double (x),                                               \
9584     __builtin_choose_expr (                                       \
9585       __builtin_types_compatible_p (typeof (x), float),           \
9586       foo_float (x),                                              \
9587       /* @r{The void expression results in a compile-time error}  \
9588          @r{when assigning the result to something.}  */          \
9589       (void)0))
9590 @end smallexample
9592 @emph{Note:} This construct is only available for C@.  Furthermore, the
9593 unused expression (@var{exp1} or @var{exp2} depending on the value of
9594 @var{const_exp}) may still generate syntax errors.  This may change in
9595 future revisions.
9597 @end deftypefn
9599 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9601 The built-in function @code{__builtin_complex} is provided for use in
9602 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9603 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
9604 real binary floating-point type, and the result has the corresponding
9605 complex type with real and imaginary parts @var{real} and @var{imag}.
9606 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9607 infinities, NaNs and negative zeros are involved.
9609 @end deftypefn
9611 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9612 You can use the built-in function @code{__builtin_constant_p} to
9613 determine if a value is known to be constant at compile time and hence
9614 that GCC can perform constant-folding on expressions involving that
9615 value.  The argument of the function is the value to test.  The function
9616 returns the integer 1 if the argument is known to be a compile-time
9617 constant and 0 if it is not known to be a compile-time constant.  A
9618 return of 0 does not indicate that the value is @emph{not} a constant,
9619 but merely that GCC cannot prove it is a constant with the specified
9620 value of the @option{-O} option.
9622 You typically use this function in an embedded application where
9623 memory is a critical resource.  If you have some complex calculation,
9624 you may want it to be folded if it involves constants, but need to call
9625 a function if it does not.  For example:
9627 @smallexample
9628 #define Scale_Value(X)      \
9629   (__builtin_constant_p (X) \
9630   ? ((X) * SCALE + OFFSET) : Scale (X))
9631 @end smallexample
9633 You may use this built-in function in either a macro or an inline
9634 function.  However, if you use it in an inlined function and pass an
9635 argument of the function as the argument to the built-in, GCC 
9636 never returns 1 when you call the inline function with a string constant
9637 or compound literal (@pxref{Compound Literals}) and does not return 1
9638 when you pass a constant numeric value to the inline function unless you
9639 specify the @option{-O} option.
9641 You may also use @code{__builtin_constant_p} in initializers for static
9642 data.  For instance, you can write
9644 @smallexample
9645 static const int table[] = @{
9646    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9647    /* @r{@dots{}} */
9649 @end smallexample
9651 @noindent
9652 This is an acceptable initializer even if @var{EXPRESSION} is not a
9653 constant expression, including the case where
9654 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9655 folded to a constant but @var{EXPRESSION} contains operands that are
9656 not otherwise permitted in a static initializer (for example,
9657 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
9658 built-in in this case, because it has no opportunity to perform
9659 optimization.
9661 Previous versions of GCC did not accept this built-in in data
9662 initializers.  The earliest version where it is completely safe is
9663 3.0.1.
9664 @end deftypefn
9666 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9667 @opindex fprofile-arcs
9668 You may use @code{__builtin_expect} to provide the compiler with
9669 branch prediction information.  In general, you should prefer to
9670 use actual profile feedback for this (@option{-fprofile-arcs}), as
9671 programmers are notoriously bad at predicting how their programs
9672 actually perform.  However, there are applications in which this
9673 data is hard to collect.
9675 The return value is the value of @var{exp}, which should be an integral
9676 expression.  The semantics of the built-in are that it is expected that
9677 @var{exp} == @var{c}.  For example:
9679 @smallexample
9680 if (__builtin_expect (x, 0))
9681   foo ();
9682 @end smallexample
9684 @noindent
9685 indicates that we do not expect to call @code{foo}, since
9686 we expect @code{x} to be zero.  Since you are limited to integral
9687 expressions for @var{exp}, you should use constructions such as
9689 @smallexample
9690 if (__builtin_expect (ptr != NULL, 1))
9691   foo (*ptr);
9692 @end smallexample
9694 @noindent
9695 when testing pointer or floating-point values.
9696 @end deftypefn
9698 @deftypefn {Built-in Function} void __builtin_trap (void)
9699 This function causes the program to exit abnormally.  GCC implements
9700 this function by using a target-dependent mechanism (such as
9701 intentionally executing an illegal instruction) or by calling
9702 @code{abort}.  The mechanism used may vary from release to release so
9703 you should not rely on any particular implementation.
9704 @end deftypefn
9706 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9707 If control flow reaches the point of the @code{__builtin_unreachable},
9708 the program is undefined.  It is useful in situations where the
9709 compiler cannot deduce the unreachability of the code.
9711 One such case is immediately following an @code{asm} statement that
9712 either never terminates, or one that transfers control elsewhere
9713 and never returns.  In this example, without the
9714 @code{__builtin_unreachable}, GCC issues a warning that control
9715 reaches the end of a non-void function.  It also generates code
9716 to return after the @code{asm}.
9718 @smallexample
9719 int f (int c, int v)
9721   if (c)
9722     @{
9723       return v;
9724     @}
9725   else
9726     @{
9727       asm("jmp error_handler");
9728       __builtin_unreachable ();
9729     @}
9731 @end smallexample
9733 @noindent
9734 Because the @code{asm} statement unconditionally transfers control out
9735 of the function, control never reaches the end of the function
9736 body.  The @code{__builtin_unreachable} is in fact unreachable and
9737 communicates this fact to the compiler.
9739 Another use for @code{__builtin_unreachable} is following a call a
9740 function that never returns but that is not declared
9741 @code{__attribute__((noreturn))}, as in this example:
9743 @smallexample
9744 void function_that_never_returns (void);
9746 int g (int c)
9748   if (c)
9749     @{
9750       return 1;
9751     @}
9752   else
9753     @{
9754       function_that_never_returns ();
9755       __builtin_unreachable ();
9756     @}
9758 @end smallexample
9760 @end deftypefn
9762 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9763 This function returns its first argument, and allows the compiler
9764 to assume that the returned pointer is at least @var{align} bytes
9765 aligned.  This built-in can have either two or three arguments,
9766 if it has three, the third argument should have integer type, and
9767 if it is nonzero means misalignment offset.  For example:
9769 @smallexample
9770 void *x = __builtin_assume_aligned (arg, 16);
9771 @end smallexample
9773 @noindent
9774 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9775 16-byte aligned, while:
9777 @smallexample
9778 void *x = __builtin_assume_aligned (arg, 32, 8);
9779 @end smallexample
9781 @noindent
9782 means that the compiler can assume for @code{x}, set to @code{arg}, that
9783 @code{(char *) x - 8} is 32-byte aligned.
9784 @end deftypefn
9786 @deftypefn {Built-in Function} int __builtin_LINE ()
9787 This function is the equivalent to the preprocessor @code{__LINE__}
9788 macro and returns the line number of the invocation of the built-in.
9789 In a C++ default argument for a function @var{F}, it gets the line number of
9790 the call to @var{F}.
9791 @end deftypefn
9793 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9794 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9795 macro and returns the function name the invocation of the built-in is in.
9796 @end deftypefn
9798 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9799 This function is the equivalent to the preprocessor @code{__FILE__}
9800 macro and returns the file name the invocation of the built-in is in.
9801 In a C++ default argument for a function @var{F}, it gets the file name of
9802 the call to @var{F}.
9803 @end deftypefn
9805 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9806 This function is used to flush the processor's instruction cache for
9807 the region of memory between @var{begin} inclusive and @var{end}
9808 exclusive.  Some targets require that the instruction cache be
9809 flushed, after modifying memory containing code, in order to obtain
9810 deterministic behavior.
9812 If the target does not require instruction cache flushes,
9813 @code{__builtin___clear_cache} has no effect.  Otherwise either
9814 instructions are emitted in-line to clear the instruction cache or a
9815 call to the @code{__clear_cache} function in libgcc is made.
9816 @end deftypefn
9818 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9819 This function is used to minimize cache-miss latency by moving data into
9820 a cache before it is accessed.
9821 You can insert calls to @code{__builtin_prefetch} into code for which
9822 you know addresses of data in memory that is likely to be accessed soon.
9823 If the target supports them, data prefetch instructions are generated.
9824 If the prefetch is done early enough before the access then the data will
9825 be in the cache by the time it is accessed.
9827 The value of @var{addr} is the address of the memory to prefetch.
9828 There are two optional arguments, @var{rw} and @var{locality}.
9829 The value of @var{rw} is a compile-time constant one or zero; one
9830 means that the prefetch is preparing for a write to the memory address
9831 and zero, the default, means that the prefetch is preparing for a read.
9832 The value @var{locality} must be a compile-time constant integer between
9833 zero and three.  A value of zero means that the data has no temporal
9834 locality, so it need not be left in the cache after the access.  A value
9835 of three means that the data has a high degree of temporal locality and
9836 should be left in all levels of cache possible.  Values of one and two
9837 mean, respectively, a low or moderate degree of temporal locality.  The
9838 default is three.
9840 @smallexample
9841 for (i = 0; i < n; i++)
9842   @{
9843     a[i] = a[i] + b[i];
9844     __builtin_prefetch (&a[i+j], 1, 1);
9845     __builtin_prefetch (&b[i+j], 0, 1);
9846     /* @r{@dots{}} */
9847   @}
9848 @end smallexample
9850 Data prefetch does not generate faults if @var{addr} is invalid, but
9851 the address expression itself must be valid.  For example, a prefetch
9852 of @code{p->next} does not fault if @code{p->next} is not a valid
9853 address, but evaluation faults if @code{p} is not a valid address.
9855 If the target does not support data prefetch, the address expression
9856 is evaluated if it includes side effects but no other code is generated
9857 and GCC does not issue a warning.
9858 @end deftypefn
9860 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9861 Returns a positive infinity, if supported by the floating-point format,
9862 else @code{DBL_MAX}.  This function is suitable for implementing the
9863 ISO C macro @code{HUGE_VAL}.
9864 @end deftypefn
9866 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9867 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9868 @end deftypefn
9870 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9871 Similar to @code{__builtin_huge_val}, except the return
9872 type is @code{long double}.
9873 @end deftypefn
9875 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9876 This built-in implements the C99 fpclassify functionality.  The first
9877 five int arguments should be the target library's notion of the
9878 possible FP classes and are used for return values.  They must be
9879 constant values and they must appear in this order: @code{FP_NAN},
9880 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9881 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
9882 to classify.  GCC treats the last argument as type-generic, which
9883 means it does not do default promotion from float to double.
9884 @end deftypefn
9886 @deftypefn {Built-in Function} double __builtin_inf (void)
9887 Similar to @code{__builtin_huge_val}, except a warning is generated
9888 if the target floating-point format does not support infinities.
9889 @end deftypefn
9891 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9892 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9893 @end deftypefn
9895 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9896 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9897 @end deftypefn
9899 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9900 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9901 @end deftypefn
9903 @deftypefn {Built-in Function} float __builtin_inff (void)
9904 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9905 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9906 @end deftypefn
9908 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9909 Similar to @code{__builtin_inf}, except the return
9910 type is @code{long double}.
9911 @end deftypefn
9913 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9914 Similar to @code{isinf}, except the return value is -1 for
9915 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9916 Note while the parameter list is an
9917 ellipsis, this function only accepts exactly one floating-point
9918 argument.  GCC treats this parameter as type-generic, which means it
9919 does not do default promotion from float to double.
9920 @end deftypefn
9922 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9923 This is an implementation of the ISO C99 function @code{nan}.
9925 Since ISO C99 defines this function in terms of @code{strtod}, which we
9926 do not implement, a description of the parsing is in order.  The string
9927 is parsed as by @code{strtol}; that is, the base is recognized by
9928 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
9929 in the significand such that the least significant bit of the number
9930 is at the least significant bit of the significand.  The number is
9931 truncated to fit the significand field provided.  The significand is
9932 forced to be a quiet NaN@.
9934 This function, if given a string literal all of which would have been
9935 consumed by @code{strtol}, is evaluated early enough that it is considered a
9936 compile-time constant.
9937 @end deftypefn
9939 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9940 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9941 @end deftypefn
9943 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9944 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9945 @end deftypefn
9947 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9948 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9949 @end deftypefn
9951 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9952 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9953 @end deftypefn
9955 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9956 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9957 @end deftypefn
9959 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9960 Similar to @code{__builtin_nan}, except the significand is forced
9961 to be a signaling NaN@.  The @code{nans} function is proposed by
9962 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9963 @end deftypefn
9965 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9966 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9967 @end deftypefn
9969 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9970 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9971 @end deftypefn
9973 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9974 Returns one plus the index of the least significant 1-bit of @var{x}, or
9975 if @var{x} is zero, returns zero.
9976 @end deftypefn
9978 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9979 Returns the number of leading 0-bits in @var{x}, starting at the most
9980 significant bit position.  If @var{x} is 0, the result is undefined.
9981 @end deftypefn
9983 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9984 Returns the number of trailing 0-bits in @var{x}, starting at the least
9985 significant bit position.  If @var{x} is 0, the result is undefined.
9986 @end deftypefn
9988 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9989 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9990 number of bits following the most significant bit that are identical
9991 to it.  There are no special cases for 0 or other values. 
9992 @end deftypefn
9994 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9995 Returns the number of 1-bits in @var{x}.
9996 @end deftypefn
9998 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9999 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
10000 modulo 2.
10001 @end deftypefn
10003 @deftypefn {Built-in Function} int __builtin_ffsl (long)
10004 Similar to @code{__builtin_ffs}, except the argument type is
10005 @code{long}.
10006 @end deftypefn
10008 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
10009 Similar to @code{__builtin_clz}, except the argument type is
10010 @code{unsigned long}.
10011 @end deftypefn
10013 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
10014 Similar to @code{__builtin_ctz}, except the argument type is
10015 @code{unsigned long}.
10016 @end deftypefn
10018 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
10019 Similar to @code{__builtin_clrsb}, except the argument type is
10020 @code{long}.
10021 @end deftypefn
10023 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
10024 Similar to @code{__builtin_popcount}, except the argument type is
10025 @code{unsigned long}.
10026 @end deftypefn
10028 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
10029 Similar to @code{__builtin_parity}, except the argument type is
10030 @code{unsigned long}.
10031 @end deftypefn
10033 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
10034 Similar to @code{__builtin_ffs}, except the argument type is
10035 @code{long long}.
10036 @end deftypefn
10038 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
10039 Similar to @code{__builtin_clz}, except the argument type is
10040 @code{unsigned long long}.
10041 @end deftypefn
10043 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
10044 Similar to @code{__builtin_ctz}, except the argument type is
10045 @code{unsigned long long}.
10046 @end deftypefn
10048 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
10049 Similar to @code{__builtin_clrsb}, except the argument type is
10050 @code{long long}.
10051 @end deftypefn
10053 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10054 Similar to @code{__builtin_popcount}, except the argument type is
10055 @code{unsigned long long}.
10056 @end deftypefn
10058 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10059 Similar to @code{__builtin_parity}, except the argument type is
10060 @code{unsigned long long}.
10061 @end deftypefn
10063 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10064 Returns the first argument raised to the power of the second.  Unlike the
10065 @code{pow} function no guarantees about precision and rounding are made.
10066 @end deftypefn
10068 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10069 Similar to @code{__builtin_powi}, except the argument and return types
10070 are @code{float}.
10071 @end deftypefn
10073 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10074 Similar to @code{__builtin_powi}, except the argument and return types
10075 are @code{long double}.
10076 @end deftypefn
10078 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10079 Returns @var{x} with the order of the bytes reversed; for example,
10080 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
10081 exactly 8 bits.
10082 @end deftypefn
10084 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10085 Similar to @code{__builtin_bswap16}, except the argument and return types
10086 are 32 bit.
10087 @end deftypefn
10089 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10090 Similar to @code{__builtin_bswap32}, except the argument and return types
10091 are 64 bit.
10092 @end deftypefn
10094 @node Target Builtins
10095 @section Built-in Functions Specific to Particular Target Machines
10097 On some target machines, GCC supports many built-in functions specific
10098 to those machines.  Generally these generate calls to specific machine
10099 instructions, but allow the compiler to schedule those calls.
10101 @menu
10102 * AArch64 Built-in Functions::
10103 * Alpha Built-in Functions::
10104 * Altera Nios II Built-in Functions::
10105 * ARC Built-in Functions::
10106 * ARC SIMD Built-in Functions::
10107 * ARM iWMMXt Built-in Functions::
10108 * ARM C Language Extensions (ACLE)::
10109 * ARM Floating Point Status and Control Intrinsics::
10110 * AVR Built-in Functions::
10111 * Blackfin Built-in Functions::
10112 * FR-V Built-in Functions::
10113 * X86 Built-in Functions::
10114 * X86 transactional memory intrinsics::
10115 * MIPS DSP Built-in Functions::
10116 * MIPS Paired-Single Support::
10117 * MIPS Loongson Built-in Functions::
10118 * Other MIPS Built-in Functions::
10119 * MSP430 Built-in Functions::
10120 * NDS32 Built-in Functions::
10121 * picoChip Built-in Functions::
10122 * PowerPC Built-in Functions::
10123 * PowerPC AltiVec/VSX Built-in Functions::
10124 * PowerPC Hardware Transactional Memory Built-in Functions::
10125 * RX Built-in Functions::
10126 * S/390 System z Built-in Functions::
10127 * SH Built-in Functions::
10128 * SPARC VIS Built-in Functions::
10129 * SPU Built-in Functions::
10130 * TI C6X Built-in Functions::
10131 * TILE-Gx Built-in Functions::
10132 * TILEPro Built-in Functions::
10133 @end menu
10135 @node AArch64 Built-in Functions
10136 @subsection AArch64 Built-in Functions
10138 These built-in functions are available for the AArch64 family of
10139 processors.
10140 @smallexample
10141 unsigned int __builtin_aarch64_get_fpcr ()
10142 void __builtin_aarch64_set_fpcr (unsigned int)
10143 unsigned int __builtin_aarch64_get_fpsr ()
10144 void __builtin_aarch64_set_fpsr (unsigned int)
10145 @end smallexample
10147 @node Alpha Built-in Functions
10148 @subsection Alpha Built-in Functions
10150 These built-in functions are available for the Alpha family of
10151 processors, depending on the command-line switches used.
10153 The following built-in functions are always available.  They
10154 all generate the machine instruction that is part of the name.
10156 @smallexample
10157 long __builtin_alpha_implver (void)
10158 long __builtin_alpha_rpcc (void)
10159 long __builtin_alpha_amask (long)
10160 long __builtin_alpha_cmpbge (long, long)
10161 long __builtin_alpha_extbl (long, long)
10162 long __builtin_alpha_extwl (long, long)
10163 long __builtin_alpha_extll (long, long)
10164 long __builtin_alpha_extql (long, long)
10165 long __builtin_alpha_extwh (long, long)
10166 long __builtin_alpha_extlh (long, long)
10167 long __builtin_alpha_extqh (long, long)
10168 long __builtin_alpha_insbl (long, long)
10169 long __builtin_alpha_inswl (long, long)
10170 long __builtin_alpha_insll (long, long)
10171 long __builtin_alpha_insql (long, long)
10172 long __builtin_alpha_inswh (long, long)
10173 long __builtin_alpha_inslh (long, long)
10174 long __builtin_alpha_insqh (long, long)
10175 long __builtin_alpha_mskbl (long, long)
10176 long __builtin_alpha_mskwl (long, long)
10177 long __builtin_alpha_mskll (long, long)
10178 long __builtin_alpha_mskql (long, long)
10179 long __builtin_alpha_mskwh (long, long)
10180 long __builtin_alpha_msklh (long, long)
10181 long __builtin_alpha_mskqh (long, long)
10182 long __builtin_alpha_umulh (long, long)
10183 long __builtin_alpha_zap (long, long)
10184 long __builtin_alpha_zapnot (long, long)
10185 @end smallexample
10187 The following built-in functions are always with @option{-mmax}
10188 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10189 later.  They all generate the machine instruction that is part
10190 of the name.
10192 @smallexample
10193 long __builtin_alpha_pklb (long)
10194 long __builtin_alpha_pkwb (long)
10195 long __builtin_alpha_unpkbl (long)
10196 long __builtin_alpha_unpkbw (long)
10197 long __builtin_alpha_minub8 (long, long)
10198 long __builtin_alpha_minsb8 (long, long)
10199 long __builtin_alpha_minuw4 (long, long)
10200 long __builtin_alpha_minsw4 (long, long)
10201 long __builtin_alpha_maxub8 (long, long)
10202 long __builtin_alpha_maxsb8 (long, long)
10203 long __builtin_alpha_maxuw4 (long, long)
10204 long __builtin_alpha_maxsw4 (long, long)
10205 long __builtin_alpha_perr (long, long)
10206 @end smallexample
10208 The following built-in functions are always with @option{-mcix}
10209 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10210 later.  They all generate the machine instruction that is part
10211 of the name.
10213 @smallexample
10214 long __builtin_alpha_cttz (long)
10215 long __builtin_alpha_ctlz (long)
10216 long __builtin_alpha_ctpop (long)
10217 @end smallexample
10219 The following built-in functions are available on systems that use the OSF/1
10220 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
10221 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10222 @code{rdval} and @code{wrval}.
10224 @smallexample
10225 void *__builtin_thread_pointer (void)
10226 void __builtin_set_thread_pointer (void *)
10227 @end smallexample
10229 @node Altera Nios II Built-in Functions
10230 @subsection Altera Nios II Built-in Functions
10232 These built-in functions are available for the Altera Nios II
10233 family of processors.
10235 The following built-in functions are always available.  They
10236 all generate the machine instruction that is part of the name.
10238 @example
10239 int __builtin_ldbio (volatile const void *)
10240 int __builtin_ldbuio (volatile const void *)
10241 int __builtin_ldhio (volatile const void *)
10242 int __builtin_ldhuio (volatile const void *)
10243 int __builtin_ldwio (volatile const void *)
10244 void __builtin_stbio (volatile void *, int)
10245 void __builtin_sthio (volatile void *, int)
10246 void __builtin_stwio (volatile void *, int)
10247 void __builtin_sync (void)
10248 int __builtin_rdctl (int) 
10249 void __builtin_wrctl (int, int)
10250 @end example
10252 The following built-in functions are always available.  They
10253 all generate a Nios II Custom Instruction. The name of the
10254 function represents the types that the function takes and
10255 returns. The letter before the @code{n} is the return type
10256 or void if absent. The @code{n} represents the first parameter
10257 to all the custom instructions, the custom instruction number.
10258 The two letters after the @code{n} represent the up to two
10259 parameters to the function.
10261 The letters represent the following data types:
10262 @table @code
10263 @item <no letter>
10264 @code{void} for return type and no parameter for parameter types.
10266 @item i
10267 @code{int} for return type and parameter type
10269 @item f
10270 @code{float} for return type and parameter type
10272 @item p
10273 @code{void *} for return type and parameter type
10275 @end table
10277 And the function names are:
10278 @example
10279 void __builtin_custom_n (void)
10280 void __builtin_custom_ni (int)
10281 void __builtin_custom_nf (float)
10282 void __builtin_custom_np (void *)
10283 void __builtin_custom_nii (int, int)
10284 void __builtin_custom_nif (int, float)
10285 void __builtin_custom_nip (int, void *)
10286 void __builtin_custom_nfi (float, int)
10287 void __builtin_custom_nff (float, float)
10288 void __builtin_custom_nfp (float, void *)
10289 void __builtin_custom_npi (void *, int)
10290 void __builtin_custom_npf (void *, float)
10291 void __builtin_custom_npp (void *, void *)
10292 int __builtin_custom_in (void)
10293 int __builtin_custom_ini (int)
10294 int __builtin_custom_inf (float)
10295 int __builtin_custom_inp (void *)
10296 int __builtin_custom_inii (int, int)
10297 int __builtin_custom_inif (int, float)
10298 int __builtin_custom_inip (int, void *)
10299 int __builtin_custom_infi (float, int)
10300 int __builtin_custom_inff (float, float)
10301 int __builtin_custom_infp (float, void *)
10302 int __builtin_custom_inpi (void *, int)
10303 int __builtin_custom_inpf (void *, float)
10304 int __builtin_custom_inpp (void *, void *)
10305 float __builtin_custom_fn (void)
10306 float __builtin_custom_fni (int)
10307 float __builtin_custom_fnf (float)
10308 float __builtin_custom_fnp (void *)
10309 float __builtin_custom_fnii (int, int)
10310 float __builtin_custom_fnif (int, float)
10311 float __builtin_custom_fnip (int, void *)
10312 float __builtin_custom_fnfi (float, int)
10313 float __builtin_custom_fnff (float, float)
10314 float __builtin_custom_fnfp (float, void *)
10315 float __builtin_custom_fnpi (void *, int)
10316 float __builtin_custom_fnpf (void *, float)
10317 float __builtin_custom_fnpp (void *, void *)
10318 void * __builtin_custom_pn (void)
10319 void * __builtin_custom_pni (int)
10320 void * __builtin_custom_pnf (float)
10321 void * __builtin_custom_pnp (void *)
10322 void * __builtin_custom_pnii (int, int)
10323 void * __builtin_custom_pnif (int, float)
10324 void * __builtin_custom_pnip (int, void *)
10325 void * __builtin_custom_pnfi (float, int)
10326 void * __builtin_custom_pnff (float, float)
10327 void * __builtin_custom_pnfp (float, void *)
10328 void * __builtin_custom_pnpi (void *, int)
10329 void * __builtin_custom_pnpf (void *, float)
10330 void * __builtin_custom_pnpp (void *, void *)
10331 @end example
10333 @node ARC Built-in Functions
10334 @subsection ARC Built-in Functions
10336 The following built-in functions are provided for ARC targets.  The
10337 built-ins generate the corresponding assembly instructions.  In the
10338 examples given below, the generated code often requires an operand or
10339 result to be in a register.  Where necessary further code will be
10340 generated to ensure this is true, but for brevity this is not
10341 described in each case.
10343 @emph{Note:} Using a built-in to generate an instruction not supported
10344 by a target may cause problems. At present the compiler is not
10345 guaranteed to detect such misuse, and as a result an internal compiler
10346 error may be generated.
10348 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10349 Return 1 if @var{val} is known to have the byte alignment given
10350 by @var{alignval}, otherwise return 0.
10351 Note that this is different from
10352 @smallexample
10353 __alignof__(*(char *)@var{val}) >= alignval
10354 @end smallexample
10355 because __alignof__ sees only the type of the dereference, whereas
10356 __builtin_arc_align uses alignment information from the pointer
10357 as well as from the pointed-to type.
10358 The information available will depend on optimization level.
10359 @end deftypefn
10361 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10362 Generates
10363 @example
10365 @end example
10366 @end deftypefn
10368 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10369 The operand is the number of a register to be read.  Generates:
10370 @example
10371 mov  @var{dest}, r@var{regno}
10372 @end example
10373 where the value in @var{dest} will be the result returned from the
10374 built-in.
10375 @end deftypefn
10377 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10378 The first operand is the number of a register to be written, the
10379 second operand is a compile time constant to write into that
10380 register.  Generates:
10381 @example
10382 mov  r@var{regno}, @var{val}
10383 @end example
10384 @end deftypefn
10386 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10387 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10388 Generates:
10389 @example
10390 divaw  @var{dest}, @var{a}, @var{b}
10391 @end example
10392 where the value in @var{dest} will be the result returned from the
10393 built-in.
10394 @end deftypefn
10396 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10397 Generates
10398 @example
10399 flag  @var{a}
10400 @end example
10401 @end deftypefn
10403 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10404 The operand, @var{auxv}, is the address of an auxiliary register and
10405 must be a compile time constant.  Generates:
10406 @example
10407 lr  @var{dest}, [@var{auxr}]
10408 @end example
10409 Where the value in @var{dest} will be the result returned from the
10410 built-in.
10411 @end deftypefn
10413 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10414 Only available with @option{-mmul64}.  Generates:
10415 @example
10416 mul64  @var{a}, @var{b}
10417 @end example
10418 @end deftypefn
10420 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10421 Only available with @option{-mmul64}.  Generates:
10422 @example
10423 mulu64  @var{a}, @var{b}
10424 @end example
10425 @end deftypefn
10427 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10428 Generates:
10429 @example
10431 @end example
10432 @end deftypefn
10434 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10435 Only valid if the @samp{norm} instruction is available through the
10436 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10437 Generates:
10438 @example
10439 norm  @var{dest}, @var{src}
10440 @end example
10441 Where the value in @var{dest} will be the result returned from the
10442 built-in.
10443 @end deftypefn
10445 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
10446 Only valid if the @samp{normw} instruction is available through the
10447 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10448 Generates:
10449 @example
10450 normw  @var{dest}, @var{src}
10451 @end example
10452 Where the value in @var{dest} will be the result returned from the
10453 built-in.
10454 @end deftypefn
10456 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
10457 Generates:
10458 @example
10459 rtie
10460 @end example
10461 @end deftypefn
10463 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
10464 Generates:
10465 @example
10466 sleep  @var{a}
10467 @end example
10468 @end deftypefn
10470 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10471 The first argument, @var{auxv}, is the address of an auxiliary
10472 register, the second argument, @var{val}, is a compile time constant
10473 to be written to the register.  Generates:
10474 @example
10475 sr  @var{auxr}, [@var{val}]
10476 @end example
10477 @end deftypefn
10479 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
10480 Only valid with @option{-mswap}.  Generates:
10481 @example
10482 swap  @var{dest}, @var{src}
10483 @end example
10484 Where the value in @var{dest} will be the result returned from the
10485 built-in.
10486 @end deftypefn
10488 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
10489 Generates:
10490 @example
10492 @end example
10493 @end deftypefn
10495 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
10496 Only available with @option{-mcpu=ARC700}.  Generates:
10497 @example
10498 sync
10499 @end example
10500 @end deftypefn
10502 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
10503 Only available with @option{-mcpu=ARC700}.  Generates:
10504 @example
10505 trap_s  @var{c}
10506 @end example
10507 @end deftypefn
10509 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
10510 Only available with @option{-mcpu=ARC700}.  Generates:
10511 @example
10512 unimp_s
10513 @end example
10514 @end deftypefn
10516 The instructions generated by the following builtins are not
10517 considered as candidates for scheduling.  They are not moved around by
10518 the compiler during scheduling, and thus can be expected to appear
10519 where they are put in the C code:
10520 @example
10521 __builtin_arc_brk()
10522 __builtin_arc_core_read()
10523 __builtin_arc_core_write()
10524 __builtin_arc_flag()
10525 __builtin_arc_lr()
10526 __builtin_arc_sleep()
10527 __builtin_arc_sr()
10528 __builtin_arc_swi()
10529 @end example
10531 @node ARC SIMD Built-in Functions
10532 @subsection ARC SIMD Built-in Functions
10534 SIMD builtins provided by the compiler can be used to generate the
10535 vector instructions.  This section describes the available builtins
10536 and their usage in programs.  With the @option{-msimd} option, the
10537 compiler provides 128-bit vector types, which can be specified using
10538 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
10539 can be included to use the following predefined types:
10540 @example
10541 typedef int __v4si   __attribute__((vector_size(16)));
10542 typedef short __v8hi __attribute__((vector_size(16)));
10543 @end example
10545 These types can be used to define 128-bit variables.  The built-in
10546 functions listed in the following section can be used on these
10547 variables to generate the vector operations.
10549 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10550 @file{arc-simd.h} also provides equivalent macros called
10551 @code{_@var{someinsn}} that can be used for programming ease and
10552 improved readability.  The following macros for DMA control are also
10553 provided:
10554 @example
10555 #define _setup_dma_in_channel_reg _vdiwr
10556 #define _setup_dma_out_channel_reg _vdowr
10557 @end example
10559 The following is a complete list of all the SIMD built-ins provided
10560 for ARC, grouped by calling signature.
10562 The following take two @code{__v8hi} arguments and return a
10563 @code{__v8hi} result:
10564 @example
10565 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10566 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10567 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10568 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10569 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10570 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10571 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10572 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10573 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10574 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10575 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10576 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10577 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10578 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10579 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10580 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10581 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10582 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10583 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10584 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10585 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10586 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10587 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10588 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10589 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10590 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10591 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10592 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10593 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10594 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10595 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10596 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10597 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10598 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10599 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10600 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10601 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10602 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10603 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10604 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10605 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10606 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10607 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10608 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10609 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10610 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10611 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10612 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10613 @end example
10615 The following take one @code{__v8hi} and one @code{int} argument and return a
10616 @code{__v8hi} result:
10618 @example
10619 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10620 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10621 __v8hi __builtin_arc_vbminw (__v8hi, int)
10622 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10623 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10624 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10625 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10626 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10627 @end example
10629 The following take one @code{__v8hi} argument and one @code{int} argument which
10630 must be a 3-bit compile time constant indicating a register number
10631 I0-I7.  They return a @code{__v8hi} result.
10632 @example
10633 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10634 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10635 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10636 @end example
10638 The following take one @code{__v8hi} argument and one @code{int}
10639 argument which must be a 6-bit compile time constant.  They return a
10640 @code{__v8hi} result.
10641 @example
10642 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10643 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10644 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10645 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10646 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10647 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10648 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10649 @end example
10651 The following take one @code{__v8hi} argument and one @code{int} argument which
10652 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10653 result.
10654 @example
10655 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10656 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10657 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10658 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10659 @end example
10661 The following take two @code{int} arguments, the second of which which
10662 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10663 result:
10664 @example
10665 __v8hi __builtin_arc_vmovaw (int, const int)
10666 __v8hi __builtin_arc_vmovw (int, const int)
10667 __v8hi __builtin_arc_vmovzw (int, const int)
10668 @end example
10670 The following take a single @code{__v8hi} argument and return a
10671 @code{__v8hi} result:
10672 @example
10673 __v8hi __builtin_arc_vabsaw (__v8hi)
10674 __v8hi __builtin_arc_vabsw (__v8hi)
10675 __v8hi __builtin_arc_vaddsuw (__v8hi)
10676 __v8hi __builtin_arc_vexch1 (__v8hi)
10677 __v8hi __builtin_arc_vexch2 (__v8hi)
10678 __v8hi __builtin_arc_vexch4 (__v8hi)
10679 __v8hi __builtin_arc_vsignw (__v8hi)
10680 __v8hi __builtin_arc_vupbaw (__v8hi)
10681 __v8hi __builtin_arc_vupbw (__v8hi)
10682 __v8hi __builtin_arc_vupsbaw (__v8hi)
10683 __v8hi __builtin_arc_vupsbw (__v8hi)
10684 @end example
10686 The followign take two @code{int} arguments and return no result:
10687 @example
10688 void __builtin_arc_vdirun (int, int)
10689 void __builtin_arc_vdorun (int, int)
10690 @end example
10692 The following take two @code{int} arguments and return no result.  The
10693 first argument must a 3-bit compile time constant indicating one of
10694 the DR0-DR7 DMA setup channels:
10695 @example
10696 void __builtin_arc_vdiwr (const int, int)
10697 void __builtin_arc_vdowr (const int, int)
10698 @end example
10700 The following take an @code{int} argument and return no result:
10701 @example
10702 void __builtin_arc_vendrec (int)
10703 void __builtin_arc_vrec (int)
10704 void __builtin_arc_vrecrun (int)
10705 void __builtin_arc_vrun (int)
10706 @end example
10708 The following take a @code{__v8hi} argument and two @code{int}
10709 arguments and return a @code{__v8hi} result.  The second argument must
10710 be a 3-bit compile time constants, indicating one the registers I0-I7,
10711 and the third argument must be an 8-bit compile time constant.
10713 @emph{Note:} Although the equivalent hardware instructions do not take
10714 an SIMD register as an operand, these builtins overwrite the relevant
10715 bits of the @code{__v8hi} register provided as the first argument with
10716 the value loaded from the @code{[Ib, u8]} location in the SDM.
10718 @example
10719 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10720 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10721 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10722 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10723 @end example
10725 The following take two @code{int} arguments and return a @code{__v8hi}
10726 result.  The first argument must be a 3-bit compile time constants,
10727 indicating one the registers I0-I7, and the second argument must be an
10728 8-bit compile time constant.
10730 @example
10731 __v8hi __builtin_arc_vld128 (const int, const int)
10732 __v8hi __builtin_arc_vld64w (const int, const int)
10733 @end example
10735 The following take a @code{__v8hi} argument and two @code{int}
10736 arguments and return no result.  The second argument must be a 3-bit
10737 compile time constants, indicating one the registers I0-I7, and the
10738 third argument must be an 8-bit compile time constant.
10740 @example
10741 void __builtin_arc_vst128 (__v8hi, const int, const int)
10742 void __builtin_arc_vst64 (__v8hi, const int, const int)
10743 @end example
10745 The following take a @code{__v8hi} argument and three @code{int}
10746 arguments and return no result.  The second argument must be a 3-bit
10747 compile-time constant, identifying the 16-bit sub-register to be
10748 stored, the third argument must be a 3-bit compile time constants,
10749 indicating one the registers I0-I7, and the fourth argument must be an
10750 8-bit compile time constant.
10752 @example
10753 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10754 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10755 @end example
10757 @node ARM iWMMXt Built-in Functions
10758 @subsection ARM iWMMXt Built-in Functions
10760 These built-in functions are available for the ARM family of
10761 processors when the @option{-mcpu=iwmmxt} switch is used:
10763 @smallexample
10764 typedef int v2si __attribute__ ((vector_size (8)));
10765 typedef short v4hi __attribute__ ((vector_size (8)));
10766 typedef char v8qi __attribute__ ((vector_size (8)));
10768 int __builtin_arm_getwcgr0 (void)
10769 void __builtin_arm_setwcgr0 (int)
10770 int __builtin_arm_getwcgr1 (void)
10771 void __builtin_arm_setwcgr1 (int)
10772 int __builtin_arm_getwcgr2 (void)
10773 void __builtin_arm_setwcgr2 (int)
10774 int __builtin_arm_getwcgr3 (void)
10775 void __builtin_arm_setwcgr3 (int)
10776 int __builtin_arm_textrmsb (v8qi, int)
10777 int __builtin_arm_textrmsh (v4hi, int)
10778 int __builtin_arm_textrmsw (v2si, int)
10779 int __builtin_arm_textrmub (v8qi, int)
10780 int __builtin_arm_textrmuh (v4hi, int)
10781 int __builtin_arm_textrmuw (v2si, int)
10782 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10783 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10784 v2si __builtin_arm_tinsrw (v2si, int, int)
10785 long long __builtin_arm_tmia (long long, int, int)
10786 long long __builtin_arm_tmiabb (long long, int, int)
10787 long long __builtin_arm_tmiabt (long long, int, int)
10788 long long __builtin_arm_tmiaph (long long, int, int)
10789 long long __builtin_arm_tmiatb (long long, int, int)
10790 long long __builtin_arm_tmiatt (long long, int, int)
10791 int __builtin_arm_tmovmskb (v8qi)
10792 int __builtin_arm_tmovmskh (v4hi)
10793 int __builtin_arm_tmovmskw (v2si)
10794 long long __builtin_arm_waccb (v8qi)
10795 long long __builtin_arm_wacch (v4hi)
10796 long long __builtin_arm_waccw (v2si)
10797 v8qi __builtin_arm_waddb (v8qi, v8qi)
10798 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10799 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10800 v4hi __builtin_arm_waddh (v4hi, v4hi)
10801 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10802 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10803 v2si __builtin_arm_waddw (v2si, v2si)
10804 v2si __builtin_arm_waddwss (v2si, v2si)
10805 v2si __builtin_arm_waddwus (v2si, v2si)
10806 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10807 long long __builtin_arm_wand(long long, long long)
10808 long long __builtin_arm_wandn (long long, long long)
10809 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10810 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10811 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10812 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10813 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10814 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10815 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10816 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10817 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10818 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10819 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10820 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10821 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10822 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10823 long long __builtin_arm_wmacsz (v4hi, v4hi)
10824 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10825 long long __builtin_arm_wmacuz (v4hi, v4hi)
10826 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10827 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10828 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10829 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10830 v2si __builtin_arm_wmaxsw (v2si, v2si)
10831 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10832 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10833 v2si __builtin_arm_wmaxuw (v2si, v2si)
10834 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10835 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10836 v2si __builtin_arm_wminsw (v2si, v2si)
10837 v8qi __builtin_arm_wminub (v8qi, v8qi)
10838 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10839 v2si __builtin_arm_wminuw (v2si, v2si)
10840 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10841 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10842 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10843 long long __builtin_arm_wor (long long, long long)
10844 v2si __builtin_arm_wpackdss (long long, long long)
10845 v2si __builtin_arm_wpackdus (long long, long long)
10846 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10847 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10848 v4hi __builtin_arm_wpackwss (v2si, v2si)
10849 v4hi __builtin_arm_wpackwus (v2si, v2si)
10850 long long __builtin_arm_wrord (long long, long long)
10851 long long __builtin_arm_wrordi (long long, int)
10852 v4hi __builtin_arm_wrorh (v4hi, long long)
10853 v4hi __builtin_arm_wrorhi (v4hi, int)
10854 v2si __builtin_arm_wrorw (v2si, long long)
10855 v2si __builtin_arm_wrorwi (v2si, int)
10856 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10857 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10858 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10859 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10860 v4hi __builtin_arm_wshufh (v4hi, int)
10861 long long __builtin_arm_wslld (long long, long long)
10862 long long __builtin_arm_wslldi (long long, int)
10863 v4hi __builtin_arm_wsllh (v4hi, long long)
10864 v4hi __builtin_arm_wsllhi (v4hi, int)
10865 v2si __builtin_arm_wsllw (v2si, long long)
10866 v2si __builtin_arm_wsllwi (v2si, int)
10867 long long __builtin_arm_wsrad (long long, long long)
10868 long long __builtin_arm_wsradi (long long, int)
10869 v4hi __builtin_arm_wsrah (v4hi, long long)
10870 v4hi __builtin_arm_wsrahi (v4hi, int)
10871 v2si __builtin_arm_wsraw (v2si, long long)
10872 v2si __builtin_arm_wsrawi (v2si, int)
10873 long long __builtin_arm_wsrld (long long, long long)
10874 long long __builtin_arm_wsrldi (long long, int)
10875 v4hi __builtin_arm_wsrlh (v4hi, long long)
10876 v4hi __builtin_arm_wsrlhi (v4hi, int)
10877 v2si __builtin_arm_wsrlw (v2si, long long)
10878 v2si __builtin_arm_wsrlwi (v2si, int)
10879 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10880 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10881 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10882 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10883 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10884 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10885 v2si __builtin_arm_wsubw (v2si, v2si)
10886 v2si __builtin_arm_wsubwss (v2si, v2si)
10887 v2si __builtin_arm_wsubwus (v2si, v2si)
10888 v4hi __builtin_arm_wunpckehsb (v8qi)
10889 v2si __builtin_arm_wunpckehsh (v4hi)
10890 long long __builtin_arm_wunpckehsw (v2si)
10891 v4hi __builtin_arm_wunpckehub (v8qi)
10892 v2si __builtin_arm_wunpckehuh (v4hi)
10893 long long __builtin_arm_wunpckehuw (v2si)
10894 v4hi __builtin_arm_wunpckelsb (v8qi)
10895 v2si __builtin_arm_wunpckelsh (v4hi)
10896 long long __builtin_arm_wunpckelsw (v2si)
10897 v4hi __builtin_arm_wunpckelub (v8qi)
10898 v2si __builtin_arm_wunpckeluh (v4hi)
10899 long long __builtin_arm_wunpckeluw (v2si)
10900 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10901 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10902 v2si __builtin_arm_wunpckihw (v2si, v2si)
10903 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10904 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10905 v2si __builtin_arm_wunpckilw (v2si, v2si)
10906 long long __builtin_arm_wxor (long long, long long)
10907 long long __builtin_arm_wzero ()
10908 @end smallexample
10911 @node ARM C Language Extensions (ACLE)
10912 @subsection ARM C Language Extensions (ACLE)
10914 GCC implements extensions for C as described in the ARM C Language
10915 Extensions (ACLE) specification, which can be found at
10916 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
10918 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
10919 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
10920 intrinsics can be found at
10921 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
10922 The built-in intrinsics for the Advanced SIMD extension are available when
10923 NEON is enabled.
10925 Currently, ARM and AArch64 back-ends do not support ACLE 2.0 fully.  Both
10926 back-ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM backend's
10927 16-bit floating-point Advanded SIMD Intrinsics currently comply to ACLE v1.1.
10928 AArch64's backend does not have support for 16-bit floating point Advanced SIMD
10929 Intrinsics yet.
10931 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
10932 availability of extensions.
10934 @node ARM Floating Point Status and Control Intrinsics
10935 @subsection ARM Floating Point Status and Control Intrinsics
10937 These built-in functions are available for the ARM family of
10938 processors with floating-point unit.
10940 @smallexample
10941 unsigned int __builtin_arm_get_fpscr ()
10942 void __builtin_arm_set_fpscr (unsigned int)
10943 @end smallexample
10945 @node AVR Built-in Functions
10946 @subsection AVR Built-in Functions
10948 For each built-in function for AVR, there is an equally named,
10949 uppercase built-in macro defined. That way users can easily query if
10950 or if not a specific built-in is implemented or not. For example, if
10951 @code{__builtin_avr_nop} is available the macro
10952 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10954 The following built-in functions map to the respective machine
10955 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10956 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10957 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10958 as library call if no hardware multiplier is available.
10960 @smallexample
10961 void __builtin_avr_nop (void)
10962 void __builtin_avr_sei (void)
10963 void __builtin_avr_cli (void)
10964 void __builtin_avr_sleep (void)
10965 void __builtin_avr_wdr (void)
10966 unsigned char __builtin_avr_swap (unsigned char)
10967 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10968 int __builtin_avr_fmuls (char, char)
10969 int __builtin_avr_fmulsu (char, unsigned char)
10970 @end smallexample
10972 In order to delay execution for a specific number of cycles, GCC
10973 implements
10974 @smallexample
10975 void __builtin_avr_delay_cycles (unsigned long ticks)
10976 @end smallexample
10978 @noindent
10979 @code{ticks} is the number of ticks to delay execution. Note that this
10980 built-in does not take into account the effect of interrupts that
10981 might increase delay time. @code{ticks} must be a compile-time
10982 integer constant; delays with a variable number of cycles are not supported.
10984 @smallexample
10985 char __builtin_avr_flash_segment (const __memx void*)
10986 @end smallexample
10988 @noindent
10989 This built-in takes a byte address to the 24-bit
10990 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10991 the number of the flash segment (the 64 KiB chunk) where the address
10992 points to.  Counting starts at @code{0}.
10993 If the address does not point to flash memory, return @code{-1}.
10995 @smallexample
10996 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10997 @end smallexample
10999 @noindent
11000 Insert bits from @var{bits} into @var{val} and return the resulting
11001 value. The nibbles of @var{map} determine how the insertion is
11002 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
11003 @enumerate
11004 @item If @var{X} is @code{0xf},
11005 then the @var{n}-th bit of @var{val} is returned unaltered.
11007 @item If X is in the range 0@dots{}7,
11008 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
11010 @item If X is in the range 8@dots{}@code{0xe},
11011 then the @var{n}-th result bit is undefined.
11012 @end enumerate
11014 @noindent
11015 One typical use case for this built-in is adjusting input and
11016 output values to non-contiguous port layouts. Some examples:
11018 @smallexample
11019 // same as val, bits is unused
11020 __builtin_avr_insert_bits (0xffffffff, bits, val)
11021 @end smallexample
11023 @smallexample
11024 // same as bits, val is unused
11025 __builtin_avr_insert_bits (0x76543210, bits, val)
11026 @end smallexample
11028 @smallexample
11029 // same as rotating bits by 4
11030 __builtin_avr_insert_bits (0x32107654, bits, 0)
11031 @end smallexample
11033 @smallexample
11034 // high nibble of result is the high nibble of val
11035 // low nibble of result is the low nibble of bits
11036 __builtin_avr_insert_bits (0xffff3210, bits, val)
11037 @end smallexample
11039 @smallexample
11040 // reverse the bit order of bits
11041 __builtin_avr_insert_bits (0x01234567, bits, 0)
11042 @end smallexample
11044 @node Blackfin Built-in Functions
11045 @subsection Blackfin Built-in Functions
11047 Currently, there are two Blackfin-specific built-in functions.  These are
11048 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
11049 using inline assembly; by using these built-in functions the compiler can
11050 automatically add workarounds for hardware errata involving these
11051 instructions.  These functions are named as follows:
11053 @smallexample
11054 void __builtin_bfin_csync (void)
11055 void __builtin_bfin_ssync (void)
11056 @end smallexample
11058 @node FR-V Built-in Functions
11059 @subsection FR-V Built-in Functions
11061 GCC provides many FR-V-specific built-in functions.  In general,
11062 these functions are intended to be compatible with those described
11063 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11064 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
11065 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11066 pointer rather than by value.
11068 Most of the functions are named after specific FR-V instructions.
11069 Such functions are said to be ``directly mapped'' and are summarized
11070 here in tabular form.
11072 @menu
11073 * Argument Types::
11074 * Directly-mapped Integer Functions::
11075 * Directly-mapped Media Functions::
11076 * Raw read/write Functions::
11077 * Other Built-in Functions::
11078 @end menu
11080 @node Argument Types
11081 @subsubsection Argument Types
11083 The arguments to the built-in functions can be divided into three groups:
11084 register numbers, compile-time constants and run-time values.  In order
11085 to make this classification clear at a glance, the arguments and return
11086 values are given the following pseudo types:
11088 @multitable @columnfractions .20 .30 .15 .35
11089 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11090 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11091 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11092 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11093 @item @code{uw2} @tab @code{unsigned long long} @tab No
11094 @tab an unsigned doubleword
11095 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11096 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11097 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11098 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11099 @end multitable
11101 These pseudo types are not defined by GCC, they are simply a notational
11102 convenience used in this manual.
11104 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11105 and @code{sw2} are evaluated at run time.  They correspond to
11106 register operands in the underlying FR-V instructions.
11108 @code{const} arguments represent immediate operands in the underlying
11109 FR-V instructions.  They must be compile-time constants.
11111 @code{acc} arguments are evaluated at compile time and specify the number
11112 of an accumulator register.  For example, an @code{acc} argument of 2
11113 selects the ACC2 register.
11115 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11116 number of an IACC register.  See @pxref{Other Built-in Functions}
11117 for more details.
11119 @node Directly-mapped Integer Functions
11120 @subsubsection Directly-mapped Integer Functions
11122 The functions listed below map directly to FR-V I-type instructions.
11124 @multitable @columnfractions .45 .32 .23
11125 @item Function prototype @tab Example usage @tab Assembly output
11126 @item @code{sw1 __ADDSS (sw1, sw1)}
11127 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11128 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11129 @item @code{sw1 __SCAN (sw1, sw1)}
11130 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11131 @tab @code{SCAN @var{a},@var{b},@var{c}}
11132 @item @code{sw1 __SCUTSS (sw1)}
11133 @tab @code{@var{b} = __SCUTSS (@var{a})}
11134 @tab @code{SCUTSS @var{a},@var{b}}
11135 @item @code{sw1 __SLASS (sw1, sw1)}
11136 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11137 @tab @code{SLASS @var{a},@var{b},@var{c}}
11138 @item @code{void __SMASS (sw1, sw1)}
11139 @tab @code{__SMASS (@var{a}, @var{b})}
11140 @tab @code{SMASS @var{a},@var{b}}
11141 @item @code{void __SMSSS (sw1, sw1)}
11142 @tab @code{__SMSSS (@var{a}, @var{b})}
11143 @tab @code{SMSSS @var{a},@var{b}}
11144 @item @code{void __SMU (sw1, sw1)}
11145 @tab @code{__SMU (@var{a}, @var{b})}
11146 @tab @code{SMU @var{a},@var{b}}
11147 @item @code{sw2 __SMUL (sw1, sw1)}
11148 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11149 @tab @code{SMUL @var{a},@var{b},@var{c}}
11150 @item @code{sw1 __SUBSS (sw1, sw1)}
11151 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11152 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11153 @item @code{uw2 __UMUL (uw1, uw1)}
11154 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11155 @tab @code{UMUL @var{a},@var{b},@var{c}}
11156 @end multitable
11158 @node Directly-mapped Media Functions
11159 @subsubsection Directly-mapped Media Functions
11161 The functions listed below map directly to FR-V M-type instructions.
11163 @multitable @columnfractions .45 .32 .23
11164 @item Function prototype @tab Example usage @tab Assembly output
11165 @item @code{uw1 __MABSHS (sw1)}
11166 @tab @code{@var{b} = __MABSHS (@var{a})}
11167 @tab @code{MABSHS @var{a},@var{b}}
11168 @item @code{void __MADDACCS (acc, acc)}
11169 @tab @code{__MADDACCS (@var{b}, @var{a})}
11170 @tab @code{MADDACCS @var{a},@var{b}}
11171 @item @code{sw1 __MADDHSS (sw1, sw1)}
11172 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11173 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11174 @item @code{uw1 __MADDHUS (uw1, uw1)}
11175 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11176 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11177 @item @code{uw1 __MAND (uw1, uw1)}
11178 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11179 @tab @code{MAND @var{a},@var{b},@var{c}}
11180 @item @code{void __MASACCS (acc, acc)}
11181 @tab @code{__MASACCS (@var{b}, @var{a})}
11182 @tab @code{MASACCS @var{a},@var{b}}
11183 @item @code{uw1 __MAVEH (uw1, uw1)}
11184 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11185 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11186 @item @code{uw2 __MBTOH (uw1)}
11187 @tab @code{@var{b} = __MBTOH (@var{a})}
11188 @tab @code{MBTOH @var{a},@var{b}}
11189 @item @code{void __MBTOHE (uw1 *, uw1)}
11190 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11191 @tab @code{MBTOHE @var{a},@var{b}}
11192 @item @code{void __MCLRACC (acc)}
11193 @tab @code{__MCLRACC (@var{a})}
11194 @tab @code{MCLRACC @var{a}}
11195 @item @code{void __MCLRACCA (void)}
11196 @tab @code{__MCLRACCA ()}
11197 @tab @code{MCLRACCA}
11198 @item @code{uw1 __Mcop1 (uw1, uw1)}
11199 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11200 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11201 @item @code{uw1 __Mcop2 (uw1, uw1)}
11202 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11203 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11204 @item @code{uw1 __MCPLHI (uw2, const)}
11205 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11206 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11207 @item @code{uw1 __MCPLI (uw2, const)}
11208 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11209 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11210 @item @code{void __MCPXIS (acc, sw1, sw1)}
11211 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11212 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11213 @item @code{void __MCPXIU (acc, uw1, uw1)}
11214 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11215 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11216 @item @code{void __MCPXRS (acc, sw1, sw1)}
11217 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11218 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11219 @item @code{void __MCPXRU (acc, uw1, uw1)}
11220 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11221 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11222 @item @code{uw1 __MCUT (acc, uw1)}
11223 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11224 @tab @code{MCUT @var{a},@var{b},@var{c}}
11225 @item @code{uw1 __MCUTSS (acc, sw1)}
11226 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11227 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11228 @item @code{void __MDADDACCS (acc, acc)}
11229 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11230 @tab @code{MDADDACCS @var{a},@var{b}}
11231 @item @code{void __MDASACCS (acc, acc)}
11232 @tab @code{__MDASACCS (@var{b}, @var{a})}
11233 @tab @code{MDASACCS @var{a},@var{b}}
11234 @item @code{uw2 __MDCUTSSI (acc, const)}
11235 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11236 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11237 @item @code{uw2 __MDPACKH (uw2, uw2)}
11238 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11239 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11240 @item @code{uw2 __MDROTLI (uw2, const)}
11241 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11242 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11243 @item @code{void __MDSUBACCS (acc, acc)}
11244 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11245 @tab @code{MDSUBACCS @var{a},@var{b}}
11246 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11247 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11248 @tab @code{MDUNPACKH @var{a},@var{b}}
11249 @item @code{uw2 __MEXPDHD (uw1, const)}
11250 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11251 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11252 @item @code{uw1 __MEXPDHW (uw1, const)}
11253 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11254 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11255 @item @code{uw1 __MHDSETH (uw1, const)}
11256 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11257 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11258 @item @code{sw1 __MHDSETS (const)}
11259 @tab @code{@var{b} = __MHDSETS (@var{a})}
11260 @tab @code{MHDSETS #@var{a},@var{b}}
11261 @item @code{uw1 __MHSETHIH (uw1, const)}
11262 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11263 @tab @code{MHSETHIH #@var{a},@var{b}}
11264 @item @code{sw1 __MHSETHIS (sw1, const)}
11265 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11266 @tab @code{MHSETHIS #@var{a},@var{b}}
11267 @item @code{uw1 __MHSETLOH (uw1, const)}
11268 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11269 @tab @code{MHSETLOH #@var{a},@var{b}}
11270 @item @code{sw1 __MHSETLOS (sw1, const)}
11271 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11272 @tab @code{MHSETLOS #@var{a},@var{b}}
11273 @item @code{uw1 __MHTOB (uw2)}
11274 @tab @code{@var{b} = __MHTOB (@var{a})}
11275 @tab @code{MHTOB @var{a},@var{b}}
11276 @item @code{void __MMACHS (acc, sw1, sw1)}
11277 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11278 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11279 @item @code{void __MMACHU (acc, uw1, uw1)}
11280 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11281 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11282 @item @code{void __MMRDHS (acc, sw1, sw1)}
11283 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11284 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11285 @item @code{void __MMRDHU (acc, uw1, uw1)}
11286 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11287 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11288 @item @code{void __MMULHS (acc, sw1, sw1)}
11289 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11290 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11291 @item @code{void __MMULHU (acc, uw1, uw1)}
11292 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11293 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11294 @item @code{void __MMULXHS (acc, sw1, sw1)}
11295 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11296 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11297 @item @code{void __MMULXHU (acc, uw1, uw1)}
11298 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11299 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11300 @item @code{uw1 __MNOT (uw1)}
11301 @tab @code{@var{b} = __MNOT (@var{a})}
11302 @tab @code{MNOT @var{a},@var{b}}
11303 @item @code{uw1 __MOR (uw1, uw1)}
11304 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11305 @tab @code{MOR @var{a},@var{b},@var{c}}
11306 @item @code{uw1 __MPACKH (uh, uh)}
11307 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11308 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11309 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11310 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11311 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11312 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11313 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11314 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11315 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11316 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11317 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11318 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11319 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11320 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11321 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11322 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11323 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11324 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11325 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11326 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11327 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11328 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11329 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11330 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11331 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11332 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11333 @item @code{void __MQMACHS (acc, sw2, sw2)}
11334 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11335 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11336 @item @code{void __MQMACHU (acc, uw2, uw2)}
11337 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11338 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11339 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11340 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11341 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11342 @item @code{void __MQMULHS (acc, sw2, sw2)}
11343 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11344 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11345 @item @code{void __MQMULHU (acc, uw2, uw2)}
11346 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11347 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11348 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11349 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11350 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11351 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11352 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11353 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11354 @item @code{sw2 __MQSATHS (sw2, sw2)}
11355 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11356 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11357 @item @code{uw2 __MQSLLHI (uw2, int)}
11358 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11359 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11360 @item @code{sw2 __MQSRAHI (sw2, int)}
11361 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11362 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11363 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11364 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11365 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11366 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11367 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11368 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11369 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11370 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11371 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11372 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11373 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11374 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11375 @item @code{uw1 __MRDACC (acc)}
11376 @tab @code{@var{b} = __MRDACC (@var{a})}
11377 @tab @code{MRDACC @var{a},@var{b}}
11378 @item @code{uw1 __MRDACCG (acc)}
11379 @tab @code{@var{b} = __MRDACCG (@var{a})}
11380 @tab @code{MRDACCG @var{a},@var{b}}
11381 @item @code{uw1 __MROTLI (uw1, const)}
11382 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11383 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11384 @item @code{uw1 __MROTRI (uw1, const)}
11385 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11386 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11387 @item @code{sw1 __MSATHS (sw1, sw1)}
11388 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11389 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11390 @item @code{uw1 __MSATHU (uw1, uw1)}
11391 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11392 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11393 @item @code{uw1 __MSLLHI (uw1, const)}
11394 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11395 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11396 @item @code{sw1 __MSRAHI (sw1, const)}
11397 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11398 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11399 @item @code{uw1 __MSRLHI (uw1, const)}
11400 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11401 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11402 @item @code{void __MSUBACCS (acc, acc)}
11403 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11404 @tab @code{MSUBACCS @var{a},@var{b}}
11405 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11406 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11407 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11408 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11409 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11410 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11411 @item @code{void __MTRAP (void)}
11412 @tab @code{__MTRAP ()}
11413 @tab @code{MTRAP}
11414 @item @code{uw2 __MUNPACKH (uw1)}
11415 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11416 @tab @code{MUNPACKH @var{a},@var{b}}
11417 @item @code{uw1 __MWCUT (uw2, uw1)}
11418 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11419 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11420 @item @code{void __MWTACC (acc, uw1)}
11421 @tab @code{__MWTACC (@var{b}, @var{a})}
11422 @tab @code{MWTACC @var{a},@var{b}}
11423 @item @code{void __MWTACCG (acc, uw1)}
11424 @tab @code{__MWTACCG (@var{b}, @var{a})}
11425 @tab @code{MWTACCG @var{a},@var{b}}
11426 @item @code{uw1 __MXOR (uw1, uw1)}
11427 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11428 @tab @code{MXOR @var{a},@var{b},@var{c}}
11429 @end multitable
11431 @node Raw read/write Functions
11432 @subsubsection Raw read/write Functions
11434 This sections describes built-in functions related to read and write
11435 instructions to access memory.  These functions generate
11436 @code{membar} instructions to flush the I/O load and stores where
11437 appropriate, as described in Fujitsu's manual described above.
11439 @table @code
11441 @item unsigned char __builtin_read8 (void *@var{data})
11442 @item unsigned short __builtin_read16 (void *@var{data})
11443 @item unsigned long __builtin_read32 (void *@var{data})
11444 @item unsigned long long __builtin_read64 (void *@var{data})
11446 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11447 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11448 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11449 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11450 @end table
11452 @node Other Built-in Functions
11453 @subsubsection Other Built-in Functions
11455 This section describes built-in functions that are not named after
11456 a specific FR-V instruction.
11458 @table @code
11459 @item sw2 __IACCreadll (iacc @var{reg})
11460 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
11461 for future expansion and must be 0.
11463 @item sw1 __IACCreadl (iacc @var{reg})
11464 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11465 Other values of @var{reg} are rejected as invalid.
11467 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11468 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
11469 is reserved for future expansion and must be 0.
11471 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11472 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11473 is 1.  Other values of @var{reg} are rejected as invalid.
11475 @item void __data_prefetch0 (const void *@var{x})
11476 Use the @code{dcpl} instruction to load the contents of address @var{x}
11477 into the data cache.
11479 @item void __data_prefetch (const void *@var{x})
11480 Use the @code{nldub} instruction to load the contents of address @var{x}
11481 into the data cache.  The instruction is issued in slot I1@.
11482 @end table
11484 @node X86 Built-in Functions
11485 @subsection X86 Built-in Functions
11487 These built-in functions are available for the i386 and x86-64 family
11488 of computers, depending on the command-line switches used.
11490 If you specify command-line switches such as @option{-msse},
11491 the compiler could use the extended instruction sets even if the built-ins
11492 are not used explicitly in the program.  For this reason, applications
11493 that perform run-time CPU detection must compile separate files for each
11494 supported architecture, using the appropriate flags.  In particular,
11495 the file containing the CPU detection code should be compiled without
11496 these options.
11498 The following machine modes are available for use with MMX built-in functions
11499 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11500 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11501 vector of eight 8-bit integers.  Some of the built-in functions operate on
11502 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11504 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11505 of two 32-bit floating-point values.
11507 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11508 floating-point values.  Some instructions use a vector of four 32-bit
11509 integers, these use @code{V4SI}.  Finally, some instructions operate on an
11510 entire vector register, interpreting it as a 128-bit integer, these use mode
11511 @code{TI}.
11513 In 64-bit mode, the x86-64 family of processors uses additional built-in
11514 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11515 floating point and @code{TC} 128-bit complex floating-point values.
11517 The following floating-point built-in functions are available in 64-bit
11518 mode.  All of them implement the function that is part of the name.
11520 @smallexample
11521 __float128 __builtin_fabsq (__float128)
11522 __float128 __builtin_copysignq (__float128, __float128)
11523 @end smallexample
11525 The following built-in function is always available.
11527 @table @code
11528 @item void __builtin_ia32_pause (void)
11529 Generates the @code{pause} machine instruction with a compiler memory
11530 barrier.
11531 @end table
11533 The following floating-point built-in functions are made available in the
11534 64-bit mode.
11536 @table @code
11537 @item __float128 __builtin_infq (void)
11538 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11539 @findex __builtin_infq
11541 @item __float128 __builtin_huge_valq (void)
11542 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11543 @findex __builtin_huge_valq
11544 @end table
11546 The following built-in functions are always available and can be used to
11547 check the target platform type.
11549 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11550 This function runs the CPU detection code to check the type of CPU and the
11551 features supported.  This built-in function needs to be invoked along with the built-in functions
11552 to check CPU type and features, @code{__builtin_cpu_is} and
11553 @code{__builtin_cpu_supports}, only when used in a function that is
11554 executed before any constructors are called.  The CPU detection code is
11555 automatically executed in a very high priority constructor.
11557 For example, this function has to be used in @code{ifunc} resolvers that
11558 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11559 and @code{__builtin_cpu_supports}, or in constructors on targets that
11560 don't support constructor priority.
11561 @smallexample
11563 static void (*resolve_memcpy (void)) (void)
11565   // ifunc resolvers fire before constructors, explicitly call the init
11566   // function.
11567   __builtin_cpu_init ();
11568   if (__builtin_cpu_supports ("ssse3"))
11569     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11570   else
11571     return default_memcpy;
11574 void *memcpy (void *, const void *, size_t)
11575      __attribute__ ((ifunc ("resolve_memcpy")));
11576 @end smallexample
11578 @end deftypefn
11580 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11581 This function returns a positive integer if the run-time CPU
11582 is of type @var{cpuname}
11583 and returns @code{0} otherwise. The following CPU names can be detected:
11585 @table @samp
11586 @item intel
11587 Intel CPU.
11589 @item atom
11590 Intel Atom CPU.
11592 @item core2
11593 Intel Core 2 CPU.
11595 @item corei7
11596 Intel Core i7 CPU.
11598 @item nehalem
11599 Intel Core i7 Nehalem CPU.
11601 @item westmere
11602 Intel Core i7 Westmere CPU.
11604 @item sandybridge
11605 Intel Core i7 Sandy Bridge CPU.
11607 @item amd
11608 AMD CPU.
11610 @item amdfam10h
11611 AMD Family 10h CPU.
11613 @item barcelona
11614 AMD Family 10h Barcelona CPU.
11616 @item shanghai
11617 AMD Family 10h Shanghai CPU.
11619 @item istanbul
11620 AMD Family 10h Istanbul CPU.
11622 @item btver1
11623 AMD Family 14h CPU.
11625 @item amdfam15h
11626 AMD Family 15h CPU.
11628 @item bdver1
11629 AMD Family 15h Bulldozer version 1.
11631 @item bdver2
11632 AMD Family 15h Bulldozer version 2.
11634 @item bdver3
11635 AMD Family 15h Bulldozer version 3.
11637 @item bdver4
11638 AMD Family 15h Bulldozer version 4.
11640 @item btver2
11641 AMD Family 16h CPU.
11642 @end table
11644 Here is an example:
11645 @smallexample
11646 if (__builtin_cpu_is ("corei7"))
11647   @{
11648      do_corei7 (); // Core i7 specific implementation.
11649   @}
11650 else
11651   @{
11652      do_generic (); // Generic implementation.
11653   @}
11654 @end smallexample
11655 @end deftypefn
11657 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11658 This function returns a positive integer if the run-time CPU
11659 supports @var{feature}
11660 and returns @code{0} otherwise. The following features can be detected:
11662 @table @samp
11663 @item cmov
11664 CMOV instruction.
11665 @item mmx
11666 MMX instructions.
11667 @item popcnt
11668 POPCNT instruction.
11669 @item sse
11670 SSE instructions.
11671 @item sse2
11672 SSE2 instructions.
11673 @item sse3
11674 SSE3 instructions.
11675 @item ssse3
11676 SSSE3 instructions.
11677 @item sse4.1
11678 SSE4.1 instructions.
11679 @item sse4.2
11680 SSE4.2 instructions.
11681 @item avx
11682 AVX instructions.
11683 @item avx2
11684 AVX2 instructions.
11685 @item avx512f
11686 AVX512F instructions.
11687 @end table
11689 Here is an example:
11690 @smallexample
11691 if (__builtin_cpu_supports ("popcnt"))
11692   @{
11693      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11694   @}
11695 else
11696   @{
11697      count = generic_countbits (n); //generic implementation.
11698   @}
11699 @end smallexample
11700 @end deftypefn
11703 The following built-in functions are made available by @option{-mmmx}.
11704 All of them generate the machine instruction that is part of the name.
11706 @smallexample
11707 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11708 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11709 v2si __builtin_ia32_paddd (v2si, v2si)
11710 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11711 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11712 v2si __builtin_ia32_psubd (v2si, v2si)
11713 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11714 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11715 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11716 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11717 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11718 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11719 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11720 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11721 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11722 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11723 di __builtin_ia32_pand (di, di)
11724 di __builtin_ia32_pandn (di,di)
11725 di __builtin_ia32_por (di, di)
11726 di __builtin_ia32_pxor (di, di)
11727 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11728 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11729 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11730 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11731 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11732 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11733 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11734 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11735 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11736 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11737 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11738 v2si __builtin_ia32_punpckldq (v2si, v2si)
11739 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11740 v4hi __builtin_ia32_packssdw (v2si, v2si)
11741 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11743 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11744 v2si __builtin_ia32_pslld (v2si, v2si)
11745 v1di __builtin_ia32_psllq (v1di, v1di)
11746 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11747 v2si __builtin_ia32_psrld (v2si, v2si)
11748 v1di __builtin_ia32_psrlq (v1di, v1di)
11749 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11750 v2si __builtin_ia32_psrad (v2si, v2si)
11751 v4hi __builtin_ia32_psllwi (v4hi, int)
11752 v2si __builtin_ia32_pslldi (v2si, int)
11753 v1di __builtin_ia32_psllqi (v1di, int)
11754 v4hi __builtin_ia32_psrlwi (v4hi, int)
11755 v2si __builtin_ia32_psrldi (v2si, int)
11756 v1di __builtin_ia32_psrlqi (v1di, int)
11757 v4hi __builtin_ia32_psrawi (v4hi, int)
11758 v2si __builtin_ia32_psradi (v2si, int)
11760 @end smallexample
11762 The following built-in functions are made available either with
11763 @option{-msse}, or with a combination of @option{-m3dnow} and
11764 @option{-march=athlon}.  All of them generate the machine
11765 instruction that is part of the name.
11767 @smallexample
11768 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11769 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11770 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11771 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11772 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11773 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11774 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11775 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11776 int __builtin_ia32_pmovmskb (v8qi)
11777 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11778 void __builtin_ia32_movntq (di *, di)
11779 void __builtin_ia32_sfence (void)
11780 @end smallexample
11782 The following built-in functions are available when @option{-msse} is used.
11783 All of them generate the machine instruction that is part of the name.
11785 @smallexample
11786 int __builtin_ia32_comieq (v4sf, v4sf)
11787 int __builtin_ia32_comineq (v4sf, v4sf)
11788 int __builtin_ia32_comilt (v4sf, v4sf)
11789 int __builtin_ia32_comile (v4sf, v4sf)
11790 int __builtin_ia32_comigt (v4sf, v4sf)
11791 int __builtin_ia32_comige (v4sf, v4sf)
11792 int __builtin_ia32_ucomieq (v4sf, v4sf)
11793 int __builtin_ia32_ucomineq (v4sf, v4sf)
11794 int __builtin_ia32_ucomilt (v4sf, v4sf)
11795 int __builtin_ia32_ucomile (v4sf, v4sf)
11796 int __builtin_ia32_ucomigt (v4sf, v4sf)
11797 int __builtin_ia32_ucomige (v4sf, v4sf)
11798 v4sf __builtin_ia32_addps (v4sf, v4sf)
11799 v4sf __builtin_ia32_subps (v4sf, v4sf)
11800 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11801 v4sf __builtin_ia32_divps (v4sf, v4sf)
11802 v4sf __builtin_ia32_addss (v4sf, v4sf)
11803 v4sf __builtin_ia32_subss (v4sf, v4sf)
11804 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11805 v4sf __builtin_ia32_divss (v4sf, v4sf)
11806 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11807 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11808 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11809 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11810 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11811 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11812 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11813 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11814 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11815 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11816 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11817 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11818 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11819 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11820 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11821 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11822 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11823 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11824 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11825 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11826 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11827 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11828 v4sf __builtin_ia32_minps (v4sf, v4sf)
11829 v4sf __builtin_ia32_minss (v4sf, v4sf)
11830 v4sf __builtin_ia32_andps (v4sf, v4sf)
11831 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11832 v4sf __builtin_ia32_orps (v4sf, v4sf)
11833 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11834 v4sf __builtin_ia32_movss (v4sf, v4sf)
11835 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11836 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11837 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11838 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11839 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11840 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11841 v2si __builtin_ia32_cvtps2pi (v4sf)
11842 int __builtin_ia32_cvtss2si (v4sf)
11843 v2si __builtin_ia32_cvttps2pi (v4sf)
11844 int __builtin_ia32_cvttss2si (v4sf)
11845 v4sf __builtin_ia32_rcpps (v4sf)
11846 v4sf __builtin_ia32_rsqrtps (v4sf)
11847 v4sf __builtin_ia32_sqrtps (v4sf)
11848 v4sf __builtin_ia32_rcpss (v4sf)
11849 v4sf __builtin_ia32_rsqrtss (v4sf)
11850 v4sf __builtin_ia32_sqrtss (v4sf)
11851 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11852 void __builtin_ia32_movntps (float *, v4sf)
11853 int __builtin_ia32_movmskps (v4sf)
11854 @end smallexample
11856 The following built-in functions are available when @option{-msse} is used.
11858 @table @code
11859 @item v4sf __builtin_ia32_loadups (float *)
11860 Generates the @code{movups} machine instruction as a load from memory.
11861 @item void __builtin_ia32_storeups (float *, v4sf)
11862 Generates the @code{movups} machine instruction as a store to memory.
11863 @item v4sf __builtin_ia32_loadss (float *)
11864 Generates the @code{movss} machine instruction as a load from memory.
11865 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11866 Generates the @code{movhps} machine instruction as a load from memory.
11867 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11868 Generates the @code{movlps} machine instruction as a load from memory
11869 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11870 Generates the @code{movhps} machine instruction as a store to memory.
11871 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11872 Generates the @code{movlps} machine instruction as a store to memory.
11873 @end table
11875 The following built-in functions are available when @option{-msse2} is used.
11876 All of them generate the machine instruction that is part of the name.
11878 @smallexample
11879 int __builtin_ia32_comisdeq (v2df, v2df)
11880 int __builtin_ia32_comisdlt (v2df, v2df)
11881 int __builtin_ia32_comisdle (v2df, v2df)
11882 int __builtin_ia32_comisdgt (v2df, v2df)
11883 int __builtin_ia32_comisdge (v2df, v2df)
11884 int __builtin_ia32_comisdneq (v2df, v2df)
11885 int __builtin_ia32_ucomisdeq (v2df, v2df)
11886 int __builtin_ia32_ucomisdlt (v2df, v2df)
11887 int __builtin_ia32_ucomisdle (v2df, v2df)
11888 int __builtin_ia32_ucomisdgt (v2df, v2df)
11889 int __builtin_ia32_ucomisdge (v2df, v2df)
11890 int __builtin_ia32_ucomisdneq (v2df, v2df)
11891 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11892 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11893 v2df __builtin_ia32_cmplepd (v2df, v2df)
11894 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11895 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11896 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11897 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11898 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11899 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11900 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11901 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11902 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11903 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11904 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11905 v2df __builtin_ia32_cmplesd (v2df, v2df)
11906 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11907 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11908 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11909 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11910 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11911 v2di __builtin_ia32_paddq (v2di, v2di)
11912 v2di __builtin_ia32_psubq (v2di, v2di)
11913 v2df __builtin_ia32_addpd (v2df, v2df)
11914 v2df __builtin_ia32_subpd (v2df, v2df)
11915 v2df __builtin_ia32_mulpd (v2df, v2df)
11916 v2df __builtin_ia32_divpd (v2df, v2df)
11917 v2df __builtin_ia32_addsd (v2df, v2df)
11918 v2df __builtin_ia32_subsd (v2df, v2df)
11919 v2df __builtin_ia32_mulsd (v2df, v2df)
11920 v2df __builtin_ia32_divsd (v2df, v2df)
11921 v2df __builtin_ia32_minpd (v2df, v2df)
11922 v2df __builtin_ia32_maxpd (v2df, v2df)
11923 v2df __builtin_ia32_minsd (v2df, v2df)
11924 v2df __builtin_ia32_maxsd (v2df, v2df)
11925 v2df __builtin_ia32_andpd (v2df, v2df)
11926 v2df __builtin_ia32_andnpd (v2df, v2df)
11927 v2df __builtin_ia32_orpd (v2df, v2df)
11928 v2df __builtin_ia32_xorpd (v2df, v2df)
11929 v2df __builtin_ia32_movsd (v2df, v2df)
11930 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11931 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11932 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11933 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11934 v4si __builtin_ia32_paddd128 (v4si, v4si)
11935 v2di __builtin_ia32_paddq128 (v2di, v2di)
11936 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11937 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11938 v4si __builtin_ia32_psubd128 (v4si, v4si)
11939 v2di __builtin_ia32_psubq128 (v2di, v2di)
11940 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11941 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11942 v2di __builtin_ia32_pand128 (v2di, v2di)
11943 v2di __builtin_ia32_pandn128 (v2di, v2di)
11944 v2di __builtin_ia32_por128 (v2di, v2di)
11945 v2di __builtin_ia32_pxor128 (v2di, v2di)
11946 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11947 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11948 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11949 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11950 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11951 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11952 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11953 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11954 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11955 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11956 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11957 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11958 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11959 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11960 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11961 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11962 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11963 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11964 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11965 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11966 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11967 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11968 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11969 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11970 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11971 v2df __builtin_ia32_loadupd (double *)
11972 void __builtin_ia32_storeupd (double *, v2df)
11973 v2df __builtin_ia32_loadhpd (v2df, double const *)
11974 v2df __builtin_ia32_loadlpd (v2df, double const *)
11975 int __builtin_ia32_movmskpd (v2df)
11976 int __builtin_ia32_pmovmskb128 (v16qi)
11977 void __builtin_ia32_movnti (int *, int)
11978 void __builtin_ia32_movnti64 (long long int *, long long int)
11979 void __builtin_ia32_movntpd (double *, v2df)
11980 void __builtin_ia32_movntdq (v2df *, v2df)
11981 v4si __builtin_ia32_pshufd (v4si, int)
11982 v8hi __builtin_ia32_pshuflw (v8hi, int)
11983 v8hi __builtin_ia32_pshufhw (v8hi, int)
11984 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11985 v2df __builtin_ia32_sqrtpd (v2df)
11986 v2df __builtin_ia32_sqrtsd (v2df)
11987 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11988 v2df __builtin_ia32_cvtdq2pd (v4si)
11989 v4sf __builtin_ia32_cvtdq2ps (v4si)
11990 v4si __builtin_ia32_cvtpd2dq (v2df)
11991 v2si __builtin_ia32_cvtpd2pi (v2df)
11992 v4sf __builtin_ia32_cvtpd2ps (v2df)
11993 v4si __builtin_ia32_cvttpd2dq (v2df)
11994 v2si __builtin_ia32_cvttpd2pi (v2df)
11995 v2df __builtin_ia32_cvtpi2pd (v2si)
11996 int __builtin_ia32_cvtsd2si (v2df)
11997 int __builtin_ia32_cvttsd2si (v2df)
11998 long long __builtin_ia32_cvtsd2si64 (v2df)
11999 long long __builtin_ia32_cvttsd2si64 (v2df)
12000 v4si __builtin_ia32_cvtps2dq (v4sf)
12001 v2df __builtin_ia32_cvtps2pd (v4sf)
12002 v4si __builtin_ia32_cvttps2dq (v4sf)
12003 v2df __builtin_ia32_cvtsi2sd (v2df, int)
12004 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
12005 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
12006 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
12007 void __builtin_ia32_clflush (const void *)
12008 void __builtin_ia32_lfence (void)
12009 void __builtin_ia32_mfence (void)
12010 v16qi __builtin_ia32_loaddqu (const char *)
12011 void __builtin_ia32_storedqu (char *, v16qi)
12012 v1di __builtin_ia32_pmuludq (v2si, v2si)
12013 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
12014 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
12015 v4si __builtin_ia32_pslld128 (v4si, v4si)
12016 v2di __builtin_ia32_psllq128 (v2di, v2di)
12017 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
12018 v4si __builtin_ia32_psrld128 (v4si, v4si)
12019 v2di __builtin_ia32_psrlq128 (v2di, v2di)
12020 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
12021 v4si __builtin_ia32_psrad128 (v4si, v4si)
12022 v2di __builtin_ia32_pslldqi128 (v2di, int)
12023 v8hi __builtin_ia32_psllwi128 (v8hi, int)
12024 v4si __builtin_ia32_pslldi128 (v4si, int)
12025 v2di __builtin_ia32_psllqi128 (v2di, int)
12026 v2di __builtin_ia32_psrldqi128 (v2di, int)
12027 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
12028 v4si __builtin_ia32_psrldi128 (v4si, int)
12029 v2di __builtin_ia32_psrlqi128 (v2di, int)
12030 v8hi __builtin_ia32_psrawi128 (v8hi, int)
12031 v4si __builtin_ia32_psradi128 (v4si, int)
12032 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
12033 v2di __builtin_ia32_movq128 (v2di)
12034 @end smallexample
12036 The following built-in functions are available when @option{-msse3} is used.
12037 All of them generate the machine instruction that is part of the name.
12039 @smallexample
12040 v2df __builtin_ia32_addsubpd (v2df, v2df)
12041 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
12042 v2df __builtin_ia32_haddpd (v2df, v2df)
12043 v4sf __builtin_ia32_haddps (v4sf, v4sf)
12044 v2df __builtin_ia32_hsubpd (v2df, v2df)
12045 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
12046 v16qi __builtin_ia32_lddqu (char const *)
12047 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
12048 v4sf __builtin_ia32_movshdup (v4sf)
12049 v4sf __builtin_ia32_movsldup (v4sf)
12050 void __builtin_ia32_mwait (unsigned int, unsigned int)
12051 @end smallexample
12053 The following built-in functions are available when @option{-mssse3} is used.
12054 All of them generate the machine instruction that is part of the name.
12056 @smallexample
12057 v2si __builtin_ia32_phaddd (v2si, v2si)
12058 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
12059 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
12060 v2si __builtin_ia32_phsubd (v2si, v2si)
12061 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
12062 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
12063 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
12064 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
12065 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
12066 v8qi __builtin_ia32_psignb (v8qi, v8qi)
12067 v2si __builtin_ia32_psignd (v2si, v2si)
12068 v4hi __builtin_ia32_psignw (v4hi, v4hi)
12069 v1di __builtin_ia32_palignr (v1di, v1di, int)
12070 v8qi __builtin_ia32_pabsb (v8qi)
12071 v2si __builtin_ia32_pabsd (v2si)
12072 v4hi __builtin_ia32_pabsw (v4hi)
12073 @end smallexample
12075 The following built-in functions are available when @option{-mssse3} is used.
12076 All of them generate the machine instruction that is part of the name.
12078 @smallexample
12079 v4si __builtin_ia32_phaddd128 (v4si, v4si)
12080 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
12081 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
12082 v4si __builtin_ia32_phsubd128 (v4si, v4si)
12083 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
12084 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
12085 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
12086 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
12087 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
12088 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
12089 v4si __builtin_ia32_psignd128 (v4si, v4si)
12090 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
12091 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
12092 v16qi __builtin_ia32_pabsb128 (v16qi)
12093 v4si __builtin_ia32_pabsd128 (v4si)
12094 v8hi __builtin_ia32_pabsw128 (v8hi)
12095 @end smallexample
12097 The following built-in functions are available when @option{-msse4.1} is
12098 used.  All of them generate the machine instruction that is part of the
12099 name.
12101 @smallexample
12102 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
12103 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
12104 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
12105 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
12106 v2df __builtin_ia32_dppd (v2df, v2df, const int)
12107 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
12108 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
12109 v2di __builtin_ia32_movntdqa (v2di *);
12110 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
12111 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
12112 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
12113 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
12114 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
12115 v8hi __builtin_ia32_phminposuw128 (v8hi)
12116 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
12117 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
12118 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
12119 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
12120 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
12121 v4si __builtin_ia32_pminsd128 (v4si, v4si)
12122 v4si __builtin_ia32_pminud128 (v4si, v4si)
12123 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
12124 v4si __builtin_ia32_pmovsxbd128 (v16qi)
12125 v2di __builtin_ia32_pmovsxbq128 (v16qi)
12126 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
12127 v2di __builtin_ia32_pmovsxdq128 (v4si)
12128 v4si __builtin_ia32_pmovsxwd128 (v8hi)
12129 v2di __builtin_ia32_pmovsxwq128 (v8hi)
12130 v4si __builtin_ia32_pmovzxbd128 (v16qi)
12131 v2di __builtin_ia32_pmovzxbq128 (v16qi)
12132 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
12133 v2di __builtin_ia32_pmovzxdq128 (v4si)
12134 v4si __builtin_ia32_pmovzxwd128 (v8hi)
12135 v2di __builtin_ia32_pmovzxwq128 (v8hi)
12136 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
12137 v4si __builtin_ia32_pmulld128 (v4si, v4si)
12138 int __builtin_ia32_ptestc128 (v2di, v2di)
12139 int __builtin_ia32_ptestnzc128 (v2di, v2di)
12140 int __builtin_ia32_ptestz128 (v2di, v2di)
12141 v2df __builtin_ia32_roundpd (v2df, const int)
12142 v4sf __builtin_ia32_roundps (v4sf, const int)
12143 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
12144 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
12145 @end smallexample
12147 The following built-in functions are available when @option{-msse4.1} is
12148 used.
12150 @table @code
12151 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
12152 Generates the @code{insertps} machine instruction.
12153 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
12154 Generates the @code{pextrb} machine instruction.
12155 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
12156 Generates the @code{pinsrb} machine instruction.
12157 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
12158 Generates the @code{pinsrd} machine instruction.
12159 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
12160 Generates the @code{pinsrq} machine instruction in 64bit mode.
12161 @end table
12163 The following built-in functions are changed to generate new SSE4.1
12164 instructions when @option{-msse4.1} is used.
12166 @table @code
12167 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
12168 Generates the @code{extractps} machine instruction.
12169 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
12170 Generates the @code{pextrd} machine instruction.
12171 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
12172 Generates the @code{pextrq} machine instruction in 64bit mode.
12173 @end table
12175 The following built-in functions are available when @option{-msse4.2} is
12176 used.  All of them generate the machine instruction that is part of the
12177 name.
12179 @smallexample
12180 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
12181 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
12182 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
12183 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
12184 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
12185 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
12186 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
12187 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
12188 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
12189 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
12190 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
12191 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
12192 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
12193 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
12194 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
12195 @end smallexample
12197 The following built-in functions are available when @option{-msse4.2} is
12198 used.
12200 @table @code
12201 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
12202 Generates the @code{crc32b} machine instruction.
12203 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
12204 Generates the @code{crc32w} machine instruction.
12205 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
12206 Generates the @code{crc32l} machine instruction.
12207 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
12208 Generates the @code{crc32q} machine instruction.
12209 @end table
12211 The following built-in functions are changed to generate new SSE4.2
12212 instructions when @option{-msse4.2} is used.
12214 @table @code
12215 @item int __builtin_popcount (unsigned int)
12216 Generates the @code{popcntl} machine instruction.
12217 @item int __builtin_popcountl (unsigned long)
12218 Generates the @code{popcntl} or @code{popcntq} machine instruction,
12219 depending on the size of @code{unsigned long}.
12220 @item int __builtin_popcountll (unsigned long long)
12221 Generates the @code{popcntq} machine instruction.
12222 @end table
12224 The following built-in functions are available when @option{-mavx} is
12225 used. All of them generate the machine instruction that is part of the
12226 name.
12228 @smallexample
12229 v4df __builtin_ia32_addpd256 (v4df,v4df)
12230 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
12231 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
12232 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
12233 v4df __builtin_ia32_andnpd256 (v4df,v4df)
12234 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
12235 v4df __builtin_ia32_andpd256 (v4df,v4df)
12236 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
12237 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
12238 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
12239 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
12240 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
12241 v2df __builtin_ia32_cmppd (v2df,v2df,int)
12242 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
12243 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
12244 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
12245 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
12246 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
12247 v4df __builtin_ia32_cvtdq2pd256 (v4si)
12248 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
12249 v4si __builtin_ia32_cvtpd2dq256 (v4df)
12250 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
12251 v8si __builtin_ia32_cvtps2dq256 (v8sf)
12252 v4df __builtin_ia32_cvtps2pd256 (v4sf)
12253 v4si __builtin_ia32_cvttpd2dq256 (v4df)
12254 v8si __builtin_ia32_cvttps2dq256 (v8sf)
12255 v4df __builtin_ia32_divpd256 (v4df,v4df)
12256 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
12257 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
12258 v4df __builtin_ia32_haddpd256 (v4df,v4df)
12259 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
12260 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
12261 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
12262 v32qi __builtin_ia32_lddqu256 (pcchar)
12263 v32qi __builtin_ia32_loaddqu256 (pcchar)
12264 v4df __builtin_ia32_loadupd256 (pcdouble)
12265 v8sf __builtin_ia32_loadups256 (pcfloat)
12266 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
12267 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
12268 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
12269 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
12270 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
12271 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
12272 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
12273 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
12274 v4df __builtin_ia32_maxpd256 (v4df,v4df)
12275 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
12276 v4df __builtin_ia32_minpd256 (v4df,v4df)
12277 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
12278 v4df __builtin_ia32_movddup256 (v4df)
12279 int __builtin_ia32_movmskpd256 (v4df)
12280 int __builtin_ia32_movmskps256 (v8sf)
12281 v8sf __builtin_ia32_movshdup256 (v8sf)
12282 v8sf __builtin_ia32_movsldup256 (v8sf)
12283 v4df __builtin_ia32_mulpd256 (v4df,v4df)
12284 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
12285 v4df __builtin_ia32_orpd256 (v4df,v4df)
12286 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
12287 v2df __builtin_ia32_pd_pd256 (v4df)
12288 v4df __builtin_ia32_pd256_pd (v2df)
12289 v4sf __builtin_ia32_ps_ps256 (v8sf)
12290 v8sf __builtin_ia32_ps256_ps (v4sf)
12291 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
12292 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
12293 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
12294 v8sf __builtin_ia32_rcpps256 (v8sf)
12295 v4df __builtin_ia32_roundpd256 (v4df,int)
12296 v8sf __builtin_ia32_roundps256 (v8sf,int)
12297 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
12298 v8sf __builtin_ia32_rsqrtps256 (v8sf)
12299 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
12300 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
12301 v4si __builtin_ia32_si_si256 (v8si)
12302 v8si __builtin_ia32_si256_si (v4si)
12303 v4df __builtin_ia32_sqrtpd256 (v4df)
12304 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
12305 v8sf __builtin_ia32_sqrtps256 (v8sf)
12306 void __builtin_ia32_storedqu256 (pchar,v32qi)
12307 void __builtin_ia32_storeupd256 (pdouble,v4df)
12308 void __builtin_ia32_storeups256 (pfloat,v8sf)
12309 v4df __builtin_ia32_subpd256 (v4df,v4df)
12310 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
12311 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
12312 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
12313 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
12314 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
12315 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
12316 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
12317 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
12318 v4sf __builtin_ia32_vbroadcastss (pcfloat)
12319 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
12320 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
12321 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
12322 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
12323 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
12324 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
12325 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
12326 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
12327 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
12328 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
12329 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
12330 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
12331 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
12332 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
12333 v2df __builtin_ia32_vpermilpd (v2df,int)
12334 v4df __builtin_ia32_vpermilpd256 (v4df,int)
12335 v4sf __builtin_ia32_vpermilps (v4sf,int)
12336 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
12337 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
12338 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
12339 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
12340 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
12341 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
12342 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
12343 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
12344 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
12345 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
12346 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
12347 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
12348 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
12349 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
12350 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
12351 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
12352 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
12353 void __builtin_ia32_vzeroall (void)
12354 void __builtin_ia32_vzeroupper (void)
12355 v4df __builtin_ia32_xorpd256 (v4df,v4df)
12356 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
12357 @end smallexample
12359 The following built-in functions are available when @option{-mavx2} is
12360 used. All of them generate the machine instruction that is part of the
12361 name.
12363 @smallexample
12364 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
12365 v32qi __builtin_ia32_pabsb256 (v32qi)
12366 v16hi __builtin_ia32_pabsw256 (v16hi)
12367 v8si __builtin_ia32_pabsd256 (v8si)
12368 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
12369 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
12370 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
12371 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
12372 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
12373 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
12374 v8si __builtin_ia32_paddd256 (v8si,v8si)
12375 v4di __builtin_ia32_paddq256 (v4di,v4di)
12376 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
12377 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
12378 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
12379 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
12380 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
12381 v4di __builtin_ia32_andsi256 (v4di,v4di)
12382 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
12383 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
12384 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
12385 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
12386 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
12387 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
12388 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
12389 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
12390 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
12391 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
12392 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
12393 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
12394 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
12395 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
12396 v8si __builtin_ia32_phaddd256 (v8si,v8si)
12397 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
12398 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
12399 v8si __builtin_ia32_phsubd256 (v8si,v8si)
12400 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
12401 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
12402 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
12403 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
12404 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
12405 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
12406 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
12407 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
12408 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
12409 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
12410 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
12411 v8si __builtin_ia32_pminsd256 (v8si,v8si)
12412 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
12413 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
12414 v8si __builtin_ia32_pminud256 (v8si,v8si)
12415 int __builtin_ia32_pmovmskb256 (v32qi)
12416 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
12417 v8si __builtin_ia32_pmovsxbd256 (v16qi)
12418 v4di __builtin_ia32_pmovsxbq256 (v16qi)
12419 v8si __builtin_ia32_pmovsxwd256 (v8hi)
12420 v4di __builtin_ia32_pmovsxwq256 (v8hi)
12421 v4di __builtin_ia32_pmovsxdq256 (v4si)
12422 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
12423 v8si __builtin_ia32_pmovzxbd256 (v16qi)
12424 v4di __builtin_ia32_pmovzxbq256 (v16qi)
12425 v8si __builtin_ia32_pmovzxwd256 (v8hi)
12426 v4di __builtin_ia32_pmovzxwq256 (v8hi)
12427 v4di __builtin_ia32_pmovzxdq256 (v4si)
12428 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12429 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12430 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12431 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12432 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12433 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12434 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12435 v4di __builtin_ia32_por256 (v4di,v4di)
12436 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12437 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12438 v8si __builtin_ia32_pshufd256 (v8si,int)
12439 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12440 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12441 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12442 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12443 v8si __builtin_ia32_psignd256 (v8si,v8si)
12444 v4di __builtin_ia32_pslldqi256 (v4di,int)
12445 v16hi __builtin_ia32_psllwi256 (16hi,int)
12446 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12447 v8si __builtin_ia32_pslldi256 (v8si,int)
12448 v8si __builtin_ia32_pslld256(v8si,v4si)
12449 v4di __builtin_ia32_psllqi256 (v4di,int)
12450 v4di __builtin_ia32_psllq256(v4di,v2di)
12451 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12452 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12453 v8si __builtin_ia32_psradi256 (v8si,int)
12454 v8si __builtin_ia32_psrad256 (v8si,v4si)
12455 v4di __builtin_ia32_psrldqi256 (v4di, int)
12456 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12457 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12458 v8si __builtin_ia32_psrldi256 (v8si,int)
12459 v8si __builtin_ia32_psrld256 (v8si,v4si)
12460 v4di __builtin_ia32_psrlqi256 (v4di,int)
12461 v4di __builtin_ia32_psrlq256(v4di,v2di)
12462 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12463 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12464 v8si __builtin_ia32_psubd256 (v8si,v8si)
12465 v4di __builtin_ia32_psubq256 (v4di,v4di)
12466 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12467 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12468 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12469 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12470 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12471 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12472 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12473 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12474 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12475 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12476 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12477 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12478 v4di __builtin_ia32_pxor256 (v4di,v4di)
12479 v4di __builtin_ia32_movntdqa256 (pv4di)
12480 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12481 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12482 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12483 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12484 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12485 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12486 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12487 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12488 v8si __builtin_ia32_pbroadcastd256 (v4si)
12489 v4di __builtin_ia32_pbroadcastq256 (v2di)
12490 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12491 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12492 v4si __builtin_ia32_pbroadcastd128 (v4si)
12493 v2di __builtin_ia32_pbroadcastq128 (v2di)
12494 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12495 v4df __builtin_ia32_permdf256 (v4df,int)
12496 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12497 v4di __builtin_ia32_permdi256 (v4di,int)
12498 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12499 v4di __builtin_ia32_extract128i256 (v4di,int)
12500 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12501 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12502 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12503 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12504 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12505 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12506 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12507 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12508 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12509 v8si __builtin_ia32_psllv8si (v8si,v8si)
12510 v4si __builtin_ia32_psllv4si (v4si,v4si)
12511 v4di __builtin_ia32_psllv4di (v4di,v4di)
12512 v2di __builtin_ia32_psllv2di (v2di,v2di)
12513 v8si __builtin_ia32_psrav8si (v8si,v8si)
12514 v4si __builtin_ia32_psrav4si (v4si,v4si)
12515 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12516 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12517 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12518 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12519 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12520 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12521 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12522 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12523 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12524 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12525 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12526 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12527 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12528 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12529 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12530 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12531 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12532 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12533 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12534 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12535 @end smallexample
12537 The following built-in functions are available when @option{-maes} is
12538 used.  All of them generate the machine instruction that is part of the
12539 name.
12541 @smallexample
12542 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12543 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12544 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12545 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12546 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12547 v2di __builtin_ia32_aesimc128 (v2di)
12548 @end smallexample
12550 The following built-in function is available when @option{-mpclmul} is
12551 used.
12553 @table @code
12554 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12555 Generates the @code{pclmulqdq} machine instruction.
12556 @end table
12558 The following built-in function is available when @option{-mfsgsbase} is
12559 used.  All of them generate the machine instruction that is part of the
12560 name.
12562 @smallexample
12563 unsigned int __builtin_ia32_rdfsbase32 (void)
12564 unsigned long long __builtin_ia32_rdfsbase64 (void)
12565 unsigned int __builtin_ia32_rdgsbase32 (void)
12566 unsigned long long __builtin_ia32_rdgsbase64 (void)
12567 void _writefsbase_u32 (unsigned int)
12568 void _writefsbase_u64 (unsigned long long)
12569 void _writegsbase_u32 (unsigned int)
12570 void _writegsbase_u64 (unsigned long long)
12571 @end smallexample
12573 The following built-in function is available when @option{-mrdrnd} is
12574 used.  All of them generate the machine instruction that is part of the
12575 name.
12577 @smallexample
12578 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12579 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12580 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12581 @end smallexample
12583 The following built-in functions are available when @option{-msse4a} is used.
12584 All of them generate the machine instruction that is part of the name.
12586 @smallexample
12587 void __builtin_ia32_movntsd (double *, v2df)
12588 void __builtin_ia32_movntss (float *, v4sf)
12589 v2di __builtin_ia32_extrq  (v2di, v16qi)
12590 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12591 v2di __builtin_ia32_insertq (v2di, v2di)
12592 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12593 @end smallexample
12595 The following built-in functions are available when @option{-mxop} is used.
12596 @smallexample
12597 v2df __builtin_ia32_vfrczpd (v2df)
12598 v4sf __builtin_ia32_vfrczps (v4sf)
12599 v2df __builtin_ia32_vfrczsd (v2df)
12600 v4sf __builtin_ia32_vfrczss (v4sf)
12601 v4df __builtin_ia32_vfrczpd256 (v4df)
12602 v8sf __builtin_ia32_vfrczps256 (v8sf)
12603 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12604 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12605 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12606 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12607 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12608 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12609 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12610 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12611 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12612 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12613 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12614 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12615 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12616 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12617 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12618 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12619 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12620 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12621 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12622 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12623 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12624 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12625 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12626 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12627 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12628 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12629 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12630 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12631 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12632 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12633 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12634 v4si __builtin_ia32_vpcomged (v4si, v4si)
12635 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12636 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12637 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12638 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12639 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12640 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12641 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12642 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12643 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12644 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12645 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12646 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12647 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12648 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12649 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12650 v4si __builtin_ia32_vpcomled (v4si, v4si)
12651 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12652 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12653 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12654 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12655 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12656 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12657 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12658 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12659 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12660 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12661 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12662 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12663 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12664 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12665 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12666 v4si __builtin_ia32_vpcomned (v4si, v4si)
12667 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12668 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12669 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12670 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12671 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12672 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12673 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12674 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12675 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12676 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12677 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12678 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12679 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12680 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12681 v4si __builtin_ia32_vphaddbd (v16qi)
12682 v2di __builtin_ia32_vphaddbq (v16qi)
12683 v8hi __builtin_ia32_vphaddbw (v16qi)
12684 v2di __builtin_ia32_vphadddq (v4si)
12685 v4si __builtin_ia32_vphaddubd (v16qi)
12686 v2di __builtin_ia32_vphaddubq (v16qi)
12687 v8hi __builtin_ia32_vphaddubw (v16qi)
12688 v2di __builtin_ia32_vphaddudq (v4si)
12689 v4si __builtin_ia32_vphadduwd (v8hi)
12690 v2di __builtin_ia32_vphadduwq (v8hi)
12691 v4si __builtin_ia32_vphaddwd (v8hi)
12692 v2di __builtin_ia32_vphaddwq (v8hi)
12693 v8hi __builtin_ia32_vphsubbw (v16qi)
12694 v2di __builtin_ia32_vphsubdq (v4si)
12695 v4si __builtin_ia32_vphsubwd (v8hi)
12696 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12697 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12698 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12699 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12700 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12701 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12702 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12703 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12704 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12705 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12706 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12707 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12708 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12709 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12710 v4si __builtin_ia32_vprotd (v4si, v4si)
12711 v2di __builtin_ia32_vprotq (v2di, v2di)
12712 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12713 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12714 v4si __builtin_ia32_vpshad (v4si, v4si)
12715 v2di __builtin_ia32_vpshaq (v2di, v2di)
12716 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12717 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12718 v4si __builtin_ia32_vpshld (v4si, v4si)
12719 v2di __builtin_ia32_vpshlq (v2di, v2di)
12720 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12721 @end smallexample
12723 The following built-in functions are available when @option{-mfma4} is used.
12724 All of them generate the machine instruction that is part of the name.
12726 @smallexample
12727 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12728 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12729 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12730 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12731 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12732 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12733 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12734 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12735 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12736 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12737 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12738 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12739 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12740 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12741 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12742 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12743 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
12744 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
12745 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
12746 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
12747 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12748 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12749 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12750 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12751 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12752 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12753 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12754 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12755 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12756 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12757 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12758 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12760 @end smallexample
12762 The following built-in functions are available when @option{-mlwp} is used.
12764 @smallexample
12765 void __builtin_ia32_llwpcb16 (void *);
12766 void __builtin_ia32_llwpcb32 (void *);
12767 void __builtin_ia32_llwpcb64 (void *);
12768 void * __builtin_ia32_llwpcb16 (void);
12769 void * __builtin_ia32_llwpcb32 (void);
12770 void * __builtin_ia32_llwpcb64 (void);
12771 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12772 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12773 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12774 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12775 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12776 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12777 @end smallexample
12779 The following built-in functions are available when @option{-mbmi} is used.
12780 All of them generate the machine instruction that is part of the name.
12781 @smallexample
12782 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12783 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12784 @end smallexample
12786 The following built-in functions are available when @option{-mbmi2} is used.
12787 All of them generate the machine instruction that is part of the name.
12788 @smallexample
12789 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12790 unsigned int _pdep_u32 (unsigned int, unsigned int)
12791 unsigned int _pext_u32 (unsigned int, unsigned int)
12792 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12793 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12794 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12795 @end smallexample
12797 The following built-in functions are available when @option{-mlzcnt} is used.
12798 All of them generate the machine instruction that is part of the name.
12799 @smallexample
12800 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12801 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12802 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12803 @end smallexample
12805 The following built-in functions are available when @option{-mfxsr} is used.
12806 All of them generate the machine instruction that is part of the name.
12807 @smallexample
12808 void __builtin_ia32_fxsave (void *)
12809 void __builtin_ia32_fxrstor (void *)
12810 void __builtin_ia32_fxsave64 (void *)
12811 void __builtin_ia32_fxrstor64 (void *)
12812 @end smallexample
12814 The following built-in functions are available when @option{-mxsave} is used.
12815 All of them generate the machine instruction that is part of the name.
12816 @smallexample
12817 void __builtin_ia32_xsave (void *, long long)
12818 void __builtin_ia32_xrstor (void *, long long)
12819 void __builtin_ia32_xsave64 (void *, long long)
12820 void __builtin_ia32_xrstor64 (void *, long long)
12821 @end smallexample
12823 The following built-in functions are available when @option{-mxsaveopt} is used.
12824 All of them generate the machine instruction that is part of the name.
12825 @smallexample
12826 void __builtin_ia32_xsaveopt (void *, long long)
12827 void __builtin_ia32_xsaveopt64 (void *, long long)
12828 @end smallexample
12830 The following built-in functions are available when @option{-mtbm} is used.
12831 Both of them generate the immediate form of the bextr machine instruction.
12832 @smallexample
12833 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12834 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12835 @end smallexample
12838 The following built-in functions are available when @option{-m3dnow} is used.
12839 All of them generate the machine instruction that is part of the name.
12841 @smallexample
12842 void __builtin_ia32_femms (void)
12843 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12844 v2si __builtin_ia32_pf2id (v2sf)
12845 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12846 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12847 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12848 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12849 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12850 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12851 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12852 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12853 v2sf __builtin_ia32_pfrcp (v2sf)
12854 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12855 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12856 v2sf __builtin_ia32_pfrsqrt (v2sf)
12857 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12858 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12859 v2sf __builtin_ia32_pi2fd (v2si)
12860 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12861 @end smallexample
12863 The following built-in functions are available when both @option{-m3dnow}
12864 and @option{-march=athlon} are used.  All of them generate the machine
12865 instruction that is part of the name.
12867 @smallexample
12868 v2si __builtin_ia32_pf2iw (v2sf)
12869 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12870 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12871 v2sf __builtin_ia32_pi2fw (v2si)
12872 v2sf __builtin_ia32_pswapdsf (v2sf)
12873 v2si __builtin_ia32_pswapdsi (v2si)
12874 @end smallexample
12876 The following built-in functions are available when @option{-mrtm} is used
12877 They are used for restricted transactional memory. These are the internal
12878 low level functions. Normally the functions in 
12879 @ref{X86 transactional memory intrinsics} should be used instead.
12881 @smallexample
12882 int __builtin_ia32_xbegin ()
12883 void __builtin_ia32_xend ()
12884 void __builtin_ia32_xabort (status)
12885 int __builtin_ia32_xtest ()
12886 @end smallexample
12888 @node X86 transactional memory intrinsics
12889 @subsection X86 transaction memory intrinsics
12891 Hardware transactional memory intrinsics for i386. These allow to use
12892 memory transactions with RTM (Restricted Transactional Memory).
12893 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12894 This support is enabled with the @option{-mrtm} option.
12896 A memory transaction commits all changes to memory in an atomic way,
12897 as visible to other threads. If the transaction fails it is rolled back
12898 and all side effects discarded.
12900 Generally there is no guarantee that a memory transaction ever succeeds
12901 and suitable fallback code always needs to be supplied.
12903 @deftypefn {RTM Function} {unsigned} _xbegin ()
12904 Start a RTM (Restricted Transactional Memory) transaction. 
12905 Returns _XBEGIN_STARTED when the transaction
12906 started successfully (note this is not 0, so the constant has to be 
12907 explicitely tested). When the transaction aborts all side effects
12908 are undone and an abort code is returned. There is no guarantee
12909 any transaction ever succeeds, so there always needs to be a valid
12910 tested fallback path.
12911 @end deftypefn
12913 @smallexample
12914 #include <immintrin.h>
12916 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12917     ... transaction code...
12918     _xend ();
12919 @} else @{
12920     ... non transactional fallback path...
12922 @end smallexample
12924 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12926 @table @code
12927 @item _XABORT_EXPLICIT
12928 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12929 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12930 @item _XABORT_RETRY
12931 Transaction retry is possible.
12932 @item _XABORT_CONFLICT
12933 Transaction abort due to a memory conflict with another thread
12934 @item _XABORT_CAPACITY
12935 Transaction abort due to the transaction using too much memory
12936 @item _XABORT_DEBUG
12937 Transaction abort due to a debug trap
12938 @item _XABORT_NESTED
12939 Transaction abort in a inner nested transaction
12940 @end table
12942 @deftypefn {RTM Function} {void} _xend ()
12943 Commit the current transaction. When no transaction is active this will
12944 fault. All memory side effects of the transactions will become visible
12945 to other threads in an atomic matter.
12946 @end deftypefn
12948 @deftypefn {RTM Function} {int} _xtest ()
12949 Return a value not zero when a transaction is currently active, otherwise 0.
12950 @end deftypefn
12952 @deftypefn {RTM Function} {void} _xabort (status)
12953 Abort the current transaction. When no transaction is active this is a no-op.
12954 status must be a 8bit constant, that is included in the status code returned
12955 by @code{_xbegin}
12956 @end deftypefn
12958 @node MIPS DSP Built-in Functions
12959 @subsection MIPS DSP Built-in Functions
12961 The MIPS DSP Application-Specific Extension (ASE) includes new
12962 instructions that are designed to improve the performance of DSP and
12963 media applications.  It provides instructions that operate on packed
12964 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12966 GCC supports MIPS DSP operations using both the generic
12967 vector extensions (@pxref{Vector Extensions}) and a collection of
12968 MIPS-specific built-in functions.  Both kinds of support are
12969 enabled by the @option{-mdsp} command-line option.
12971 Revision 2 of the ASE was introduced in the second half of 2006.
12972 This revision adds extra instructions to the original ASE, but is
12973 otherwise backwards-compatible with it.  You can select revision 2
12974 using the command-line option @option{-mdspr2}; this option implies
12975 @option{-mdsp}.
12977 The SCOUNT and POS bits of the DSP control register are global.  The
12978 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12979 POS bits.  During optimization, the compiler does not delete these
12980 instructions and it does not delete calls to functions containing
12981 these instructions.
12983 At present, GCC only provides support for operations on 32-bit
12984 vectors.  The vector type associated with 8-bit integer data is
12985 usually called @code{v4i8}, the vector type associated with Q7
12986 is usually called @code{v4q7}, the vector type associated with 16-bit
12987 integer data is usually called @code{v2i16}, and the vector type
12988 associated with Q15 is usually called @code{v2q15}.  They can be
12989 defined in C as follows:
12991 @smallexample
12992 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12993 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12994 typedef short v2i16 __attribute__ ((vector_size(4)));
12995 typedef short v2q15 __attribute__ ((vector_size(4)));
12996 @end smallexample
12998 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12999 initialized in the same way as aggregates.  For example:
13001 @smallexample
13002 v4i8 a = @{1, 2, 3, 4@};
13003 v4i8 b;
13004 b = (v4i8) @{5, 6, 7, 8@};
13006 v2q15 c = @{0x0fcb, 0x3a75@};
13007 v2q15 d;
13008 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13009 @end smallexample
13011 @emph{Note:} The CPU's endianness determines the order in which values
13012 are packed.  On little-endian targets, the first value is the least
13013 significant and the last value is the most significant.  The opposite
13014 order applies to big-endian targets.  For example, the code above
13015 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13016 and @code{4} on big-endian targets.
13018 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13019 representation.  As shown in this example, the integer representation
13020 of a Q7 value can be obtained by multiplying the fractional value by
13021 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
13022 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
13023 @code{0x1.0p31}.
13025 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13026 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
13027 and @code{c} and @code{d} are @code{v2q15} values.
13029 @multitable @columnfractions .50 .50
13030 @item C code @tab MIPS instruction
13031 @item @code{a + b} @tab @code{addu.qb}
13032 @item @code{c + d} @tab @code{addq.ph}
13033 @item @code{a - b} @tab @code{subu.qb}
13034 @item @code{c - d} @tab @code{subq.ph}
13035 @end multitable
13037 The table below lists the @code{v2i16} operation for which
13038 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
13039 @code{v2i16} values.
13041 @multitable @columnfractions .50 .50
13042 @item C code @tab MIPS instruction
13043 @item @code{e * f} @tab @code{mul.ph}
13044 @end multitable
13046 It is easier to describe the DSP built-in functions if we first define
13047 the following types:
13049 @smallexample
13050 typedef int q31;
13051 typedef int i32;
13052 typedef unsigned int ui32;
13053 typedef long long a64;
13054 @end smallexample
13056 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13057 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13058 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13059 @code{long long}, but we use @code{a64} to indicate values that are
13060 placed in one of the four DSP accumulators (@code{$ac0},
13061 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13063 Also, some built-in functions prefer or require immediate numbers as
13064 parameters, because the corresponding DSP instructions accept both immediate
13065 numbers and register operands, or accept immediate numbers only.  The
13066 immediate parameters are listed as follows.
13068 @smallexample
13069 imm0_3: 0 to 3.
13070 imm0_7: 0 to 7.
13071 imm0_15: 0 to 15.
13072 imm0_31: 0 to 31.
13073 imm0_63: 0 to 63.
13074 imm0_255: 0 to 255.
13075 imm_n32_31: -32 to 31.
13076 imm_n512_511: -512 to 511.
13077 @end smallexample
13079 The following built-in functions map directly to a particular MIPS DSP
13080 instruction.  Please refer to the architecture specification
13081 for details on what each instruction does.
13083 @smallexample
13084 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13085 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13086 q31 __builtin_mips_addq_s_w (q31, q31)
13087 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13088 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13089 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13090 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13091 q31 __builtin_mips_subq_s_w (q31, q31)
13092 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13093 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13094 i32 __builtin_mips_addsc (i32, i32)
13095 i32 __builtin_mips_addwc (i32, i32)
13096 i32 __builtin_mips_modsub (i32, i32)
13097 i32 __builtin_mips_raddu_w_qb (v4i8)
13098 v2q15 __builtin_mips_absq_s_ph (v2q15)
13099 q31 __builtin_mips_absq_s_w (q31)
13100 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13101 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13102 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13103 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13104 q31 __builtin_mips_preceq_w_phl (v2q15)
13105 q31 __builtin_mips_preceq_w_phr (v2q15)
13106 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13107 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13108 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13109 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13110 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13111 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13112 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13113 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13114 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13115 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13116 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13117 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13118 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13119 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13120 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13121 q31 __builtin_mips_shll_s_w (q31, i32)
13122 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13123 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13124 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13125 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13126 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13127 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13128 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13129 q31 __builtin_mips_shra_r_w (q31, i32)
13130 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13131 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13132 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13133 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13134 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13135 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13136 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13137 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13138 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13139 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13140 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13141 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13142 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13143 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13144 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13145 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13146 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13147 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13148 i32 __builtin_mips_bitrev (i32)
13149 i32 __builtin_mips_insv (i32, i32)
13150 v4i8 __builtin_mips_repl_qb (imm0_255)
13151 v4i8 __builtin_mips_repl_qb (i32)
13152 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13153 v2q15 __builtin_mips_repl_ph (i32)
13154 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13155 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13156 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13157 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13158 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13159 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13160 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13161 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13162 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13163 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13164 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13165 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13166 i32 __builtin_mips_extr_w (a64, imm0_31)
13167 i32 __builtin_mips_extr_w (a64, i32)
13168 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13169 i32 __builtin_mips_extr_s_h (a64, i32)
13170 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13171 i32 __builtin_mips_extr_rs_w (a64, i32)
13172 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13173 i32 __builtin_mips_extr_r_w (a64, i32)
13174 i32 __builtin_mips_extp (a64, imm0_31)
13175 i32 __builtin_mips_extp (a64, i32)
13176 i32 __builtin_mips_extpdp (a64, imm0_31)
13177 i32 __builtin_mips_extpdp (a64, i32)
13178 a64 __builtin_mips_shilo (a64, imm_n32_31)
13179 a64 __builtin_mips_shilo (a64, i32)
13180 a64 __builtin_mips_mthlip (a64, i32)
13181 void __builtin_mips_wrdsp (i32, imm0_63)
13182 i32 __builtin_mips_rddsp (imm0_63)
13183 i32 __builtin_mips_lbux (void *, i32)
13184 i32 __builtin_mips_lhx (void *, i32)
13185 i32 __builtin_mips_lwx (void *, i32)
13186 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13187 i32 __builtin_mips_bposge32 (void)
13188 a64 __builtin_mips_madd (a64, i32, i32);
13189 a64 __builtin_mips_maddu (a64, ui32, ui32);
13190 a64 __builtin_mips_msub (a64, i32, i32);
13191 a64 __builtin_mips_msubu (a64, ui32, ui32);
13192 a64 __builtin_mips_mult (i32, i32);
13193 a64 __builtin_mips_multu (ui32, ui32);
13194 @end smallexample
13196 The following built-in functions map directly to a particular MIPS DSP REV 2
13197 instruction.  Please refer to the architecture specification
13198 for details on what each instruction does.
13200 @smallexample
13201 v4q7 __builtin_mips_absq_s_qb (v4q7);
13202 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13203 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13204 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13205 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13206 i32 __builtin_mips_append (i32, i32, imm0_31);
13207 i32 __builtin_mips_balign (i32, i32, imm0_3);
13208 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13209 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13210 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13211 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13212 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13213 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13214 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13215 q31 __builtin_mips_mulq_rs_w (q31, q31);
13216 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13217 q31 __builtin_mips_mulq_s_w (q31, q31);
13218 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13219 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13220 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13221 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13222 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13223 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13224 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13225 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13226 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13227 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13228 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13229 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13230 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13231 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13232 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13233 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13234 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13235 q31 __builtin_mips_addqh_w (q31, q31);
13236 q31 __builtin_mips_addqh_r_w (q31, q31);
13237 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13238 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13239 q31 __builtin_mips_subqh_w (q31, q31);
13240 q31 __builtin_mips_subqh_r_w (q31, q31);
13241 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13242 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13243 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13244 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13245 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13246 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13247 @end smallexample
13250 @node MIPS Paired-Single Support
13251 @subsection MIPS Paired-Single Support
13253 The MIPS64 architecture includes a number of instructions that
13254 operate on pairs of single-precision floating-point values.
13255 Each pair is packed into a 64-bit floating-point register,
13256 with one element being designated the ``upper half'' and
13257 the other being designated the ``lower half''.
13259 GCC supports paired-single operations using both the generic
13260 vector extensions (@pxref{Vector Extensions}) and a collection of
13261 MIPS-specific built-in functions.  Both kinds of support are
13262 enabled by the @option{-mpaired-single} command-line option.
13264 The vector type associated with paired-single values is usually
13265 called @code{v2sf}.  It can be defined in C as follows:
13267 @smallexample
13268 typedef float v2sf __attribute__ ((vector_size (8)));
13269 @end smallexample
13271 @code{v2sf} values are initialized in the same way as aggregates.
13272 For example:
13274 @smallexample
13275 v2sf a = @{1.5, 9.1@};
13276 v2sf b;
13277 float e, f;
13278 b = (v2sf) @{e, f@};
13279 @end smallexample
13281 @emph{Note:} The CPU's endianness determines which value is stored in
13282 the upper half of a register and which value is stored in the lower half.
13283 On little-endian targets, the first value is the lower one and the second
13284 value is the upper one.  The opposite order applies to big-endian targets.
13285 For example, the code above sets the lower half of @code{a} to
13286 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13288 @node MIPS Loongson Built-in Functions
13289 @subsection MIPS Loongson Built-in Functions
13291 GCC provides intrinsics to access the SIMD instructions provided by the
13292 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
13293 available after inclusion of the @code{loongson.h} header file,
13294 operate on the following 64-bit vector types:
13296 @itemize
13297 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13298 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13299 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13300 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13301 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13302 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13303 @end itemize
13305 The intrinsics provided are listed below; each is named after the
13306 machine instruction to which it corresponds, with suffixes added as
13307 appropriate to distinguish intrinsics that expand to the same machine
13308 instruction yet have different argument types.  Refer to the architecture
13309 documentation for a description of the functionality of each
13310 instruction.
13312 @smallexample
13313 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13314 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13315 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13316 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13317 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13318 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13319 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13320 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13321 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13322 uint64_t paddd_u (uint64_t s, uint64_t t);
13323 int64_t paddd_s (int64_t s, int64_t t);
13324 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13325 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13326 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13327 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13328 uint64_t pandn_ud (uint64_t s, uint64_t t);
13329 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13330 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13331 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13332 int64_t pandn_sd (int64_t s, int64_t t);
13333 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13334 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13335 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13336 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13337 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13338 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13339 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13340 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13341 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13342 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13343 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13344 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13345 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13346 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13347 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13348 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13349 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13350 uint16x4_t pextrh_u (uint16x4_t s, int field);
13351 int16x4_t pextrh_s (int16x4_t s, int field);
13352 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13353 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13354 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13355 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13356 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13357 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13358 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13359 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13360 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13361 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13362 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13363 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13364 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13365 uint8x8_t pmovmskb_u (uint8x8_t s);
13366 int8x8_t pmovmskb_s (int8x8_t s);
13367 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13368 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13369 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13370 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13371 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13372 uint16x4_t biadd (uint8x8_t s);
13373 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13374 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13375 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13376 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13377 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13378 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13379 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13380 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13381 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13382 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13383 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13384 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13385 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13386 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13387 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13388 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13389 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13390 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13391 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13392 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13393 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13394 uint64_t psubd_u (uint64_t s, uint64_t t);
13395 int64_t psubd_s (int64_t s, int64_t t);
13396 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13397 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13398 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13399 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13400 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13401 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13402 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13403 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13404 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13405 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13406 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13407 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13408 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13409 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13410 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13411 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13412 @end smallexample
13414 @menu
13415 * Paired-Single Arithmetic::
13416 * Paired-Single Built-in Functions::
13417 * MIPS-3D Built-in Functions::
13418 @end menu
13420 @node Paired-Single Arithmetic
13421 @subsubsection Paired-Single Arithmetic
13423 The table below lists the @code{v2sf} operations for which hardware
13424 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
13425 values and @code{x} is an integral value.
13427 @multitable @columnfractions .50 .50
13428 @item C code @tab MIPS instruction
13429 @item @code{a + b} @tab @code{add.ps}
13430 @item @code{a - b} @tab @code{sub.ps}
13431 @item @code{-a} @tab @code{neg.ps}
13432 @item @code{a * b} @tab @code{mul.ps}
13433 @item @code{a * b + c} @tab @code{madd.ps}
13434 @item @code{a * b - c} @tab @code{msub.ps}
13435 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13436 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13437 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13438 @end multitable
13440 Note that the multiply-accumulate instructions can be disabled
13441 using the command-line option @code{-mno-fused-madd}.
13443 @node Paired-Single Built-in Functions
13444 @subsubsection Paired-Single Built-in Functions
13446 The following paired-single functions map directly to a particular
13447 MIPS instruction.  Please refer to the architecture specification
13448 for details on what each instruction does.
13450 @table @code
13451 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13452 Pair lower lower (@code{pll.ps}).
13454 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13455 Pair upper lower (@code{pul.ps}).
13457 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13458 Pair lower upper (@code{plu.ps}).
13460 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13461 Pair upper upper (@code{puu.ps}).
13463 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13464 Convert pair to paired single (@code{cvt.ps.s}).
13466 @item float __builtin_mips_cvt_s_pl (v2sf)
13467 Convert pair lower to single (@code{cvt.s.pl}).
13469 @item float __builtin_mips_cvt_s_pu (v2sf)
13470 Convert pair upper to single (@code{cvt.s.pu}).
13472 @item v2sf __builtin_mips_abs_ps (v2sf)
13473 Absolute value (@code{abs.ps}).
13475 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13476 Align variable (@code{alnv.ps}).
13478 @emph{Note:} The value of the third parameter must be 0 or 4
13479 modulo 8, otherwise the result is unpredictable.  Please read the
13480 instruction description for details.
13481 @end table
13483 The following multi-instruction functions are also available.
13484 In each case, @var{cond} can be any of the 16 floating-point conditions:
13485 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13486 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13487 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13489 @table @code
13490 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13491 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13492 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13493 @code{movt.ps}/@code{movf.ps}).
13495 The @code{movt} functions return the value @var{x} computed by:
13497 @smallexample
13498 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13499 mov.ps @var{x},@var{c}
13500 movt.ps @var{x},@var{d},@var{cc}
13501 @end smallexample
13503 The @code{movf} functions are similar but use @code{movf.ps} instead
13504 of @code{movt.ps}.
13506 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13507 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13508 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13509 @code{bc1t}/@code{bc1f}).
13511 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13512 and return either the upper or lower half of the result.  For example:
13514 @smallexample
13515 v2sf a, b;
13516 if (__builtin_mips_upper_c_eq_ps (a, b))
13517   upper_halves_are_equal ();
13518 else
13519   upper_halves_are_unequal ();
13521 if (__builtin_mips_lower_c_eq_ps (a, b))
13522   lower_halves_are_equal ();
13523 else
13524   lower_halves_are_unequal ();
13525 @end smallexample
13526 @end table
13528 @node MIPS-3D Built-in Functions
13529 @subsubsection MIPS-3D Built-in Functions
13531 The MIPS-3D Application-Specific Extension (ASE) includes additional
13532 paired-single instructions that are designed to improve the performance
13533 of 3D graphics operations.  Support for these instructions is controlled
13534 by the @option{-mips3d} command-line option.
13536 The functions listed below map directly to a particular MIPS-3D
13537 instruction.  Please refer to the architecture specification for
13538 more details on what each instruction does.
13540 @table @code
13541 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13542 Reduction add (@code{addr.ps}).
13544 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13545 Reduction multiply (@code{mulr.ps}).
13547 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13548 Convert paired single to paired word (@code{cvt.pw.ps}).
13550 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13551 Convert paired word to paired single (@code{cvt.ps.pw}).
13553 @item float __builtin_mips_recip1_s (float)
13554 @itemx double __builtin_mips_recip1_d (double)
13555 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13556 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13558 @item float __builtin_mips_recip2_s (float, float)
13559 @itemx double __builtin_mips_recip2_d (double, double)
13560 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13561 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13563 @item float __builtin_mips_rsqrt1_s (float)
13564 @itemx double __builtin_mips_rsqrt1_d (double)
13565 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13566 Reduced-precision reciprocal square root (sequence step 1)
13567 (@code{rsqrt1.@var{fmt}}).
13569 @item float __builtin_mips_rsqrt2_s (float, float)
13570 @itemx double __builtin_mips_rsqrt2_d (double, double)
13571 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13572 Reduced-precision reciprocal square root (sequence step 2)
13573 (@code{rsqrt2.@var{fmt}}).
13574 @end table
13576 The following multi-instruction functions are also available.
13577 In each case, @var{cond} can be any of the 16 floating-point conditions:
13578 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13579 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13580 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13582 @table @code
13583 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13584 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13585 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13586 @code{bc1t}/@code{bc1f}).
13588 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13589 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13590 For example:
13592 @smallexample
13593 float a, b;
13594 if (__builtin_mips_cabs_eq_s (a, b))
13595   true ();
13596 else
13597   false ();
13598 @end smallexample
13600 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13601 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13602 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13603 @code{bc1t}/@code{bc1f}).
13605 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13606 and return either the upper or lower half of the result.  For example:
13608 @smallexample
13609 v2sf a, b;
13610 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13611   upper_halves_are_equal ();
13612 else
13613   upper_halves_are_unequal ();
13615 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13616   lower_halves_are_equal ();
13617 else
13618   lower_halves_are_unequal ();
13619 @end smallexample
13621 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13622 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13623 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13624 @code{movt.ps}/@code{movf.ps}).
13626 The @code{movt} functions return the value @var{x} computed by:
13628 @smallexample
13629 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13630 mov.ps @var{x},@var{c}
13631 movt.ps @var{x},@var{d},@var{cc}
13632 @end smallexample
13634 The @code{movf} functions are similar but use @code{movf.ps} instead
13635 of @code{movt.ps}.
13637 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13638 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13639 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13640 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13641 Comparison of two paired-single values
13642 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13643 @code{bc1any2t}/@code{bc1any2f}).
13645 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13646 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13647 result is true and the @code{all} forms return true if both results are true.
13648 For example:
13650 @smallexample
13651 v2sf a, b;
13652 if (__builtin_mips_any_c_eq_ps (a, b))
13653   one_is_true ();
13654 else
13655   both_are_false ();
13657 if (__builtin_mips_all_c_eq_ps (a, b))
13658   both_are_true ();
13659 else
13660   one_is_false ();
13661 @end smallexample
13663 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13664 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13665 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13666 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13667 Comparison of four paired-single values
13668 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13669 @code{bc1any4t}/@code{bc1any4f}).
13671 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13672 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13673 The @code{any} forms return true if any of the four results are true
13674 and the @code{all} forms return true if all four results are true.
13675 For example:
13677 @smallexample
13678 v2sf a, b, c, d;
13679 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13680   some_are_true ();
13681 else
13682   all_are_false ();
13684 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13685   all_are_true ();
13686 else
13687   some_are_false ();
13688 @end smallexample
13689 @end table
13691 @node Other MIPS Built-in Functions
13692 @subsection Other MIPS Built-in Functions
13694 GCC provides other MIPS-specific built-in functions:
13696 @table @code
13697 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13698 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13699 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13700 when this function is available.
13702 @item unsigned int __builtin_mips_get_fcsr (void)
13703 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13704 Get and set the contents of the floating-point control and status register
13705 (FPU control register 31).  These functions are only available in hard-float
13706 code but can be called in both MIPS16 and non-MIPS16 contexts.
13708 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13709 register except the condition codes, which GCC assumes are preserved.
13710 @end table
13712 @node MSP430 Built-in Functions
13713 @subsection MSP430 Built-in Functions
13715 GCC provides a couple of special builtin functions to aid in the
13716 writing of interrupt handlers in C.
13718 @table @code
13719 @item __bic_SR_register_on_exit (int @var{mask})
13720 This clears the indicated bits in the saved copy of the status register
13721 currently residing on the stack.  This only works inside interrupt
13722 handlers and the changes to the status register will only take affect
13723 once the handler returns.
13725 @item __bis_SR_register_on_exit (int @var{mask})
13726 This sets the indicated bits in the saved copy of the status register
13727 currently residing on the stack.  This only works inside interrupt
13728 handlers and the changes to the status register will only take affect
13729 once the handler returns.
13731 @item __delay_cycles (long long @var{cycles})
13732 This inserts an instruction sequence that takes exactly @var{cycles}
13733 cycles (between 0 and about 17E9) to complete.  The inserted sequence
13734 may use jumps, loops, or no-ops, and does not interfere with any other
13735 instructions.  Note that @var{cycles} must be a compile-time constant
13736 integer - that is, you must pass a number, not a variable that may be
13737 optimized to a constant later.  The number of cycles delayed by this
13738 builtin is exact.
13739 @end table
13741 @node NDS32 Built-in Functions
13742 @subsection NDS32 Built-in Functions
13744 These built-in functions are available for the NDS32 target:
13746 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13747 Insert an ISYNC instruction into the instruction stream where
13748 @var{addr} is an instruction address for serialization.
13749 @end deftypefn
13751 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13752 Insert an ISB instruction into the instruction stream.
13753 @end deftypefn
13755 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13756 Return the content of a system register which is mapped by @var{sr}.
13757 @end deftypefn
13759 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13760 Return the content of a user space register which is mapped by @var{usr}.
13761 @end deftypefn
13763 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13764 Move the @var{value} to a system register which is mapped by @var{sr}.
13765 @end deftypefn
13767 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13768 Move the @var{value} to a user space register which is mapped by @var{usr}.
13769 @end deftypefn
13771 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13772 Enable global interrupt.
13773 @end deftypefn
13775 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13776 Disable global interrupt.
13777 @end deftypefn
13779 @node picoChip Built-in Functions
13780 @subsection picoChip Built-in Functions
13782 GCC provides an interface to selected machine instructions from the
13783 picoChip instruction set.
13785 @table @code
13786 @item int __builtin_sbc (int @var{value})
13787 Sign bit count.  Return the number of consecutive bits in @var{value}
13788 that have the same value as the sign bit.  The result is the number of
13789 leading sign bits minus one, giving the number of redundant sign bits in
13790 @var{value}.
13792 @item int __builtin_byteswap (int @var{value})
13793 Byte swap.  Return the result of swapping the upper and lower bytes of
13794 @var{value}.
13796 @item int __builtin_brev (int @var{value})
13797 Bit reversal.  Return the result of reversing the bits in
13798 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13799 and so on.
13801 @item int __builtin_adds (int @var{x}, int @var{y})
13802 Saturating addition.  Return the result of adding @var{x} and @var{y},
13803 storing the value 32767 if the result overflows.
13805 @item int __builtin_subs (int @var{x}, int @var{y})
13806 Saturating subtraction.  Return the result of subtracting @var{y} from
13807 @var{x}, storing the value @minus{}32768 if the result overflows.
13809 @item void __builtin_halt (void)
13810 Halt.  The processor stops execution.  This built-in is useful for
13811 implementing assertions.
13813 @end table
13815 @node PowerPC Built-in Functions
13816 @subsection PowerPC Built-in Functions
13818 These built-in functions are available for the PowerPC family of
13819 processors:
13820 @smallexample
13821 float __builtin_recipdivf (float, float);
13822 float __builtin_rsqrtf (float);
13823 double __builtin_recipdiv (double, double);
13824 double __builtin_rsqrt (double);
13825 uint64_t __builtin_ppc_get_timebase ();
13826 unsigned long __builtin_ppc_mftb ();
13827 double __builtin_unpack_longdouble (long double, int);
13828 long double __builtin_pack_longdouble (double, double);
13829 @end smallexample
13831 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13832 @code{__builtin_rsqrtf} functions generate multiple instructions to
13833 implement the reciprocal sqrt functionality using reciprocal sqrt
13834 estimate instructions.
13836 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13837 functions generate multiple instructions to implement division using
13838 the reciprocal estimate instructions.
13840 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13841 functions generate instructions to read the Time Base Register.  The
13842 @code{__builtin_ppc_get_timebase} function may generate multiple
13843 instructions and always returns the 64 bits of the Time Base Register.
13844 The @code{__builtin_ppc_mftb} function always generates one instruction and
13845 returns the Time Base Register value as an unsigned long, throwing away
13846 the most significant word on 32-bit environments.
13848 The following built-in functions are available for the PowerPC family
13849 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13850 or @option{-mpopcntd}):
13851 @smallexample
13852 long __builtin_bpermd (long, long);
13853 int __builtin_divwe (int, int);
13854 int __builtin_divweo (int, int);
13855 unsigned int __builtin_divweu (unsigned int, unsigned int);
13856 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13857 long __builtin_divde (long, long);
13858 long __builtin_divdeo (long, long);
13859 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13860 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13861 unsigned int cdtbcd (unsigned int);
13862 unsigned int cbcdtd (unsigned int);
13863 unsigned int addg6s (unsigned int, unsigned int);
13864 @end smallexample
13866 The @code{__builtin_divde}, @code{__builtin_divdeo},
13867 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13868 64-bit environment support ISA 2.06 or later.
13870 The following built-in functions are available for the PowerPC family
13871 of processors when hardware decimal floating point
13872 (@option{-mhard-dfp}) is available:
13873 @smallexample
13874 _Decimal64 __builtin_dxex (_Decimal64);
13875 _Decimal128 __builtin_dxexq (_Decimal128);
13876 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13877 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13878 _Decimal64 __builtin_denbcd (int, _Decimal64);
13879 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13880 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13881 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13882 _Decimal64 __builtin_dscli (_Decimal64, int);
13883 _Decimal128 __builitn_dscliq (_Decimal128, int);
13884 _Decimal64 __builtin_dscri (_Decimal64, int);
13885 _Decimal128 __builitn_dscriq (_Decimal128, int);
13886 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13887 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13888 @end smallexample
13890 The following built-in functions are available for the PowerPC family
13891 of processors when the Vector Scalar (vsx) instruction set is
13892 available:
13893 @smallexample
13894 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13895 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13896                                                 unsigned long long);
13897 @end smallexample
13899 @node PowerPC AltiVec/VSX Built-in Functions
13900 @subsection PowerPC AltiVec Built-in Functions
13902 GCC provides an interface for the PowerPC family of processors to access
13903 the AltiVec operations described in Motorola's AltiVec Programming
13904 Interface Manual.  The interface is made available by including
13905 @code{<altivec.h>} and using @option{-maltivec} and
13906 @option{-mabi=altivec}.  The interface supports the following vector
13907 types.
13909 @smallexample
13910 vector unsigned char
13911 vector signed char
13912 vector bool char
13914 vector unsigned short
13915 vector signed short
13916 vector bool short
13917 vector pixel
13919 vector unsigned int
13920 vector signed int
13921 vector bool int
13922 vector float
13923 @end smallexample
13925 If @option{-mvsx} is used the following additional vector types are
13926 implemented.
13928 @smallexample
13929 vector unsigned long
13930 vector signed long
13931 vector double
13932 @end smallexample
13934 The long types are only implemented for 64-bit code generation, and
13935 the long type is only used in the floating point/integer conversion
13936 instructions.
13938 GCC's implementation of the high-level language interface available from
13939 C and C++ code differs from Motorola's documentation in several ways.
13941 @itemize @bullet
13943 @item
13944 A vector constant is a list of constant expressions within curly braces.
13946 @item
13947 A vector initializer requires no cast if the vector constant is of the
13948 same type as the variable it is initializing.
13950 @item
13951 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13952 vector type is the default signedness of the base type.  The default
13953 varies depending on the operating system, so a portable program should
13954 always specify the signedness.
13956 @item
13957 Compiling with @option{-maltivec} adds keywords @code{__vector},
13958 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13959 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13960 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13961 disabled.  To use them, you must include @code{<altivec.h>} instead.
13963 @item
13964 GCC allows using a @code{typedef} name as the type specifier for a
13965 vector type.
13967 @item
13968 For C, overloaded functions are implemented with macros so the following
13969 does not work:
13971 @smallexample
13972   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13973 @end smallexample
13975 @noindent
13976 Since @code{vec_add} is a macro, the vector constant in the example
13977 is treated as four separate arguments.  Wrap the entire argument in
13978 parentheses for this to work.
13979 @end itemize
13981 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13982 Internally, GCC uses built-in functions to achieve the functionality in
13983 the aforementioned header file, but they are not supported and are
13984 subject to change without notice.
13986 The following interfaces are supported for the generic and specific
13987 AltiVec operations and the AltiVec predicates.  In cases where there
13988 is a direct mapping between generic and specific operations, only the
13989 generic names are shown here, although the specific operations can also
13990 be used.
13992 Arguments that are documented as @code{const int} require literal
13993 integral values within the range required for that operation.
13995 @smallexample
13996 vector signed char vec_abs (vector signed char);
13997 vector signed short vec_abs (vector signed short);
13998 vector signed int vec_abs (vector signed int);
13999 vector float vec_abs (vector float);
14001 vector signed char vec_abss (vector signed char);
14002 vector signed short vec_abss (vector signed short);
14003 vector signed int vec_abss (vector signed int);
14005 vector signed char vec_add (vector bool char, vector signed char);
14006 vector signed char vec_add (vector signed char, vector bool char);
14007 vector signed char vec_add (vector signed char, vector signed char);
14008 vector unsigned char vec_add (vector bool char, vector unsigned char);
14009 vector unsigned char vec_add (vector unsigned char, vector bool char);
14010 vector unsigned char vec_add (vector unsigned char,
14011                               vector unsigned char);
14012 vector signed short vec_add (vector bool short, vector signed short);
14013 vector signed short vec_add (vector signed short, vector bool short);
14014 vector signed short vec_add (vector signed short, vector signed short);
14015 vector unsigned short vec_add (vector bool short,
14016                                vector unsigned short);
14017 vector unsigned short vec_add (vector unsigned short,
14018                                vector bool short);
14019 vector unsigned short vec_add (vector unsigned short,
14020                                vector unsigned short);
14021 vector signed int vec_add (vector bool int, vector signed int);
14022 vector signed int vec_add (vector signed int, vector bool int);
14023 vector signed int vec_add (vector signed int, vector signed int);
14024 vector unsigned int vec_add (vector bool int, vector unsigned int);
14025 vector unsigned int vec_add (vector unsigned int, vector bool int);
14026 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
14027 vector float vec_add (vector float, vector float);
14029 vector float vec_vaddfp (vector float, vector float);
14031 vector signed int vec_vadduwm (vector bool int, vector signed int);
14032 vector signed int vec_vadduwm (vector signed int, vector bool int);
14033 vector signed int vec_vadduwm (vector signed int, vector signed int);
14034 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
14035 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
14036 vector unsigned int vec_vadduwm (vector unsigned int,
14037                                  vector unsigned int);
14039 vector signed short vec_vadduhm (vector bool short,
14040                                  vector signed short);
14041 vector signed short vec_vadduhm (vector signed short,
14042                                  vector bool short);
14043 vector signed short vec_vadduhm (vector signed short,
14044                                  vector signed short);
14045 vector unsigned short vec_vadduhm (vector bool short,
14046                                    vector unsigned short);
14047 vector unsigned short vec_vadduhm (vector unsigned short,
14048                                    vector bool short);
14049 vector unsigned short vec_vadduhm (vector unsigned short,
14050                                    vector unsigned short);
14052 vector signed char vec_vaddubm (vector bool char, vector signed char);
14053 vector signed char vec_vaddubm (vector signed char, vector bool char);
14054 vector signed char vec_vaddubm (vector signed char, vector signed char);
14055 vector unsigned char vec_vaddubm (vector bool char,
14056                                   vector unsigned char);
14057 vector unsigned char vec_vaddubm (vector unsigned char,
14058                                   vector bool char);
14059 vector unsigned char vec_vaddubm (vector unsigned char,
14060                                   vector unsigned char);
14062 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14064 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14065 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14066 vector unsigned char vec_adds (vector unsigned char,
14067                                vector unsigned char);
14068 vector signed char vec_adds (vector bool char, vector signed char);
14069 vector signed char vec_adds (vector signed char, vector bool char);
14070 vector signed char vec_adds (vector signed char, vector signed char);
14071 vector unsigned short vec_adds (vector bool short,
14072                                 vector unsigned short);
14073 vector unsigned short vec_adds (vector unsigned short,
14074                                 vector bool short);
14075 vector unsigned short vec_adds (vector unsigned short,
14076                                 vector unsigned short);
14077 vector signed short vec_adds (vector bool short, vector signed short);
14078 vector signed short vec_adds (vector signed short, vector bool short);
14079 vector signed short vec_adds (vector signed short, vector signed short);
14080 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14081 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14082 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14083 vector signed int vec_adds (vector bool int, vector signed int);
14084 vector signed int vec_adds (vector signed int, vector bool int);
14085 vector signed int vec_adds (vector signed int, vector signed int);
14087 vector signed int vec_vaddsws (vector bool int, vector signed int);
14088 vector signed int vec_vaddsws (vector signed int, vector bool int);
14089 vector signed int vec_vaddsws (vector signed int, vector signed int);
14091 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14092 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14093 vector unsigned int vec_vadduws (vector unsigned int,
14094                                  vector unsigned int);
14096 vector signed short vec_vaddshs (vector bool short,
14097                                  vector signed short);
14098 vector signed short vec_vaddshs (vector signed short,
14099                                  vector bool short);
14100 vector signed short vec_vaddshs (vector signed short,
14101                                  vector signed short);
14103 vector unsigned short vec_vadduhs (vector bool short,
14104                                    vector unsigned short);
14105 vector unsigned short vec_vadduhs (vector unsigned short,
14106                                    vector bool short);
14107 vector unsigned short vec_vadduhs (vector unsigned short,
14108                                    vector unsigned short);
14110 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14111 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14112 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14114 vector unsigned char vec_vaddubs (vector bool char,
14115                                   vector unsigned char);
14116 vector unsigned char vec_vaddubs (vector unsigned char,
14117                                   vector bool char);
14118 vector unsigned char vec_vaddubs (vector unsigned char,
14119                                   vector unsigned char);
14121 vector float vec_and (vector float, vector float);
14122 vector float vec_and (vector float, vector bool int);
14123 vector float vec_and (vector bool int, vector float);
14124 vector bool int vec_and (vector bool int, vector bool int);
14125 vector signed int vec_and (vector bool int, vector signed int);
14126 vector signed int vec_and (vector signed int, vector bool int);
14127 vector signed int vec_and (vector signed int, vector signed int);
14128 vector unsigned int vec_and (vector bool int, vector unsigned int);
14129 vector unsigned int vec_and (vector unsigned int, vector bool int);
14130 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14131 vector bool short vec_and (vector bool short, vector bool short);
14132 vector signed short vec_and (vector bool short, vector signed short);
14133 vector signed short vec_and (vector signed short, vector bool short);
14134 vector signed short vec_and (vector signed short, vector signed short);
14135 vector unsigned short vec_and (vector bool short,
14136                                vector unsigned short);
14137 vector unsigned short vec_and (vector unsigned short,
14138                                vector bool short);
14139 vector unsigned short vec_and (vector unsigned short,
14140                                vector unsigned short);
14141 vector signed char vec_and (vector bool char, vector signed char);
14142 vector bool char vec_and (vector bool char, vector bool char);
14143 vector signed char vec_and (vector signed char, vector bool char);
14144 vector signed char vec_and (vector signed char, vector signed char);
14145 vector unsigned char vec_and (vector bool char, vector unsigned char);
14146 vector unsigned char vec_and (vector unsigned char, vector bool char);
14147 vector unsigned char vec_and (vector unsigned char,
14148                               vector unsigned char);
14150 vector float vec_andc (vector float, vector float);
14151 vector float vec_andc (vector float, vector bool int);
14152 vector float vec_andc (vector bool int, vector float);
14153 vector bool int vec_andc (vector bool int, vector bool int);
14154 vector signed int vec_andc (vector bool int, vector signed int);
14155 vector signed int vec_andc (vector signed int, vector bool int);
14156 vector signed int vec_andc (vector signed int, vector signed int);
14157 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14158 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14159 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14160 vector bool short vec_andc (vector bool short, vector bool short);
14161 vector signed short vec_andc (vector bool short, vector signed short);
14162 vector signed short vec_andc (vector signed short, vector bool short);
14163 vector signed short vec_andc (vector signed short, vector signed short);
14164 vector unsigned short vec_andc (vector bool short,
14165                                 vector unsigned short);
14166 vector unsigned short vec_andc (vector unsigned short,
14167                                 vector bool short);
14168 vector unsigned short vec_andc (vector unsigned short,
14169                                 vector unsigned short);
14170 vector signed char vec_andc (vector bool char, vector signed char);
14171 vector bool char vec_andc (vector bool char, vector bool char);
14172 vector signed char vec_andc (vector signed char, vector bool char);
14173 vector signed char vec_andc (vector signed char, vector signed char);
14174 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14175 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14176 vector unsigned char vec_andc (vector unsigned char,
14177                                vector unsigned char);
14179 vector unsigned char vec_avg (vector unsigned char,
14180                               vector unsigned char);
14181 vector signed char vec_avg (vector signed char, vector signed char);
14182 vector unsigned short vec_avg (vector unsigned short,
14183                                vector unsigned short);
14184 vector signed short vec_avg (vector signed short, vector signed short);
14185 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14186 vector signed int vec_avg (vector signed int, vector signed int);
14188 vector signed int vec_vavgsw (vector signed int, vector signed int);
14190 vector unsigned int vec_vavguw (vector unsigned int,
14191                                 vector unsigned int);
14193 vector signed short vec_vavgsh (vector signed short,
14194                                 vector signed short);
14196 vector unsigned short vec_vavguh (vector unsigned short,
14197                                   vector unsigned short);
14199 vector signed char vec_vavgsb (vector signed char, vector signed char);
14201 vector unsigned char vec_vavgub (vector unsigned char,
14202                                  vector unsigned char);
14204 vector float vec_copysign (vector float);
14206 vector float vec_ceil (vector float);
14208 vector signed int vec_cmpb (vector float, vector float);
14210 vector bool char vec_cmpeq (vector signed char, vector signed char);
14211 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14212 vector bool short vec_cmpeq (vector signed short, vector signed short);
14213 vector bool short vec_cmpeq (vector unsigned short,
14214                              vector unsigned short);
14215 vector bool int vec_cmpeq (vector signed int, vector signed int);
14216 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14217 vector bool int vec_cmpeq (vector float, vector float);
14219 vector bool int vec_vcmpeqfp (vector float, vector float);
14221 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14222 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14224 vector bool short vec_vcmpequh (vector signed short,
14225                                 vector signed short);
14226 vector bool short vec_vcmpequh (vector unsigned short,
14227                                 vector unsigned short);
14229 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14230 vector bool char vec_vcmpequb (vector unsigned char,
14231                                vector unsigned char);
14233 vector bool int vec_cmpge (vector float, vector float);
14235 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14236 vector bool char vec_cmpgt (vector signed char, vector signed char);
14237 vector bool short vec_cmpgt (vector unsigned short,
14238                              vector unsigned short);
14239 vector bool short vec_cmpgt (vector signed short, vector signed short);
14240 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14241 vector bool int vec_cmpgt (vector signed int, vector signed int);
14242 vector bool int vec_cmpgt (vector float, vector float);
14244 vector bool int vec_vcmpgtfp (vector float, vector float);
14246 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14248 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14250 vector bool short vec_vcmpgtsh (vector signed short,
14251                                 vector signed short);
14253 vector bool short vec_vcmpgtuh (vector unsigned short,
14254                                 vector unsigned short);
14256 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14258 vector bool char vec_vcmpgtub (vector unsigned char,
14259                                vector unsigned char);
14261 vector bool int vec_cmple (vector float, vector float);
14263 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14264 vector bool char vec_cmplt (vector signed char, vector signed char);
14265 vector bool short vec_cmplt (vector unsigned short,
14266                              vector unsigned short);
14267 vector bool short vec_cmplt (vector signed short, vector signed short);
14268 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14269 vector bool int vec_cmplt (vector signed int, vector signed int);
14270 vector bool int vec_cmplt (vector float, vector float);
14272 vector float vec_cpsgn (vector float, vector float);
14274 vector float vec_ctf (vector unsigned int, const int);
14275 vector float vec_ctf (vector signed int, const int);
14276 vector double vec_ctf (vector unsigned long, const int);
14277 vector double vec_ctf (vector signed long, const int);
14279 vector float vec_vcfsx (vector signed int, const int);
14281 vector float vec_vcfux (vector unsigned int, const int);
14283 vector signed int vec_cts (vector float, const int);
14284 vector signed long vec_cts (vector double, const int);
14286 vector unsigned int vec_ctu (vector float, const int);
14287 vector unsigned long vec_ctu (vector double, const int);
14289 void vec_dss (const int);
14291 void vec_dssall (void);
14293 void vec_dst (const vector unsigned char *, int, const int);
14294 void vec_dst (const vector signed char *, int, const int);
14295 void vec_dst (const vector bool char *, int, const int);
14296 void vec_dst (const vector unsigned short *, int, const int);
14297 void vec_dst (const vector signed short *, int, const int);
14298 void vec_dst (const vector bool short *, int, const int);
14299 void vec_dst (const vector pixel *, int, const int);
14300 void vec_dst (const vector unsigned int *, int, const int);
14301 void vec_dst (const vector signed int *, int, const int);
14302 void vec_dst (const vector bool int *, int, const int);
14303 void vec_dst (const vector float *, int, const int);
14304 void vec_dst (const unsigned char *, int, const int);
14305 void vec_dst (const signed char *, int, const int);
14306 void vec_dst (const unsigned short *, int, const int);
14307 void vec_dst (const short *, int, const int);
14308 void vec_dst (const unsigned int *, int, const int);
14309 void vec_dst (const int *, int, const int);
14310 void vec_dst (const unsigned long *, int, const int);
14311 void vec_dst (const long *, int, const int);
14312 void vec_dst (const float *, int, const int);
14314 void vec_dstst (const vector unsigned char *, int, const int);
14315 void vec_dstst (const vector signed char *, int, const int);
14316 void vec_dstst (const vector bool char *, int, const int);
14317 void vec_dstst (const vector unsigned short *, int, const int);
14318 void vec_dstst (const vector signed short *, int, const int);
14319 void vec_dstst (const vector bool short *, int, const int);
14320 void vec_dstst (const vector pixel *, int, const int);
14321 void vec_dstst (const vector unsigned int *, int, const int);
14322 void vec_dstst (const vector signed int *, int, const int);
14323 void vec_dstst (const vector bool int *, int, const int);
14324 void vec_dstst (const vector float *, int, const int);
14325 void vec_dstst (const unsigned char *, int, const int);
14326 void vec_dstst (const signed char *, int, const int);
14327 void vec_dstst (const unsigned short *, int, const int);
14328 void vec_dstst (const short *, int, const int);
14329 void vec_dstst (const unsigned int *, int, const int);
14330 void vec_dstst (const int *, int, const int);
14331 void vec_dstst (const unsigned long *, int, const int);
14332 void vec_dstst (const long *, int, const int);
14333 void vec_dstst (const float *, int, const int);
14335 void vec_dststt (const vector unsigned char *, int, const int);
14336 void vec_dststt (const vector signed char *, int, const int);
14337 void vec_dststt (const vector bool char *, int, const int);
14338 void vec_dststt (const vector unsigned short *, int, const int);
14339 void vec_dststt (const vector signed short *, int, const int);
14340 void vec_dststt (const vector bool short *, int, const int);
14341 void vec_dststt (const vector pixel *, int, const int);
14342 void vec_dststt (const vector unsigned int *, int, const int);
14343 void vec_dststt (const vector signed int *, int, const int);
14344 void vec_dststt (const vector bool int *, int, const int);
14345 void vec_dststt (const vector float *, int, const int);
14346 void vec_dststt (const unsigned char *, int, const int);
14347 void vec_dststt (const signed char *, int, const int);
14348 void vec_dststt (const unsigned short *, int, const int);
14349 void vec_dststt (const short *, int, const int);
14350 void vec_dststt (const unsigned int *, int, const int);
14351 void vec_dststt (const int *, int, const int);
14352 void vec_dststt (const unsigned long *, int, const int);
14353 void vec_dststt (const long *, int, const int);
14354 void vec_dststt (const float *, int, const int);
14356 void vec_dstt (const vector unsigned char *, int, const int);
14357 void vec_dstt (const vector signed char *, int, const int);
14358 void vec_dstt (const vector bool char *, int, const int);
14359 void vec_dstt (const vector unsigned short *, int, const int);
14360 void vec_dstt (const vector signed short *, int, const int);
14361 void vec_dstt (const vector bool short *, int, const int);
14362 void vec_dstt (const vector pixel *, int, const int);
14363 void vec_dstt (const vector unsigned int *, int, const int);
14364 void vec_dstt (const vector signed int *, int, const int);
14365 void vec_dstt (const vector bool int *, int, const int);
14366 void vec_dstt (const vector float *, int, const int);
14367 void vec_dstt (const unsigned char *, int, const int);
14368 void vec_dstt (const signed char *, int, const int);
14369 void vec_dstt (const unsigned short *, int, const int);
14370 void vec_dstt (const short *, int, const int);
14371 void vec_dstt (const unsigned int *, int, const int);
14372 void vec_dstt (const int *, int, const int);
14373 void vec_dstt (const unsigned long *, int, const int);
14374 void vec_dstt (const long *, int, const int);
14375 void vec_dstt (const float *, int, const int);
14377 vector float vec_expte (vector float);
14379 vector float vec_floor (vector float);
14381 vector float vec_ld (int, const vector float *);
14382 vector float vec_ld (int, const float *);
14383 vector bool int vec_ld (int, const vector bool int *);
14384 vector signed int vec_ld (int, const vector signed int *);
14385 vector signed int vec_ld (int, const int *);
14386 vector signed int vec_ld (int, const long *);
14387 vector unsigned int vec_ld (int, const vector unsigned int *);
14388 vector unsigned int vec_ld (int, const unsigned int *);
14389 vector unsigned int vec_ld (int, const unsigned long *);
14390 vector bool short vec_ld (int, const vector bool short *);
14391 vector pixel vec_ld (int, const vector pixel *);
14392 vector signed short vec_ld (int, const vector signed short *);
14393 vector signed short vec_ld (int, const short *);
14394 vector unsigned short vec_ld (int, const vector unsigned short *);
14395 vector unsigned short vec_ld (int, const unsigned short *);
14396 vector bool char vec_ld (int, const vector bool char *);
14397 vector signed char vec_ld (int, const vector signed char *);
14398 vector signed char vec_ld (int, const signed char *);
14399 vector unsigned char vec_ld (int, const vector unsigned char *);
14400 vector unsigned char vec_ld (int, const unsigned char *);
14402 vector signed char vec_lde (int, const signed char *);
14403 vector unsigned char vec_lde (int, const unsigned char *);
14404 vector signed short vec_lde (int, const short *);
14405 vector unsigned short vec_lde (int, const unsigned short *);
14406 vector float vec_lde (int, const float *);
14407 vector signed int vec_lde (int, const int *);
14408 vector unsigned int vec_lde (int, const unsigned int *);
14409 vector signed int vec_lde (int, const long *);
14410 vector unsigned int vec_lde (int, const unsigned long *);
14412 vector float vec_lvewx (int, float *);
14413 vector signed int vec_lvewx (int, int *);
14414 vector unsigned int vec_lvewx (int, unsigned int *);
14415 vector signed int vec_lvewx (int, long *);
14416 vector unsigned int vec_lvewx (int, unsigned long *);
14418 vector signed short vec_lvehx (int, short *);
14419 vector unsigned short vec_lvehx (int, unsigned short *);
14421 vector signed char vec_lvebx (int, char *);
14422 vector unsigned char vec_lvebx (int, unsigned char *);
14424 vector float vec_ldl (int, const vector float *);
14425 vector float vec_ldl (int, const float *);
14426 vector bool int vec_ldl (int, const vector bool int *);
14427 vector signed int vec_ldl (int, const vector signed int *);
14428 vector signed int vec_ldl (int, const int *);
14429 vector signed int vec_ldl (int, const long *);
14430 vector unsigned int vec_ldl (int, const vector unsigned int *);
14431 vector unsigned int vec_ldl (int, const unsigned int *);
14432 vector unsigned int vec_ldl (int, const unsigned long *);
14433 vector bool short vec_ldl (int, const vector bool short *);
14434 vector pixel vec_ldl (int, const vector pixel *);
14435 vector signed short vec_ldl (int, const vector signed short *);
14436 vector signed short vec_ldl (int, const short *);
14437 vector unsigned short vec_ldl (int, const vector unsigned short *);
14438 vector unsigned short vec_ldl (int, const unsigned short *);
14439 vector bool char vec_ldl (int, const vector bool char *);
14440 vector signed char vec_ldl (int, const vector signed char *);
14441 vector signed char vec_ldl (int, const signed char *);
14442 vector unsigned char vec_ldl (int, const vector unsigned char *);
14443 vector unsigned char vec_ldl (int, const unsigned char *);
14445 vector float vec_loge (vector float);
14447 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14448 vector unsigned char vec_lvsl (int, const volatile signed char *);
14449 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14450 vector unsigned char vec_lvsl (int, const volatile short *);
14451 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14452 vector unsigned char vec_lvsl (int, const volatile int *);
14453 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14454 vector unsigned char vec_lvsl (int, const volatile long *);
14455 vector unsigned char vec_lvsl (int, const volatile float *);
14457 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14458 vector unsigned char vec_lvsr (int, const volatile signed char *);
14459 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14460 vector unsigned char vec_lvsr (int, const volatile short *);
14461 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14462 vector unsigned char vec_lvsr (int, const volatile int *);
14463 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14464 vector unsigned char vec_lvsr (int, const volatile long *);
14465 vector unsigned char vec_lvsr (int, const volatile float *);
14467 vector float vec_madd (vector float, vector float, vector float);
14469 vector signed short vec_madds (vector signed short,
14470                                vector signed short,
14471                                vector signed short);
14473 vector unsigned char vec_max (vector bool char, vector unsigned char);
14474 vector unsigned char vec_max (vector unsigned char, vector bool char);
14475 vector unsigned char vec_max (vector unsigned char,
14476                               vector unsigned char);
14477 vector signed char vec_max (vector bool char, vector signed char);
14478 vector signed char vec_max (vector signed char, vector bool char);
14479 vector signed char vec_max (vector signed char, vector signed char);
14480 vector unsigned short vec_max (vector bool short,
14481                                vector unsigned short);
14482 vector unsigned short vec_max (vector unsigned short,
14483                                vector bool short);
14484 vector unsigned short vec_max (vector unsigned short,
14485                                vector unsigned short);
14486 vector signed short vec_max (vector bool short, vector signed short);
14487 vector signed short vec_max (vector signed short, vector bool short);
14488 vector signed short vec_max (vector signed short, vector signed short);
14489 vector unsigned int vec_max (vector bool int, vector unsigned int);
14490 vector unsigned int vec_max (vector unsigned int, vector bool int);
14491 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14492 vector signed int vec_max (vector bool int, vector signed int);
14493 vector signed int vec_max (vector signed int, vector bool int);
14494 vector signed int vec_max (vector signed int, vector signed int);
14495 vector float vec_max (vector float, vector float);
14497 vector float vec_vmaxfp (vector float, vector float);
14499 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14500 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14501 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14503 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14504 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14505 vector unsigned int vec_vmaxuw (vector unsigned int,
14506                                 vector unsigned int);
14508 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14509 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14510 vector signed short vec_vmaxsh (vector signed short,
14511                                 vector signed short);
14513 vector unsigned short vec_vmaxuh (vector bool short,
14514                                   vector unsigned short);
14515 vector unsigned short vec_vmaxuh (vector unsigned short,
14516                                   vector bool short);
14517 vector unsigned short vec_vmaxuh (vector unsigned short,
14518                                   vector unsigned short);
14520 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14521 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14522 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14524 vector unsigned char vec_vmaxub (vector bool char,
14525                                  vector unsigned char);
14526 vector unsigned char vec_vmaxub (vector unsigned char,
14527                                  vector bool char);
14528 vector unsigned char vec_vmaxub (vector unsigned char,
14529                                  vector unsigned char);
14531 vector bool char vec_mergeh (vector bool char, vector bool char);
14532 vector signed char vec_mergeh (vector signed char, vector signed char);
14533 vector unsigned char vec_mergeh (vector unsigned char,
14534                                  vector unsigned char);
14535 vector bool short vec_mergeh (vector bool short, vector bool short);
14536 vector pixel vec_mergeh (vector pixel, vector pixel);
14537 vector signed short vec_mergeh (vector signed short,
14538                                 vector signed short);
14539 vector unsigned short vec_mergeh (vector unsigned short,
14540                                   vector unsigned short);
14541 vector float vec_mergeh (vector float, vector float);
14542 vector bool int vec_mergeh (vector bool int, vector bool int);
14543 vector signed int vec_mergeh (vector signed int, vector signed int);
14544 vector unsigned int vec_mergeh (vector unsigned int,
14545                                 vector unsigned int);
14547 vector float vec_vmrghw (vector float, vector float);
14548 vector bool int vec_vmrghw (vector bool int, vector bool int);
14549 vector signed int vec_vmrghw (vector signed int, vector signed int);
14550 vector unsigned int vec_vmrghw (vector unsigned int,
14551                                 vector unsigned int);
14553 vector bool short vec_vmrghh (vector bool short, vector bool short);
14554 vector signed short vec_vmrghh (vector signed short,
14555                                 vector signed short);
14556 vector unsigned short vec_vmrghh (vector unsigned short,
14557                                   vector unsigned short);
14558 vector pixel vec_vmrghh (vector pixel, vector pixel);
14560 vector bool char vec_vmrghb (vector bool char, vector bool char);
14561 vector signed char vec_vmrghb (vector signed char, vector signed char);
14562 vector unsigned char vec_vmrghb (vector unsigned char,
14563                                  vector unsigned char);
14565 vector bool char vec_mergel (vector bool char, vector bool char);
14566 vector signed char vec_mergel (vector signed char, vector signed char);
14567 vector unsigned char vec_mergel (vector unsigned char,
14568                                  vector unsigned char);
14569 vector bool short vec_mergel (vector bool short, vector bool short);
14570 vector pixel vec_mergel (vector pixel, vector pixel);
14571 vector signed short vec_mergel (vector signed short,
14572                                 vector signed short);
14573 vector unsigned short vec_mergel (vector unsigned short,
14574                                   vector unsigned short);
14575 vector float vec_mergel (vector float, vector float);
14576 vector bool int vec_mergel (vector bool int, vector bool int);
14577 vector signed int vec_mergel (vector signed int, vector signed int);
14578 vector unsigned int vec_mergel (vector unsigned int,
14579                                 vector unsigned int);
14581 vector float vec_vmrglw (vector float, vector float);
14582 vector signed int vec_vmrglw (vector signed int, vector signed int);
14583 vector unsigned int vec_vmrglw (vector unsigned int,
14584                                 vector unsigned int);
14585 vector bool int vec_vmrglw (vector bool int, vector bool int);
14587 vector bool short vec_vmrglh (vector bool short, vector bool short);
14588 vector signed short vec_vmrglh (vector signed short,
14589                                 vector signed short);
14590 vector unsigned short vec_vmrglh (vector unsigned short,
14591                                   vector unsigned short);
14592 vector pixel vec_vmrglh (vector pixel, vector pixel);
14594 vector bool char vec_vmrglb (vector bool char, vector bool char);
14595 vector signed char vec_vmrglb (vector signed char, vector signed char);
14596 vector unsigned char vec_vmrglb (vector unsigned char,
14597                                  vector unsigned char);
14599 vector unsigned short vec_mfvscr (void);
14601 vector unsigned char vec_min (vector bool char, vector unsigned char);
14602 vector unsigned char vec_min (vector unsigned char, vector bool char);
14603 vector unsigned char vec_min (vector unsigned char,
14604                               vector unsigned char);
14605 vector signed char vec_min (vector bool char, vector signed char);
14606 vector signed char vec_min (vector signed char, vector bool char);
14607 vector signed char vec_min (vector signed char, vector signed char);
14608 vector unsigned short vec_min (vector bool short,
14609                                vector unsigned short);
14610 vector unsigned short vec_min (vector unsigned short,
14611                                vector bool short);
14612 vector unsigned short vec_min (vector unsigned short,
14613                                vector unsigned short);
14614 vector signed short vec_min (vector bool short, vector signed short);
14615 vector signed short vec_min (vector signed short, vector bool short);
14616 vector signed short vec_min (vector signed short, vector signed short);
14617 vector unsigned int vec_min (vector bool int, vector unsigned int);
14618 vector unsigned int vec_min (vector unsigned int, vector bool int);
14619 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14620 vector signed int vec_min (vector bool int, vector signed int);
14621 vector signed int vec_min (vector signed int, vector bool int);
14622 vector signed int vec_min (vector signed int, vector signed int);
14623 vector float vec_min (vector float, vector float);
14625 vector float vec_vminfp (vector float, vector float);
14627 vector signed int vec_vminsw (vector bool int, vector signed int);
14628 vector signed int vec_vminsw (vector signed int, vector bool int);
14629 vector signed int vec_vminsw (vector signed int, vector signed int);
14631 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14632 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14633 vector unsigned int vec_vminuw (vector unsigned int,
14634                                 vector unsigned int);
14636 vector signed short vec_vminsh (vector bool short, vector signed short);
14637 vector signed short vec_vminsh (vector signed short, vector bool short);
14638 vector signed short vec_vminsh (vector signed short,
14639                                 vector signed short);
14641 vector unsigned short vec_vminuh (vector bool short,
14642                                   vector unsigned short);
14643 vector unsigned short vec_vminuh (vector unsigned short,
14644                                   vector bool short);
14645 vector unsigned short vec_vminuh (vector unsigned short,
14646                                   vector unsigned short);
14648 vector signed char vec_vminsb (vector bool char, vector signed char);
14649 vector signed char vec_vminsb (vector signed char, vector bool char);
14650 vector signed char vec_vminsb (vector signed char, vector signed char);
14652 vector unsigned char vec_vminub (vector bool char,
14653                                  vector unsigned char);
14654 vector unsigned char vec_vminub (vector unsigned char,
14655                                  vector bool char);
14656 vector unsigned char vec_vminub (vector unsigned char,
14657                                  vector unsigned char);
14659 vector signed short vec_mladd (vector signed short,
14660                                vector signed short,
14661                                vector signed short);
14662 vector signed short vec_mladd (vector signed short,
14663                                vector unsigned short,
14664                                vector unsigned short);
14665 vector signed short vec_mladd (vector unsigned short,
14666                                vector signed short,
14667                                vector signed short);
14668 vector unsigned short vec_mladd (vector unsigned short,
14669                                  vector unsigned short,
14670                                  vector unsigned short);
14672 vector signed short vec_mradds (vector signed short,
14673                                 vector signed short,
14674                                 vector signed short);
14676 vector unsigned int vec_msum (vector unsigned char,
14677                               vector unsigned char,
14678                               vector unsigned int);
14679 vector signed int vec_msum (vector signed char,
14680                             vector unsigned char,
14681                             vector signed int);
14682 vector unsigned int vec_msum (vector unsigned short,
14683                               vector unsigned short,
14684                               vector unsigned int);
14685 vector signed int vec_msum (vector signed short,
14686                             vector signed short,
14687                             vector signed int);
14689 vector signed int vec_vmsumshm (vector signed short,
14690                                 vector signed short,
14691                                 vector signed int);
14693 vector unsigned int vec_vmsumuhm (vector unsigned short,
14694                                   vector unsigned short,
14695                                   vector unsigned int);
14697 vector signed int vec_vmsummbm (vector signed char,
14698                                 vector unsigned char,
14699                                 vector signed int);
14701 vector unsigned int vec_vmsumubm (vector unsigned char,
14702                                   vector unsigned char,
14703                                   vector unsigned int);
14705 vector unsigned int vec_msums (vector unsigned short,
14706                                vector unsigned short,
14707                                vector unsigned int);
14708 vector signed int vec_msums (vector signed short,
14709                              vector signed short,
14710                              vector signed int);
14712 vector signed int vec_vmsumshs (vector signed short,
14713                                 vector signed short,
14714                                 vector signed int);
14716 vector unsigned int vec_vmsumuhs (vector unsigned short,
14717                                   vector unsigned short,
14718                                   vector unsigned int);
14720 void vec_mtvscr (vector signed int);
14721 void vec_mtvscr (vector unsigned int);
14722 void vec_mtvscr (vector bool int);
14723 void vec_mtvscr (vector signed short);
14724 void vec_mtvscr (vector unsigned short);
14725 void vec_mtvscr (vector bool short);
14726 void vec_mtvscr (vector pixel);
14727 void vec_mtvscr (vector signed char);
14728 void vec_mtvscr (vector unsigned char);
14729 void vec_mtvscr (vector bool char);
14731 vector unsigned short vec_mule (vector unsigned char,
14732                                 vector unsigned char);
14733 vector signed short vec_mule (vector signed char,
14734                               vector signed char);
14735 vector unsigned int vec_mule (vector unsigned short,
14736                               vector unsigned short);
14737 vector signed int vec_mule (vector signed short, vector signed short);
14739 vector signed int vec_vmulesh (vector signed short,
14740                                vector signed short);
14742 vector unsigned int vec_vmuleuh (vector unsigned short,
14743                                  vector unsigned short);
14745 vector signed short vec_vmulesb (vector signed char,
14746                                  vector signed char);
14748 vector unsigned short vec_vmuleub (vector unsigned char,
14749                                   vector unsigned char);
14751 vector unsigned short vec_mulo (vector unsigned char,
14752                                 vector unsigned char);
14753 vector signed short vec_mulo (vector signed char, vector signed char);
14754 vector unsigned int vec_mulo (vector unsigned short,
14755                               vector unsigned short);
14756 vector signed int vec_mulo (vector signed short, vector signed short);
14758 vector signed int vec_vmulosh (vector signed short,
14759                                vector signed short);
14761 vector unsigned int vec_vmulouh (vector unsigned short,
14762                                  vector unsigned short);
14764 vector signed short vec_vmulosb (vector signed char,
14765                                  vector signed char);
14767 vector unsigned short vec_vmuloub (vector unsigned char,
14768                                    vector unsigned char);
14770 vector float vec_nmsub (vector float, vector float, vector float);
14772 vector float vec_nor (vector float, vector float);
14773 vector signed int vec_nor (vector signed int, vector signed int);
14774 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14775 vector bool int vec_nor (vector bool int, vector bool int);
14776 vector signed short vec_nor (vector signed short, vector signed short);
14777 vector unsigned short vec_nor (vector unsigned short,
14778                                vector unsigned short);
14779 vector bool short vec_nor (vector bool short, vector bool short);
14780 vector signed char vec_nor (vector signed char, vector signed char);
14781 vector unsigned char vec_nor (vector unsigned char,
14782                               vector unsigned char);
14783 vector bool char vec_nor (vector bool char, vector bool char);
14785 vector float vec_or (vector float, vector float);
14786 vector float vec_or (vector float, vector bool int);
14787 vector float vec_or (vector bool int, vector float);
14788 vector bool int vec_or (vector bool int, vector bool int);
14789 vector signed int vec_or (vector bool int, vector signed int);
14790 vector signed int vec_or (vector signed int, vector bool int);
14791 vector signed int vec_or (vector signed int, vector signed int);
14792 vector unsigned int vec_or (vector bool int, vector unsigned int);
14793 vector unsigned int vec_or (vector unsigned int, vector bool int);
14794 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14795 vector bool short vec_or (vector bool short, vector bool short);
14796 vector signed short vec_or (vector bool short, vector signed short);
14797 vector signed short vec_or (vector signed short, vector bool short);
14798 vector signed short vec_or (vector signed short, vector signed short);
14799 vector unsigned short vec_or (vector bool short, vector unsigned short);
14800 vector unsigned short vec_or (vector unsigned short, vector bool short);
14801 vector unsigned short vec_or (vector unsigned short,
14802                               vector unsigned short);
14803 vector signed char vec_or (vector bool char, vector signed char);
14804 vector bool char vec_or (vector bool char, vector bool char);
14805 vector signed char vec_or (vector signed char, vector bool char);
14806 vector signed char vec_or (vector signed char, vector signed char);
14807 vector unsigned char vec_or (vector bool char, vector unsigned char);
14808 vector unsigned char vec_or (vector unsigned char, vector bool char);
14809 vector unsigned char vec_or (vector unsigned char,
14810                              vector unsigned char);
14812 vector signed char vec_pack (vector signed short, vector signed short);
14813 vector unsigned char vec_pack (vector unsigned short,
14814                                vector unsigned short);
14815 vector bool char vec_pack (vector bool short, vector bool short);
14816 vector signed short vec_pack (vector signed int, vector signed int);
14817 vector unsigned short vec_pack (vector unsigned int,
14818                                 vector unsigned int);
14819 vector bool short vec_pack (vector bool int, vector bool int);
14821 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14822 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14823 vector unsigned short vec_vpkuwum (vector unsigned int,
14824                                    vector unsigned int);
14826 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14827 vector signed char vec_vpkuhum (vector signed short,
14828                                 vector signed short);
14829 vector unsigned char vec_vpkuhum (vector unsigned short,
14830                                   vector unsigned short);
14832 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14834 vector unsigned char vec_packs (vector unsigned short,
14835                                 vector unsigned short);
14836 vector signed char vec_packs (vector signed short, vector signed short);
14837 vector unsigned short vec_packs (vector unsigned int,
14838                                  vector unsigned int);
14839 vector signed short vec_packs (vector signed int, vector signed int);
14841 vector signed short vec_vpkswss (vector signed int, vector signed int);
14843 vector unsigned short vec_vpkuwus (vector unsigned int,
14844                                    vector unsigned int);
14846 vector signed char vec_vpkshss (vector signed short,
14847                                 vector signed short);
14849 vector unsigned char vec_vpkuhus (vector unsigned short,
14850                                   vector unsigned short);
14852 vector unsigned char vec_packsu (vector unsigned short,
14853                                  vector unsigned short);
14854 vector unsigned char vec_packsu (vector signed short,
14855                                  vector signed short);
14856 vector unsigned short vec_packsu (vector unsigned int,
14857                                   vector unsigned int);
14858 vector unsigned short vec_packsu (vector signed int, vector signed int);
14860 vector unsigned short vec_vpkswus (vector signed int,
14861                                    vector signed int);
14863 vector unsigned char vec_vpkshus (vector signed short,
14864                                   vector signed short);
14866 vector float vec_perm (vector float,
14867                        vector float,
14868                        vector unsigned char);
14869 vector signed int vec_perm (vector signed int,
14870                             vector signed int,
14871                             vector unsigned char);
14872 vector unsigned int vec_perm (vector unsigned int,
14873                               vector unsigned int,
14874                               vector unsigned char);
14875 vector bool int vec_perm (vector bool int,
14876                           vector bool int,
14877                           vector unsigned char);
14878 vector signed short vec_perm (vector signed short,
14879                               vector signed short,
14880                               vector unsigned char);
14881 vector unsigned short vec_perm (vector unsigned short,
14882                                 vector unsigned short,
14883                                 vector unsigned char);
14884 vector bool short vec_perm (vector bool short,
14885                             vector bool short,
14886                             vector unsigned char);
14887 vector pixel vec_perm (vector pixel,
14888                        vector pixel,
14889                        vector unsigned char);
14890 vector signed char vec_perm (vector signed char,
14891                              vector signed char,
14892                              vector unsigned char);
14893 vector unsigned char vec_perm (vector unsigned char,
14894                                vector unsigned char,
14895                                vector unsigned char);
14896 vector bool char vec_perm (vector bool char,
14897                            vector bool char,
14898                            vector unsigned char);
14900 vector float vec_re (vector float);
14902 vector signed char vec_rl (vector signed char,
14903                            vector unsigned char);
14904 vector unsigned char vec_rl (vector unsigned char,
14905                              vector unsigned char);
14906 vector signed short vec_rl (vector signed short, vector unsigned short);
14907 vector unsigned short vec_rl (vector unsigned short,
14908                               vector unsigned short);
14909 vector signed int vec_rl (vector signed int, vector unsigned int);
14910 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14912 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14913 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14915 vector signed short vec_vrlh (vector signed short,
14916                               vector unsigned short);
14917 vector unsigned short vec_vrlh (vector unsigned short,
14918                                 vector unsigned short);
14920 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14921 vector unsigned char vec_vrlb (vector unsigned char,
14922                                vector unsigned char);
14924 vector float vec_round (vector float);
14926 vector float vec_recip (vector float, vector float);
14928 vector float vec_rsqrt (vector float);
14930 vector float vec_rsqrte (vector float);
14932 vector float vec_sel (vector float, vector float, vector bool int);
14933 vector float vec_sel (vector float, vector float, vector unsigned int);
14934 vector signed int vec_sel (vector signed int,
14935                            vector signed int,
14936                            vector bool int);
14937 vector signed int vec_sel (vector signed int,
14938                            vector signed int,
14939                            vector unsigned int);
14940 vector unsigned int vec_sel (vector unsigned int,
14941                              vector unsigned int,
14942                              vector bool int);
14943 vector unsigned int vec_sel (vector unsigned int,
14944                              vector unsigned int,
14945                              vector unsigned int);
14946 vector bool int vec_sel (vector bool int,
14947                          vector bool int,
14948                          vector bool int);
14949 vector bool int vec_sel (vector bool int,
14950                          vector bool int,
14951                          vector unsigned int);
14952 vector signed short vec_sel (vector signed short,
14953                              vector signed short,
14954                              vector bool short);
14955 vector signed short vec_sel (vector signed short,
14956                              vector signed short,
14957                              vector unsigned short);
14958 vector unsigned short vec_sel (vector unsigned short,
14959                                vector unsigned short,
14960                                vector bool short);
14961 vector unsigned short vec_sel (vector unsigned short,
14962                                vector unsigned short,
14963                                vector unsigned short);
14964 vector bool short vec_sel (vector bool short,
14965                            vector bool short,
14966                            vector bool short);
14967 vector bool short vec_sel (vector bool short,
14968                            vector bool short,
14969                            vector unsigned short);
14970 vector signed char vec_sel (vector signed char,
14971                             vector signed char,
14972                             vector bool char);
14973 vector signed char vec_sel (vector signed char,
14974                             vector signed char,
14975                             vector unsigned char);
14976 vector unsigned char vec_sel (vector unsigned char,
14977                               vector unsigned char,
14978                               vector bool char);
14979 vector unsigned char vec_sel (vector unsigned char,
14980                               vector unsigned char,
14981                               vector unsigned char);
14982 vector bool char vec_sel (vector bool char,
14983                           vector bool char,
14984                           vector bool char);
14985 vector bool char vec_sel (vector bool char,
14986                           vector bool char,
14987                           vector unsigned char);
14989 vector signed char vec_sl (vector signed char,
14990                            vector unsigned char);
14991 vector unsigned char vec_sl (vector unsigned char,
14992                              vector unsigned char);
14993 vector signed short vec_sl (vector signed short, vector unsigned short);
14994 vector unsigned short vec_sl (vector unsigned short,
14995                               vector unsigned short);
14996 vector signed int vec_sl (vector signed int, vector unsigned int);
14997 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14999 vector signed int vec_vslw (vector signed int, vector unsigned int);
15000 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
15002 vector signed short vec_vslh (vector signed short,
15003                               vector unsigned short);
15004 vector unsigned short vec_vslh (vector unsigned short,
15005                                 vector unsigned short);
15007 vector signed char vec_vslb (vector signed char, vector unsigned char);
15008 vector unsigned char vec_vslb (vector unsigned char,
15009                                vector unsigned char);
15011 vector float vec_sld (vector float, vector float, const int);
15012 vector signed int vec_sld (vector signed int,
15013                            vector signed int,
15014                            const int);
15015 vector unsigned int vec_sld (vector unsigned int,
15016                              vector unsigned int,
15017                              const int);
15018 vector bool int vec_sld (vector bool int,
15019                          vector bool int,
15020                          const int);
15021 vector signed short vec_sld (vector signed short,
15022                              vector signed short,
15023                              const int);
15024 vector unsigned short vec_sld (vector unsigned short,
15025                                vector unsigned short,
15026                                const int);
15027 vector bool short vec_sld (vector bool short,
15028                            vector bool short,
15029                            const int);
15030 vector pixel vec_sld (vector pixel,
15031                       vector pixel,
15032                       const int);
15033 vector signed char vec_sld (vector signed char,
15034                             vector signed char,
15035                             const int);
15036 vector unsigned char vec_sld (vector unsigned char,
15037                               vector unsigned char,
15038                               const int);
15039 vector bool char vec_sld (vector bool char,
15040                           vector bool char,
15041                           const int);
15043 vector signed int vec_sll (vector signed int,
15044                            vector unsigned int);
15045 vector signed int vec_sll (vector signed int,
15046                            vector unsigned short);
15047 vector signed int vec_sll (vector signed int,
15048                            vector unsigned char);
15049 vector unsigned int vec_sll (vector unsigned int,
15050                              vector unsigned int);
15051 vector unsigned int vec_sll (vector unsigned int,
15052                              vector unsigned short);
15053 vector unsigned int vec_sll (vector unsigned int,
15054                              vector unsigned char);
15055 vector bool int vec_sll (vector bool int,
15056                          vector unsigned int);
15057 vector bool int vec_sll (vector bool int,
15058                          vector unsigned short);
15059 vector bool int vec_sll (vector bool int,
15060                          vector unsigned char);
15061 vector signed short vec_sll (vector signed short,
15062                              vector unsigned int);
15063 vector signed short vec_sll (vector signed short,
15064                              vector unsigned short);
15065 vector signed short vec_sll (vector signed short,
15066                              vector unsigned char);
15067 vector unsigned short vec_sll (vector unsigned short,
15068                                vector unsigned int);
15069 vector unsigned short vec_sll (vector unsigned short,
15070                                vector unsigned short);
15071 vector unsigned short vec_sll (vector unsigned short,
15072                                vector unsigned char);
15073 vector bool short vec_sll (vector bool short, vector unsigned int);
15074 vector bool short vec_sll (vector bool short, vector unsigned short);
15075 vector bool short vec_sll (vector bool short, vector unsigned char);
15076 vector pixel vec_sll (vector pixel, vector unsigned int);
15077 vector pixel vec_sll (vector pixel, vector unsigned short);
15078 vector pixel vec_sll (vector pixel, vector unsigned char);
15079 vector signed char vec_sll (vector signed char, vector unsigned int);
15080 vector signed char vec_sll (vector signed char, vector unsigned short);
15081 vector signed char vec_sll (vector signed char, vector unsigned char);
15082 vector unsigned char vec_sll (vector unsigned char,
15083                               vector unsigned int);
15084 vector unsigned char vec_sll (vector unsigned char,
15085                               vector unsigned short);
15086 vector unsigned char vec_sll (vector unsigned char,
15087                               vector unsigned char);
15088 vector bool char vec_sll (vector bool char, vector unsigned int);
15089 vector bool char vec_sll (vector bool char, vector unsigned short);
15090 vector bool char vec_sll (vector bool char, vector unsigned char);
15092 vector float vec_slo (vector float, vector signed char);
15093 vector float vec_slo (vector float, vector unsigned char);
15094 vector signed int vec_slo (vector signed int, vector signed char);
15095 vector signed int vec_slo (vector signed int, vector unsigned char);
15096 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15097 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15098 vector signed short vec_slo (vector signed short, vector signed char);
15099 vector signed short vec_slo (vector signed short, vector unsigned char);
15100 vector unsigned short vec_slo (vector unsigned short,
15101                                vector signed char);
15102 vector unsigned short vec_slo (vector unsigned short,
15103                                vector unsigned char);
15104 vector pixel vec_slo (vector pixel, vector signed char);
15105 vector pixel vec_slo (vector pixel, vector unsigned char);
15106 vector signed char vec_slo (vector signed char, vector signed char);
15107 vector signed char vec_slo (vector signed char, vector unsigned char);
15108 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15109 vector unsigned char vec_slo (vector unsigned char,
15110                               vector unsigned char);
15112 vector signed char vec_splat (vector signed char, const int);
15113 vector unsigned char vec_splat (vector unsigned char, const int);
15114 vector bool char vec_splat (vector bool char, const int);
15115 vector signed short vec_splat (vector signed short, const int);
15116 vector unsigned short vec_splat (vector unsigned short, const int);
15117 vector bool short vec_splat (vector bool short, const int);
15118 vector pixel vec_splat (vector pixel, const int);
15119 vector float vec_splat (vector float, const int);
15120 vector signed int vec_splat (vector signed int, const int);
15121 vector unsigned int vec_splat (vector unsigned int, const int);
15122 vector bool int vec_splat (vector bool int, const int);
15123 vector signed long vec_splat (vector signed long, const int);
15124 vector unsigned long vec_splat (vector unsigned long, const int);
15126 vector signed char vec_splats (signed char);
15127 vector unsigned char vec_splats (unsigned char);
15128 vector signed short vec_splats (signed short);
15129 vector unsigned short vec_splats (unsigned short);
15130 vector signed int vec_splats (signed int);
15131 vector unsigned int vec_splats (unsigned int);
15132 vector float vec_splats (float);
15134 vector float vec_vspltw (vector float, const int);
15135 vector signed int vec_vspltw (vector signed int, const int);
15136 vector unsigned int vec_vspltw (vector unsigned int, const int);
15137 vector bool int vec_vspltw (vector bool int, const int);
15139 vector bool short vec_vsplth (vector bool short, const int);
15140 vector signed short vec_vsplth (vector signed short, const int);
15141 vector unsigned short vec_vsplth (vector unsigned short, const int);
15142 vector pixel vec_vsplth (vector pixel, const int);
15144 vector signed char vec_vspltb (vector signed char, const int);
15145 vector unsigned char vec_vspltb (vector unsigned char, const int);
15146 vector bool char vec_vspltb (vector bool char, const int);
15148 vector signed char vec_splat_s8 (const int);
15150 vector signed short vec_splat_s16 (const int);
15152 vector signed int vec_splat_s32 (const int);
15154 vector unsigned char vec_splat_u8 (const int);
15156 vector unsigned short vec_splat_u16 (const int);
15158 vector unsigned int vec_splat_u32 (const int);
15160 vector signed char vec_sr (vector signed char, vector unsigned char);
15161 vector unsigned char vec_sr (vector unsigned char,
15162                              vector unsigned char);
15163 vector signed short vec_sr (vector signed short,
15164                             vector unsigned short);
15165 vector unsigned short vec_sr (vector unsigned short,
15166                               vector unsigned short);
15167 vector signed int vec_sr (vector signed int, vector unsigned int);
15168 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15170 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15171 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15173 vector signed short vec_vsrh (vector signed short,
15174                               vector unsigned short);
15175 vector unsigned short vec_vsrh (vector unsigned short,
15176                                 vector unsigned short);
15178 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15179 vector unsigned char vec_vsrb (vector unsigned char,
15180                                vector unsigned char);
15182 vector signed char vec_sra (vector signed char, vector unsigned char);
15183 vector unsigned char vec_sra (vector unsigned char,
15184                               vector unsigned char);
15185 vector signed short vec_sra (vector signed short,
15186                              vector unsigned short);
15187 vector unsigned short vec_sra (vector unsigned short,
15188                                vector unsigned short);
15189 vector signed int vec_sra (vector signed int, vector unsigned int);
15190 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15192 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15193 vector unsigned int vec_vsraw (vector unsigned int,
15194                                vector unsigned int);
15196 vector signed short vec_vsrah (vector signed short,
15197                                vector unsigned short);
15198 vector unsigned short vec_vsrah (vector unsigned short,
15199                                  vector unsigned short);
15201 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15202 vector unsigned char vec_vsrab (vector unsigned char,
15203                                 vector unsigned char);
15205 vector signed int vec_srl (vector signed int, vector unsigned int);
15206 vector signed int vec_srl (vector signed int, vector unsigned short);
15207 vector signed int vec_srl (vector signed int, vector unsigned char);
15208 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15209 vector unsigned int vec_srl (vector unsigned int,
15210                              vector unsigned short);
15211 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15212 vector bool int vec_srl (vector bool int, vector unsigned int);
15213 vector bool int vec_srl (vector bool int, vector unsigned short);
15214 vector bool int vec_srl (vector bool int, vector unsigned char);
15215 vector signed short vec_srl (vector signed short, vector unsigned int);
15216 vector signed short vec_srl (vector signed short,
15217                              vector unsigned short);
15218 vector signed short vec_srl (vector signed short, vector unsigned char);
15219 vector unsigned short vec_srl (vector unsigned short,
15220                                vector unsigned int);
15221 vector unsigned short vec_srl (vector unsigned short,
15222                                vector unsigned short);
15223 vector unsigned short vec_srl (vector unsigned short,
15224                                vector unsigned char);
15225 vector bool short vec_srl (vector bool short, vector unsigned int);
15226 vector bool short vec_srl (vector bool short, vector unsigned short);
15227 vector bool short vec_srl (vector bool short, vector unsigned char);
15228 vector pixel vec_srl (vector pixel, vector unsigned int);
15229 vector pixel vec_srl (vector pixel, vector unsigned short);
15230 vector pixel vec_srl (vector pixel, vector unsigned char);
15231 vector signed char vec_srl (vector signed char, vector unsigned int);
15232 vector signed char vec_srl (vector signed char, vector unsigned short);
15233 vector signed char vec_srl (vector signed char, vector unsigned char);
15234 vector unsigned char vec_srl (vector unsigned char,
15235                               vector unsigned int);
15236 vector unsigned char vec_srl (vector unsigned char,
15237                               vector unsigned short);
15238 vector unsigned char vec_srl (vector unsigned char,
15239                               vector unsigned char);
15240 vector bool char vec_srl (vector bool char, vector unsigned int);
15241 vector bool char vec_srl (vector bool char, vector unsigned short);
15242 vector bool char vec_srl (vector bool char, vector unsigned char);
15244 vector float vec_sro (vector float, vector signed char);
15245 vector float vec_sro (vector float, vector unsigned char);
15246 vector signed int vec_sro (vector signed int, vector signed char);
15247 vector signed int vec_sro (vector signed int, vector unsigned char);
15248 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15249 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15250 vector signed short vec_sro (vector signed short, vector signed char);
15251 vector signed short vec_sro (vector signed short, vector unsigned char);
15252 vector unsigned short vec_sro (vector unsigned short,
15253                                vector signed char);
15254 vector unsigned short vec_sro (vector unsigned short,
15255                                vector unsigned char);
15256 vector pixel vec_sro (vector pixel, vector signed char);
15257 vector pixel vec_sro (vector pixel, vector unsigned char);
15258 vector signed char vec_sro (vector signed char, vector signed char);
15259 vector signed char vec_sro (vector signed char, vector unsigned char);
15260 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15261 vector unsigned char vec_sro (vector unsigned char,
15262                               vector unsigned char);
15264 void vec_st (vector float, int, vector float *);
15265 void vec_st (vector float, int, float *);
15266 void vec_st (vector signed int, int, vector signed int *);
15267 void vec_st (vector signed int, int, int *);
15268 void vec_st (vector unsigned int, int, vector unsigned int *);
15269 void vec_st (vector unsigned int, int, unsigned int *);
15270 void vec_st (vector bool int, int, vector bool int *);
15271 void vec_st (vector bool int, int, unsigned int *);
15272 void vec_st (vector bool int, int, int *);
15273 void vec_st (vector signed short, int, vector signed short *);
15274 void vec_st (vector signed short, int, short *);
15275 void vec_st (vector unsigned short, int, vector unsigned short *);
15276 void vec_st (vector unsigned short, int, unsigned short *);
15277 void vec_st (vector bool short, int, vector bool short *);
15278 void vec_st (vector bool short, int, unsigned short *);
15279 void vec_st (vector pixel, int, vector pixel *);
15280 void vec_st (vector pixel, int, unsigned short *);
15281 void vec_st (vector pixel, int, short *);
15282 void vec_st (vector bool short, int, short *);
15283 void vec_st (vector signed char, int, vector signed char *);
15284 void vec_st (vector signed char, int, signed char *);
15285 void vec_st (vector unsigned char, int, vector unsigned char *);
15286 void vec_st (vector unsigned char, int, unsigned char *);
15287 void vec_st (vector bool char, int, vector bool char *);
15288 void vec_st (vector bool char, int, unsigned char *);
15289 void vec_st (vector bool char, int, signed char *);
15291 void vec_ste (vector signed char, int, signed char *);
15292 void vec_ste (vector unsigned char, int, unsigned char *);
15293 void vec_ste (vector bool char, int, signed char *);
15294 void vec_ste (vector bool char, int, unsigned char *);
15295 void vec_ste (vector signed short, int, short *);
15296 void vec_ste (vector unsigned short, int, unsigned short *);
15297 void vec_ste (vector bool short, int, short *);
15298 void vec_ste (vector bool short, int, unsigned short *);
15299 void vec_ste (vector pixel, int, short *);
15300 void vec_ste (vector pixel, int, unsigned short *);
15301 void vec_ste (vector float, int, float *);
15302 void vec_ste (vector signed int, int, int *);
15303 void vec_ste (vector unsigned int, int, unsigned int *);
15304 void vec_ste (vector bool int, int, int *);
15305 void vec_ste (vector bool int, int, unsigned int *);
15307 void vec_stvewx (vector float, int, float *);
15308 void vec_stvewx (vector signed int, int, int *);
15309 void vec_stvewx (vector unsigned int, int, unsigned int *);
15310 void vec_stvewx (vector bool int, int, int *);
15311 void vec_stvewx (vector bool int, int, unsigned int *);
15313 void vec_stvehx (vector signed short, int, short *);
15314 void vec_stvehx (vector unsigned short, int, unsigned short *);
15315 void vec_stvehx (vector bool short, int, short *);
15316 void vec_stvehx (vector bool short, int, unsigned short *);
15317 void vec_stvehx (vector pixel, int, short *);
15318 void vec_stvehx (vector pixel, int, unsigned short *);
15320 void vec_stvebx (vector signed char, int, signed char *);
15321 void vec_stvebx (vector unsigned char, int, unsigned char *);
15322 void vec_stvebx (vector bool char, int, signed char *);
15323 void vec_stvebx (vector bool char, int, unsigned char *);
15325 void vec_stl (vector float, int, vector float *);
15326 void vec_stl (vector float, int, float *);
15327 void vec_stl (vector signed int, int, vector signed int *);
15328 void vec_stl (vector signed int, int, int *);
15329 void vec_stl (vector unsigned int, int, vector unsigned int *);
15330 void vec_stl (vector unsigned int, int, unsigned int *);
15331 void vec_stl (vector bool int, int, vector bool int *);
15332 void vec_stl (vector bool int, int, unsigned int *);
15333 void vec_stl (vector bool int, int, int *);
15334 void vec_stl (vector signed short, int, vector signed short *);
15335 void vec_stl (vector signed short, int, short *);
15336 void vec_stl (vector unsigned short, int, vector unsigned short *);
15337 void vec_stl (vector unsigned short, int, unsigned short *);
15338 void vec_stl (vector bool short, int, vector bool short *);
15339 void vec_stl (vector bool short, int, unsigned short *);
15340 void vec_stl (vector bool short, int, short *);
15341 void vec_stl (vector pixel, int, vector pixel *);
15342 void vec_stl (vector pixel, int, unsigned short *);
15343 void vec_stl (vector pixel, int, short *);
15344 void vec_stl (vector signed char, int, vector signed char *);
15345 void vec_stl (vector signed char, int, signed char *);
15346 void vec_stl (vector unsigned char, int, vector unsigned char *);
15347 void vec_stl (vector unsigned char, int, unsigned char *);
15348 void vec_stl (vector bool char, int, vector bool char *);
15349 void vec_stl (vector bool char, int, unsigned char *);
15350 void vec_stl (vector bool char, int, signed char *);
15352 vector signed char vec_sub (vector bool char, vector signed char);
15353 vector signed char vec_sub (vector signed char, vector bool char);
15354 vector signed char vec_sub (vector signed char, vector signed char);
15355 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15356 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15357 vector unsigned char vec_sub (vector unsigned char,
15358                               vector unsigned char);
15359 vector signed short vec_sub (vector bool short, vector signed short);
15360 vector signed short vec_sub (vector signed short, vector bool short);
15361 vector signed short vec_sub (vector signed short, vector signed short);
15362 vector unsigned short vec_sub (vector bool short,
15363                                vector unsigned short);
15364 vector unsigned short vec_sub (vector unsigned short,
15365                                vector bool short);
15366 vector unsigned short vec_sub (vector unsigned short,
15367                                vector unsigned short);
15368 vector signed int vec_sub (vector bool int, vector signed int);
15369 vector signed int vec_sub (vector signed int, vector bool int);
15370 vector signed int vec_sub (vector signed int, vector signed int);
15371 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15372 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15373 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15374 vector float vec_sub (vector float, vector float);
15376 vector float vec_vsubfp (vector float, vector float);
15378 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15379 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15380 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15381 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15382 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15383 vector unsigned int vec_vsubuwm (vector unsigned int,
15384                                  vector unsigned int);
15386 vector signed short vec_vsubuhm (vector bool short,
15387                                  vector signed short);
15388 vector signed short vec_vsubuhm (vector signed short,
15389                                  vector bool short);
15390 vector signed short vec_vsubuhm (vector signed short,
15391                                  vector signed short);
15392 vector unsigned short vec_vsubuhm (vector bool short,
15393                                    vector unsigned short);
15394 vector unsigned short vec_vsubuhm (vector unsigned short,
15395                                    vector bool short);
15396 vector unsigned short vec_vsubuhm (vector unsigned short,
15397                                    vector unsigned short);
15399 vector signed char vec_vsububm (vector bool char, vector signed char);
15400 vector signed char vec_vsububm (vector signed char, vector bool char);
15401 vector signed char vec_vsububm (vector signed char, vector signed char);
15402 vector unsigned char vec_vsububm (vector bool char,
15403                                   vector unsigned char);
15404 vector unsigned char vec_vsububm (vector unsigned char,
15405                                   vector bool char);
15406 vector unsigned char vec_vsububm (vector unsigned char,
15407                                   vector unsigned char);
15409 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15411 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15412 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15413 vector unsigned char vec_subs (vector unsigned char,
15414                                vector unsigned char);
15415 vector signed char vec_subs (vector bool char, vector signed char);
15416 vector signed char vec_subs (vector signed char, vector bool char);
15417 vector signed char vec_subs (vector signed char, vector signed char);
15418 vector unsigned short vec_subs (vector bool short,
15419                                 vector unsigned short);
15420 vector unsigned short vec_subs (vector unsigned short,
15421                                 vector bool short);
15422 vector unsigned short vec_subs (vector unsigned short,
15423                                 vector unsigned short);
15424 vector signed short vec_subs (vector bool short, vector signed short);
15425 vector signed short vec_subs (vector signed short, vector bool short);
15426 vector signed short vec_subs (vector signed short, vector signed short);
15427 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15428 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15429 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15430 vector signed int vec_subs (vector bool int, vector signed int);
15431 vector signed int vec_subs (vector signed int, vector bool int);
15432 vector signed int vec_subs (vector signed int, vector signed int);
15434 vector signed int vec_vsubsws (vector bool int, vector signed int);
15435 vector signed int vec_vsubsws (vector signed int, vector bool int);
15436 vector signed int vec_vsubsws (vector signed int, vector signed int);
15438 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15439 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15440 vector unsigned int vec_vsubuws (vector unsigned int,
15441                                  vector unsigned int);
15443 vector signed short vec_vsubshs (vector bool short,
15444                                  vector signed short);
15445 vector signed short vec_vsubshs (vector signed short,
15446                                  vector bool short);
15447 vector signed short vec_vsubshs (vector signed short,
15448                                  vector signed short);
15450 vector unsigned short vec_vsubuhs (vector bool short,
15451                                    vector unsigned short);
15452 vector unsigned short vec_vsubuhs (vector unsigned short,
15453                                    vector bool short);
15454 vector unsigned short vec_vsubuhs (vector unsigned short,
15455                                    vector unsigned short);
15457 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15458 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15459 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15461 vector unsigned char vec_vsububs (vector bool char,
15462                                   vector unsigned char);
15463 vector unsigned char vec_vsububs (vector unsigned char,
15464                                   vector bool char);
15465 vector unsigned char vec_vsububs (vector unsigned char,
15466                                   vector unsigned char);
15468 vector unsigned int vec_sum4s (vector unsigned char,
15469                                vector unsigned int);
15470 vector signed int vec_sum4s (vector signed char, vector signed int);
15471 vector signed int vec_sum4s (vector signed short, vector signed int);
15473 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15475 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15477 vector unsigned int vec_vsum4ubs (vector unsigned char,
15478                                   vector unsigned int);
15480 vector signed int vec_sum2s (vector signed int, vector signed int);
15482 vector signed int vec_sums (vector signed int, vector signed int);
15484 vector float vec_trunc (vector float);
15486 vector signed short vec_unpackh (vector signed char);
15487 vector bool short vec_unpackh (vector bool char);
15488 vector signed int vec_unpackh (vector signed short);
15489 vector bool int vec_unpackh (vector bool short);
15490 vector unsigned int vec_unpackh (vector pixel);
15492 vector bool int vec_vupkhsh (vector bool short);
15493 vector signed int vec_vupkhsh (vector signed short);
15495 vector unsigned int vec_vupkhpx (vector pixel);
15497 vector bool short vec_vupkhsb (vector bool char);
15498 vector signed short vec_vupkhsb (vector signed char);
15500 vector signed short vec_unpackl (vector signed char);
15501 vector bool short vec_unpackl (vector bool char);
15502 vector unsigned int vec_unpackl (vector pixel);
15503 vector signed int vec_unpackl (vector signed short);
15504 vector bool int vec_unpackl (vector bool short);
15506 vector unsigned int vec_vupklpx (vector pixel);
15508 vector bool int vec_vupklsh (vector bool short);
15509 vector signed int vec_vupklsh (vector signed short);
15511 vector bool short vec_vupklsb (vector bool char);
15512 vector signed short vec_vupklsb (vector signed char);
15514 vector float vec_xor (vector float, vector float);
15515 vector float vec_xor (vector float, vector bool int);
15516 vector float vec_xor (vector bool int, vector float);
15517 vector bool int vec_xor (vector bool int, vector bool int);
15518 vector signed int vec_xor (vector bool int, vector signed int);
15519 vector signed int vec_xor (vector signed int, vector bool int);
15520 vector signed int vec_xor (vector signed int, vector signed int);
15521 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15522 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15523 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15524 vector bool short vec_xor (vector bool short, vector bool short);
15525 vector signed short vec_xor (vector bool short, vector signed short);
15526 vector signed short vec_xor (vector signed short, vector bool short);
15527 vector signed short vec_xor (vector signed short, vector signed short);
15528 vector unsigned short vec_xor (vector bool short,
15529                                vector unsigned short);
15530 vector unsigned short vec_xor (vector unsigned short,
15531                                vector bool short);
15532 vector unsigned short vec_xor (vector unsigned short,
15533                                vector unsigned short);
15534 vector signed char vec_xor (vector bool char, vector signed char);
15535 vector bool char vec_xor (vector bool char, vector bool char);
15536 vector signed char vec_xor (vector signed char, vector bool char);
15537 vector signed char vec_xor (vector signed char, vector signed char);
15538 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15539 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15540 vector unsigned char vec_xor (vector unsigned char,
15541                               vector unsigned char);
15543 int vec_all_eq (vector signed char, vector bool char);
15544 int vec_all_eq (vector signed char, vector signed char);
15545 int vec_all_eq (vector unsigned char, vector bool char);
15546 int vec_all_eq (vector unsigned char, vector unsigned char);
15547 int vec_all_eq (vector bool char, vector bool char);
15548 int vec_all_eq (vector bool char, vector unsigned char);
15549 int vec_all_eq (vector bool char, vector signed char);
15550 int vec_all_eq (vector signed short, vector bool short);
15551 int vec_all_eq (vector signed short, vector signed short);
15552 int vec_all_eq (vector unsigned short, vector bool short);
15553 int vec_all_eq (vector unsigned short, vector unsigned short);
15554 int vec_all_eq (vector bool short, vector bool short);
15555 int vec_all_eq (vector bool short, vector unsigned short);
15556 int vec_all_eq (vector bool short, vector signed short);
15557 int vec_all_eq (vector pixel, vector pixel);
15558 int vec_all_eq (vector signed int, vector bool int);
15559 int vec_all_eq (vector signed int, vector signed int);
15560 int vec_all_eq (vector unsigned int, vector bool int);
15561 int vec_all_eq (vector unsigned int, vector unsigned int);
15562 int vec_all_eq (vector bool int, vector bool int);
15563 int vec_all_eq (vector bool int, vector unsigned int);
15564 int vec_all_eq (vector bool int, vector signed int);
15565 int vec_all_eq (vector float, vector float);
15567 int vec_all_ge (vector bool char, vector unsigned char);
15568 int vec_all_ge (vector unsigned char, vector bool char);
15569 int vec_all_ge (vector unsigned char, vector unsigned char);
15570 int vec_all_ge (vector bool char, vector signed char);
15571 int vec_all_ge (vector signed char, vector bool char);
15572 int vec_all_ge (vector signed char, vector signed char);
15573 int vec_all_ge (vector bool short, vector unsigned short);
15574 int vec_all_ge (vector unsigned short, vector bool short);
15575 int vec_all_ge (vector unsigned short, vector unsigned short);
15576 int vec_all_ge (vector signed short, vector signed short);
15577 int vec_all_ge (vector bool short, vector signed short);
15578 int vec_all_ge (vector signed short, vector bool short);
15579 int vec_all_ge (vector bool int, vector unsigned int);
15580 int vec_all_ge (vector unsigned int, vector bool int);
15581 int vec_all_ge (vector unsigned int, vector unsigned int);
15582 int vec_all_ge (vector bool int, vector signed int);
15583 int vec_all_ge (vector signed int, vector bool int);
15584 int vec_all_ge (vector signed int, vector signed int);
15585 int vec_all_ge (vector float, vector float);
15587 int vec_all_gt (vector bool char, vector unsigned char);
15588 int vec_all_gt (vector unsigned char, vector bool char);
15589 int vec_all_gt (vector unsigned char, vector unsigned char);
15590 int vec_all_gt (vector bool char, vector signed char);
15591 int vec_all_gt (vector signed char, vector bool char);
15592 int vec_all_gt (vector signed char, vector signed char);
15593 int vec_all_gt (vector bool short, vector unsigned short);
15594 int vec_all_gt (vector unsigned short, vector bool short);
15595 int vec_all_gt (vector unsigned short, vector unsigned short);
15596 int vec_all_gt (vector bool short, vector signed short);
15597 int vec_all_gt (vector signed short, vector bool short);
15598 int vec_all_gt (vector signed short, vector signed short);
15599 int vec_all_gt (vector bool int, vector unsigned int);
15600 int vec_all_gt (vector unsigned int, vector bool int);
15601 int vec_all_gt (vector unsigned int, vector unsigned int);
15602 int vec_all_gt (vector bool int, vector signed int);
15603 int vec_all_gt (vector signed int, vector bool int);
15604 int vec_all_gt (vector signed int, vector signed int);
15605 int vec_all_gt (vector float, vector float);
15607 int vec_all_in (vector float, vector float);
15609 int vec_all_le (vector bool char, vector unsigned char);
15610 int vec_all_le (vector unsigned char, vector bool char);
15611 int vec_all_le (vector unsigned char, vector unsigned char);
15612 int vec_all_le (vector bool char, vector signed char);
15613 int vec_all_le (vector signed char, vector bool char);
15614 int vec_all_le (vector signed char, vector signed char);
15615 int vec_all_le (vector bool short, vector unsigned short);
15616 int vec_all_le (vector unsigned short, vector bool short);
15617 int vec_all_le (vector unsigned short, vector unsigned short);
15618 int vec_all_le (vector bool short, vector signed short);
15619 int vec_all_le (vector signed short, vector bool short);
15620 int vec_all_le (vector signed short, vector signed short);
15621 int vec_all_le (vector bool int, vector unsigned int);
15622 int vec_all_le (vector unsigned int, vector bool int);
15623 int vec_all_le (vector unsigned int, vector unsigned int);
15624 int vec_all_le (vector bool int, vector signed int);
15625 int vec_all_le (vector signed int, vector bool int);
15626 int vec_all_le (vector signed int, vector signed int);
15627 int vec_all_le (vector float, vector float);
15629 int vec_all_lt (vector bool char, vector unsigned char);
15630 int vec_all_lt (vector unsigned char, vector bool char);
15631 int vec_all_lt (vector unsigned char, vector unsigned char);
15632 int vec_all_lt (vector bool char, vector signed char);
15633 int vec_all_lt (vector signed char, vector bool char);
15634 int vec_all_lt (vector signed char, vector signed char);
15635 int vec_all_lt (vector bool short, vector unsigned short);
15636 int vec_all_lt (vector unsigned short, vector bool short);
15637 int vec_all_lt (vector unsigned short, vector unsigned short);
15638 int vec_all_lt (vector bool short, vector signed short);
15639 int vec_all_lt (vector signed short, vector bool short);
15640 int vec_all_lt (vector signed short, vector signed short);
15641 int vec_all_lt (vector bool int, vector unsigned int);
15642 int vec_all_lt (vector unsigned int, vector bool int);
15643 int vec_all_lt (vector unsigned int, vector unsigned int);
15644 int vec_all_lt (vector bool int, vector signed int);
15645 int vec_all_lt (vector signed int, vector bool int);
15646 int vec_all_lt (vector signed int, vector signed int);
15647 int vec_all_lt (vector float, vector float);
15649 int vec_all_nan (vector float);
15651 int vec_all_ne (vector signed char, vector bool char);
15652 int vec_all_ne (vector signed char, vector signed char);
15653 int vec_all_ne (vector unsigned char, vector bool char);
15654 int vec_all_ne (vector unsigned char, vector unsigned char);
15655 int vec_all_ne (vector bool char, vector bool char);
15656 int vec_all_ne (vector bool char, vector unsigned char);
15657 int vec_all_ne (vector bool char, vector signed char);
15658 int vec_all_ne (vector signed short, vector bool short);
15659 int vec_all_ne (vector signed short, vector signed short);
15660 int vec_all_ne (vector unsigned short, vector bool short);
15661 int vec_all_ne (vector unsigned short, vector unsigned short);
15662 int vec_all_ne (vector bool short, vector bool short);
15663 int vec_all_ne (vector bool short, vector unsigned short);
15664 int vec_all_ne (vector bool short, vector signed short);
15665 int vec_all_ne (vector pixel, vector pixel);
15666 int vec_all_ne (vector signed int, vector bool int);
15667 int vec_all_ne (vector signed int, vector signed int);
15668 int vec_all_ne (vector unsigned int, vector bool int);
15669 int vec_all_ne (vector unsigned int, vector unsigned int);
15670 int vec_all_ne (vector bool int, vector bool int);
15671 int vec_all_ne (vector bool int, vector unsigned int);
15672 int vec_all_ne (vector bool int, vector signed int);
15673 int vec_all_ne (vector float, vector float);
15675 int vec_all_nge (vector float, vector float);
15677 int vec_all_ngt (vector float, vector float);
15679 int vec_all_nle (vector float, vector float);
15681 int vec_all_nlt (vector float, vector float);
15683 int vec_all_numeric (vector float);
15685 int vec_any_eq (vector signed char, vector bool char);
15686 int vec_any_eq (vector signed char, vector signed char);
15687 int vec_any_eq (vector unsigned char, vector bool char);
15688 int vec_any_eq (vector unsigned char, vector unsigned char);
15689 int vec_any_eq (vector bool char, vector bool char);
15690 int vec_any_eq (vector bool char, vector unsigned char);
15691 int vec_any_eq (vector bool char, vector signed char);
15692 int vec_any_eq (vector signed short, vector bool short);
15693 int vec_any_eq (vector signed short, vector signed short);
15694 int vec_any_eq (vector unsigned short, vector bool short);
15695 int vec_any_eq (vector unsigned short, vector unsigned short);
15696 int vec_any_eq (vector bool short, vector bool short);
15697 int vec_any_eq (vector bool short, vector unsigned short);
15698 int vec_any_eq (vector bool short, vector signed short);
15699 int vec_any_eq (vector pixel, vector pixel);
15700 int vec_any_eq (vector signed int, vector bool int);
15701 int vec_any_eq (vector signed int, vector signed int);
15702 int vec_any_eq (vector unsigned int, vector bool int);
15703 int vec_any_eq (vector unsigned int, vector unsigned int);
15704 int vec_any_eq (vector bool int, vector bool int);
15705 int vec_any_eq (vector bool int, vector unsigned int);
15706 int vec_any_eq (vector bool int, vector signed int);
15707 int vec_any_eq (vector float, vector float);
15709 int vec_any_ge (vector signed char, vector bool char);
15710 int vec_any_ge (vector unsigned char, vector bool char);
15711 int vec_any_ge (vector unsigned char, vector unsigned char);
15712 int vec_any_ge (vector signed char, vector signed char);
15713 int vec_any_ge (vector bool char, vector unsigned char);
15714 int vec_any_ge (vector bool char, vector signed char);
15715 int vec_any_ge (vector unsigned short, vector bool short);
15716 int vec_any_ge (vector unsigned short, vector unsigned short);
15717 int vec_any_ge (vector signed short, vector signed short);
15718 int vec_any_ge (vector signed short, vector bool short);
15719 int vec_any_ge (vector bool short, vector unsigned short);
15720 int vec_any_ge (vector bool short, vector signed short);
15721 int vec_any_ge (vector signed int, vector bool int);
15722 int vec_any_ge (vector unsigned int, vector bool int);
15723 int vec_any_ge (vector unsigned int, vector unsigned int);
15724 int vec_any_ge (vector signed int, vector signed int);
15725 int vec_any_ge (vector bool int, vector unsigned int);
15726 int vec_any_ge (vector bool int, vector signed int);
15727 int vec_any_ge (vector float, vector float);
15729 int vec_any_gt (vector bool char, vector unsigned char);
15730 int vec_any_gt (vector unsigned char, vector bool char);
15731 int vec_any_gt (vector unsigned char, vector unsigned char);
15732 int vec_any_gt (vector bool char, vector signed char);
15733 int vec_any_gt (vector signed char, vector bool char);
15734 int vec_any_gt (vector signed char, vector signed char);
15735 int vec_any_gt (vector bool short, vector unsigned short);
15736 int vec_any_gt (vector unsigned short, vector bool short);
15737 int vec_any_gt (vector unsigned short, vector unsigned short);
15738 int vec_any_gt (vector bool short, vector signed short);
15739 int vec_any_gt (vector signed short, vector bool short);
15740 int vec_any_gt (vector signed short, vector signed short);
15741 int vec_any_gt (vector bool int, vector unsigned int);
15742 int vec_any_gt (vector unsigned int, vector bool int);
15743 int vec_any_gt (vector unsigned int, vector unsigned int);
15744 int vec_any_gt (vector bool int, vector signed int);
15745 int vec_any_gt (vector signed int, vector bool int);
15746 int vec_any_gt (vector signed int, vector signed int);
15747 int vec_any_gt (vector float, vector float);
15749 int vec_any_le (vector bool char, vector unsigned char);
15750 int vec_any_le (vector unsigned char, vector bool char);
15751 int vec_any_le (vector unsigned char, vector unsigned char);
15752 int vec_any_le (vector bool char, vector signed char);
15753 int vec_any_le (vector signed char, vector bool char);
15754 int vec_any_le (vector signed char, vector signed char);
15755 int vec_any_le (vector bool short, vector unsigned short);
15756 int vec_any_le (vector unsigned short, vector bool short);
15757 int vec_any_le (vector unsigned short, vector unsigned short);
15758 int vec_any_le (vector bool short, vector signed short);
15759 int vec_any_le (vector signed short, vector bool short);
15760 int vec_any_le (vector signed short, vector signed short);
15761 int vec_any_le (vector bool int, vector unsigned int);
15762 int vec_any_le (vector unsigned int, vector bool int);
15763 int vec_any_le (vector unsigned int, vector unsigned int);
15764 int vec_any_le (vector bool int, vector signed int);
15765 int vec_any_le (vector signed int, vector bool int);
15766 int vec_any_le (vector signed int, vector signed int);
15767 int vec_any_le (vector float, vector float);
15769 int vec_any_lt (vector bool char, vector unsigned char);
15770 int vec_any_lt (vector unsigned char, vector bool char);
15771 int vec_any_lt (vector unsigned char, vector unsigned char);
15772 int vec_any_lt (vector bool char, vector signed char);
15773 int vec_any_lt (vector signed char, vector bool char);
15774 int vec_any_lt (vector signed char, vector signed char);
15775 int vec_any_lt (vector bool short, vector unsigned short);
15776 int vec_any_lt (vector unsigned short, vector bool short);
15777 int vec_any_lt (vector unsigned short, vector unsigned short);
15778 int vec_any_lt (vector bool short, vector signed short);
15779 int vec_any_lt (vector signed short, vector bool short);
15780 int vec_any_lt (vector signed short, vector signed short);
15781 int vec_any_lt (vector bool int, vector unsigned int);
15782 int vec_any_lt (vector unsigned int, vector bool int);
15783 int vec_any_lt (vector unsigned int, vector unsigned int);
15784 int vec_any_lt (vector bool int, vector signed int);
15785 int vec_any_lt (vector signed int, vector bool int);
15786 int vec_any_lt (vector signed int, vector signed int);
15787 int vec_any_lt (vector float, vector float);
15789 int vec_any_nan (vector float);
15791 int vec_any_ne (vector signed char, vector bool char);
15792 int vec_any_ne (vector signed char, vector signed char);
15793 int vec_any_ne (vector unsigned char, vector bool char);
15794 int vec_any_ne (vector unsigned char, vector unsigned char);
15795 int vec_any_ne (vector bool char, vector bool char);
15796 int vec_any_ne (vector bool char, vector unsigned char);
15797 int vec_any_ne (vector bool char, vector signed char);
15798 int vec_any_ne (vector signed short, vector bool short);
15799 int vec_any_ne (vector signed short, vector signed short);
15800 int vec_any_ne (vector unsigned short, vector bool short);
15801 int vec_any_ne (vector unsigned short, vector unsigned short);
15802 int vec_any_ne (vector bool short, vector bool short);
15803 int vec_any_ne (vector bool short, vector unsigned short);
15804 int vec_any_ne (vector bool short, vector signed short);
15805 int vec_any_ne (vector pixel, vector pixel);
15806 int vec_any_ne (vector signed int, vector bool int);
15807 int vec_any_ne (vector signed int, vector signed int);
15808 int vec_any_ne (vector unsigned int, vector bool int);
15809 int vec_any_ne (vector unsigned int, vector unsigned int);
15810 int vec_any_ne (vector bool int, vector bool int);
15811 int vec_any_ne (vector bool int, vector unsigned int);
15812 int vec_any_ne (vector bool int, vector signed int);
15813 int vec_any_ne (vector float, vector float);
15815 int vec_any_nge (vector float, vector float);
15817 int vec_any_ngt (vector float, vector float);
15819 int vec_any_nle (vector float, vector float);
15821 int vec_any_nlt (vector float, vector float);
15823 int vec_any_numeric (vector float);
15825 int vec_any_out (vector float, vector float);
15826 @end smallexample
15828 If the vector/scalar (VSX) instruction set is available, the following
15829 additional functions are available:
15831 @smallexample
15832 vector double vec_abs (vector double);
15833 vector double vec_add (vector double, vector double);
15834 vector double vec_and (vector double, vector double);
15835 vector double vec_and (vector double, vector bool long);
15836 vector double vec_and (vector bool long, vector double);
15837 vector long vec_and (vector long, vector long);
15838 vector long vec_and (vector long, vector bool long);
15839 vector long vec_and (vector bool long, vector long);
15840 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15841 vector unsigned long vec_and (vector unsigned long, vector bool long);
15842 vector unsigned long vec_and (vector bool long, vector unsigned long);
15843 vector double vec_andc (vector double, vector double);
15844 vector double vec_andc (vector double, vector bool long);
15845 vector double vec_andc (vector bool long, vector double);
15846 vector long vec_andc (vector long, vector long);
15847 vector long vec_andc (vector long, vector bool long);
15848 vector long vec_andc (vector bool long, vector long);
15849 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15850 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15851 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15852 vector double vec_ceil (vector double);
15853 vector bool long vec_cmpeq (vector double, vector double);
15854 vector bool long vec_cmpge (vector double, vector double);
15855 vector bool long vec_cmpgt (vector double, vector double);
15856 vector bool long vec_cmple (vector double, vector double);
15857 vector bool long vec_cmplt (vector double, vector double);
15858 vector double vec_cpsgn (vector double, vector double);
15859 vector float vec_div (vector float, vector float);
15860 vector double vec_div (vector double, vector double);
15861 vector long vec_div (vector long, vector long);
15862 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15863 vector double vec_floor (vector double);
15864 vector double vec_ld (int, const vector double *);
15865 vector double vec_ld (int, const double *);
15866 vector double vec_ldl (int, const vector double *);
15867 vector double vec_ldl (int, const double *);
15868 vector unsigned char vec_lvsl (int, const volatile double *);
15869 vector unsigned char vec_lvsr (int, const volatile double *);
15870 vector double vec_madd (vector double, vector double, vector double);
15871 vector double vec_max (vector double, vector double);
15872 vector signed long vec_mergeh (vector signed long, vector signed long);
15873 vector signed long vec_mergeh (vector signed long, vector bool long);
15874 vector signed long vec_mergeh (vector bool long, vector signed long);
15875 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15876 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15877 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15878 vector signed long vec_mergel (vector signed long, vector signed long);
15879 vector signed long vec_mergel (vector signed long, vector bool long);
15880 vector signed long vec_mergel (vector bool long, vector signed long);
15881 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15882 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15883 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15884 vector double vec_min (vector double, vector double);
15885 vector float vec_msub (vector float, vector float, vector float);
15886 vector double vec_msub (vector double, vector double, vector double);
15887 vector float vec_mul (vector float, vector float);
15888 vector double vec_mul (vector double, vector double);
15889 vector long vec_mul (vector long, vector long);
15890 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15891 vector float vec_nearbyint (vector float);
15892 vector double vec_nearbyint (vector double);
15893 vector float vec_nmadd (vector float, vector float, vector float);
15894 vector double vec_nmadd (vector double, vector double, vector double);
15895 vector double vec_nmsub (vector double, vector double, vector double);
15896 vector double vec_nor (vector double, vector double);
15897 vector long vec_nor (vector long, vector long);
15898 vector long vec_nor (vector long, vector bool long);
15899 vector long vec_nor (vector bool long, vector long);
15900 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15901 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15902 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15903 vector double vec_or (vector double, vector double);
15904 vector double vec_or (vector double, vector bool long);
15905 vector double vec_or (vector bool long, vector double);
15906 vector long vec_or (vector long, vector long);
15907 vector long vec_or (vector long, vector bool long);
15908 vector long vec_or (vector bool long, vector long);
15909 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15910 vector unsigned long vec_or (vector unsigned long, vector bool long);
15911 vector unsigned long vec_or (vector bool long, vector unsigned long);
15912 vector double vec_perm (vector double, vector double, vector unsigned char);
15913 vector long vec_perm (vector long, vector long, vector unsigned char);
15914 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15915                                vector unsigned char);
15916 vector double vec_rint (vector double);
15917 vector double vec_recip (vector double, vector double);
15918 vector double vec_rsqrt (vector double);
15919 vector double vec_rsqrte (vector double);
15920 vector double vec_sel (vector double, vector double, vector bool long);
15921 vector double vec_sel (vector double, vector double, vector unsigned long);
15922 vector long vec_sel (vector long, vector long, vector long);
15923 vector long vec_sel (vector long, vector long, vector unsigned long);
15924 vector long vec_sel (vector long, vector long, vector bool long);
15925 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15926                               vector long);
15927 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15928                               vector unsigned long);
15929 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15930                               vector bool long);
15931 vector double vec_splats (double);
15932 vector signed long vec_splats (signed long);
15933 vector unsigned long vec_splats (unsigned long);
15934 vector float vec_sqrt (vector float);
15935 vector double vec_sqrt (vector double);
15936 void vec_st (vector double, int, vector double *);
15937 void vec_st (vector double, int, double *);
15938 vector double vec_sub (vector double, vector double);
15939 vector double vec_trunc (vector double);
15940 vector double vec_xor (vector double, vector double);
15941 vector double vec_xor (vector double, vector bool long);
15942 vector double vec_xor (vector bool long, vector double);
15943 vector long vec_xor (vector long, vector long);
15944 vector long vec_xor (vector long, vector bool long);
15945 vector long vec_xor (vector bool long, vector long);
15946 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15947 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15948 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15949 int vec_all_eq (vector double, vector double);
15950 int vec_all_ge (vector double, vector double);
15951 int vec_all_gt (vector double, vector double);
15952 int vec_all_le (vector double, vector double);
15953 int vec_all_lt (vector double, vector double);
15954 int vec_all_nan (vector double);
15955 int vec_all_ne (vector double, vector double);
15956 int vec_all_nge (vector double, vector double);
15957 int vec_all_ngt (vector double, vector double);
15958 int vec_all_nle (vector double, vector double);
15959 int vec_all_nlt (vector double, vector double);
15960 int vec_all_numeric (vector double);
15961 int vec_any_eq (vector double, vector double);
15962 int vec_any_ge (vector double, vector double);
15963 int vec_any_gt (vector double, vector double);
15964 int vec_any_le (vector double, vector double);
15965 int vec_any_lt (vector double, vector double);
15966 int vec_any_nan (vector double);
15967 int vec_any_ne (vector double, vector double);
15968 int vec_any_nge (vector double, vector double);
15969 int vec_any_ngt (vector double, vector double);
15970 int vec_any_nle (vector double, vector double);
15971 int vec_any_nlt (vector double, vector double);
15972 int vec_any_numeric (vector double);
15974 vector double vec_vsx_ld (int, const vector double *);
15975 vector double vec_vsx_ld (int, const double *);
15976 vector float vec_vsx_ld (int, const vector float *);
15977 vector float vec_vsx_ld (int, const float *);
15978 vector bool int vec_vsx_ld (int, const vector bool int *);
15979 vector signed int vec_vsx_ld (int, const vector signed int *);
15980 vector signed int vec_vsx_ld (int, const int *);
15981 vector signed int vec_vsx_ld (int, const long *);
15982 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15983 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15984 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15985 vector bool short vec_vsx_ld (int, const vector bool short *);
15986 vector pixel vec_vsx_ld (int, const vector pixel *);
15987 vector signed short vec_vsx_ld (int, const vector signed short *);
15988 vector signed short vec_vsx_ld (int, const short *);
15989 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15990 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15991 vector bool char vec_vsx_ld (int, const vector bool char *);
15992 vector signed char vec_vsx_ld (int, const vector signed char *);
15993 vector signed char vec_vsx_ld (int, const signed char *);
15994 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15995 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15997 void vec_vsx_st (vector double, int, vector double *);
15998 void vec_vsx_st (vector double, int, double *);
15999 void vec_vsx_st (vector float, int, vector float *);
16000 void vec_vsx_st (vector float, int, float *);
16001 void vec_vsx_st (vector signed int, int, vector signed int *);
16002 void vec_vsx_st (vector signed int, int, int *);
16003 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
16004 void vec_vsx_st (vector unsigned int, int, unsigned int *);
16005 void vec_vsx_st (vector bool int, int, vector bool int *);
16006 void vec_vsx_st (vector bool int, int, unsigned int *);
16007 void vec_vsx_st (vector bool int, int, int *);
16008 void vec_vsx_st (vector signed short, int, vector signed short *);
16009 void vec_vsx_st (vector signed short, int, short *);
16010 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
16011 void vec_vsx_st (vector unsigned short, int, unsigned short *);
16012 void vec_vsx_st (vector bool short, int, vector bool short *);
16013 void vec_vsx_st (vector bool short, int, unsigned short *);
16014 void vec_vsx_st (vector pixel, int, vector pixel *);
16015 void vec_vsx_st (vector pixel, int, unsigned short *);
16016 void vec_vsx_st (vector pixel, int, short *);
16017 void vec_vsx_st (vector bool short, int, short *);
16018 void vec_vsx_st (vector signed char, int, vector signed char *);
16019 void vec_vsx_st (vector signed char, int, signed char *);
16020 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
16021 void vec_vsx_st (vector unsigned char, int, unsigned char *);
16022 void vec_vsx_st (vector bool char, int, vector bool char *);
16023 void vec_vsx_st (vector bool char, int, unsigned char *);
16024 void vec_vsx_st (vector bool char, int, signed char *);
16026 vector double vec_xxpermdi (vector double, vector double, int);
16027 vector float vec_xxpermdi (vector float, vector float, int);
16028 vector long long vec_xxpermdi (vector long long, vector long long, int);
16029 vector unsigned long long vec_xxpermdi (vector unsigned long long,
16030                                         vector unsigned long long, int);
16031 vector int vec_xxpermdi (vector int, vector int, int);
16032 vector unsigned int vec_xxpermdi (vector unsigned int,
16033                                   vector unsigned int, int);
16034 vector short vec_xxpermdi (vector short, vector short, int);
16035 vector unsigned short vec_xxpermdi (vector unsigned short,
16036                                     vector unsigned short, int);
16037 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
16038 vector unsigned char vec_xxpermdi (vector unsigned char,
16039                                    vector unsigned char, int);
16041 vector double vec_xxsldi (vector double, vector double, int);
16042 vector float vec_xxsldi (vector float, vector float, int);
16043 vector long long vec_xxsldi (vector long long, vector long long, int);
16044 vector unsigned long long vec_xxsldi (vector unsigned long long,
16045                                       vector unsigned long long, int);
16046 vector int vec_xxsldi (vector int, vector int, int);
16047 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
16048 vector short vec_xxsldi (vector short, vector short, int);
16049 vector unsigned short vec_xxsldi (vector unsigned short,
16050                                   vector unsigned short, int);
16051 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
16052 vector unsigned char vec_xxsldi (vector unsigned char,
16053                                  vector unsigned char, int);
16054 @end smallexample
16056 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16057 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16058 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
16059 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16060 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16062 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16063 instruction set is available, the following additional functions are
16064 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
16065 can use @var{vector long} instead of @var{vector long long},
16066 @var{vector bool long} instead of @var{vector bool long long}, and
16067 @var{vector unsigned long} instead of @var{vector unsigned long long}.
16069 @smallexample
16070 vector long long vec_abs (vector long long);
16072 vector long long vec_add (vector long long, vector long long);
16073 vector unsigned long long vec_add (vector unsigned long long,
16074                                    vector unsigned long long);
16076 int vec_all_eq (vector long long, vector long long);
16077 int vec_all_eq (vector unsigned long long, vector unsigned long long);
16078 int vec_all_ge (vector long long, vector long long);
16079 int vec_all_ge (vector unsigned long long, vector unsigned long long);
16080 int vec_all_gt (vector long long, vector long long);
16081 int vec_all_gt (vector unsigned long long, vector unsigned long long);
16082 int vec_all_le (vector long long, vector long long);
16083 int vec_all_le (vector unsigned long long, vector unsigned long long);
16084 int vec_all_lt (vector long long, vector long long);
16085 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16086 int vec_all_ne (vector long long, vector long long);
16087 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16089 int vec_any_eq (vector long long, vector long long);
16090 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16091 int vec_any_ge (vector long long, vector long long);
16092 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16093 int vec_any_gt (vector long long, vector long long);
16094 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16095 int vec_any_le (vector long long, vector long long);
16096 int vec_any_le (vector unsigned long long, vector unsigned long long);
16097 int vec_any_lt (vector long long, vector long long);
16098 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16099 int vec_any_ne (vector long long, vector long long);
16100 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16102 vector long long vec_eqv (vector long long, vector long long);
16103 vector long long vec_eqv (vector bool long long, vector long long);
16104 vector long long vec_eqv (vector long long, vector bool long long);
16105 vector unsigned long long vec_eqv (vector unsigned long long,
16106                                    vector unsigned long long);
16107 vector unsigned long long vec_eqv (vector bool long long,
16108                                    vector unsigned long long);
16109 vector unsigned long long vec_eqv (vector unsigned long long,
16110                                    vector bool long long);
16111 vector int vec_eqv (vector int, vector int);
16112 vector int vec_eqv (vector bool int, vector int);
16113 vector int vec_eqv (vector int, vector bool int);
16114 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16115 vector unsigned int vec_eqv (vector bool unsigned int,
16116                              vector unsigned int);
16117 vector unsigned int vec_eqv (vector unsigned int,
16118                              vector bool unsigned int);
16119 vector short vec_eqv (vector short, vector short);
16120 vector short vec_eqv (vector bool short, vector short);
16121 vector short vec_eqv (vector short, vector bool short);
16122 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16123 vector unsigned short vec_eqv (vector bool unsigned short,
16124                                vector unsigned short);
16125 vector unsigned short vec_eqv (vector unsigned short,
16126                                vector bool unsigned short);
16127 vector signed char vec_eqv (vector signed char, vector signed char);
16128 vector signed char vec_eqv (vector bool signed char, vector signed char);
16129 vector signed char vec_eqv (vector signed char, vector bool signed char);
16130 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16131 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16132 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16134 vector long long vec_max (vector long long, vector long long);
16135 vector unsigned long long vec_max (vector unsigned long long,
16136                                    vector unsigned long long);
16138 vector signed int vec_mergee (vector signed int, vector signed int);
16139 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16140 vector bool int vec_mergee (vector bool int, vector bool int);
16142 vector signed int vec_mergeo (vector signed int, vector signed int);
16143 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16144 vector bool int vec_mergeo (vector bool int, vector bool int);
16146 vector long long vec_min (vector long long, vector long long);
16147 vector unsigned long long vec_min (vector unsigned long long,
16148                                    vector unsigned long long);
16150 vector long long vec_nand (vector long long, vector long long);
16151 vector long long vec_nand (vector bool long long, vector long long);
16152 vector long long vec_nand (vector long long, vector bool long long);
16153 vector unsigned long long vec_nand (vector unsigned long long,
16154                                     vector unsigned long long);
16155 vector unsigned long long vec_nand (vector bool long long,
16156                                    vector unsigned long long);
16157 vector unsigned long long vec_nand (vector unsigned long long,
16158                                     vector bool long long);
16159 vector int vec_nand (vector int, vector int);
16160 vector int vec_nand (vector bool int, vector int);
16161 vector int vec_nand (vector int, vector bool int);
16162 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16163 vector unsigned int vec_nand (vector bool unsigned int,
16164                               vector unsigned int);
16165 vector unsigned int vec_nand (vector unsigned int,
16166                               vector bool unsigned int);
16167 vector short vec_nand (vector short, vector short);
16168 vector short vec_nand (vector bool short, vector short);
16169 vector short vec_nand (vector short, vector bool short);
16170 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16171 vector unsigned short vec_nand (vector bool unsigned short,
16172                                 vector unsigned short);
16173 vector unsigned short vec_nand (vector unsigned short,
16174                                 vector bool unsigned short);
16175 vector signed char vec_nand (vector signed char, vector signed char);
16176 vector signed char vec_nand (vector bool signed char, vector signed char);
16177 vector signed char vec_nand (vector signed char, vector bool signed char);
16178 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16179 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16180 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16182 vector long long vec_orc (vector long long, vector long long);
16183 vector long long vec_orc (vector bool long long, vector long long);
16184 vector long long vec_orc (vector long long, vector bool long long);
16185 vector unsigned long long vec_orc (vector unsigned long long,
16186                                    vector unsigned long long);
16187 vector unsigned long long vec_orc (vector bool long long,
16188                                    vector unsigned long long);
16189 vector unsigned long long vec_orc (vector unsigned long long,
16190                                    vector bool long long);
16191 vector int vec_orc (vector int, vector int);
16192 vector int vec_orc (vector bool int, vector int);
16193 vector int vec_orc (vector int, vector bool int);
16194 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16195 vector unsigned int vec_orc (vector bool unsigned int,
16196                              vector unsigned int);
16197 vector unsigned int vec_orc (vector unsigned int,
16198                              vector bool unsigned int);
16199 vector short vec_orc (vector short, vector short);
16200 vector short vec_orc (vector bool short, vector short);
16201 vector short vec_orc (vector short, vector bool short);
16202 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16203 vector unsigned short vec_orc (vector bool unsigned short,
16204                                vector unsigned short);
16205 vector unsigned short vec_orc (vector unsigned short,
16206                                vector bool unsigned short);
16207 vector signed char vec_orc (vector signed char, vector signed char);
16208 vector signed char vec_orc (vector bool signed char, vector signed char);
16209 vector signed char vec_orc (vector signed char, vector bool signed char);
16210 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16211 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16212 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16214 vector int vec_pack (vector long long, vector long long);
16215 vector unsigned int vec_pack (vector unsigned long long,
16216                               vector unsigned long long);
16217 vector bool int vec_pack (vector bool long long, vector bool long long);
16219 vector int vec_packs (vector long long, vector long long);
16220 vector unsigned int vec_packs (vector unsigned long long,
16221                                vector unsigned long long);
16223 vector unsigned int vec_packsu (vector long long, vector long long);
16224 vector unsigned int vec_packsu (vector unsigned long long,
16225                                 vector unsigned long long);
16227 vector long long vec_rl (vector long long,
16228                          vector unsigned long long);
16229 vector long long vec_rl (vector unsigned long long,
16230                          vector unsigned long long);
16232 vector long long vec_sl (vector long long, vector unsigned long long);
16233 vector long long vec_sl (vector unsigned long long,
16234                          vector unsigned long long);
16236 vector long long vec_sr (vector long long, vector unsigned long long);
16237 vector unsigned long long char vec_sr (vector unsigned long long,
16238                                        vector unsigned long long);
16240 vector long long vec_sra (vector long long, vector unsigned long long);
16241 vector unsigned long long vec_sra (vector unsigned long long,
16242                                    vector unsigned long long);
16244 vector long long vec_sub (vector long long, vector long long);
16245 vector unsigned long long vec_sub (vector unsigned long long,
16246                                    vector unsigned long long);
16248 vector long long vec_unpackh (vector int);
16249 vector unsigned long long vec_unpackh (vector unsigned int);
16251 vector long long vec_unpackl (vector int);
16252 vector unsigned long long vec_unpackl (vector unsigned int);
16254 vector long long vec_vaddudm (vector long long, vector long long);
16255 vector long long vec_vaddudm (vector bool long long, vector long long);
16256 vector long long vec_vaddudm (vector long long, vector bool long long);
16257 vector unsigned long long vec_vaddudm (vector unsigned long long,
16258                                        vector unsigned long long);
16259 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16260                                        vector unsigned long long);
16261 vector unsigned long long vec_vaddudm (vector unsigned long long,
16262                                        vector bool unsigned long long);
16264 vector long long vec_vbpermq (vector signed char, vector signed char);
16265 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16267 vector long long vec_cntlz (vector long long);
16268 vector unsigned long long vec_cntlz (vector unsigned long long);
16269 vector int vec_cntlz (vector int);
16270 vector unsigned int vec_cntlz (vector int);
16271 vector short vec_cntlz (vector short);
16272 vector unsigned short vec_cntlz (vector unsigned short);
16273 vector signed char vec_cntlz (vector signed char);
16274 vector unsigned char vec_cntlz (vector unsigned char);
16276 vector long long vec_vclz (vector long long);
16277 vector unsigned long long vec_vclz (vector unsigned long long);
16278 vector int vec_vclz (vector int);
16279 vector unsigned int vec_vclz (vector int);
16280 vector short vec_vclz (vector short);
16281 vector unsigned short vec_vclz (vector unsigned short);
16282 vector signed char vec_vclz (vector signed char);
16283 vector unsigned char vec_vclz (vector unsigned char);
16285 vector signed char vec_vclzb (vector signed char);
16286 vector unsigned char vec_vclzb (vector unsigned char);
16288 vector long long vec_vclzd (vector long long);
16289 vector unsigned long long vec_vclzd (vector unsigned long long);
16291 vector short vec_vclzh (vector short);
16292 vector unsigned short vec_vclzh (vector unsigned short);
16294 vector int vec_vclzw (vector int);
16295 vector unsigned int vec_vclzw (vector int);
16297 vector signed char vec_vgbbd (vector signed char);
16298 vector unsigned char vec_vgbbd (vector unsigned char);
16300 vector long long vec_vmaxsd (vector long long, vector long long);
16302 vector unsigned long long vec_vmaxud (vector unsigned long long,
16303                                       unsigned vector long long);
16305 vector long long vec_vminsd (vector long long, vector long long);
16307 vector unsigned long long vec_vminud (vector long long,
16308                                       vector long long);
16310 vector int vec_vpksdss (vector long long, vector long long);
16311 vector unsigned int vec_vpksdss (vector long long, vector long long);
16313 vector unsigned int vec_vpkudus (vector unsigned long long,
16314                                  vector unsigned long long);
16316 vector int vec_vpkudum (vector long long, vector long long);
16317 vector unsigned int vec_vpkudum (vector unsigned long long,
16318                                  vector unsigned long long);
16319 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16321 vector long long vec_vpopcnt (vector long long);
16322 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16323 vector int vec_vpopcnt (vector int);
16324 vector unsigned int vec_vpopcnt (vector int);
16325 vector short vec_vpopcnt (vector short);
16326 vector unsigned short vec_vpopcnt (vector unsigned short);
16327 vector signed char vec_vpopcnt (vector signed char);
16328 vector unsigned char vec_vpopcnt (vector unsigned char);
16330 vector signed char vec_vpopcntb (vector signed char);
16331 vector unsigned char vec_vpopcntb (vector unsigned char);
16333 vector long long vec_vpopcntd (vector long long);
16334 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16336 vector short vec_vpopcnth (vector short);
16337 vector unsigned short vec_vpopcnth (vector unsigned short);
16339 vector int vec_vpopcntw (vector int);
16340 vector unsigned int vec_vpopcntw (vector int);
16342 vector long long vec_vrld (vector long long, vector unsigned long long);
16343 vector unsigned long long vec_vrld (vector unsigned long long,
16344                                     vector unsigned long long);
16346 vector long long vec_vsld (vector long long, vector unsigned long long);
16347 vector long long vec_vsld (vector unsigned long long,
16348                            vector unsigned long long);
16350 vector long long vec_vsrad (vector long long, vector unsigned long long);
16351 vector unsigned long long vec_vsrad (vector unsigned long long,
16352                                      vector unsigned long long);
16354 vector long long vec_vsrd (vector long long, vector unsigned long long);
16355 vector unsigned long long char vec_vsrd (vector unsigned long long,
16356                                          vector unsigned long long);
16358 vector long long vec_vsubudm (vector long long, vector long long);
16359 vector long long vec_vsubudm (vector bool long long, vector long long);
16360 vector long long vec_vsubudm (vector long long, vector bool long long);
16361 vector unsigned long long vec_vsubudm (vector unsigned long long,
16362                                        vector unsigned long long);
16363 vector unsigned long long vec_vsubudm (vector bool long long,
16364                                        vector unsigned long long);
16365 vector unsigned long long vec_vsubudm (vector unsigned long long,
16366                                        vector bool long long);
16368 vector long long vec_vupkhsw (vector int);
16369 vector unsigned long long vec_vupkhsw (vector unsigned int);
16371 vector long long vec_vupklsw (vector int);
16372 vector unsigned long long vec_vupklsw (vector int);
16373 @end smallexample
16375 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16376 instruction set is available, the following additional functions are
16377 available for 64-bit targets.  New vector types
16378 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16379 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16380 builtins.
16382 The normal vector extract, and set operations work on
16383 @var{vector __int128_t} and @var{vector __uint128_t} types,
16384 but the index value must be 0.
16386 @smallexample
16387 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16388 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16390 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16391 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16393 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16394                                 vector __int128_t);
16395 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
16396                                  vector __uint128_t);
16398 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16399                                 vector __int128_t);
16400 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
16401                                  vector __uint128_t);
16403 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16404                                 vector __int128_t);
16405 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
16406                                  vector __uint128_t);
16408 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16409                                 vector __int128_t);
16410 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16411                                  vector __uint128_t);
16413 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16414 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16416 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16417 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16419 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16420 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16421 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16422 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16423 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16424 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16425 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16426 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16427 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16428 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16429 @end smallexample
16431 If the cryptographic instructions are enabled (@option{-mcrypto} or
16432 @option{-mcpu=power8}), the following builtins are enabled.
16434 @smallexample
16435 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16437 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16438                                                     vector unsigned long long);
16440 vector unsigned long long __builtin_crypto_vcipherlast
16441                                      (vector unsigned long long,
16442                                       vector unsigned long long);
16444 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16445                                                      vector unsigned long long);
16447 vector unsigned long long __builtin_crypto_vncipherlast
16448                                      (vector unsigned long long,
16449                                       vector unsigned long long);
16451 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16452                                                 vector unsigned char,
16453                                                 vector unsigned char);
16455 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16456                                                  vector unsigned short,
16457                                                  vector unsigned short);
16459 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16460                                                vector unsigned int,
16461                                                vector unsigned int);
16463 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16464                                                      vector unsigned long long,
16465                                                      vector unsigned long long);
16467 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16468                                                vector unsigned char);
16470 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16471                                                 vector unsigned short);
16473 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16474                                               vector unsigned int);
16476 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16477                                                     vector unsigned long long);
16479 vector unsigned long long __builtin_crypto_vshasigmad
16480                                (vector unsigned long long, int, int);
16482 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16483                                                  int, int);
16484 @end smallexample
16486 The second argument to the @var{__builtin_crypto_vshasigmad} and
16487 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16488 integer that is 0 or 1.  The third argument to these builtin functions
16489 must be a constant integer in the range of 0 to 15.
16491 @node PowerPC Hardware Transactional Memory Built-in Functions
16492 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16493 GCC provides two interfaces for accessing the Hardware Transactional
16494 Memory (HTM) instructions available on some of the PowerPC family
16495 of prcoessors (eg, POWER8).  The two interfaces come in a low level
16496 interface, consisting of built-in functions specific to PowerPC and a
16497 higher level interface consisting of inline functions that are common
16498 between PowerPC and S/390.
16500 @subsubsection PowerPC HTM Low Level Built-in Functions
16502 The following low level built-in functions are available with
16503 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16504 They all generate the machine instruction that is part of the name.
16506 The HTM built-ins return true or false depending on their success and
16507 their arguments match exactly the type and order of the associated
16508 hardware instruction's operands.  Refer to the ISA manual for a
16509 description of each instruction's operands.
16511 @smallexample
16512 unsigned int __builtin_tbegin (unsigned int)
16513 unsigned int __builtin_tend (unsigned int)
16515 unsigned int __builtin_tabort (unsigned int)
16516 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16517 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16518 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16519 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16521 unsigned int __builtin_tcheck (unsigned int)
16522 unsigned int __builtin_treclaim (unsigned int)
16523 unsigned int __builtin_trechkpt (void)
16524 unsigned int __builtin_tsr (unsigned int)
16525 @end smallexample
16527 In addition to the above HTM built-ins, we have added built-ins for
16528 some common extended mnemonics of the HTM instructions:
16530 @smallexample
16531 unsigned int __builtin_tendall (void)
16532 unsigned int __builtin_tresume (void)
16533 unsigned int __builtin_tsuspend (void)
16534 @end smallexample
16536 The following set of built-in functions are available to gain access
16537 to the HTM specific special purpose registers.
16539 @smallexample
16540 unsigned long __builtin_get_texasr (void)
16541 unsigned long __builtin_get_texasru (void)
16542 unsigned long __builtin_get_tfhar (void)
16543 unsigned long __builtin_get_tfiar (void)
16545 void __builtin_set_texasr (unsigned long);
16546 void __builtin_set_texasru (unsigned long);
16547 void __builtin_set_tfhar (unsigned long);
16548 void __builtin_set_tfiar (unsigned long);
16549 @end smallexample
16551 Example usage of these low level built-in functions may look like:
16553 @smallexample
16554 #include <htmintrin.h>
16556 int num_retries = 10;
16558 while (1)
16559   @{
16560     if (__builtin_tbegin (0))
16561       @{
16562         /* Transaction State Initiated.  */
16563         if (is_locked (lock))
16564           __builtin_tabort (0);
16565         ... transaction code...
16566         __builtin_tend (0);
16567         break;
16568       @}
16569     else
16570       @{
16571         /* Transaction State Failed.  Use locks if the transaction
16572            failure is "persistent" or we've tried too many times.  */
16573         if (num_retries-- <= 0
16574             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16575           @{
16576             acquire_lock (lock);
16577             ... non transactional fallback path...
16578             release_lock (lock);
16579             break;
16580           @}
16581       @}
16582   @}
16583 @end smallexample
16585 One final built-in function has been added that returns the value of
16586 the 2-bit Transaction State field of the Machine Status Register (MSR)
16587 as stored in @code{CR0}.
16589 @smallexample
16590 unsigned long __builtin_ttest (void)
16591 @end smallexample
16593 This built-in can be used to determine the current transaction state
16594 using the following code example:
16596 @smallexample
16597 #include <htmintrin.h>
16599 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16601 if (tx_state == _HTM_TRANSACTIONAL)
16602   @{
16603     /* Code to use in transactional state.  */
16604   @}
16605 else if (tx_state == _HTM_NONTRANSACTIONAL)
16606   @{
16607     /* Code to use in non-transactional state.  */
16608   @}
16609 else if (tx_state == _HTM_SUSPENDED)
16610   @{
16611     /* Code to use in transaction suspended state.  */
16612   @}
16613 @end smallexample
16615 @subsubsection PowerPC HTM High Level Inline Functions
16617 The following high level HTM interface is made available by including
16618 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16619 where CPU is `power8' or later.  This interface is common between PowerPC
16620 and S/390, allowing users to write one HTM source implementation that
16621 can be compiled and executed on either system.
16623 @smallexample
16624 long __TM_simple_begin (void)
16625 long __TM_begin (void* const TM_buff)
16626 long __TM_end (void)
16627 void __TM_abort (void)
16628 void __TM_named_abort (unsigned char const code)
16629 void __TM_resume (void)
16630 void __TM_suspend (void)
16632 long __TM_is_user_abort (void* const TM_buff)
16633 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16634 long __TM_is_illegal (void* const TM_buff)
16635 long __TM_is_footprint_exceeded (void* const TM_buff)
16636 long __TM_nesting_depth (void* const TM_buff)
16637 long __TM_is_nested_too_deep(void* const TM_buff)
16638 long __TM_is_conflict(void* const TM_buff)
16639 long __TM_is_failure_persistent(void* const TM_buff)
16640 long __TM_failure_address(void* const TM_buff)
16641 long long __TM_failure_code(void* const TM_buff)
16642 @end smallexample
16644 Using these common set of HTM inline functions, we can create
16645 a more portable version of the HTM example in the previous
16646 section that will work on either PowerPC or S/390:
16648 @smallexample
16649 #include <htmxlintrin.h>
16651 int num_retries = 10;
16652 TM_buff_type TM_buff;
16654 while (1)
16655   @{
16656     if (__TM_begin (TM_buff))
16657       @{
16658         /* Transaction State Initiated.  */
16659         if (is_locked (lock))
16660           __TM_abort ();
16661         ... transaction code...
16662         __TM_end ();
16663         break;
16664       @}
16665     else
16666       @{
16667         /* Transaction State Failed.  Use locks if the transaction
16668            failure is "persistent" or we've tried too many times.  */
16669         if (num_retries-- <= 0
16670             || __TM_is_failure_persistent (TM_buff))
16671           @{
16672             acquire_lock (lock);
16673             ... non transactional fallback path...
16674             release_lock (lock);
16675             break;
16676           @}
16677       @}
16678   @}
16679 @end smallexample
16681 @node RX Built-in Functions
16682 @subsection RX Built-in Functions
16683 GCC supports some of the RX instructions which cannot be expressed in
16684 the C programming language via the use of built-in functions.  The
16685 following functions are supported:
16687 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
16688 Generates the @code{brk} machine instruction.
16689 @end deftypefn
16691 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
16692 Generates the @code{clrpsw} machine instruction to clear the specified
16693 bit in the processor status word.
16694 @end deftypefn
16696 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
16697 Generates the @code{int} machine instruction to generate an interrupt
16698 with the specified value.
16699 @end deftypefn
16701 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
16702 Generates the @code{machi} machine instruction to add the result of
16703 multiplying the top 16 bits of the two arguments into the
16704 accumulator.
16705 @end deftypefn
16707 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
16708 Generates the @code{maclo} machine instruction to add the result of
16709 multiplying the bottom 16 bits of the two arguments into the
16710 accumulator.
16711 @end deftypefn
16713 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
16714 Generates the @code{mulhi} machine instruction to place the result of
16715 multiplying the top 16 bits of the two arguments into the
16716 accumulator.
16717 @end deftypefn
16719 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
16720 Generates the @code{mullo} machine instruction to place the result of
16721 multiplying the bottom 16 bits of the two arguments into the
16722 accumulator.
16723 @end deftypefn
16725 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
16726 Generates the @code{mvfachi} machine instruction to read the top
16727 32 bits of the accumulator.
16728 @end deftypefn
16730 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
16731 Generates the @code{mvfacmi} machine instruction to read the middle
16732 32 bits of the accumulator.
16733 @end deftypefn
16735 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
16736 Generates the @code{mvfc} machine instruction which reads the control
16737 register specified in its argument and returns its value.
16738 @end deftypefn
16740 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
16741 Generates the @code{mvtachi} machine instruction to set the top
16742 32 bits of the accumulator.
16743 @end deftypefn
16745 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
16746 Generates the @code{mvtaclo} machine instruction to set the bottom
16747 32 bits of the accumulator.
16748 @end deftypefn
16750 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
16751 Generates the @code{mvtc} machine instruction which sets control
16752 register number @code{reg} to @code{val}.
16753 @end deftypefn
16755 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
16756 Generates the @code{mvtipl} machine instruction set the interrupt
16757 priority level.
16758 @end deftypefn
16760 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
16761 Generates the @code{racw} machine instruction to round the accumulator
16762 according to the specified mode.
16763 @end deftypefn
16765 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
16766 Generates the @code{revw} machine instruction which swaps the bytes in
16767 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16768 and also bits 16--23 occupy bits 24--31 and vice versa.
16769 @end deftypefn
16771 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
16772 Generates the @code{rmpa} machine instruction which initiates a
16773 repeated multiply and accumulate sequence.
16774 @end deftypefn
16776 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
16777 Generates the @code{round} machine instruction which returns the
16778 floating-point argument rounded according to the current rounding mode
16779 set in the floating-point status word register.
16780 @end deftypefn
16782 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
16783 Generates the @code{sat} machine instruction which returns the
16784 saturated value of the argument.
16785 @end deftypefn
16787 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
16788 Generates the @code{setpsw} machine instruction to set the specified
16789 bit in the processor status word.
16790 @end deftypefn
16792 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
16793 Generates the @code{wait} machine instruction.
16794 @end deftypefn
16796 @node S/390 System z Built-in Functions
16797 @subsection S/390 System z Built-in Functions
16798 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16799 Generates the @code{tbegin} machine instruction starting a
16800 non-constraint hardware transaction.  If the parameter is non-NULL the
16801 memory area is used to store the transaction diagnostic buffer and
16802 will be passed as first operand to @code{tbegin}.  This buffer can be
16803 defined using the @code{struct __htm_tdb} C struct defined in
16804 @code{htmintrin.h} and must reside on a double-word boundary.  The
16805 second tbegin operand is set to @code{0xff0c}. This enables
16806 save/restore of all GPRs and disables aborts for FPR and AR
16807 manipulations inside the transaction body.  The condition code set by
16808 the tbegin instruction is returned as integer value.  The tbegin
16809 instruction by definition overwrites the content of all FPRs.  The
16810 compiler will generate code which saves and restores the FPRs.  For
16811 soft-float code it is recommended to used the @code{*_nofloat}
16812 variant.  In order to prevent a TDB from being written it is required
16813 to pass an constant zero value as parameter.  Passing the zero value
16814 through a variable is not sufficient.  Although modifications of
16815 access registers inside the transaction will not trigger an
16816 transaction abort it is not supported to actually modify them.  Access
16817 registers do not get saved when entering a transaction. They will have
16818 undefined state when reaching the abort code.
16819 @end deftypefn
16821 Macros for the possible return codes of tbegin are defined in the
16822 @code{htmintrin.h} header file:
16824 @table @code
16825 @item _HTM_TBEGIN_STARTED
16826 @code{tbegin} has been executed as part of normal processing.  The
16827 transaction body is supposed to be executed.
16828 @item _HTM_TBEGIN_INDETERMINATE
16829 The transaction was aborted due to an indeterminate condition which
16830 might be persistent.
16831 @item _HTM_TBEGIN_TRANSIENT
16832 The transaction aborted due to a transient failure.  The transaction
16833 should be re-executed in that case.
16834 @item _HTM_TBEGIN_PERSISTENT
16835 The transaction aborted due to a persistent failure.  Re-execution
16836 under same circumstances will not be productive.
16837 @end table
16839 @defmac _HTM_FIRST_USER_ABORT_CODE
16840 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16841 specifies the first abort code which can be used for
16842 @code{__builtin_tabort}.  Values below this threshold are reserved for
16843 machine use.
16844 @end defmac
16846 @deftp {Data type} {struct __htm_tdb}
16847 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16848 the structure of the transaction diagnostic block as specified in the
16849 Principles of Operation manual chapter 5-91.
16850 @end deftp
16852 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16853 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16854 Using this variant in code making use of FPRs will leave the FPRs in
16855 undefined state when entering the transaction abort handler code.
16856 @end deftypefn
16858 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16859 In addition to @code{__builtin_tbegin} a loop for transient failures
16860 is generated.  If tbegin returns a condition code of 2 the transaction
16861 will be retried as often as specified in the second argument.  The
16862 perform processor assist instruction is used to tell the CPU about the
16863 number of fails so far.
16864 @end deftypefn
16866 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16867 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16868 restores.  Using this variant in code making use of FPRs will leave
16869 the FPRs in undefined state when entering the transaction abort
16870 handler code.
16871 @end deftypefn
16873 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16874 Generates the @code{tbeginc} machine instruction starting a constraint
16875 hardware transaction.  The second operand is set to @code{0xff08}.
16876 @end deftypefn
16878 @deftypefn {Built-in Function} int __builtin_tend (void)
16879 Generates the @code{tend} machine instruction finishing a transaction
16880 and making the changes visible to other threads.  The condition code
16881 generated by tend is returned as integer value.
16882 @end deftypefn
16884 @deftypefn {Built-in Function} void __builtin_tabort (int)
16885 Generates the @code{tabort} machine instruction with the specified
16886 abort code.  Abort codes from 0 through 255 are reserved and will
16887 result in an error message.
16888 @end deftypefn
16890 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16891 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16892 integer parameter is loaded into rX and a value of zero is loaded into
16893 rY.  The integer parameter specifies the number of times the
16894 transaction repeatedly aborted.
16895 @end deftypefn
16897 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16898 Generates the @code{etnd} machine instruction.  The current nesting
16899 depth is returned as integer value.  For a nesting depth of 0 the code
16900 is not executed as part of an transaction.
16901 @end deftypefn
16903 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16905 Generates the @code{ntstg} machine instruction.  The second argument
16906 is written to the first arguments location.  The store operation will
16907 not be rolled-back in case of an transaction abort.
16908 @end deftypefn
16910 @node SH Built-in Functions
16911 @subsection SH Built-in Functions
16912 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16913 families of processors:
16915 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16916 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16917 used by system code that manages threads and execution contexts.  The compiler
16918 normally does not generate code that modifies the contents of @samp{GBR} and
16919 thus the value is preserved across function calls.  Changing the @samp{GBR}
16920 value in user code must be done with caution, since the compiler might use
16921 @samp{GBR} in order to access thread local variables.
16923 @end deftypefn
16925 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16926 Returns the value that is currently set in the @samp{GBR} register.
16927 Memory loads and stores that use the thread pointer as a base address are
16928 turned into @samp{GBR} based displacement loads and stores, if possible.
16929 For example:
16930 @smallexample
16931 struct my_tcb
16933    int a, b, c, d, e;
16936 int get_tcb_value (void)
16938   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16939   return ((my_tcb*)__builtin_thread_pointer ())->c;
16942 @end smallexample
16943 @end deftypefn
16945 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16946 Returns the value that is currently set in the @samp{FPSCR} register.
16947 @end deftypefn
16949 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16950 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16951 preserving the current values of the FR, SZ and PR bits.
16952 @end deftypefn
16954 @node SPARC VIS Built-in Functions
16955 @subsection SPARC VIS Built-in Functions
16957 GCC supports SIMD operations on the SPARC using both the generic vector
16958 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16959 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16960 switch, the VIS extension is exposed as the following built-in functions:
16962 @smallexample
16963 typedef int v1si __attribute__ ((vector_size (4)));
16964 typedef int v2si __attribute__ ((vector_size (8)));
16965 typedef short v4hi __attribute__ ((vector_size (8)));
16966 typedef short v2hi __attribute__ ((vector_size (4)));
16967 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16968 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16970 void __builtin_vis_write_gsr (int64_t);
16971 int64_t __builtin_vis_read_gsr (void);
16973 void * __builtin_vis_alignaddr (void *, long);
16974 void * __builtin_vis_alignaddrl (void *, long);
16975 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16976 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16977 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16978 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16980 v4hi __builtin_vis_fexpand (v4qi);
16982 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16983 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16984 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16985 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16986 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16987 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16988 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16990 v4qi __builtin_vis_fpack16 (v4hi);
16991 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16992 v2hi __builtin_vis_fpackfix (v2si);
16993 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16995 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16997 long __builtin_vis_edge8 (void *, void *);
16998 long __builtin_vis_edge8l (void *, void *);
16999 long __builtin_vis_edge16 (void *, void *);
17000 long __builtin_vis_edge16l (void *, void *);
17001 long __builtin_vis_edge32 (void *, void *);
17002 long __builtin_vis_edge32l (void *, void *);
17004 long __builtin_vis_fcmple16 (v4hi, v4hi);
17005 long __builtin_vis_fcmple32 (v2si, v2si);
17006 long __builtin_vis_fcmpne16 (v4hi, v4hi);
17007 long __builtin_vis_fcmpne32 (v2si, v2si);
17008 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
17009 long __builtin_vis_fcmpgt32 (v2si, v2si);
17010 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
17011 long __builtin_vis_fcmpeq32 (v2si, v2si);
17013 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
17014 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
17015 v2si __builtin_vis_fpadd32 (v2si, v2si);
17016 v1si __builtin_vis_fpadd32s (v1si, v1si);
17017 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
17018 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
17019 v2si __builtin_vis_fpsub32 (v2si, v2si);
17020 v1si __builtin_vis_fpsub32s (v1si, v1si);
17022 long __builtin_vis_array8 (long, long);
17023 long __builtin_vis_array16 (long, long);
17024 long __builtin_vis_array32 (long, long);
17025 @end smallexample
17027 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
17028 functions also become available:
17030 @smallexample
17031 long __builtin_vis_bmask (long, long);
17032 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
17033 v2si __builtin_vis_bshufflev2si (v2si, v2si);
17034 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
17035 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
17037 long __builtin_vis_edge8n (void *, void *);
17038 long __builtin_vis_edge8ln (void *, void *);
17039 long __builtin_vis_edge16n (void *, void *);
17040 long __builtin_vis_edge16ln (void *, void *);
17041 long __builtin_vis_edge32n (void *, void *);
17042 long __builtin_vis_edge32ln (void *, void *);
17043 @end smallexample
17045 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
17046 functions also become available:
17048 @smallexample
17049 void __builtin_vis_cmask8 (long);
17050 void __builtin_vis_cmask16 (long);
17051 void __builtin_vis_cmask32 (long);
17053 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
17055 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
17056 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
17057 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
17058 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
17059 v2si __builtin_vis_fsll16 (v2si, v2si);
17060 v2si __builtin_vis_fslas16 (v2si, v2si);
17061 v2si __builtin_vis_fsrl16 (v2si, v2si);
17062 v2si __builtin_vis_fsra16 (v2si, v2si);
17064 long __builtin_vis_pdistn (v8qi, v8qi);
17066 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
17068 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
17069 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
17071 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
17072 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
17073 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
17074 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
17075 v2si __builtin_vis_fpadds32 (v2si, v2si);
17076 v1si __builtin_vis_fpadds32s (v1si, v1si);
17077 v2si __builtin_vis_fpsubs32 (v2si, v2si);
17078 v1si __builtin_vis_fpsubs32s (v1si, v1si);
17080 long __builtin_vis_fucmple8 (v8qi, v8qi);
17081 long __builtin_vis_fucmpne8 (v8qi, v8qi);
17082 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
17083 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
17085 float __builtin_vis_fhadds (float, float);
17086 double __builtin_vis_fhaddd (double, double);
17087 float __builtin_vis_fhsubs (float, float);
17088 double __builtin_vis_fhsubd (double, double);
17089 float __builtin_vis_fnhadds (float, float);
17090 double __builtin_vis_fnhaddd (double, double);
17092 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17093 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17094 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17095 @end smallexample
17097 @node SPU Built-in Functions
17098 @subsection SPU Built-in Functions
17100 GCC provides extensions for the SPU processor as described in the
17101 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17102 found at @uref{http://cell.scei.co.jp/} or
17103 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
17104 implementation differs in several ways.
17106 @itemize @bullet
17108 @item
17109 The optional extension of specifying vector constants in parentheses is
17110 not supported.
17112 @item
17113 A vector initializer requires no cast if the vector constant is of the
17114 same type as the variable it is initializing.
17116 @item
17117 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17118 vector type is the default signedness of the base type.  The default
17119 varies depending on the operating system, so a portable program should
17120 always specify the signedness.
17122 @item
17123 By default, the keyword @code{__vector} is added. The macro
17124 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17125 undefined.
17127 @item
17128 GCC allows using a @code{typedef} name as the type specifier for a
17129 vector type.
17131 @item
17132 For C, overloaded functions are implemented with macros so the following
17133 does not work:
17135 @smallexample
17136   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17137 @end smallexample
17139 @noindent
17140 Since @code{spu_add} is a macro, the vector constant in the example
17141 is treated as four separate arguments.  Wrap the entire argument in
17142 parentheses for this to work.
17144 @item
17145 The extended version of @code{__builtin_expect} is not supported.
17147 @end itemize
17149 @emph{Note:} Only the interface described in the aforementioned
17150 specification is supported. Internally, GCC uses built-in functions to
17151 implement the required functionality, but these are not supported and
17152 are subject to change without notice.
17154 @node TI C6X Built-in Functions
17155 @subsection TI C6X Built-in Functions
17157 GCC provides intrinsics to access certain instructions of the TI C6X
17158 processors.  These intrinsics, listed below, are available after
17159 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
17160 to C6X instructions.
17162 @smallexample
17164 int _sadd (int, int)
17165 int _ssub (int, int)
17166 int _sadd2 (int, int)
17167 int _ssub2 (int, int)
17168 long long _mpy2 (int, int)
17169 long long _smpy2 (int, int)
17170 int _add4 (int, int)
17171 int _sub4 (int, int)
17172 int _saddu4 (int, int)
17174 int _smpy (int, int)
17175 int _smpyh (int, int)
17176 int _smpyhl (int, int)
17177 int _smpylh (int, int)
17179 int _sshl (int, int)
17180 int _subc (int, int)
17182 int _avg2 (int, int)
17183 int _avgu4 (int, int)
17185 int _clrr (int, int)
17186 int _extr (int, int)
17187 int _extru (int, int)
17188 int _abs (int)
17189 int _abs2 (int)
17191 @end smallexample
17193 @node TILE-Gx Built-in Functions
17194 @subsection TILE-Gx Built-in Functions
17196 GCC provides intrinsics to access every instruction of the TILE-Gx
17197 processor.  The intrinsics are of the form:
17199 @smallexample
17201 unsigned long long __insn_@var{op} (...)
17203 @end smallexample
17205 Where @var{op} is the name of the instruction.  Refer to the ISA manual
17206 for the complete list of instructions.
17208 GCC also provides intrinsics to directly access the network registers.
17209 The intrinsics are:
17211 @smallexample
17213 unsigned long long __tile_idn0_receive (void)
17214 unsigned long long __tile_idn1_receive (void)
17215 unsigned long long __tile_udn0_receive (void)
17216 unsigned long long __tile_udn1_receive (void)
17217 unsigned long long __tile_udn2_receive (void)
17218 unsigned long long __tile_udn3_receive (void)
17219 void __tile_idn_send (unsigned long long)
17220 void __tile_udn_send (unsigned long long)
17222 @end smallexample
17224 The intrinsic @code{void __tile_network_barrier (void)} is used to
17225 guarantee that no network operations before it are reordered with
17226 those after it.
17228 @node TILEPro Built-in Functions
17229 @subsection TILEPro Built-in Functions
17231 GCC provides intrinsics to access every instruction of the TILEPro
17232 processor.  The intrinsics are of the form:
17234 @smallexample
17236 unsigned __insn_@var{op} (...)
17238 @end smallexample
17240 @noindent
17241 where @var{op} is the name of the instruction.  Refer to the ISA manual
17242 for the complete list of instructions.
17244 GCC also provides intrinsics to directly access the network registers.
17245 The intrinsics are:
17247 @smallexample
17249 unsigned __tile_idn0_receive (void)
17250 unsigned __tile_idn1_receive (void)
17251 unsigned __tile_sn_receive (void)
17252 unsigned __tile_udn0_receive (void)
17253 unsigned __tile_udn1_receive (void)
17254 unsigned __tile_udn2_receive (void)
17255 unsigned __tile_udn3_receive (void)
17256 void __tile_idn_send (unsigned)
17257 void __tile_sn_send (unsigned)
17258 void __tile_udn_send (unsigned)
17260 @end smallexample
17262 The intrinsic @code{void __tile_network_barrier (void)} is used to
17263 guarantee that no network operations before it are reordered with
17264 those after it.
17266 @node Target Format Checks
17267 @section Format Checks Specific to Particular Target Machines
17269 For some target machines, GCC supports additional options to the
17270 format attribute
17271 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17273 @menu
17274 * Solaris Format Checks::
17275 * Darwin Format Checks::
17276 @end menu
17278 @node Solaris Format Checks
17279 @subsection Solaris Format Checks
17281 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17282 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
17283 conversions, and the two-argument @code{%b} conversion for displaying
17284 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
17286 @node Darwin Format Checks
17287 @subsection Darwin Format Checks
17289 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17290 attribute context.  Declarations made with such attribution are parsed for correct syntax
17291 and format argument types.  However, parsing of the format string itself is currently undefined
17292 and is not carried out by this version of the compiler.
17294 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17295 also be used as format arguments.  Note that the relevant headers are only likely to be
17296 available on Darwin (OSX) installations.  On such installations, the XCode and system
17297 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17298 associated functions.
17300 @node Pragmas
17301 @section Pragmas Accepted by GCC
17302 @cindex pragmas
17303 @cindex @code{#pragma}
17305 GCC supports several types of pragmas, primarily in order to compile
17306 code originally written for other compilers.  Note that in general
17307 we do not recommend the use of pragmas; @xref{Function Attributes},
17308 for further explanation.
17310 @menu
17311 * ARM Pragmas::
17312 * M32C Pragmas::
17313 * MeP Pragmas::
17314 * RS/6000 and PowerPC Pragmas::
17315 * Darwin Pragmas::
17316 * Solaris Pragmas::
17317 * Symbol-Renaming Pragmas::
17318 * Structure-Packing Pragmas::
17319 * Weak Pragmas::
17320 * Diagnostic Pragmas::
17321 * Visibility Pragmas::
17322 * Push/Pop Macro Pragmas::
17323 * Function Specific Option Pragmas::
17324 * Loop-Specific Pragmas::
17325 @end menu
17327 @node ARM Pragmas
17328 @subsection ARM Pragmas
17330 The ARM target defines pragmas for controlling the default addition of
17331 @code{long_call} and @code{short_call} attributes to functions.
17332 @xref{Function Attributes}, for information about the effects of these
17333 attributes.
17335 @table @code
17336 @item long_calls
17337 @cindex pragma, long_calls
17338 Set all subsequent functions to have the @code{long_call} attribute.
17340 @item no_long_calls
17341 @cindex pragma, no_long_calls
17342 Set all subsequent functions to have the @code{short_call} attribute.
17344 @item long_calls_off
17345 @cindex pragma, long_calls_off
17346 Do not affect the @code{long_call} or @code{short_call} attributes of
17347 subsequent functions.
17348 @end table
17350 @node M32C Pragmas
17351 @subsection M32C Pragmas
17353 @table @code
17354 @item GCC memregs @var{number}
17355 @cindex pragma, memregs
17356 Overrides the command-line option @code{-memregs=} for the current
17357 file.  Use with care!  This pragma must be before any function in the
17358 file, and mixing different memregs values in different objects may
17359 make them incompatible.  This pragma is useful when a
17360 performance-critical function uses a memreg for temporary values,
17361 as it may allow you to reduce the number of memregs used.
17363 @item ADDRESS @var{name} @var{address}
17364 @cindex pragma, address
17365 For any declared symbols matching @var{name}, this does three things
17366 to that symbol: it forces the symbol to be located at the given
17367 address (a number), it forces the symbol to be volatile, and it
17368 changes the symbol's scope to be static.  This pragma exists for
17369 compatibility with other compilers, but note that the common
17370 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17371 instead).  Example:
17373 @smallexample
17374 #pragma ADDRESS port3 0x103
17375 char port3;
17376 @end smallexample
17378 @end table
17380 @node MeP Pragmas
17381 @subsection MeP Pragmas
17383 @table @code
17385 @item custom io_volatile (on|off)
17386 @cindex pragma, custom io_volatile
17387 Overrides the command-line option @code{-mio-volatile} for the current
17388 file.  Note that for compatibility with future GCC releases, this
17389 option should only be used once before any @code{io} variables in each
17390 file.
17392 @item GCC coprocessor available @var{registers}
17393 @cindex pragma, coprocessor available
17394 Specifies which coprocessor registers are available to the register
17395 allocator.  @var{registers} may be a single register, register range
17396 separated by ellipses, or comma-separated list of those.  Example:
17398 @smallexample
17399 #pragma GCC coprocessor available $c0...$c10, $c28
17400 @end smallexample
17402 @item GCC coprocessor call_saved @var{registers}
17403 @cindex pragma, coprocessor call_saved
17404 Specifies which coprocessor registers are to be saved and restored by
17405 any function using them.  @var{registers} may be a single register,
17406 register range separated by ellipses, or comma-separated list of
17407 those.  Example:
17409 @smallexample
17410 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17411 @end smallexample
17413 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17414 @cindex pragma, coprocessor subclass
17415 Creates and defines a register class.  These register classes can be
17416 used by inline @code{asm} constructs.  @var{registers} may be a single
17417 register, register range separated by ellipses, or comma-separated
17418 list of those.  Example:
17420 @smallexample
17421 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17423 asm ("cpfoo %0" : "=B" (x));
17424 @end smallexample
17426 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17427 @cindex pragma, disinterrupt
17428 For the named functions, the compiler adds code to disable interrupts
17429 for the duration of those functions.  If any functions so named 
17430 are not encountered in the source, a warning is emitted that the pragma is
17431 not used.  Examples:
17433 @smallexample
17434 #pragma disinterrupt foo
17435 #pragma disinterrupt bar, grill
17436 int foo () @{ @dots{} @}
17437 @end smallexample
17439 @item GCC call @var{name} , @var{name} @dots{}
17440 @cindex pragma, call
17441 For the named functions, the compiler always uses a register-indirect
17442 call model when calling the named functions.  Examples:
17444 @smallexample
17445 extern int foo ();
17446 #pragma call foo
17447 @end smallexample
17449 @end table
17451 @node RS/6000 and PowerPC Pragmas
17452 @subsection RS/6000 and PowerPC Pragmas
17454 The RS/6000 and PowerPC targets define one pragma for controlling
17455 whether or not the @code{longcall} attribute is added to function
17456 declarations by default.  This pragma overrides the @option{-mlongcall}
17457 option, but not the @code{longcall} and @code{shortcall} attributes.
17458 @xref{RS/6000 and PowerPC Options}, for more information about when long
17459 calls are and are not necessary.
17461 @table @code
17462 @item longcall (1)
17463 @cindex pragma, longcall
17464 Apply the @code{longcall} attribute to all subsequent function
17465 declarations.
17467 @item longcall (0)
17468 Do not apply the @code{longcall} attribute to subsequent function
17469 declarations.
17470 @end table
17472 @c Describe h8300 pragmas here.
17473 @c Describe sh pragmas here.
17474 @c Describe v850 pragmas here.
17476 @node Darwin Pragmas
17477 @subsection Darwin Pragmas
17479 The following pragmas are available for all architectures running the
17480 Darwin operating system.  These are useful for compatibility with other
17481 Mac OS compilers.
17483 @table @code
17484 @item mark @var{tokens}@dots{}
17485 @cindex pragma, mark
17486 This pragma is accepted, but has no effect.
17488 @item options align=@var{alignment}
17489 @cindex pragma, options align
17490 This pragma sets the alignment of fields in structures.  The values of
17491 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17492 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
17493 properly; to restore the previous setting, use @code{reset} for the
17494 @var{alignment}.
17496 @item segment @var{tokens}@dots{}
17497 @cindex pragma, segment
17498 This pragma is accepted, but has no effect.
17500 @item unused (@var{var} [, @var{var}]@dots{})
17501 @cindex pragma, unused
17502 This pragma declares variables to be possibly unused.  GCC does not
17503 produce warnings for the listed variables.  The effect is similar to
17504 that of the @code{unused} attribute, except that this pragma may appear
17505 anywhere within the variables' scopes.
17506 @end table
17508 @node Solaris Pragmas
17509 @subsection Solaris Pragmas
17511 The Solaris target supports @code{#pragma redefine_extname}
17512 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
17513 @code{#pragma} directives for compatibility with the system compiler.
17515 @table @code
17516 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17517 @cindex pragma, align
17519 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17520 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17521 Attributes}).  Macro expansion occurs on the arguments to this pragma
17522 when compiling C and Objective-C@.  It does not currently occur when
17523 compiling C++, but this is a bug which may be fixed in a future
17524 release.
17526 @item fini (@var{function} [, @var{function}]...)
17527 @cindex pragma, fini
17529 This pragma causes each listed @var{function} to be called after
17530 main, or during shared module unloading, by adding a call to the
17531 @code{.fini} section.
17533 @item init (@var{function} [, @var{function}]...)
17534 @cindex pragma, init
17536 This pragma causes each listed @var{function} to be called during
17537 initialization (before @code{main}) or during shared module loading, by
17538 adding a call to the @code{.init} section.
17540 @end table
17542 @node Symbol-Renaming Pragmas
17543 @subsection Symbol-Renaming Pragmas
17545 GCC supports a @code{#pragma} directive that changes the name used in
17546 assembly for a given declaration. This effect can also be achieved
17547 using the asm labels extension (@pxref{Asm Labels}).
17549 @table @code
17550 @item redefine_extname @var{oldname} @var{newname}
17551 @cindex pragma, redefine_extname
17553 This pragma gives the C function @var{oldname} the assembly symbol
17554 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17555 is defined if this pragma is available (currently on all platforms).
17556 @end table
17558 This pragma and the asm labels extension interact in a complicated
17559 manner.  Here are some corner cases you may want to be aware of:
17561 @enumerate
17562 @item This pragma silently applies only to declarations with external
17563 linkage.  Asm labels do not have this restriction.
17565 @item In C++, this pragma silently applies only to declarations with
17566 ``C'' linkage.  Again, asm labels do not have this restriction.
17568 @item If either of the ways of changing the assembly name of a
17569 declaration are applied to a declaration whose assembly name has
17570 already been determined (either by a previous use of one of these
17571 features, or because the compiler needed the assembly name in order to
17572 generate code), and the new name is different, a warning issues and
17573 the name does not change.
17575 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17576 always the C-language name.
17577 @end enumerate
17579 @node Structure-Packing Pragmas
17580 @subsection Structure-Packing Pragmas
17582 For compatibility with Microsoft Windows compilers, GCC supports a
17583 set of @code{#pragma} directives that change the maximum alignment of
17584 members of structures (other than zero-width bit-fields), unions, and
17585 classes subsequently defined. The @var{n} value below always is required
17586 to be a small power of two and specifies the new alignment in bytes.
17588 @enumerate
17589 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17590 @item @code{#pragma pack()} sets the alignment to the one that was in
17591 effect when compilation started (see also command-line option
17592 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17593 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17594 setting on an internal stack and then optionally sets the new alignment.
17595 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17596 saved at the top of the internal stack (and removes that stack entry).
17597 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17598 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17599 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17600 @code{#pragma pack(pop)}.
17601 @end enumerate
17603 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
17604 @code{#pragma} which lays out a structure as the documented
17605 @code{__attribute__ ((ms_struct))}.
17606 @enumerate
17607 @item @code{#pragma ms_struct on} turns on the layout for structures
17608 declared.
17609 @item @code{#pragma ms_struct off} turns off the layout for structures
17610 declared.
17611 @item @code{#pragma ms_struct reset} goes back to the default layout.
17612 @end enumerate
17614 @node Weak Pragmas
17615 @subsection Weak Pragmas
17617 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17618 directives for declaring symbols to be weak, and defining weak
17619 aliases.
17621 @table @code
17622 @item #pragma weak @var{symbol}
17623 @cindex pragma, weak
17624 This pragma declares @var{symbol} to be weak, as if the declaration
17625 had the attribute of the same name.  The pragma may appear before
17626 or after the declaration of @var{symbol}.  It is not an error for
17627 @var{symbol} to never be defined at all.
17629 @item #pragma weak @var{symbol1} = @var{symbol2}
17630 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17631 It is an error if @var{symbol2} is not defined in the current
17632 translation unit.
17633 @end table
17635 @node Diagnostic Pragmas
17636 @subsection Diagnostic Pragmas
17638 GCC allows the user to selectively enable or disable certain types of
17639 diagnostics, and change the kind of the diagnostic.  For example, a
17640 project's policy might require that all sources compile with
17641 @option{-Werror} but certain files might have exceptions allowing
17642 specific types of warnings.  Or, a project might selectively enable
17643 diagnostics and treat them as errors depending on which preprocessor
17644 macros are defined.
17646 @table @code
17647 @item #pragma GCC diagnostic @var{kind} @var{option}
17648 @cindex pragma, diagnostic
17650 Modifies the disposition of a diagnostic.  Note that not all
17651 diagnostics are modifiable; at the moment only warnings (normally
17652 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17653 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17654 are controllable and which option controls them.
17656 @var{kind} is @samp{error} to treat this diagnostic as an error,
17657 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17658 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17659 @var{option} is a double quoted string that matches the command-line
17660 option.
17662 @smallexample
17663 #pragma GCC diagnostic warning "-Wformat"
17664 #pragma GCC diagnostic error "-Wformat"
17665 #pragma GCC diagnostic ignored "-Wformat"
17666 @end smallexample
17668 Note that these pragmas override any command-line options.  GCC keeps
17669 track of the location of each pragma, and issues diagnostics according
17670 to the state as of that point in the source file.  Thus, pragmas occurring
17671 after a line do not affect diagnostics caused by that line.
17673 @item #pragma GCC diagnostic push
17674 @itemx #pragma GCC diagnostic pop
17676 Causes GCC to remember the state of the diagnostics as of each
17677 @code{push}, and restore to that point at each @code{pop}.  If a
17678 @code{pop} has no matching @code{push}, the command-line options are
17679 restored.
17681 @smallexample
17682 #pragma GCC diagnostic error "-Wuninitialized"
17683   foo(a);                       /* error is given for this one */
17684 #pragma GCC diagnostic push
17685 #pragma GCC diagnostic ignored "-Wuninitialized"
17686   foo(b);                       /* no diagnostic for this one */
17687 #pragma GCC diagnostic pop
17688   foo(c);                       /* error is given for this one */
17689 #pragma GCC diagnostic pop
17690   foo(d);                       /* depends on command-line options */
17691 @end smallexample
17693 @end table
17695 GCC also offers a simple mechanism for printing messages during
17696 compilation.
17698 @table @code
17699 @item #pragma message @var{string}
17700 @cindex pragma, diagnostic
17702 Prints @var{string} as a compiler message on compilation.  The message
17703 is informational only, and is neither a compilation warning nor an error.
17705 @smallexample
17706 #pragma message "Compiling " __FILE__ "..."
17707 @end smallexample
17709 @var{string} may be parenthesized, and is printed with location
17710 information.  For example,
17712 @smallexample
17713 #define DO_PRAGMA(x) _Pragma (#x)
17714 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17716 TODO(Remember to fix this)
17717 @end smallexample
17719 @noindent
17720 prints @samp{/tmp/file.c:4: note: #pragma message:
17721 TODO - Remember to fix this}.
17723 @end table
17725 @node Visibility Pragmas
17726 @subsection Visibility Pragmas
17728 @table @code
17729 @item #pragma GCC visibility push(@var{visibility})
17730 @itemx #pragma GCC visibility pop
17731 @cindex pragma, visibility
17733 This pragma allows the user to set the visibility for multiple
17734 declarations without having to give each a visibility attribute
17735 (@pxref{Function Attributes}).
17737 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17738 declarations.  Class members and template specializations are not
17739 affected; if you want to override the visibility for a particular
17740 member or instantiation, you must use an attribute.
17742 @end table
17745 @node Push/Pop Macro Pragmas
17746 @subsection Push/Pop Macro Pragmas
17748 For compatibility with Microsoft Windows compilers, GCC supports
17749 @samp{#pragma push_macro(@var{"macro_name"})}
17750 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17752 @table @code
17753 @item #pragma push_macro(@var{"macro_name"})
17754 @cindex pragma, push_macro
17755 This pragma saves the value of the macro named as @var{macro_name} to
17756 the top of the stack for this macro.
17758 @item #pragma pop_macro(@var{"macro_name"})
17759 @cindex pragma, pop_macro
17760 This pragma sets the value of the macro named as @var{macro_name} to
17761 the value on top of the stack for this macro. If the stack for
17762 @var{macro_name} is empty, the value of the macro remains unchanged.
17763 @end table
17765 For example:
17767 @smallexample
17768 #define X  1
17769 #pragma push_macro("X")
17770 #undef X
17771 #define X -1
17772 #pragma pop_macro("X")
17773 int x [X];
17774 @end smallexample
17776 @noindent
17777 In this example, the definition of X as 1 is saved by @code{#pragma
17778 push_macro} and restored by @code{#pragma pop_macro}.
17780 @node Function Specific Option Pragmas
17781 @subsection Function Specific Option Pragmas
17783 @table @code
17784 @item #pragma GCC target (@var{"string"}...)
17785 @cindex pragma GCC target
17787 This pragma allows you to set target specific options for functions
17788 defined later in the source file.  One or more strings can be
17789 specified.  Each function that is defined after this point is as
17790 if @code{attribute((target("STRING")))} was specified for that
17791 function.  The parenthesis around the options is optional.
17792 @xref{Function Attributes}, for more information about the
17793 @code{target} attribute and the attribute syntax.
17795 The @code{#pragma GCC target} pragma is presently implemented for
17796 i386/x86_64, PowerPC, and Nios II targets only.
17797 @end table
17799 @table @code
17800 @item #pragma GCC optimize (@var{"string"}...)
17801 @cindex pragma GCC optimize
17803 This pragma allows you to set global optimization options for functions
17804 defined later in the source file.  One or more strings can be
17805 specified.  Each function that is defined after this point is as
17806 if @code{attribute((optimize("STRING")))} was specified for that
17807 function.  The parenthesis around the options is optional.
17808 @xref{Function Attributes}, for more information about the
17809 @code{optimize} attribute and the attribute syntax.
17811 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17812 versions earlier than 4.4.
17813 @end table
17815 @table @code
17816 @item #pragma GCC push_options
17817 @itemx #pragma GCC pop_options
17818 @cindex pragma GCC push_options
17819 @cindex pragma GCC pop_options
17821 These pragmas maintain a stack of the current target and optimization
17822 options.  It is intended for include files where you temporarily want
17823 to switch to using a different @samp{#pragma GCC target} or
17824 @samp{#pragma GCC optimize} and then to pop back to the previous
17825 options.
17827 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17828 pragmas are not implemented in GCC versions earlier than 4.4.
17829 @end table
17831 @table @code
17832 @item #pragma GCC reset_options
17833 @cindex pragma GCC reset_options
17835 This pragma clears the current @code{#pragma GCC target} and
17836 @code{#pragma GCC optimize} to use the default switches as specified
17837 on the command line.
17839 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17840 versions earlier than 4.4.
17841 @end table
17843 @node Loop-Specific Pragmas
17844 @subsection Loop-Specific Pragmas
17846 @table @code
17847 @item #pragma GCC ivdep
17848 @cindex pragma GCC ivdep
17849 @end table
17851 With this pragma, the programmer asserts that there are no loop-carried
17852 dependencies which would prevent that consecutive iterations of
17853 the following loop can be executed concurrently with SIMD
17854 (single instruction multiple data) instructions.
17856 For example, the compiler can only unconditionally vectorize the following
17857 loop with the pragma:
17859 @smallexample
17860 void foo (int n, int *a, int *b, int *c)
17862   int i, j;
17863 #pragma GCC ivdep
17864   for (i = 0; i < n; ++i)
17865     a[i] = b[i] + c[i];
17867 @end smallexample
17869 @noindent
17870 In this example, using the @code{restrict} qualifier had the same
17871 effect. In the following example, that would not be possible. Assume
17872 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17873 that it can unconditionally vectorize the following loop:
17875 @smallexample
17876 void ignore_vec_dep (int *a, int k, int c, int m)
17878 #pragma GCC ivdep
17879   for (int i = 0; i < m; i++)
17880     a[i] = a[i + k] * c;
17882 @end smallexample
17885 @node Unnamed Fields
17886 @section Unnamed struct/union fields within structs/unions
17887 @cindex @code{struct}
17888 @cindex @code{union}
17890 As permitted by ISO C11 and for compatibility with other compilers,
17891 GCC allows you to define
17892 a structure or union that contains, as fields, structures and unions
17893 without names.  For example:
17895 @smallexample
17896 struct @{
17897   int a;
17898   union @{
17899     int b;
17900     float c;
17901   @};
17902   int d;
17903 @} foo;
17904 @end smallexample
17906 @noindent
17907 In this example, you are able to access members of the unnamed
17908 union with code like @samp{foo.b}.  Note that only unnamed structs and
17909 unions are allowed, you may not have, for example, an unnamed
17910 @code{int}.
17912 You must never create such structures that cause ambiguous field definitions.
17913 For example, in this structure:
17915 @smallexample
17916 struct @{
17917   int a;
17918   struct @{
17919     int a;
17920   @};
17921 @} foo;
17922 @end smallexample
17924 @noindent
17925 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17926 The compiler gives errors for such constructs.
17928 @opindex fms-extensions
17929 Unless @option{-fms-extensions} is used, the unnamed field must be a
17930 structure or union definition without a tag (for example, @samp{struct
17931 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
17932 also be a definition with a tag such as @samp{struct foo @{ int a;
17933 @};}, a reference to a previously defined structure or union such as
17934 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17935 previously defined structure or union type.
17937 @opindex fplan9-extensions
17938 The option @option{-fplan9-extensions} enables
17939 @option{-fms-extensions} as well as two other extensions.  First, a
17940 pointer to a structure is automatically converted to a pointer to an
17941 anonymous field for assignments and function calls.  For example:
17943 @smallexample
17944 struct s1 @{ int a; @};
17945 struct s2 @{ struct s1; @};
17946 extern void f1 (struct s1 *);
17947 void f2 (struct s2 *p) @{ f1 (p); @}
17948 @end smallexample
17950 @noindent
17951 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17952 converted into a pointer to the anonymous field.
17954 Second, when the type of an anonymous field is a @code{typedef} for a
17955 @code{struct} or @code{union}, code may refer to the field using the
17956 name of the @code{typedef}.
17958 @smallexample
17959 typedef struct @{ int a; @} s1;
17960 struct s2 @{ s1; @};
17961 s1 f1 (struct s2 *p) @{ return p->s1; @}
17962 @end smallexample
17964 These usages are only permitted when they are not ambiguous.
17966 @node Thread-Local
17967 @section Thread-Local Storage
17968 @cindex Thread-Local Storage
17969 @cindex @acronym{TLS}
17970 @cindex @code{__thread}
17972 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17973 are allocated such that there is one instance of the variable per extant
17974 thread.  The runtime model GCC uses to implement this originates
17975 in the IA-64 processor-specific ABI, but has since been migrated
17976 to other processors as well.  It requires significant support from
17977 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17978 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17979 is not available everywhere.
17981 At the user level, the extension is visible with a new storage
17982 class keyword: @code{__thread}.  For example:
17984 @smallexample
17985 __thread int i;
17986 extern __thread struct state s;
17987 static __thread char *p;
17988 @end smallexample
17990 The @code{__thread} specifier may be used alone, with the @code{extern}
17991 or @code{static} specifiers, but with no other storage class specifier.
17992 When used with @code{extern} or @code{static}, @code{__thread} must appear
17993 immediately after the other storage class specifier.
17995 The @code{__thread} specifier may be applied to any global, file-scoped
17996 static, function-scoped static, or static data member of a class.  It may
17997 not be applied to block-scoped automatic or non-static data member.
17999 When the address-of operator is applied to a thread-local variable, it is
18000 evaluated at run time and returns the address of the current thread's
18001 instance of that variable.  An address so obtained may be used by any
18002 thread.  When a thread terminates, any pointers to thread-local variables
18003 in that thread become invalid.
18005 No static initialization may refer to the address of a thread-local variable.
18007 In C++, if an initializer is present for a thread-local variable, it must
18008 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
18009 standard.
18011 See @uref{http://www.akkadia.org/drepper/tls.pdf,
18012 ELF Handling For Thread-Local Storage} for a detailed explanation of
18013 the four thread-local storage addressing models, and how the runtime
18014 is expected to function.
18016 @menu
18017 * C99 Thread-Local Edits::
18018 * C++98 Thread-Local Edits::
18019 @end menu
18021 @node C99 Thread-Local Edits
18022 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
18024 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
18025 that document the exact semantics of the language extension.
18027 @itemize @bullet
18028 @item
18029 @cite{5.1.2  Execution environments}
18031 Add new text after paragraph 1
18033 @quotation
18034 Within either execution environment, a @dfn{thread} is a flow of
18035 control within a program.  It is implementation defined whether
18036 or not there may be more than one thread associated with a program.
18037 It is implementation defined how threads beyond the first are
18038 created, the name and type of the function called at thread
18039 startup, and how threads may be terminated.  However, objects
18040 with thread storage duration shall be initialized before thread
18041 startup.
18042 @end quotation
18044 @item
18045 @cite{6.2.4  Storage durations of objects}
18047 Add new text before paragraph 3
18049 @quotation
18050 An object whose identifier is declared with the storage-class
18051 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
18052 Its lifetime is the entire execution of the thread, and its
18053 stored value is initialized only once, prior to thread startup.
18054 @end quotation
18056 @item
18057 @cite{6.4.1  Keywords}
18059 Add @code{__thread}.
18061 @item
18062 @cite{6.7.1  Storage-class specifiers}
18064 Add @code{__thread} to the list of storage class specifiers in
18065 paragraph 1.
18067 Change paragraph 2 to
18069 @quotation
18070 With the exception of @code{__thread}, at most one storage-class
18071 specifier may be given [@dots{}].  The @code{__thread} specifier may
18072 be used alone, or immediately following @code{extern} or
18073 @code{static}.
18074 @end quotation
18076 Add new text after paragraph 6
18078 @quotation
18079 The declaration of an identifier for a variable that has
18080 block scope that specifies @code{__thread} shall also
18081 specify either @code{extern} or @code{static}.
18083 The @code{__thread} specifier shall be used only with
18084 variables.
18085 @end quotation
18086 @end itemize
18088 @node C++98 Thread-Local Edits
18089 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18091 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18092 that document the exact semantics of the language extension.
18094 @itemize @bullet
18095 @item
18096 @b{[intro.execution]}
18098 New text after paragraph 4
18100 @quotation
18101 A @dfn{thread} is a flow of control within the abstract machine.
18102 It is implementation defined whether or not there may be more than
18103 one thread.
18104 @end quotation
18106 New text after paragraph 7
18108 @quotation
18109 It is unspecified whether additional action must be taken to
18110 ensure when and whether side effects are visible to other threads.
18111 @end quotation
18113 @item
18114 @b{[lex.key]}
18116 Add @code{__thread}.
18118 @item
18119 @b{[basic.start.main]}
18121 Add after paragraph 5
18123 @quotation
18124 The thread that begins execution at the @code{main} function is called
18125 the @dfn{main thread}.  It is implementation defined how functions
18126 beginning threads other than the main thread are designated or typed.
18127 A function so designated, as well as the @code{main} function, is called
18128 a @dfn{thread startup function}.  It is implementation defined what
18129 happens if a thread startup function returns.  It is implementation
18130 defined what happens to other threads when any thread calls @code{exit}.
18131 @end quotation
18133 @item
18134 @b{[basic.start.init]}
18136 Add after paragraph 4
18138 @quotation
18139 The storage for an object of thread storage duration shall be
18140 statically initialized before the first statement of the thread startup
18141 function.  An object of thread storage duration shall not require
18142 dynamic initialization.
18143 @end quotation
18145 @item
18146 @b{[basic.start.term]}
18148 Add after paragraph 3
18150 @quotation
18151 The type of an object with thread storage duration shall not have a
18152 non-trivial destructor, nor shall it be an array type whose elements
18153 (directly or indirectly) have non-trivial destructors.
18154 @end quotation
18156 @item
18157 @b{[basic.stc]}
18159 Add ``thread storage duration'' to the list in paragraph 1.
18161 Change paragraph 2
18163 @quotation
18164 Thread, static, and automatic storage durations are associated with
18165 objects introduced by declarations [@dots{}].
18166 @end quotation
18168 Add @code{__thread} to the list of specifiers in paragraph 3.
18170 @item
18171 @b{[basic.stc.thread]}
18173 New section before @b{[basic.stc.static]}
18175 @quotation
18176 The keyword @code{__thread} applied to a non-local object gives the
18177 object thread storage duration.
18179 A local variable or class data member declared both @code{static}
18180 and @code{__thread} gives the variable or member thread storage
18181 duration.
18182 @end quotation
18184 @item
18185 @b{[basic.stc.static]}
18187 Change paragraph 1
18189 @quotation
18190 All objects that have neither thread storage duration, dynamic
18191 storage duration nor are local [@dots{}].
18192 @end quotation
18194 @item
18195 @b{[dcl.stc]}
18197 Add @code{__thread} to the list in paragraph 1.
18199 Change paragraph 1
18201 @quotation
18202 With the exception of @code{__thread}, at most one
18203 @var{storage-class-specifier} shall appear in a given
18204 @var{decl-specifier-seq}.  The @code{__thread} specifier may
18205 be used alone, or immediately following the @code{extern} or
18206 @code{static} specifiers.  [@dots{}]
18207 @end quotation
18209 Add after paragraph 5
18211 @quotation
18212 The @code{__thread} specifier can be applied only to the names of objects
18213 and to anonymous unions.
18214 @end quotation
18216 @item
18217 @b{[class.mem]}
18219 Add after paragraph 6
18221 @quotation
18222 Non-@code{static} members shall not be @code{__thread}.
18223 @end quotation
18224 @end itemize
18226 @node Binary constants
18227 @section Binary constants using the @samp{0b} prefix
18228 @cindex Binary constants using the @samp{0b} prefix
18230 Integer constants can be written as binary constants, consisting of a
18231 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18232 @samp{0B}.  This is particularly useful in environments that operate a
18233 lot on the bit level (like microcontrollers).
18235 The following statements are identical:
18237 @smallexample
18238 i =       42;
18239 i =     0x2a;
18240 i =      052;
18241 i = 0b101010;
18242 @end smallexample
18244 The type of these constants follows the same rules as for octal or
18245 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18246 can be applied.
18248 @node C++ Extensions
18249 @chapter Extensions to the C++ Language
18250 @cindex extensions, C++ language
18251 @cindex C++ language extensions
18253 The GNU compiler provides these extensions to the C++ language (and you
18254 can also use most of the C language extensions in your C++ programs).  If you
18255 want to write code that checks whether these features are available, you can
18256 test for the GNU compiler the same way as for C programs: check for a
18257 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
18258 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18259 Predefined Macros,cpp,The GNU C Preprocessor}).
18261 @menu
18262 * C++ Volatiles::       What constitutes an access to a volatile object.
18263 * Restricted Pointers:: C99 restricted pointers and references.
18264 * Vague Linkage::       Where G++ puts inlines, vtables and such.
18265 * C++ Interface::       You can use a single C++ header file for both
18266                         declarations and definitions.
18267 * Template Instantiation:: Methods for ensuring that exactly one copy of
18268                         each needed template instantiation is emitted.
18269 * Bound member functions:: You can extract a function pointer to the
18270                         method denoted by a @samp{->*} or @samp{.*} expression.
18271 * C++ Attributes::      Variable, function, and type attributes for C++ only.
18272 * Function Multiversioning::   Declaring multiple function versions.
18273 * Namespace Association:: Strong using-directives for namespace association.
18274 * Type Traits::         Compiler support for type traits
18275 * Java Exceptions::     Tweaking exception handling to work with Java.
18276 * Deprecated Features:: Things will disappear from G++.
18277 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18278 @end menu
18280 @node C++ Volatiles
18281 @section When is a Volatile C++ Object Accessed?
18282 @cindex accessing volatiles
18283 @cindex volatile read
18284 @cindex volatile write
18285 @cindex volatile access
18287 The C++ standard differs from the C standard in its treatment of
18288 volatile objects.  It fails to specify what constitutes a volatile
18289 access, except to say that C++ should behave in a similar manner to C
18290 with respect to volatiles, where possible.  However, the different
18291 lvalueness of expressions between C and C++ complicate the behavior.
18292 G++ behaves the same as GCC for volatile access, @xref{C
18293 Extensions,,Volatiles}, for a description of GCC's behavior.
18295 The C and C++ language specifications differ when an object is
18296 accessed in a void context:
18298 @smallexample
18299 volatile int *src = @var{somevalue};
18300 *src;
18301 @end smallexample
18303 The C++ standard specifies that such expressions do not undergo lvalue
18304 to rvalue conversion, and that the type of the dereferenced object may
18305 be incomplete.  The C++ standard does not specify explicitly that it
18306 is lvalue to rvalue conversion that is responsible for causing an
18307 access.  There is reason to believe that it is, because otherwise
18308 certain simple expressions become undefined.  However, because it
18309 would surprise most programmers, G++ treats dereferencing a pointer to
18310 volatile object of complete type as GCC would do for an equivalent
18311 type in C@.  When the object has incomplete type, G++ issues a
18312 warning; if you wish to force an error, you must force a conversion to
18313 rvalue with, for instance, a static cast.
18315 When using a reference to volatile, G++ does not treat equivalent
18316 expressions as accesses to volatiles, but instead issues a warning that
18317 no volatile is accessed.  The rationale for this is that otherwise it
18318 becomes difficult to determine where volatile access occur, and not
18319 possible to ignore the return value from functions returning volatile
18320 references.  Again, if you wish to force a read, cast the reference to
18321 an rvalue.
18323 G++ implements the same behavior as GCC does when assigning to a
18324 volatile object---there is no reread of the assigned-to object, the
18325 assigned rvalue is reused.  Note that in C++ assignment expressions
18326 are lvalues, and if used as an lvalue, the volatile object is
18327 referred to.  For instance, @var{vref} refers to @var{vobj}, as
18328 expected, in the following example:
18330 @smallexample
18331 volatile int vobj;
18332 volatile int &vref = vobj = @var{something};
18333 @end smallexample
18335 @node Restricted Pointers
18336 @section Restricting Pointer Aliasing
18337 @cindex restricted pointers
18338 @cindex restricted references
18339 @cindex restricted this pointer
18341 As with the C front end, G++ understands the C99 feature of restricted pointers,
18342 specified with the @code{__restrict__}, or @code{__restrict} type
18343 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
18344 language flag, @code{restrict} is not a keyword in C++.
18346 In addition to allowing restricted pointers, you can specify restricted
18347 references, which indicate that the reference is not aliased in the local
18348 context.
18350 @smallexample
18351 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18353   /* @r{@dots{}} */
18355 @end smallexample
18357 @noindent
18358 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18359 @var{rref} refers to a (different) unaliased integer.
18361 You may also specify whether a member function's @var{this} pointer is
18362 unaliased by using @code{__restrict__} as a member function qualifier.
18364 @smallexample
18365 void T::fn () __restrict__
18367   /* @r{@dots{}} */
18369 @end smallexample
18371 @noindent
18372 Within the body of @code{T::fn}, @var{this} has the effective
18373 definition @code{T *__restrict__ const this}.  Notice that the
18374 interpretation of a @code{__restrict__} member function qualifier is
18375 different to that of @code{const} or @code{volatile} qualifier, in that it
18376 is applied to the pointer rather than the object.  This is consistent with
18377 other compilers that implement restricted pointers.
18379 As with all outermost parameter qualifiers, @code{__restrict__} is
18380 ignored in function definition matching.  This means you only need to
18381 specify @code{__restrict__} in a function definition, rather than
18382 in a function prototype as well.
18384 @node Vague Linkage
18385 @section Vague Linkage
18386 @cindex vague linkage
18388 There are several constructs in C++ that require space in the object
18389 file but are not clearly tied to a single translation unit.  We say that
18390 these constructs have ``vague linkage''.  Typically such constructs are
18391 emitted wherever they are needed, though sometimes we can be more
18392 clever.
18394 @table @asis
18395 @item Inline Functions
18396 Inline functions are typically defined in a header file which can be
18397 included in many different compilations.  Hopefully they can usually be
18398 inlined, but sometimes an out-of-line copy is necessary, if the address
18399 of the function is taken or if inlining fails.  In general, we emit an
18400 out-of-line copy in all translation units where one is needed.  As an
18401 exception, we only emit inline virtual functions with the vtable, since
18402 it always requires a copy.
18404 Local static variables and string constants used in an inline function
18405 are also considered to have vague linkage, since they must be shared
18406 between all inlined and out-of-line instances of the function.
18408 @item VTables
18409 @cindex vtable
18410 C++ virtual functions are implemented in most compilers using a lookup
18411 table, known as a vtable.  The vtable contains pointers to the virtual
18412 functions provided by a class, and each object of the class contains a
18413 pointer to its vtable (or vtables, in some multiple-inheritance
18414 situations).  If the class declares any non-inline, non-pure virtual
18415 functions, the first one is chosen as the ``key method'' for the class,
18416 and the vtable is only emitted in the translation unit where the key
18417 method is defined.
18419 @emph{Note:} If the chosen key method is later defined as inline, the
18420 vtable is still emitted in every translation unit that defines it.
18421 Make sure that any inline virtuals are declared inline in the class
18422 body, even if they are not defined there.
18424 @item @code{type_info} objects
18425 @cindex @code{type_info}
18426 @cindex RTTI
18427 C++ requires information about types to be written out in order to
18428 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18429 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18430 object is written out along with the vtable so that @samp{dynamic_cast}
18431 can determine the dynamic type of a class object at run time.  For all
18432 other types, we write out the @samp{type_info} object when it is used: when
18433 applying @samp{typeid} to an expression, throwing an object, or
18434 referring to a type in a catch clause or exception specification.
18436 @item Template Instantiations
18437 Most everything in this section also applies to template instantiations,
18438 but there are other options as well.
18439 @xref{Template Instantiation,,Where's the Template?}.
18441 @end table
18443 When used with GNU ld version 2.8 or later on an ELF system such as
18444 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18445 these constructs will be discarded at link time.  This is known as
18446 COMDAT support.
18448 On targets that don't support COMDAT, but do support weak symbols, GCC
18449 uses them.  This way one copy overrides all the others, but
18450 the unused copies still take up space in the executable.
18452 For targets that do not support either COMDAT or weak symbols,
18453 most entities with vague linkage are emitted as local symbols to
18454 avoid duplicate definition errors from the linker.  This does not happen
18455 for local statics in inlines, however, as having multiple copies
18456 almost certainly breaks things.
18458 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18459 another way to control placement of these constructs.
18461 @node C++ Interface
18462 @section #pragma interface and implementation
18464 @cindex interface and implementation headers, C++
18465 @cindex C++ interface and implementation headers
18466 @cindex pragmas, interface and implementation
18468 @code{#pragma interface} and @code{#pragma implementation} provide the
18469 user with a way of explicitly directing the compiler to emit entities
18470 with vague linkage (and debugging information) in a particular
18471 translation unit.
18473 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
18474 most cases, because of COMDAT support and the ``key method'' heuristic
18475 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
18476 program to grow due to unnecessary out-of-line copies of inline
18477 functions.  Currently (3.4) the only benefit of these
18478 @code{#pragma}s is reduced duplication of debugging information, and
18479 that should be addressed soon on DWARF 2 targets with the use of
18480 COMDAT groups.
18482 @table @code
18483 @item #pragma interface
18484 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18485 @kindex #pragma interface
18486 Use this directive in @emph{header files} that define object classes, to save
18487 space in most of the object files that use those classes.  Normally,
18488 local copies of certain information (backup copies of inline member
18489 functions, debugging information, and the internal tables that implement
18490 virtual functions) must be kept in each object file that includes class
18491 definitions.  You can use this pragma to avoid such duplication.  When a
18492 header file containing @samp{#pragma interface} is included in a
18493 compilation, this auxiliary information is not generated (unless
18494 the main input source file itself uses @samp{#pragma implementation}).
18495 Instead, the object files contain references to be resolved at link
18496 time.
18498 The second form of this directive is useful for the case where you have
18499 multiple headers with the same name in different directories.  If you
18500 use this form, you must specify the same string to @samp{#pragma
18501 implementation}.
18503 @item #pragma implementation
18504 @itemx #pragma implementation "@var{objects}.h"
18505 @kindex #pragma implementation
18506 Use this pragma in a @emph{main input file}, when you want full output from
18507 included header files to be generated (and made globally visible).  The
18508 included header file, in turn, should use @samp{#pragma interface}.
18509 Backup copies of inline member functions, debugging information, and the
18510 internal tables used to implement virtual functions are all generated in
18511 implementation files.
18513 @cindex implied @code{#pragma implementation}
18514 @cindex @code{#pragma implementation}, implied
18515 @cindex naming convention, implementation headers
18516 If you use @samp{#pragma implementation} with no argument, it applies to
18517 an include file with the same basename@footnote{A file's @dfn{basename}
18518 is the name stripped of all leading path information and of trailing
18519 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18520 file.  For example, in @file{allclass.cc}, giving just
18521 @samp{#pragma implementation}
18522 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18524 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
18525 an implementation file whenever you would include it from
18526 @file{allclass.cc} even if you never specified @samp{#pragma
18527 implementation}.  This was deemed to be more trouble than it was worth,
18528 however, and disabled.
18530 Use the string argument if you want a single implementation file to
18531 include code from multiple header files.  (You must also use
18532 @samp{#include} to include the header file; @samp{#pragma
18533 implementation} only specifies how to use the file---it doesn't actually
18534 include it.)
18536 There is no way to split up the contents of a single header file into
18537 multiple implementation files.
18538 @end table
18540 @cindex inlining and C++ pragmas
18541 @cindex C++ pragmas, effect on inlining
18542 @cindex pragmas in C++, effect on inlining
18543 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18544 effect on function inlining.
18546 If you define a class in a header file marked with @samp{#pragma
18547 interface}, the effect on an inline function defined in that class is
18548 similar to an explicit @code{extern} declaration---the compiler emits
18549 no code at all to define an independent version of the function.  Its
18550 definition is used only for inlining with its callers.
18552 @opindex fno-implement-inlines
18553 Conversely, when you include the same header file in a main source file
18554 that declares it as @samp{#pragma implementation}, the compiler emits
18555 code for the function itself; this defines a version of the function
18556 that can be found via pointers (or by callers compiled without
18557 inlining).  If all calls to the function can be inlined, you can avoid
18558 emitting the function by compiling with @option{-fno-implement-inlines}.
18559 If any calls are not inlined, you will get linker errors.
18561 @node Template Instantiation
18562 @section Where's the Template?
18563 @cindex template instantiation
18565 C++ templates are the first language feature to require more
18566 intelligence from the environment than one usually finds on a UNIX
18567 system.  Somehow the compiler and linker have to make sure that each
18568 template instance occurs exactly once in the executable if it is needed,
18569 and not at all otherwise.  There are two basic approaches to this
18570 problem, which are referred to as the Borland model and the Cfront model.
18572 @table @asis
18573 @item Borland model
18574 Borland C++ solved the template instantiation problem by adding the code
18575 equivalent of common blocks to their linker; the compiler emits template
18576 instances in each translation unit that uses them, and the linker
18577 collapses them together.  The advantage of this model is that the linker
18578 only has to consider the object files themselves; there is no external
18579 complexity to worry about.  This disadvantage is that compilation time
18580 is increased because the template code is being compiled repeatedly.
18581 Code written for this model tends to include definitions of all
18582 templates in the header file, since they must be seen to be
18583 instantiated.
18585 @item Cfront model
18586 The AT&T C++ translator, Cfront, solved the template instantiation
18587 problem by creating the notion of a template repository, an
18588 automatically maintained place where template instances are stored.  A
18589 more modern version of the repository works as follows: As individual
18590 object files are built, the compiler places any template definitions and
18591 instantiations encountered in the repository.  At link time, the link
18592 wrapper adds in the objects in the repository and compiles any needed
18593 instances that were not previously emitted.  The advantages of this
18594 model are more optimal compilation speed and the ability to use the
18595 system linker; to implement the Borland model a compiler vendor also
18596 needs to replace the linker.  The disadvantages are vastly increased
18597 complexity, and thus potential for error; for some code this can be
18598 just as transparent, but in practice it can been very difficult to build
18599 multiple programs in one directory and one program in multiple
18600 directories.  Code written for this model tends to separate definitions
18601 of non-inline member templates into a separate file, which should be
18602 compiled separately.
18603 @end table
18605 When used with GNU ld version 2.8 or later on an ELF system such as
18606 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18607 Borland model.  On other systems, G++ implements neither automatic
18608 model.
18610 You have the following options for dealing with template instantiations:
18612 @enumerate
18613 @item
18614 @opindex frepo
18615 Compile your template-using code with @option{-frepo}.  The compiler
18616 generates files with the extension @samp{.rpo} listing all of the
18617 template instantiations used in the corresponding object files that
18618 could be instantiated there; the link wrapper, @samp{collect2},
18619 then updates the @samp{.rpo} files to tell the compiler where to place
18620 those instantiations and rebuild any affected object files.  The
18621 link-time overhead is negligible after the first pass, as the compiler
18622 continues to place the instantiations in the same files.
18624 This is your best option for application code written for the Borland
18625 model, as it just works.  Code written for the Cfront model 
18626 needs to be modified so that the template definitions are available at
18627 one or more points of instantiation; usually this is as simple as adding
18628 @code{#include <tmethods.cc>} to the end of each template header.
18630 For library code, if you want the library to provide all of the template
18631 instantiations it needs, just try to link all of its object files
18632 together; the link will fail, but cause the instantiations to be
18633 generated as a side effect.  Be warned, however, that this may cause
18634 conflicts if multiple libraries try to provide the same instantiations.
18635 For greater control, use explicit instantiation as described in the next
18636 option.
18638 @item
18639 @opindex fno-implicit-templates
18640 Compile your code with @option{-fno-implicit-templates} to disable the
18641 implicit generation of template instances, and explicitly instantiate
18642 all the ones you use.  This approach requires more knowledge of exactly
18643 which instances you need than do the others, but it's less
18644 mysterious and allows greater control.  You can scatter the explicit
18645 instantiations throughout your program, perhaps putting them in the
18646 translation units where the instances are used or the translation units
18647 that define the templates themselves; you can put all of the explicit
18648 instantiations you need into one big file; or you can create small files
18649 like
18651 @smallexample
18652 #include "Foo.h"
18653 #include "Foo.cc"
18655 template class Foo<int>;
18656 template ostream& operator <<
18657                 (ostream&, const Foo<int>&);
18658 @end smallexample
18660 @noindent
18661 for each of the instances you need, and create a template instantiation
18662 library from those.
18664 If you are using Cfront-model code, you can probably get away with not
18665 using @option{-fno-implicit-templates} when compiling files that don't
18666 @samp{#include} the member template definitions.
18668 If you use one big file to do the instantiations, you may want to
18669 compile it without @option{-fno-implicit-templates} so you get all of the
18670 instances required by your explicit instantiations (but not by any
18671 other files) without having to specify them as well.
18673 The ISO C++ 2011 standard allows forward declaration of explicit
18674 instantiations (with @code{extern}). G++ supports explicit instantiation
18675 declarations in C++98 mode and has extended the template instantiation
18676 syntax to support instantiation of the compiler support data for a
18677 template class (i.e.@: the vtable) without instantiating any of its
18678 members (with @code{inline}), and instantiation of only the static data
18679 members of a template class, without the support data or member
18680 functions (with @code{static}):
18682 @smallexample
18683 extern template int max (int, int);
18684 inline template class Foo<int>;
18685 static template class Foo<int>;
18686 @end smallexample
18688 @item
18689 Do nothing.  Pretend G++ does implement automatic instantiation
18690 management.  Code written for the Borland model works fine, but
18691 each translation unit contains instances of each of the templates it
18692 uses.  In a large program, this can lead to an unacceptable amount of code
18693 duplication.
18694 @end enumerate
18696 @node Bound member functions
18697 @section Extracting the function pointer from a bound pointer to member function
18698 @cindex pmf
18699 @cindex pointer to member function
18700 @cindex bound pointer to member function
18702 In C++, pointer to member functions (PMFs) are implemented using a wide
18703 pointer of sorts to handle all the possible call mechanisms; the PMF
18704 needs to store information about how to adjust the @samp{this} pointer,
18705 and if the function pointed to is virtual, where to find the vtable, and
18706 where in the vtable to look for the member function.  If you are using
18707 PMFs in an inner loop, you should really reconsider that decision.  If
18708 that is not an option, you can extract the pointer to the function that
18709 would be called for a given object/PMF pair and call it directly inside
18710 the inner loop, to save a bit of time.
18712 Note that you still pay the penalty for the call through a
18713 function pointer; on most modern architectures, such a call defeats the
18714 branch prediction features of the CPU@.  This is also true of normal
18715 virtual function calls.
18717 The syntax for this extension is
18719 @smallexample
18720 extern A a;
18721 extern int (A::*fp)();
18722 typedef int (*fptr)(A *);
18724 fptr p = (fptr)(a.*fp);
18725 @end smallexample
18727 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18728 no object is needed to obtain the address of the function.  They can be
18729 converted to function pointers directly:
18731 @smallexample
18732 fptr p1 = (fptr)(&A::foo);
18733 @end smallexample
18735 @opindex Wno-pmf-conversions
18736 You must specify @option{-Wno-pmf-conversions} to use this extension.
18738 @node C++ Attributes
18739 @section C++-Specific Variable, Function, and Type Attributes
18741 Some attributes only make sense for C++ programs.
18743 @table @code
18744 @item abi_tag ("@var{tag}", ...)
18745 @cindex @code{abi_tag} attribute
18746 The @code{abi_tag} attribute can be applied to a function or class
18747 declaration.  It modifies the mangled name of the function or class to
18748 incorporate the tag name, in order to distinguish the function or
18749 class from an earlier version with a different ABI; perhaps the class
18750 has changed size, or the function has a different return type that is
18751 not encoded in the mangled name.
18753 The argument can be a list of strings of arbitrary length.  The
18754 strings are sorted on output, so the order of the list is
18755 unimportant.
18757 A redeclaration of a function or class must not add new ABI tags,
18758 since doing so would change the mangled name.
18760 The ABI tags apply to a name, so all instantiations and
18761 specializations of a template have the same tags.  The attribute will
18762 be ignored if applied to an explicit specialization or instantiation.
18764 The @option{-Wabi-tag} flag enables a warning about a class which does
18765 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18766 that needs to coexist with an earlier ABI, using this option can help
18767 to find all affected types that need to be tagged.
18769 @item init_priority (@var{priority})
18770 @cindex @code{init_priority} attribute
18773 In Standard C++, objects defined at namespace scope are guaranteed to be
18774 initialized in an order in strict accordance with that of their definitions
18775 @emph{in a given translation unit}.  No guarantee is made for initializations
18776 across translation units.  However, GNU C++ allows users to control the
18777 order of initialization of objects defined at namespace scope with the
18778 @code{init_priority} attribute by specifying a relative @var{priority},
18779 a constant integral expression currently bounded between 101 and 65535
18780 inclusive.  Lower numbers indicate a higher priority.
18782 In the following example, @code{A} would normally be created before
18783 @code{B}, but the @code{init_priority} attribute reverses that order:
18785 @smallexample
18786 Some_Class  A  __attribute__ ((init_priority (2000)));
18787 Some_Class  B  __attribute__ ((init_priority (543)));
18788 @end smallexample
18790 @noindent
18791 Note that the particular values of @var{priority} do not matter; only their
18792 relative ordering.
18794 @item java_interface
18795 @cindex @code{java_interface} attribute
18797 This type attribute informs C++ that the class is a Java interface.  It may
18798 only be applied to classes declared within an @code{extern "Java"} block.
18799 Calls to methods declared in this interface are dispatched using GCJ's
18800 interface table mechanism, instead of regular virtual table dispatch.
18802 @item warn_unused
18803 @cindex @code{warn_unused} attribute
18805 For C++ types with non-trivial constructors and/or destructors it is
18806 impossible for the compiler to determine whether a variable of this
18807 type is truly unused if it is not referenced. This type attribute
18808 informs the compiler that variables of this type should be warned
18809 about if they appear to be unused, just like variables of fundamental
18810 types.
18812 This attribute is appropriate for types which just represent a value,
18813 such as @code{std::string}; it is not appropriate for types which
18814 control a resource, such as @code{std::mutex}.
18816 This attribute is also accepted in C, but it is unnecessary because C
18817 does not have constructors or destructors.
18819 @end table
18821 See also @ref{Namespace Association}.
18823 @node Function Multiversioning
18824 @section Function Multiversioning
18825 @cindex function versions
18827 With the GNU C++ front end, for target i386, you may specify multiple
18828 versions of a function, where each function is specialized for a
18829 specific target feature.  At runtime, the appropriate version of the
18830 function is automatically executed depending on the characteristics of
18831 the execution platform.  Here is an example.
18833 @smallexample
18834 __attribute__ ((target ("default")))
18835 int foo ()
18837   // The default version of foo.
18838   return 0;
18841 __attribute__ ((target ("sse4.2")))
18842 int foo ()
18844   // foo version for SSE4.2
18845   return 1;
18848 __attribute__ ((target ("arch=atom")))
18849 int foo ()
18851   // foo version for the Intel ATOM processor
18852   return 2;
18855 __attribute__ ((target ("arch=amdfam10")))
18856 int foo ()
18858   // foo version for the AMD Family 0x10 processors.
18859   return 3;
18862 int main ()
18864   int (*p)() = &foo;
18865   assert ((*p) () == foo ());
18866   return 0;
18868 @end smallexample
18870 In the above example, four versions of function foo are created. The
18871 first version of foo with the target attribute "default" is the default
18872 version.  This version gets executed when no other target specific
18873 version qualifies for execution on a particular platform. A new version
18874 of foo is created by using the same function signature but with a
18875 different target string.  Function foo is called or a pointer to it is
18876 taken just like a regular function.  GCC takes care of doing the
18877 dispatching to call the right version at runtime.  Refer to the
18878 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18879 Function Multiversioning} for more details.
18881 @node Namespace Association
18882 @section Namespace Association
18884 @strong{Caution:} The semantics of this extension are equivalent
18885 to C++ 2011 inline namespaces.  Users should use inline namespaces
18886 instead as this extension will be removed in future versions of G++.
18888 A using-directive with @code{__attribute ((strong))} is stronger
18889 than a normal using-directive in two ways:
18891 @itemize @bullet
18892 @item
18893 Templates from the used namespace can be specialized and explicitly
18894 instantiated as though they were members of the using namespace.
18896 @item
18897 The using namespace is considered an associated namespace of all
18898 templates in the used namespace for purposes of argument-dependent
18899 name lookup.
18900 @end itemize
18902 The used namespace must be nested within the using namespace so that
18903 normal unqualified lookup works properly.
18905 This is useful for composing a namespace transparently from
18906 implementation namespaces.  For example:
18908 @smallexample
18909 namespace std @{
18910   namespace debug @{
18911     template <class T> struct A @{ @};
18912   @}
18913   using namespace debug __attribute ((__strong__));
18914   template <> struct A<int> @{ @};   // @r{OK to specialize}
18916   template <class T> void f (A<T>);
18919 int main()
18921   f (std::A<float>());             // @r{lookup finds} std::f
18922   f (std::A<int>());
18924 @end smallexample
18926 @node Type Traits
18927 @section Type Traits
18929 The C++ front end implements syntactic extensions that allow
18930 compile-time determination of 
18931 various characteristics of a type (or of a
18932 pair of types).
18934 @table @code
18935 @item __has_nothrow_assign (type)
18936 If @code{type} is const qualified or is a reference type then the trait is
18937 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18938 is true, else if @code{type} is a cv class or union type with copy assignment
18939 operators that are known not to throw an exception then the trait is true,
18940 else it is false.  Requires: @code{type} shall be a complete type,
18941 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18943 @item __has_nothrow_copy (type)
18944 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18945 @code{type} is a cv class or union type with copy constructors that
18946 are known not to throw an exception then the trait is true, else it is false.
18947 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18948 @code{void}, or an array of unknown bound.
18950 @item __has_nothrow_constructor (type)
18951 If @code{__has_trivial_constructor (type)} is true then the trait is
18952 true, else if @code{type} is a cv class or union type (or array
18953 thereof) with a default constructor that is known not to throw an
18954 exception then the trait is true, else it is false.  Requires:
18955 @code{type} shall be a complete type, (possibly cv-qualified)
18956 @code{void}, or an array of unknown bound.
18958 @item __has_trivial_assign (type)
18959 If @code{type} is const qualified or is a reference type then the trait is
18960 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
18961 true, else if @code{type} is a cv class or union type with a trivial
18962 copy assignment ([class.copy]) then the trait is true, else it is
18963 false.  Requires: @code{type} shall be a complete type, (possibly
18964 cv-qualified) @code{void}, or an array of unknown bound.
18966 @item __has_trivial_copy (type)
18967 If @code{__is_pod (type)} is true or @code{type} is a reference type
18968 then the trait is true, else if @code{type} is a cv class or union type
18969 with a trivial copy constructor ([class.copy]) then the trait
18970 is true, else it is false.  Requires: @code{type} shall be a complete
18971 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18973 @item __has_trivial_constructor (type)
18974 If @code{__is_pod (type)} is true then the trait is true, else if
18975 @code{type} is a cv class or union type (or array thereof) with a
18976 trivial default constructor ([class.ctor]) then the trait is true,
18977 else it is false.  Requires: @code{type} shall be a complete
18978 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18980 @item __has_trivial_destructor (type)
18981 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18982 the trait is true, else if @code{type} is a cv class or union type (or
18983 array thereof) with a trivial destructor ([class.dtor]) then the trait
18984 is true, else it is false.  Requires: @code{type} shall be a complete
18985 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18987 @item __has_virtual_destructor (type)
18988 If @code{type} is a class type with a virtual destructor
18989 ([class.dtor]) then the trait is true, else it is false.  Requires:
18990 @code{type} shall be a complete type, (possibly cv-qualified)
18991 @code{void}, or an array of unknown bound.
18993 @item __is_abstract (type)
18994 If @code{type} is an abstract class ([class.abstract]) then the trait
18995 is true, else it is false.  Requires: @code{type} shall be a complete
18996 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18998 @item __is_base_of (base_type, derived_type)
18999 If @code{base_type} is a base class of @code{derived_type}
19000 ([class.derived]) then the trait is true, otherwise it is false.
19001 Top-level cv qualifications of @code{base_type} and
19002 @code{derived_type} are ignored.  For the purposes of this trait, a
19003 class type is considered is own base.  Requires: if @code{__is_class
19004 (base_type)} and @code{__is_class (derived_type)} are true and
19005 @code{base_type} and @code{derived_type} are not the same type
19006 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
19007 type.  Diagnostic is produced if this requirement is not met.
19009 @item __is_class (type)
19010 If @code{type} is a cv class type, and not a union type
19011 ([basic.compound]) the trait is true, else it is false.
19013 @item __is_empty (type)
19014 If @code{__is_class (type)} is false then the trait is false.
19015 Otherwise @code{type} is considered empty if and only if: @code{type}
19016 has no non-static data members, or all non-static data members, if
19017 any, are bit-fields of length 0, and @code{type} has no virtual
19018 members, and @code{type} has no virtual base classes, and @code{type}
19019 has no base classes @code{base_type} for which
19020 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
19021 be a complete type, (possibly cv-qualified) @code{void}, or an array
19022 of unknown bound.
19024 @item __is_enum (type)
19025 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
19026 true, else it is false.
19028 @item __is_literal_type (type)
19029 If @code{type} is a literal type ([basic.types]) the trait is
19030 true, else it is false.  Requires: @code{type} shall be a complete type,
19031 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19033 @item __is_pod (type)
19034 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
19035 else it is false.  Requires: @code{type} shall be a complete type,
19036 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19038 @item __is_polymorphic (type)
19039 If @code{type} is a polymorphic class ([class.virtual]) then the trait
19040 is true, else it is false.  Requires: @code{type} shall be a complete
19041 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19043 @item __is_standard_layout (type)
19044 If @code{type} is a standard-layout type ([basic.types]) the trait is
19045 true, else it is false.  Requires: @code{type} shall be a complete
19046 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19048 @item __is_trivial (type)
19049 If @code{type} is a trivial type ([basic.types]) the trait is
19050 true, else it is false.  Requires: @code{type} shall be a complete
19051 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19053 @item __is_union (type)
19054 If @code{type} is a cv union type ([basic.compound]) the trait is
19055 true, else it is false.
19057 @item __underlying_type (type)
19058 The underlying type of @code{type}.  Requires: @code{type} shall be
19059 an enumeration type ([dcl.enum]).
19061 @end table
19063 @node Java Exceptions
19064 @section Java Exceptions
19066 The Java language uses a slightly different exception handling model
19067 from C++.  Normally, GNU C++ automatically detects when you are
19068 writing C++ code that uses Java exceptions, and handle them
19069 appropriately.  However, if C++ code only needs to execute destructors
19070 when Java exceptions are thrown through it, GCC guesses incorrectly.
19071 Sample problematic code is:
19073 @smallexample
19074   struct S @{ ~S(); @};
19075   extern void bar();    // @r{is written in Java, and may throw exceptions}
19076   void foo()
19077   @{
19078     S s;
19079     bar();
19080   @}
19081 @end smallexample
19083 @noindent
19084 The usual effect of an incorrect guess is a link failure, complaining of
19085 a missing routine called @samp{__gxx_personality_v0}.
19087 You can inform the compiler that Java exceptions are to be used in a
19088 translation unit, irrespective of what it might think, by writing
19089 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
19090 @samp{#pragma} must appear before any functions that throw or catch
19091 exceptions, or run destructors when exceptions are thrown through them.
19093 You cannot mix Java and C++ exceptions in the same translation unit.  It
19094 is believed to be safe to throw a C++ exception from one file through
19095 another file compiled for the Java exception model, or vice versa, but
19096 there may be bugs in this area.
19098 @node Deprecated Features
19099 @section Deprecated Features
19101 In the past, the GNU C++ compiler was extended to experiment with new
19102 features, at a time when the C++ language was still evolving.  Now that
19103 the C++ standard is complete, some of those features are superseded by
19104 superior alternatives.  Using the old features might cause a warning in
19105 some cases that the feature will be dropped in the future.  In other
19106 cases, the feature might be gone already.
19108 While the list below is not exhaustive, it documents some of the options
19109 that are now deprecated:
19111 @table @code
19112 @item -fexternal-templates
19113 @itemx -falt-external-templates
19114 These are two of the many ways for G++ to implement template
19115 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
19116 defines how template definitions have to be organized across
19117 implementation units.  G++ has an implicit instantiation mechanism that
19118 should work just fine for standard-conforming code.
19120 @item -fstrict-prototype
19121 @itemx -fno-strict-prototype
19122 Previously it was possible to use an empty prototype parameter list to
19123 indicate an unspecified number of parameters (like C), rather than no
19124 parameters, as C++ demands.  This feature has been removed, except where
19125 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
19126 @end table
19128 G++ allows a virtual function returning @samp{void *} to be overridden
19129 by one returning a different pointer type.  This extension to the
19130 covariant return type rules is now deprecated and will be removed from a
19131 future version.
19133 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19134 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19135 and are now removed from G++.  Code using these operators should be
19136 modified to use @code{std::min} and @code{std::max} instead.
19138 The named return value extension has been deprecated, and is now
19139 removed from G++.
19141 The use of initializer lists with new expressions has been deprecated,
19142 and is now removed from G++.
19144 Floating and complex non-type template parameters have been deprecated,
19145 and are now removed from G++.
19147 The implicit typename extension has been deprecated and is now
19148 removed from G++.
19150 The use of default arguments in function pointers, function typedefs
19151 and other places where they are not permitted by the standard is
19152 deprecated and will be removed from a future version of G++.
19154 G++ allows floating-point literals to appear in integral constant expressions,
19155 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19156 This extension is deprecated and will be removed from a future version.
19158 G++ allows static data members of const floating-point type to be declared
19159 with an initializer in a class definition. The standard only allows
19160 initializers for static members of const integral types and const
19161 enumeration types so this extension has been deprecated and will be removed
19162 from a future version.
19164 @node Backwards Compatibility
19165 @section Backwards Compatibility
19166 @cindex Backwards Compatibility
19167 @cindex ARM [Annotated C++ Reference Manual]
19169 Now that there is a definitive ISO standard C++, G++ has a specification
19170 to adhere to.  The C++ language evolved over time, and features that
19171 used to be acceptable in previous drafts of the standard, such as the ARM
19172 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
19173 compilation of C++ written to such drafts, G++ contains some backwards
19174 compatibilities.  @emph{All such backwards compatibility features are
19175 liable to disappear in future versions of G++.} They should be considered
19176 deprecated.   @xref{Deprecated Features}.
19178 @table @code
19179 @item For scope
19180 If a variable is declared at for scope, it used to remain in scope until
19181 the end of the scope that contained the for statement (rather than just
19182 within the for scope).  G++ retains this, but issues a warning, if such a
19183 variable is accessed outside the for scope.
19185 @item Implicit C language
19186 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19187 scope to set the language.  On such systems, all header files are
19188 implicitly scoped inside a C language scope.  Also, an empty prototype
19189 @code{()} is treated as an unspecified number of arguments, rather
19190 than no arguments, as C++ demands.
19191 @end table
19193 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
19194 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign