* doc/extend.texi (Arrays of Length Zero): Add missing comma.
[official-gcc.git] / gcc / doc / extend.texi
blobf68cd7f62854e6f3748caa70280b8427aa13dd7e
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{always_inline}, @code{flatten}, @code{pure}, @code{const},
2199 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2200 @code{no_instrument_function}, @code{no_split_stack},
2201 @code{section}, @code{constructor},
2202 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2203 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2204 @code{warn_unused_result}, @code{nonnull},
2205 @code{returns_nonnull}, @code{gnu_inline},
2206 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2207 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2208 @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
2209 @code{bnd_instrument},
2210 @code{error} and @code{warning}.
2211 Several other attributes are defined for functions on particular
2212 target systems.  Other attributes, including @code{section} are
2213 supported for variables declarations (@pxref{Variable Attributes}),
2214 labels (@pxref{Label Attributes})
2215 and for types (@pxref{Type Attributes}).
2217 GCC plugins may provide their own attributes.
2219 You may also specify attributes with @samp{__} preceding and following
2220 each keyword.  This allows you to use them in header files without
2221 being concerned about a possible macro of the same name.  For example,
2222 you may use @code{__noreturn__} instead of @code{noreturn}.
2224 @xref{Attribute Syntax}, for details of the exact syntax for using
2225 attributes.
2227 @table @code
2228 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2230 @item alias ("@var{target}")
2231 @cindex @code{alias} attribute
2232 The @code{alias} attribute causes the declaration to be emitted as an
2233 alias for another symbol, which must be specified.  For instance,
2235 @smallexample
2236 void __f () @{ /* @r{Do something.} */; @}
2237 void f () __attribute__ ((weak, alias ("__f")));
2238 @end smallexample
2240 @noindent
2241 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2242 mangled name for the target must be used.  It is an error if @samp{__f}
2243 is not defined in the same translation unit.
2245 Not all target machines support this attribute.
2247 @item aligned (@var{alignment})
2248 @cindex @code{aligned} attribute
2249 This attribute specifies a minimum alignment for the function,
2250 measured in bytes.
2252 You cannot use this attribute to decrease the alignment of a function,
2253 only to increase it.  However, when you explicitly specify a function
2254 alignment this overrides the effect of the
2255 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2256 function.
2258 Note that the effectiveness of @code{aligned} attributes may be
2259 limited by inherent limitations in your linker.  On many systems, the
2260 linker is only able to arrange for functions to be aligned up to a
2261 certain maximum alignment.  (For some linkers, the maximum supported
2262 alignment may be very very small.)  See your linker documentation for
2263 further information.
2265 The @code{aligned} attribute can also be used for variables and fields
2266 (@pxref{Variable Attributes}.)
2268 @item alloc_size
2269 @cindex @code{alloc_size} attribute
2270 The @code{alloc_size} attribute is used to tell the compiler that the
2271 function return value points to memory, where the size is given by
2272 one or two of the functions parameters.  GCC uses this
2273 information to improve the correctness of @code{__builtin_object_size}.
2275 The function parameter(s) denoting the allocated size are specified by
2276 one or two integer arguments supplied to the attribute.  The allocated size
2277 is either the value of the single function argument specified or the product
2278 of the two function arguments specified.  Argument numbering starts at
2279 one.
2281 For instance,
2283 @smallexample
2284 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2285 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2286 @end smallexample
2288 @noindent
2289 declares that @code{my_calloc} returns memory of the size given by
2290 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2291 of the size given by parameter 2.
2293 @item alloc_align
2294 @cindex @code{alloc_align} attribute
2295 The @code{alloc_align} attribute is used to tell the compiler that the
2296 function return value points to memory, where the returned pointer minimum
2297 alignment is given by one of the functions parameters.  GCC uses this
2298 information to improve pointer alignment analysis.
2300 The function parameter denoting the allocated alignment is specified by
2301 one integer argument, whose number is the argument of the attribute.
2302 Argument numbering starts at one.
2304 For instance,
2306 @smallexample
2307 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2308 @end smallexample
2310 @noindent
2311 declares that @code{my_memalign} returns memory with minimum alignment
2312 given by parameter 1.
2314 @item assume_aligned
2315 @cindex @code{assume_aligned} attribute
2316 The @code{assume_aligned} attribute is used to tell the compiler that the
2317 function return value points to memory, where the returned pointer minimum
2318 alignment is given by the first argument.
2319 If the attribute has two arguments, the second argument is misalignment offset.
2321 For instance
2323 @smallexample
2324 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2325 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2326 @end smallexample
2328 @noindent
2329 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2330 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2331 to 8.
2333 @item always_inline
2334 @cindex @code{always_inline} function attribute
2335 Generally, functions are not inlined unless optimization is specified.
2336 For functions declared inline, this attribute inlines the function
2337 independent of any restrictions that otherwise apply to inlining.
2338 Failure to inline such a function is diagnosed as an error.
2339 Note that if such a function is called indirectly the compiler may
2340 or may not inline it depending on optimization level and a failure
2341 to inline an indirect call may or may not be diagnosed.
2343 @item gnu_inline
2344 @cindex @code{gnu_inline} function attribute
2345 This attribute should be used with a function that is also declared
2346 with the @code{inline} keyword.  It directs GCC to treat the function
2347 as if it were defined in gnu90 mode even when compiling in C99 or
2348 gnu99 mode.
2350 If the function is declared @code{extern}, then this definition of the
2351 function is used only for inlining.  In no case is the function
2352 compiled as a standalone function, not even if you take its address
2353 explicitly.  Such an address becomes an external reference, as if you
2354 had only declared the function, and had not defined it.  This has
2355 almost the effect of a macro.  The way to use this is to put a
2356 function definition in a header file with this attribute, and put
2357 another copy of the function, without @code{extern}, in a library
2358 file.  The definition in the header file causes most calls to the
2359 function to be inlined.  If any uses of the function remain, they
2360 refer to the single copy in the library.  Note that the two
2361 definitions of the functions need not be precisely the same, although
2362 if they do not have the same effect your program may behave oddly.
2364 In C, if the function is neither @code{extern} nor @code{static}, then
2365 the function is compiled as a standalone function, as well as being
2366 inlined where possible.
2368 This is how GCC traditionally handled functions declared
2369 @code{inline}.  Since ISO C99 specifies a different semantics for
2370 @code{inline}, this function attribute is provided as a transition
2371 measure and as a useful feature in its own right.  This attribute is
2372 available in GCC 4.1.3 and later.  It is available if either of the
2373 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2374 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2375 Function is As Fast As a Macro}.
2377 In C++, this attribute does not depend on @code{extern} in any way,
2378 but it still requires the @code{inline} keyword to enable its special
2379 behavior.
2381 @item artificial
2382 @cindex @code{artificial} function attribute
2383 This attribute is useful for small inline wrappers that if possible
2384 should appear during debugging as a unit.  Depending on the debug
2385 info format it either means marking the function as artificial
2386 or using the caller location for all instructions within the inlined
2387 body.
2389 @item bank_switch
2390 @cindex interrupt handler functions
2391 When added to an interrupt handler with the M32C port, causes the
2392 prologue and epilogue to use bank switching to preserve the registers
2393 rather than saving them on the stack.
2395 @item flatten
2396 @cindex @code{flatten} function attribute
2397 Generally, inlining into a function is limited.  For a function marked with
2398 this attribute, every call inside this function is inlined, if possible.
2399 Whether the function itself is considered for inlining depends on its size and
2400 the current inlining parameters.
2402 @item error ("@var{message}")
2403 @cindex @code{error} function attribute
2404 If this attribute is used on a function declaration and a call to such a function
2405 is not eliminated through dead code elimination or other optimizations, an error
2406 that includes @var{message} is diagnosed.  This is useful
2407 for compile-time checking, especially together with @code{__builtin_constant_p}
2408 and inline functions where checking the inline function arguments is not
2409 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2410 While it is possible to leave the function undefined and thus invoke
2411 a link failure, when using this attribute the problem is diagnosed
2412 earlier and with exact location of the call even in presence of inline
2413 functions or when not emitting debugging information.
2415 @item warning ("@var{message}")
2416 @cindex @code{warning} function attribute
2417 If this attribute is used on a function declaration and a call to such a function
2418 is not eliminated through dead code elimination or other optimizations, a warning
2419 that includes @var{message} is diagnosed.  This is useful
2420 for compile-time checking, especially together with @code{__builtin_constant_p}
2421 and inline functions.  While it is possible to define the function with
2422 a message in @code{.gnu.warning*} section, when using this attribute the problem
2423 is diagnosed earlier and with exact location of the call even in presence
2424 of inline functions or when not emitting debugging information.
2426 @item cdecl
2427 @cindex functions that do pop the argument stack on the 386
2428 @opindex mrtd
2429 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2430 assume that the calling function pops off the stack space used to
2431 pass arguments.  This is
2432 useful to override the effects of the @option{-mrtd} switch.
2434 @item const
2435 @cindex @code{const} function attribute
2436 Many functions do not examine any values except their arguments, and
2437 have no effects except the return value.  Basically this is just slightly
2438 more strict class than the @code{pure} attribute below, since function is not
2439 allowed to read global memory.
2441 @cindex pointer arguments
2442 Note that a function that has pointer arguments and examines the data
2443 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2444 function that calls a non-@code{const} function usually must not be
2445 @code{const}.  It does not make sense for a @code{const} function to
2446 return @code{void}.
2448 The attribute @code{const} is not implemented in GCC versions earlier
2449 than 2.5.  An alternative way to declare that a function has no side
2450 effects, which works in the current version and in some older versions,
2451 is as follows:
2453 @smallexample
2454 typedef int intfn ();
2456 extern const intfn square;
2457 @end smallexample
2459 @noindent
2460 This approach does not work in GNU C++ from 2.6.0 on, since the language
2461 specifies that the @samp{const} must be attached to the return value.
2463 @item constructor
2464 @itemx destructor
2465 @itemx constructor (@var{priority})
2466 @itemx destructor (@var{priority})
2467 @cindex @code{constructor} function attribute
2468 @cindex @code{destructor} function attribute
2469 The @code{constructor} attribute causes the function to be called
2470 automatically before execution enters @code{main ()}.  Similarly, the
2471 @code{destructor} attribute causes the function to be called
2472 automatically after @code{main ()} completes or @code{exit ()} is
2473 called.  Functions with these attributes are useful for
2474 initializing data that is used implicitly during the execution of
2475 the program.
2477 You may provide an optional integer priority to control the order in
2478 which constructor and destructor functions are run.  A constructor
2479 with a smaller priority number runs before a constructor with a larger
2480 priority number; the opposite relationship holds for destructors.  So,
2481 if you have a constructor that allocates a resource and a destructor
2482 that deallocates the same resource, both functions typically have the
2483 same priority.  The priorities for constructor and destructor
2484 functions are the same as those specified for namespace-scope C++
2485 objects (@pxref{C++ Attributes}).
2487 These attributes are not currently implemented for Objective-C@.
2489 @item deprecated
2490 @itemx deprecated (@var{msg})
2491 @cindex @code{deprecated} attribute.
2492 The @code{deprecated} attribute results in a warning if the function
2493 is used anywhere in the source file.  This is useful when identifying
2494 functions that are expected to be removed in a future version of a
2495 program.  The warning also includes the location of the declaration
2496 of the deprecated function, to enable users to easily find further
2497 information about why the function is deprecated, or what they should
2498 do instead.  Note that the warnings only occurs for uses:
2500 @smallexample
2501 int old_fn () __attribute__ ((deprecated));
2502 int old_fn ();
2503 int (*fn_ptr)() = old_fn;
2504 @end smallexample
2506 @noindent
2507 results in a warning on line 3 but not line 2.  The optional @var{msg}
2508 argument, which must be a string, is printed in the warning if
2509 present.
2511 The @code{deprecated} attribute can also be used for variables and
2512 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2514 @item disinterrupt
2515 @cindex @code{disinterrupt} attribute
2516 On Epiphany and MeP targets, this attribute causes the compiler to emit
2517 instructions to disable interrupts for the duration of the given
2518 function.
2520 @item dllexport
2521 @cindex @code{__declspec(dllexport)}
2522 On Microsoft Windows targets and Symbian OS targets the
2523 @code{dllexport} attribute causes the compiler to provide a global
2524 pointer to a pointer in a DLL, so that it can be referenced with the
2525 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2526 name is formed by combining @code{_imp__} and the function or variable
2527 name.
2529 You can use @code{__declspec(dllexport)} as a synonym for
2530 @code{__attribute__ ((dllexport))} for compatibility with other
2531 compilers.
2533 On systems that support the @code{visibility} attribute, this
2534 attribute also implies ``default'' visibility.  It is an error to
2535 explicitly specify any other visibility.
2537 In previous versions of GCC, the @code{dllexport} attribute was ignored
2538 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2539 had been used.  The default behavior now is to emit all dllexported
2540 inline functions; however, this can cause object file-size bloat, in
2541 which case the old behavior can be restored by using
2542 @option{-fno-keep-inline-dllexport}.
2544 The attribute is also ignored for undefined symbols.
2546 When applied to C++ classes, the attribute marks defined non-inlined
2547 member functions and static data members as exports.  Static consts
2548 initialized in-class are not marked unless they are also defined
2549 out-of-class.
2551 For Microsoft Windows targets there are alternative methods for
2552 including the symbol in the DLL's export table such as using a
2553 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2554 the @option{--export-all} linker flag.
2556 @item dllimport
2557 @cindex @code{__declspec(dllimport)}
2558 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2559 attribute causes the compiler to reference a function or variable via
2560 a global pointer to a pointer that is set up by the DLL exporting the
2561 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2562 targets, the pointer name is formed by combining @code{_imp__} and the
2563 function or variable name.
2565 You can use @code{__declspec(dllimport)} as a synonym for
2566 @code{__attribute__ ((dllimport))} for compatibility with other
2567 compilers.
2569 On systems that support the @code{visibility} attribute, this
2570 attribute also implies ``default'' visibility.  It is an error to
2571 explicitly specify any other visibility.
2573 Currently, the attribute is ignored for inlined functions.  If the
2574 attribute is applied to a symbol @emph{definition}, an error is reported.
2575 If a symbol previously declared @code{dllimport} is later defined, the
2576 attribute is ignored in subsequent references, and a warning is emitted.
2577 The attribute is also overridden by a subsequent declaration as
2578 @code{dllexport}.
2580 When applied to C++ classes, the attribute marks non-inlined
2581 member functions and static data members as imports.  However, the
2582 attribute is ignored for virtual methods to allow creation of vtables
2583 using thunks.
2585 On the SH Symbian OS target the @code{dllimport} attribute also has
2586 another affect---it can cause the vtable and run-time type information
2587 for a class to be exported.  This happens when the class has a
2588 dllimported constructor or a non-inline, non-pure virtual function
2589 and, for either of those two conditions, the class also has an inline
2590 constructor or destructor and has a key function that is defined in
2591 the current translation unit.
2593 For Microsoft Windows targets the use of the @code{dllimport}
2594 attribute on functions is not necessary, but provides a small
2595 performance benefit by eliminating a thunk in the DLL@.  The use of the
2596 @code{dllimport} attribute on imported variables was required on older
2597 versions of the GNU linker, but can now be avoided by passing the
2598 @option{--enable-auto-import} switch to the GNU linker.  As with
2599 functions, using the attribute for a variable eliminates a thunk in
2600 the DLL@.
2602 One drawback to using this attribute is that a pointer to a
2603 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2604 address. However, a pointer to a @emph{function} with the
2605 @code{dllimport} attribute can be used as a constant initializer; in
2606 this case, the address of a stub function in the import lib is
2607 referenced.  On Microsoft Windows targets, the attribute can be disabled
2608 for functions by setting the @option{-mnop-fun-dllimport} flag.
2610 @item eightbit_data
2611 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2612 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2613 variable should be placed into the eight-bit data section.
2614 The compiler generates more efficient code for certain operations
2615 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2616 256 bytes of data.
2618 You must use GAS and GLD from GNU binutils version 2.7 or later for
2619 this attribute to work correctly.
2621 @item exception
2622 @cindex exception handler functions
2623 Use this attribute on the NDS32 target to indicate that the specified function
2624 is an exception handler.  The compiler will generate corresponding sections
2625 for use in an exception handler.
2627 @item exception_handler
2628 @cindex exception handler functions on the Blackfin processor
2629 Use this attribute on the Blackfin to indicate that the specified function
2630 is an exception handler.  The compiler generates function entry and
2631 exit sequences suitable for use in an exception handler when this
2632 attribute is present.
2634 @item externally_visible
2635 @cindex @code{externally_visible} attribute.
2636 This attribute, attached to a global variable or function, nullifies
2637 the effect of the @option{-fwhole-program} command-line option, so the
2638 object remains visible outside the current compilation unit.
2640 If @option{-fwhole-program} is used together with @option{-flto} and 
2641 @command{gold} is used as the linker plugin, 
2642 @code{externally_visible} attributes are automatically added to functions 
2643 (not variable yet due to a current @command{gold} issue) 
2644 that are accessed outside of LTO objects according to resolution file
2645 produced by @command{gold}.
2646 For other linkers that cannot generate resolution file,
2647 explicit @code{externally_visible} attributes are still necessary.
2649 @item far
2650 @cindex functions that handle memory bank switching
2651 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2652 use a calling convention that takes care of switching memory banks when
2653 entering and leaving a function.  This calling convention is also the
2654 default when using the @option{-mlong-calls} option.
2656 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2657 to call and return from a function.
2659 On 68HC11 the compiler generates a sequence of instructions
2660 to invoke a board-specific routine to switch the memory bank and call the
2661 real function.  The board-specific routine simulates a @code{call}.
2662 At the end of a function, it jumps to a board-specific routine
2663 instead of using @code{rts}.  The board-specific return routine simulates
2664 the @code{rtc}.
2666 On MeP targets this causes the compiler to use a calling convention
2667 that assumes the called function is too far away for the built-in
2668 addressing modes.
2670 @item fast_interrupt
2671 @cindex interrupt handler functions
2672 Use this attribute on the M32C and RX ports to indicate that the specified
2673 function is a fast interrupt handler.  This is just like the
2674 @code{interrupt} attribute, except that @code{freit} is used to return
2675 instead of @code{reit}.
2677 @item fastcall
2678 @cindex functions that pop the argument stack on the 386
2679 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2680 pass the first argument (if of integral type) in the register ECX and
2681 the second argument (if of integral type) in the register EDX@.  Subsequent
2682 and other typed arguments are passed on the stack.  The called function
2683 pops the arguments off the stack.  If the number of arguments is variable all
2684 arguments are pushed on the stack.
2686 @item thiscall
2687 @cindex functions that pop the argument stack on the 386
2688 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2689 pass the first argument (if of integral type) in the register ECX.
2690 Subsequent and other typed arguments are passed on the stack. The called
2691 function pops the arguments off the stack.
2692 If the number of arguments is variable all arguments are pushed on the
2693 stack.
2694 The @code{thiscall} attribute is intended for C++ non-static member functions.
2695 As a GCC extension, this calling convention can be used for C functions
2696 and for static member methods.
2698 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2699 @cindex @code{format} function attribute
2700 @opindex Wformat
2701 The @code{format} attribute specifies that a function takes @code{printf},
2702 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2703 should be type-checked against a format string.  For example, the
2704 declaration:
2706 @smallexample
2707 extern int
2708 my_printf (void *my_object, const char *my_format, ...)
2709       __attribute__ ((format (printf, 2, 3)));
2710 @end smallexample
2712 @noindent
2713 causes the compiler to check the arguments in calls to @code{my_printf}
2714 for consistency with the @code{printf} style format string argument
2715 @code{my_format}.
2717 The parameter @var{archetype} determines how the format string is
2718 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2719 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2720 @code{strfmon}.  (You can also use @code{__printf__},
2721 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2722 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2723 @code{ms_strftime} are also present.
2724 @var{archetype} values such as @code{printf} refer to the formats accepted
2725 by the system's C runtime library,
2726 while values prefixed with @samp{gnu_} always refer
2727 to the formats accepted by the GNU C Library.  On Microsoft Windows
2728 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2729 @file{msvcrt.dll} library.
2730 The parameter @var{string-index}
2731 specifies which argument is the format string argument (starting
2732 from 1), while @var{first-to-check} is the number of the first
2733 argument to check against the format string.  For functions
2734 where the arguments are not available to be checked (such as
2735 @code{vprintf}), specify the third parameter as zero.  In this case the
2736 compiler only checks the format string for consistency.  For
2737 @code{strftime} formats, the third parameter is required to be zero.
2738 Since non-static C++ methods have an implicit @code{this} argument, the
2739 arguments of such methods should be counted from two, not one, when
2740 giving values for @var{string-index} and @var{first-to-check}.
2742 In the example above, the format string (@code{my_format}) is the second
2743 argument of the function @code{my_print}, and the arguments to check
2744 start with the third argument, so the correct parameters for the format
2745 attribute are 2 and 3.
2747 @opindex ffreestanding
2748 @opindex fno-builtin
2749 The @code{format} attribute allows you to identify your own functions
2750 that take format strings as arguments, so that GCC can check the
2751 calls to these functions for errors.  The compiler always (unless
2752 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2753 for the standard library functions @code{printf}, @code{fprintf},
2754 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2755 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2756 warnings are requested (using @option{-Wformat}), so there is no need to
2757 modify the header file @file{stdio.h}.  In C99 mode, the functions
2758 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2759 @code{vsscanf} are also checked.  Except in strictly conforming C
2760 standard modes, the X/Open function @code{strfmon} is also checked as
2761 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2762 @xref{C Dialect Options,,Options Controlling C Dialect}.
2764 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2765 recognized in the same context.  Declarations including these format attributes
2766 are parsed for correct syntax, however the result of checking of such format
2767 strings is not yet defined, and is not carried out by this version of the
2768 compiler.
2770 The target may also provide additional types of format checks.
2771 @xref{Target Format Checks,,Format Checks Specific to Particular
2772 Target Machines}.
2774 @item format_arg (@var{string-index})
2775 @cindex @code{format_arg} function attribute
2776 @opindex Wformat-nonliteral
2777 The @code{format_arg} attribute specifies that a function takes a format
2778 string for a @code{printf}, @code{scanf}, @code{strftime} or
2779 @code{strfmon} style function and modifies it (for example, to translate
2780 it into another language), so the result can be passed to a
2781 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2782 function (with the remaining arguments to the format function the same
2783 as they would have been for the unmodified string).  For example, the
2784 declaration:
2786 @smallexample
2787 extern char *
2788 my_dgettext (char *my_domain, const char *my_format)
2789       __attribute__ ((format_arg (2)));
2790 @end smallexample
2792 @noindent
2793 causes the compiler to check the arguments in calls to a @code{printf},
2794 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2795 format string argument is a call to the @code{my_dgettext} function, for
2796 consistency with the format string argument @code{my_format}.  If the
2797 @code{format_arg} attribute had not been specified, all the compiler
2798 could tell in such calls to format functions would be that the format
2799 string argument is not constant; this would generate a warning when
2800 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2801 without the attribute.
2803 The parameter @var{string-index} specifies which argument is the format
2804 string argument (starting from one).  Since non-static C++ methods have
2805 an implicit @code{this} argument, the arguments of such methods should
2806 be counted from two.
2808 The @code{format_arg} attribute allows you to identify your own
2809 functions that modify format strings, so that GCC can check the
2810 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2811 type function whose operands are a call to one of your own function.
2812 The compiler always treats @code{gettext}, @code{dgettext}, and
2813 @code{dcgettext} in this manner except when strict ISO C support is
2814 requested by @option{-ansi} or an appropriate @option{-std} option, or
2815 @option{-ffreestanding} or @option{-fno-builtin}
2816 is used.  @xref{C Dialect Options,,Options
2817 Controlling C Dialect}.
2819 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2820 @code{NSString} reference for compatibility with the @code{format} attribute
2821 above.
2823 The target may also allow additional types in @code{format-arg} attributes.
2824 @xref{Target Format Checks,,Format Checks Specific to Particular
2825 Target Machines}.
2827 @item function_vector
2828 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2829 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2830 function should be called through the function vector.  Calling a
2831 function through the function vector reduces code size, however;
2832 the function vector has a limited size (maximum 128 entries on the H8/300
2833 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2835 On SH2A targets, this attribute declares a function to be called using the
2836 TBR relative addressing mode.  The argument to this attribute is the entry
2837 number of the same function in a vector table containing all the TBR
2838 relative addressable functions.  For correct operation the TBR must be setup
2839 accordingly to point to the start of the vector table before any functions with
2840 this attribute are invoked.  Usually a good place to do the initialization is
2841 the startup routine.  The TBR relative vector table can have at max 256 function
2842 entries.  The jumps to these functions are generated using a SH2A specific,
2843 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2844 from GNU binutils version 2.7 or later for this attribute to work correctly.
2846 Please refer the example of M16C target, to see the use of this
2847 attribute while declaring a function,
2849 In an application, for a function being called once, this attribute
2850 saves at least 8 bytes of code; and if other successive calls are being
2851 made to the same function, it saves 2 bytes of code per each of these
2852 calls.
2854 On M16C/M32C targets, the @code{function_vector} attribute declares a
2855 special page subroutine call function. Use of this attribute reduces
2856 the code size by 2 bytes for each call generated to the
2857 subroutine. The argument to the attribute is the vector number entry
2858 from the special page vector table which contains the 16 low-order
2859 bits of the subroutine's entry address. Each vector table has special
2860 page number (18 to 255) that is used in @code{jsrs} instructions.
2861 Jump addresses of the routines are generated by adding 0x0F0000 (in
2862 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2863 2-byte addresses set in the vector table. Therefore you need to ensure
2864 that all the special page vector routines should get mapped within the
2865 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2866 (for M32C).
2868 In the following example 2 bytes are saved for each call to
2869 function @code{foo}.
2871 @smallexample
2872 void foo (void) __attribute__((function_vector(0x18)));
2873 void foo (void)
2877 void bar (void)
2879     foo();
2881 @end smallexample
2883 If functions are defined in one file and are called in another file,
2884 then be sure to write this declaration in both files.
2886 This attribute is ignored for R8C target.
2888 @item ifunc ("@var{resolver}")
2889 @cindex @code{ifunc} attribute
2890 The @code{ifunc} attribute is used to mark a function as an indirect
2891 function using the STT_GNU_IFUNC symbol type extension to the ELF
2892 standard.  This allows the resolution of the symbol value to be
2893 determined dynamically at load time, and an optimized version of the
2894 routine can be selected for the particular processor or other system
2895 characteristics determined then.  To use this attribute, first define
2896 the implementation functions available, and a resolver function that
2897 returns a pointer to the selected implementation function.  The
2898 implementation functions' declarations must match the API of the
2899 function being implemented, the resolver's declaration is be a
2900 function returning pointer to void function returning void:
2902 @smallexample
2903 void *my_memcpy (void *dst, const void *src, size_t len)
2905   @dots{}
2908 static void (*resolve_memcpy (void)) (void)
2910   return my_memcpy; // we'll just always select this routine
2912 @end smallexample
2914 @noindent
2915 The exported header file declaring the function the user calls would
2916 contain:
2918 @smallexample
2919 extern void *memcpy (void *, const void *, size_t);
2920 @end smallexample
2922 @noindent
2923 allowing the user to call this as a regular function, unaware of the
2924 implementation.  Finally, the indirect function needs to be defined in
2925 the same translation unit as the resolver function:
2927 @smallexample
2928 void *memcpy (void *, const void *, size_t)
2929      __attribute__ ((ifunc ("resolve_memcpy")));
2930 @end smallexample
2932 Indirect functions cannot be weak, and require a recent binutils (at
2933 least version 2.20.1), and GNU C library (at least version 2.11.1).
2935 @item interrupt
2936 @cindex interrupt handler functions
2937 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2938 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2939 the specified function is an
2940 interrupt handler.  The compiler generates function entry and exit
2941 sequences suitable for use in an interrupt handler when this attribute
2942 is present.  With Epiphany targets it may also generate a special section with
2943 code to initialize the interrupt vector table.
2945 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2946 and SH processors can be specified via the @code{interrupt_handler} attribute.
2948 Note, on the ARC, you must specify the kind of interrupt to be handled
2949 in a parameter to the interrupt attribute like this:
2951 @smallexample
2952 void f () __attribute__ ((interrupt ("ilink1")));
2953 @end smallexample
2955 Permissible values for this parameter are: @w{@code{ilink1}} and
2956 @w{@code{ilink2}}.
2958 Note, on the AVR, the hardware globally disables interrupts when an
2959 interrupt is executed.  The first instruction of an interrupt handler
2960 declared with this attribute is a @code{SEI} instruction to
2961 re-enable interrupts.  See also the @code{signal} function attribute
2962 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2963 @code{interrupt} are specified for the same function, @code{signal}
2964 is silently ignored.
2966 Note, for the ARM, you can specify the kind of interrupt to be handled by
2967 adding an optional parameter to the interrupt attribute like this:
2969 @smallexample
2970 void f () __attribute__ ((interrupt ("IRQ")));
2971 @end smallexample
2973 @noindent
2974 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2975 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2977 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2978 may be called with a word-aligned stack pointer.
2980 Note, for the MSP430 you can provide an argument to the interrupt
2981 attribute which specifies a name or number.  If the argument is a
2982 number it indicates the slot in the interrupt vector table (0 - 31) to
2983 which this handler should be assigned.  If the argument is a name it
2984 is treated as a symbolic name for the vector slot.  These names should
2985 match up with appropriate entries in the linker script.  By default
2986 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2987 @code{reset} for vector 31 are recognised.
2989 You can also use the following function attributes to modify how
2990 normal functions interact with interrupt functions:
2992 @table @code
2993 @item critical
2994 @cindex @code{critical} attribute
2995 Critical functions disable interrupts upon entry and restore the
2996 previous interrupt state upon exit.  Critical functions cannot also
2997 have the @code{naked} or @code{reentrant} attributes.  They can have
2998 the @code{interrupt} attribute.
3000 @item reentrant
3001 @cindex @code{reentrant} attribute
3002 Reentrant functions disable interrupts upon entry and enable them
3003 upon exit.  Reentrant functions cannot also have the @code{naked}
3004 or @code{critical} attributes.  They can have the @code{interrupt}
3005 attribute.
3007 @item wakeup
3008 @cindex @code{wakeup} attribute
3009 This attribute only applies to interrupt functions.  It is silently
3010 ignored if applied to a non-interrupt function.  A wakeup interrupt
3011 function will rouse the processor from any low-power state that it
3012 might be in when the function exits.
3014 @end table
3016 On Epiphany targets one or more optional parameters can be added like this:
3018 @smallexample
3019 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3020 @end smallexample
3022 Permissible values for these parameters are: @w{@code{reset}},
3023 @w{@code{software_exception}}, @w{@code{page_miss}},
3024 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3025 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3026 Multiple parameters indicate that multiple entries in the interrupt
3027 vector table should be initialized for this function, i.e.@: for each
3028 parameter @w{@var{name}}, a jump to the function is emitted in
3029 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3030 entirely, in which case no interrupt vector table entry is provided.
3032 Note, on Epiphany targets, interrupts are enabled inside the function
3033 unless the @code{disinterrupt} attribute is also specified.
3035 On Epiphany targets, you can also use the following attribute to
3036 modify the behavior of an interrupt handler:
3037 @table @code
3038 @item forwarder_section
3039 @cindex @code{forwarder_section} attribute
3040 The interrupt handler may be in external memory which cannot be
3041 reached by a branch instruction, so generate a local memory trampoline
3042 to transfer control.  The single parameter identifies the section where
3043 the trampoline is placed.
3044 @end table
3046 The following examples are all valid uses of these attributes on
3047 Epiphany targets:
3048 @smallexample
3049 void __attribute__ ((interrupt)) universal_handler ();
3050 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3051 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3052 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3053   fast_timer_handler ();
3054 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3055   external_dma_handler ();
3056 @end smallexample
3058 On MIPS targets, you can use the following attributes to modify the behavior
3059 of an interrupt handler:
3060 @table @code
3061 @item use_shadow_register_set
3062 @cindex @code{use_shadow_register_set} attribute
3063 Assume that the handler uses a shadow register set, instead of
3064 the main general-purpose registers.
3066 @item keep_interrupts_masked
3067 @cindex @code{keep_interrupts_masked} attribute
3068 Keep interrupts masked for the whole function.  Without this attribute,
3069 GCC tries to reenable interrupts for as much of the function as it can.
3071 @item use_debug_exception_return
3072 @cindex @code{use_debug_exception_return} attribute
3073 Return using the @code{deret} instruction.  Interrupt handlers that don't
3074 have this attribute return using @code{eret} instead.
3075 @end table
3077 You can use any combination of these attributes, as shown below:
3078 @smallexample
3079 void __attribute__ ((interrupt)) v0 ();
3080 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3081 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3082 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3083 void __attribute__ ((interrupt, use_shadow_register_set,
3084                      keep_interrupts_masked)) v4 ();
3085 void __attribute__ ((interrupt, use_shadow_register_set,
3086                      use_debug_exception_return)) v5 ();
3087 void __attribute__ ((interrupt, keep_interrupts_masked,
3088                      use_debug_exception_return)) v6 ();
3089 void __attribute__ ((interrupt, use_shadow_register_set,
3090                      keep_interrupts_masked,
3091                      use_debug_exception_return)) v7 ();
3092 @end smallexample
3094 On NDS32 target, this attribute is to indicate that the specified function
3095 is an interrupt handler.  The compiler will generate corresponding sections
3096 for use in an interrupt handler.  You can use the following attributes
3097 to modify the behavior:
3098 @table @code
3099 @item nested
3100 @cindex @code{nested} attribute
3101 This interrupt service routine is interruptible.
3102 @item not_nested
3103 @cindex @code{not_nested} attribute
3104 This interrupt service routine is not interruptible.
3105 @item nested_ready
3106 @cindex @code{nested_ready} attribute
3107 This interrupt service routine is interruptible after @code{PSW.GIE}
3108 (global interrupt enable) is set.  This allows interrupt service routine to
3109 finish some short critical code before enabling interrupts.
3110 @item save_all
3111 @cindex @code{save_all} attribute
3112 The system will help save all registers into stack before entering
3113 interrupt handler.
3114 @item partial_save
3115 @cindex @code{partial_save} attribute
3116 The system will help save caller registers into stack before entering
3117 interrupt handler.
3118 @end table
3120 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3121 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3122 that must end with @code{RETB} instead of @code{RETI}).
3124 On RX targets, you may specify one or more vector numbers as arguments
3125 to the attribute, as well as naming an alternate table name.
3126 Parameters are handled sequentially, so one handler can be assigned to
3127 multiple entries in multiple tables.  One may also pass the magic
3128 string @code{"$default"} which causes the function to be used for any
3129 unfilled slots in the current table.
3131 This example shows a simple assignment of a function to one vector in
3132 the default table (note that preprocessor macros may be used for
3133 chip-specific symbolic vector names):
3134 @smallexample
3135 void __attribute__ ((interrupt (5))) txd1_handler ();
3136 @end smallexample
3138 This example assigns a function to two slots in the default table
3139 (using preprocessor macros defined elsewhere) and makes it the default
3140 for the @code{dct} table:
3141 @smallexample
3142 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3143         txd1_handler ();
3144 @end smallexample
3146 @item interrupt_handler
3147 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3148 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3149 indicate that the specified function is an interrupt handler.  The compiler
3150 generates function entry and exit sequences suitable for use in an
3151 interrupt handler when this attribute is present.
3153 @item interrupt_thread
3154 @cindex interrupt thread functions on fido
3155 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3156 that the specified function is an interrupt handler that is designed
3157 to run as a thread.  The compiler omits generate prologue/epilogue
3158 sequences and replaces the return instruction with a @code{sleep}
3159 instruction.  This attribute is available only on fido.
3161 @item isr
3162 @cindex interrupt service routines on ARM
3163 Use this attribute on ARM to write Interrupt Service Routines. This is an
3164 alias to the @code{interrupt} attribute above.
3166 @item kspisusp
3167 @cindex User stack pointer in interrupts on the Blackfin
3168 When used together with @code{interrupt_handler}, @code{exception_handler}
3169 or @code{nmi_handler}, code is generated to load the stack pointer
3170 from the USP register in the function prologue.
3172 @item l1_text
3173 @cindex @code{l1_text} function attribute
3174 This attribute specifies a function to be placed into L1 Instruction
3175 SRAM@. The function is put into a specific section named @code{.l1.text}.
3176 With @option{-mfdpic}, function calls with a such function as the callee
3177 or caller uses inlined PLT.
3179 @item l2
3180 @cindex @code{l2} function attribute
3181 On the Blackfin, this attribute specifies a function to be placed into L2
3182 SRAM. The function is put into a specific section named
3183 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3184 an inlined PLT.
3186 @item leaf
3187 @cindex @code{leaf} function attribute
3188 Calls to external functions with this attribute must return to the current
3189 compilation unit only by return or by exception handling.  In particular, leaf
3190 functions are not allowed to call callback function passed to it from the current
3191 compilation unit or directly call functions exported by the unit or longjmp
3192 into the unit.  Leaf function might still call functions from other compilation
3193 units and thus they are not necessarily leaf in the sense that they contain no
3194 function calls at all.
3196 The attribute is intended for library functions to improve dataflow analysis.
3197 The compiler takes the hint that any data not escaping the current compilation unit can
3198 not be used or modified by the leaf function.  For example, the @code{sin} function
3199 is a leaf function, but @code{qsort} is not.
3201 Note that leaf functions might invoke signals and signal handlers might be
3202 defined in the current compilation unit and use static variables.  The only
3203 compliant way to write such a signal handler is to declare such variables
3204 @code{volatile}.
3206 The attribute has no effect on functions defined within the current compilation
3207 unit.  This is to allow easy merging of multiple compilation units into one,
3208 for example, by using the link-time optimization.  For this reason the
3209 attribute is not allowed on types to annotate indirect calls.
3211 @item long_call/medium_call/short_call
3212 @cindex indirect calls on ARC
3213 @cindex indirect calls on ARM
3214 @cindex indirect calls on Epiphany
3215 These attributes specify how a particular function is called on
3216 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3217 These attributes override the
3218 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3219 and @option{-mmedium-calls} (@pxref{ARC Options})
3220 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3221 @code{long_call} attribute indicates that the function might be far
3222 away from the call site and require a different (more expensive)
3223 calling sequence.   The @code{short_call} attribute always places
3224 the offset to the function from the call site into the @samp{BL}
3225 instruction directly.
3227 For ARC, a function marked with the @code{long_call} attribute is
3228 always called using register-indirect jump-and-link instructions,
3229 thereby enabling the called function to be placed anywhere within the
3230 32-bit address space.  A function marked with the @code{medium_call}
3231 attribute will always be close enough to be called with an unconditional
3232 branch-and-link instruction, which has a 25-bit offset from
3233 the call site.  A function marked with the @code{short_call}
3234 attribute will always be close enough to be called with a conditional
3235 branch-and-link instruction, which has a 21-bit offset from
3236 the call site.
3238 @item longcall/shortcall
3239 @cindex functions called via pointer on the RS/6000 and PowerPC
3240 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3241 indicates that the function might be far away from the call site and
3242 require a different (more expensive) calling sequence.  The
3243 @code{shortcall} attribute indicates that the function is always close
3244 enough for the shorter calling sequence to be used.  These attributes
3245 override both the @option{-mlongcall} switch and, on the RS/6000 and
3246 PowerPC, the @code{#pragma longcall} setting.
3248 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3249 calls are necessary.
3251 @item long_call/near/far
3252 @cindex indirect calls on MIPS
3253 These attributes specify how a particular function is called on MIPS@.
3254 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3255 command-line switch.  The @code{long_call} and @code{far} attributes are
3256 synonyms, and cause the compiler to always call
3257 the function by first loading its address into a register, and then using
3258 the contents of that register.  The @code{near} attribute has the opposite
3259 effect; it specifies that non-PIC calls should be made using the more
3260 efficient @code{jal} instruction.
3262 @item malloc
3263 @cindex @code{malloc} attribute
3264 This tells the compiler that a function is @code{malloc}-like, i.e.,
3265 that the pointer @var{P} returned by the function cannot alias any
3266 other pointer valid when the function returns, and moreover no
3267 pointers to valid objects occur in any storage addressed by @var{P}.
3269 Using this attribute can improve optimization.  Functions like
3270 @code{malloc} and @code{calloc} have this property because they return
3271 a pointer to uninitialized or zeroed-out storage.  However, functions
3272 like @code{realloc} do not have this property, as they can return a
3273 pointer to storage containing pointers.
3275 @item mips16/nomips16
3276 @cindex @code{mips16} attribute
3277 @cindex @code{nomips16} attribute
3279 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3280 function attributes to locally select or turn off MIPS16 code generation.
3281 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3282 while MIPS16 code generation is disabled for functions with the
3283 @code{nomips16} attribute.  These attributes override the
3284 @option{-mips16} and @option{-mno-mips16} options on the command line
3285 (@pxref{MIPS Options}).
3287 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3288 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3289 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3290 may interact badly with some GCC extensions such as @code{__builtin_apply}
3291 (@pxref{Constructing Calls}).
3293 @item micromips/nomicromips
3294 @cindex @code{micromips} attribute
3295 @cindex @code{nomicromips} attribute
3297 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3298 function attributes to locally select or turn off microMIPS code generation.
3299 A function with the @code{micromips} attribute is emitted as microMIPS code,
3300 while microMIPS code generation is disabled for functions with the
3301 @code{nomicromips} attribute.  These attributes override the
3302 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3303 (@pxref{MIPS Options}).
3305 When compiling files containing mixed microMIPS and non-microMIPS code, the
3306 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3307 command line,
3308 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3309 may interact badly with some GCC extensions such as @code{__builtin_apply}
3310 (@pxref{Constructing Calls}).
3312 @item model (@var{model-name})
3313 @cindex function addressability on the M32R/D
3314 @cindex variable addressability on the IA-64
3316 On the M32R/D, use this attribute to set the addressability of an
3317 object, and of the code generated for a function.  The identifier
3318 @var{model-name} is one of @code{small}, @code{medium}, or
3319 @code{large}, representing each of the code models.
3321 Small model objects live in the lower 16MB of memory (so that their
3322 addresses can be loaded with the @code{ld24} instruction), and are
3323 callable with the @code{bl} instruction.
3325 Medium model objects may live anywhere in the 32-bit address space (the
3326 compiler generates @code{seth/add3} instructions to load their addresses),
3327 and are callable with the @code{bl} instruction.
3329 Large model objects may live anywhere in the 32-bit address space (the
3330 compiler generates @code{seth/add3} instructions to load their addresses),
3331 and may not be reachable with the @code{bl} instruction (the compiler
3332 generates the much slower @code{seth/add3/jl} instruction sequence).
3334 On IA-64, use this attribute to set the addressability of an object.
3335 At present, the only supported identifier for @var{model-name} is
3336 @code{small}, indicating addressability via ``small'' (22-bit)
3337 addresses (so that their addresses can be loaded with the @code{addl}
3338 instruction).  Caveat: such addressing is by definition not position
3339 independent and hence this attribute must not be used for objects
3340 defined by shared libraries.
3342 @item ms_abi/sysv_abi
3343 @cindex @code{ms_abi} attribute
3344 @cindex @code{sysv_abi} attribute
3346 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3347 to indicate which calling convention should be used for a function.  The
3348 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3349 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3350 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3351 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3353 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3354 requires the @option{-maccumulate-outgoing-args} option.
3356 @item callee_pop_aggregate_return (@var{number})
3357 @cindex @code{callee_pop_aggregate_return} attribute
3359 On 32-bit i?86-*-* targets, you can use this attribute to control how
3360 aggregates are returned in memory.  If the caller is responsible for
3361 popping the hidden pointer together with the rest of the arguments, specify
3362 @var{number} equal to zero.  If callee is responsible for popping the
3363 hidden pointer, specify @var{number} equal to one.  
3365 The default i386 ABI assumes that the callee pops the
3366 stack for hidden pointer.  However, on 32-bit i386 Microsoft Windows targets,
3367 the compiler assumes that the
3368 caller pops the stack for hidden pointer.
3370 @item ms_hook_prologue
3371 @cindex @code{ms_hook_prologue} attribute
3373 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3374 this function attribute to make GCC generate the ``hot-patching'' function
3375 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3376 and newer.
3378 @item hotpatch [(@var{prologue-halfwords})]
3379 @cindex @code{hotpatch} attribute
3381 On S/390 System z targets, you can use this function attribute to
3382 make GCC generate a ``hot-patching'' function prologue.  The
3383 @code{hotpatch} has no effect on funtions that are explicitly
3384 inline.  If the @option{-mhotpatch} or @option{-mno-hotpatch}
3385 command-line option is used at the same time, the @code{hotpatch}
3386 attribute takes precedence.  If an argument is given, the maximum
3387 allowed value is 1000000.
3389 @item naked
3390 @cindex function without a prologue/epilogue code
3391 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3392 RL78, RX and SPU ports.  It allows the compiler to construct the
3393 requisite function declaration, while allowing the body of the
3394 function to be assembly code. The specified function will not have
3395 prologue/epilogue sequences generated by the compiler. Only Basic
3396 @code{asm} statements can safely be included in naked functions
3397 (@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
3398 Basic @code{asm} and ``C'' code may appear to work, they cannot be
3399 depended upon to work reliably and are not supported.
3401 @item near
3402 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3403 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3404 use the normal calling convention based on @code{jsr} and @code{rts}.
3405 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3406 option.
3408 On MeP targets this attribute causes the compiler to assume the called
3409 function is close enough to use the normal calling convention,
3410 overriding the @option{-mtf} command-line option.
3412 @item nesting
3413 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3414 Use this attribute together with @code{interrupt_handler},
3415 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3416 entry code should enable nested interrupts or exceptions.
3418 @item nmi_handler
3419 @cindex NMI handler functions on the Blackfin processor
3420 Use this attribute on the Blackfin to indicate that the specified function
3421 is an NMI handler.  The compiler generates function entry and
3422 exit sequences suitable for use in an NMI handler when this
3423 attribute is present.
3425 @item nocompression
3426 @cindex @code{nocompression} attribute
3427 On MIPS targets, you can use the @code{nocompression} function attribute
3428 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3429 overrides the @option{-mips16} and @option{-mmicromips} options on the
3430 command line (@pxref{MIPS Options}).
3432 @item no_instrument_function
3433 @cindex @code{no_instrument_function} function attribute
3434 @opindex finstrument-functions
3435 If @option{-finstrument-functions} is given, profiling function calls are
3436 generated at entry and exit of most user-compiled functions.
3437 Functions with this attribute are not so instrumented.
3439 @item no_split_stack
3440 @cindex @code{no_split_stack} function attribute
3441 @opindex fsplit-stack
3442 If @option{-fsplit-stack} is given, functions have a small
3443 prologue which decides whether to split the stack.  Functions with the
3444 @code{no_split_stack} attribute do not have that prologue, and thus
3445 may run with only a small amount of stack space available.
3447 @item noinline
3448 @cindex @code{noinline} function attribute
3449 This function attribute prevents a function from being considered for
3450 inlining.
3451 @c Don't enumerate the optimizations by name here; we try to be
3452 @c future-compatible with this mechanism.
3453 If the function does not have side-effects, there are optimizations
3454 other than inlining that cause function calls to be optimized away,
3455 although the function call is live.  To keep such calls from being
3456 optimized away, put
3457 @smallexample
3458 asm ("");
3459 @end smallexample
3461 @noindent
3462 (@pxref{Extended Asm}) in the called function, to serve as a special
3463 side-effect.
3465 @item noclone
3466 @cindex @code{noclone} function attribute
3467 This function attribute prevents a function from being considered for
3468 cloning---a mechanism that produces specialized copies of functions
3469 and which is (currently) performed by interprocedural constant
3470 propagation.
3472 @item nonnull (@var{arg-index}, @dots{})
3473 @cindex @code{nonnull} function attribute
3474 The @code{nonnull} attribute specifies that some function parameters should
3475 be non-null pointers.  For instance, the declaration:
3477 @smallexample
3478 extern void *
3479 my_memcpy (void *dest, const void *src, size_t len)
3480         __attribute__((nonnull (1, 2)));
3481 @end smallexample
3483 @noindent
3484 causes the compiler to check that, in calls to @code{my_memcpy},
3485 arguments @var{dest} and @var{src} are non-null.  If the compiler
3486 determines that a null pointer is passed in an argument slot marked
3487 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3488 is issued.  The compiler may also choose to make optimizations based
3489 on the knowledge that certain function arguments will never be null.
3491 If no argument index list is given to the @code{nonnull} attribute,
3492 all pointer arguments are marked as non-null.  To illustrate, the
3493 following declaration is equivalent to the previous example:
3495 @smallexample
3496 extern void *
3497 my_memcpy (void *dest, const void *src, size_t len)
3498         __attribute__((nonnull));
3499 @end smallexample
3501 @item no_reorder
3502 @cindex @code{no_reorder} function or variable attribute
3503 Do not reorder functions or variables marked @code{no_reorder}
3504 against each other or top level assembler statements the executable.
3505 The actual order in the program will depend on the linker command
3506 line. Static variables marked like this are also not removed.
3507 This has a similar effect
3508 as the @option{-fno-toplevel-reorder} option, but only applies to the
3509 marked symbols.
3511 @item returns_nonnull
3512 @cindex @code{returns_nonnull} function attribute
3513 The @code{returns_nonnull} attribute specifies that the function
3514 return value should be a non-null pointer.  For instance, the declaration:
3516 @smallexample
3517 extern void *
3518 mymalloc (size_t len) __attribute__((returns_nonnull));
3519 @end smallexample
3521 @noindent
3522 lets the compiler optimize callers based on the knowledge
3523 that the return value will never be null.
3525 @item noreturn
3526 @cindex @code{noreturn} function attribute
3527 A few standard library functions, such as @code{abort} and @code{exit},
3528 cannot return.  GCC knows this automatically.  Some programs define
3529 their own functions that never return.  You can declare them
3530 @code{noreturn} to tell the compiler this fact.  For example,
3532 @smallexample
3533 @group
3534 void fatal () __attribute__ ((noreturn));
3536 void
3537 fatal (/* @r{@dots{}} */)
3539   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3540   exit (1);
3542 @end group
3543 @end smallexample
3545 The @code{noreturn} keyword tells the compiler to assume that
3546 @code{fatal} cannot return.  It can then optimize without regard to what
3547 would happen if @code{fatal} ever did return.  This makes slightly
3548 better code.  More importantly, it helps avoid spurious warnings of
3549 uninitialized variables.
3551 The @code{noreturn} keyword does not affect the exceptional path when that
3552 applies: a @code{noreturn}-marked function may still return to the caller
3553 by throwing an exception or calling @code{longjmp}.
3555 Do not assume that registers saved by the calling function are
3556 restored before calling the @code{noreturn} function.
3558 It does not make sense for a @code{noreturn} function to have a return
3559 type other than @code{void}.
3561 The attribute @code{noreturn} is not implemented in GCC versions
3562 earlier than 2.5.  An alternative way to declare that a function does
3563 not return, which works in the current version and in some older
3564 versions, is as follows:
3566 @smallexample
3567 typedef void voidfn ();
3569 volatile voidfn fatal;
3570 @end smallexample
3572 @noindent
3573 This approach does not work in GNU C++.
3575 @item nothrow
3576 @cindex @code{nothrow} function attribute
3577 The @code{nothrow} attribute is used to inform the compiler that a
3578 function cannot throw an exception.  For example, most functions in
3579 the standard C library can be guaranteed not to throw an exception
3580 with the notable exceptions of @code{qsort} and @code{bsearch} that
3581 take function pointer arguments.  The @code{nothrow} attribute is not
3582 implemented in GCC versions earlier than 3.3.
3584 @item nosave_low_regs
3585 @cindex @code{nosave_low_regs} attribute
3586 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3587 function should not save and restore registers R0..R7.  This can be used on SH3*
3588 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3589 interrupt handlers.
3591 @item optimize
3592 @cindex @code{optimize} function attribute
3593 The @code{optimize} attribute is used to specify that a function is to
3594 be compiled with different optimization options than specified on the
3595 command line.  Arguments can either be numbers or strings.  Numbers
3596 are assumed to be an optimization level.  Strings that begin with
3597 @code{O} are assumed to be an optimization option, while other options
3598 are assumed to be used with a @code{-f} prefix.  You can also use the
3599 @samp{#pragma GCC optimize} pragma to set the optimization options
3600 that affect more than one function.
3601 @xref{Function Specific Option Pragmas}, for details about the
3602 @samp{#pragma GCC optimize} pragma.
3604 This can be used for instance to have frequently-executed functions
3605 compiled with more aggressive optimization options that produce faster
3606 and larger code, while other functions can be compiled with less
3607 aggressive options.
3609 @item OS_main/OS_task
3610 @cindex @code{OS_main} AVR function attribute
3611 @cindex @code{OS_task} AVR function attribute
3612 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3613 do not save/restore any call-saved register in their prologue/epilogue.
3615 The @code{OS_main} attribute can be used when there @emph{is
3616 guarantee} that interrupts are disabled at the time when the function
3617 is entered.  This saves resources when the stack pointer has to be
3618 changed to set up a frame for local variables.
3620 The @code{OS_task} attribute can be used when there is @emph{no
3621 guarantee} that interrupts are disabled at that time when the function
3622 is entered like for, e@.g@. task functions in a multi-threading operating
3623 system. In that case, changing the stack pointer register is
3624 guarded by save/clear/restore of the global interrupt enable flag.
3626 The differences to the @code{naked} function attribute are:
3627 @itemize @bullet
3628 @item @code{naked} functions do not have a return instruction whereas 
3629 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3630 @code{RETI} return instruction.
3631 @item @code{naked} functions do not set up a frame for local variables
3632 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3633 as needed.
3634 @end itemize
3636 @item pcs
3637 @cindex @code{pcs} function attribute
3639 The @code{pcs} attribute can be used to control the calling convention
3640 used for a function on ARM.  The attribute takes an argument that specifies
3641 the calling convention to use.
3643 When compiling using the AAPCS ABI (or a variant of it) then valid
3644 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3645 order to use a variant other than @code{"aapcs"} then the compiler must
3646 be permitted to use the appropriate co-processor registers (i.e., the
3647 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3648 For example,
3650 @smallexample
3651 /* Argument passed in r0, and result returned in r0+r1.  */
3652 double f2d (float) __attribute__((pcs("aapcs")));
3653 @end smallexample
3655 Variadic functions always use the @code{"aapcs"} calling convention and
3656 the compiler rejects attempts to specify an alternative.
3658 @item pure
3659 @cindex @code{pure} function attribute
3660 Many functions have no effects except the return value and their
3661 return value depends only on the parameters and/or global variables.
3662 Such a function can be subject
3663 to common subexpression elimination and loop optimization just as an
3664 arithmetic operator would be.  These functions should be declared
3665 with the attribute @code{pure}.  For example,
3667 @smallexample
3668 int square (int) __attribute__ ((pure));
3669 @end smallexample
3671 @noindent
3672 says that the hypothetical function @code{square} is safe to call
3673 fewer times than the program says.
3675 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3676 Interesting non-pure functions are functions with infinite loops or those
3677 depending on volatile memory or other system resource, that may change between
3678 two consecutive calls (such as @code{feof} in a multithreading environment).
3680 The attribute @code{pure} is not implemented in GCC versions earlier
3681 than 2.96.
3683 @item hot
3684 @cindex @code{hot} function attribute
3685 The @code{hot} attribute on a function is used to inform the compiler that
3686 the function is a hot spot of the compiled program.  The function is
3687 optimized more aggressively and on many targets it is placed into a special
3688 subsection of the text section so all hot functions appear close together,
3689 improving locality.
3691 When profile feedback is available, via @option{-fprofile-use}, hot functions
3692 are automatically detected and this attribute is ignored.
3694 The @code{hot} attribute on functions is not implemented in GCC versions
3695 earlier than 4.3.
3697 @item cold
3698 @cindex @code{cold} function attribute
3699 The @code{cold} attribute on functions is used to inform the compiler that
3700 the function is unlikely to be executed.  The function is optimized for
3701 size rather than speed and on many targets it is placed into a special
3702 subsection of the text section so all cold functions appear close together,
3703 improving code locality of non-cold parts of program.  The paths leading
3704 to calls of cold functions within code are marked as unlikely by the branch
3705 prediction mechanism.  It is thus useful to mark functions used to handle
3706 unlikely conditions, such as @code{perror}, as cold to improve optimization
3707 of hot functions that do call marked functions in rare occasions.
3709 When profile feedback is available, via @option{-fprofile-use}, cold functions
3710 are automatically detected and this attribute is ignored.
3712 The @code{cold} attribute on functions is not implemented in GCC versions
3713 earlier than 4.3.
3715 @item no_sanitize_address
3716 @itemx no_address_safety_analysis
3717 @cindex @code{no_sanitize_address} function attribute
3718 The @code{no_sanitize_address} attribute on functions is used
3719 to inform the compiler that it should not instrument memory accesses
3720 in the function when compiling with the @option{-fsanitize=address} option.
3721 The @code{no_address_safety_analysis} is a deprecated alias of the
3722 @code{no_sanitize_address} attribute, new code should use
3723 @code{no_sanitize_address}.
3725 @item no_sanitize_undefined
3726 @cindex @code{no_sanitize_undefined} function attribute
3727 The @code{no_sanitize_undefined} attribute on functions is used
3728 to inform the compiler that it should not check for undefined behavior
3729 in the function when compiling with the @option{-fsanitize=undefined} option.
3731 @item bnd_legacy
3732 @cindex @code{bnd_legacy} function attribute
3733 The @code{bnd_legacy} attribute on functions is used to inform
3734 compiler that function should not be instrumented when compiled
3735 with @option{-fcheck-pointer-bounds} option.
3737 @item bnd_instrument
3738 @cindex @code{bnd_instrument} function attribute
3739 The @code{bnd_instrument} attribute on functions is used to inform
3740 compiler that function should be instrumented when compiled
3741 with @option{-fchkp-instrument-marked-only} option.
3743 @item regparm (@var{number})
3744 @cindex @code{regparm} attribute
3745 @cindex functions that are passed arguments in registers on the 386
3746 On the Intel 386, the @code{regparm} attribute causes the compiler to
3747 pass arguments number one to @var{number} if they are of integral type
3748 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3749 take a variable number of arguments continue to be passed all of their
3750 arguments on the stack.
3752 Beware that on some ELF systems this attribute is unsuitable for
3753 global functions in shared libraries with lazy binding (which is the
3754 default).  Lazy binding sends the first call via resolving code in
3755 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3756 per the standard calling conventions.  Solaris 8 is affected by this.
3757 Systems with the GNU C Library version 2.1 or higher
3758 and FreeBSD are believed to be
3759 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3760 disabled with the linker or the loader if desired, to avoid the
3761 problem.)
3763 @item reset
3764 @cindex reset handler functions
3765 Use this attribute on the NDS32 target to indicate that the specified function
3766 is a reset handler.  The compiler will generate corresponding sections
3767 for use in a reset handler.  You can use the following attributes
3768 to provide extra exception handling:
3769 @table @code
3770 @item nmi
3771 @cindex @code{nmi} attribute
3772 Provide a user-defined function to handle NMI exception.
3773 @item warm
3774 @cindex @code{warm} attribute
3775 Provide a user-defined function to handle warm reset exception.
3776 @end table
3778 @item sseregparm
3779 @cindex @code{sseregparm} attribute
3780 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3781 causes the compiler to pass up to 3 floating-point arguments in
3782 SSE registers instead of on the stack.  Functions that take a
3783 variable number of arguments continue to pass all of their
3784 floating-point arguments on the stack.
3786 @item force_align_arg_pointer
3787 @cindex @code{force_align_arg_pointer} attribute
3788 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3789 applied to individual function definitions, generating an alternate
3790 prologue and epilogue that realigns the run-time stack if necessary.
3791 This supports mixing legacy codes that run with a 4-byte aligned stack
3792 with modern codes that keep a 16-byte stack for SSE compatibility.
3794 @item renesas
3795 @cindex @code{renesas} attribute
3796 On SH targets this attribute specifies that the function or struct follows the
3797 Renesas ABI.
3799 @item resbank
3800 @cindex @code{resbank} attribute
3801 On the SH2A target, this attribute enables the high-speed register
3802 saving and restoration using a register bank for @code{interrupt_handler}
3803 routines.  Saving to the bank is performed automatically after the CPU
3804 accepts an interrupt that uses a register bank.
3806 The nineteen 32-bit registers comprising general register R0 to R14,
3807 control register GBR, and system registers MACH, MACL, and PR and the
3808 vector table address offset are saved into a register bank.  Register
3809 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3810 from the bank is executed by issuing a RESBANK instruction.
3812 @item returns_twice
3813 @cindex @code{returns_twice} attribute
3814 The @code{returns_twice} attribute tells the compiler that a function may
3815 return more than one time.  The compiler ensures that all registers
3816 are dead before calling such a function and emits a warning about
3817 the variables that may be clobbered after the second return from the
3818 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3819 The @code{longjmp}-like counterpart of such function, if any, might need
3820 to be marked with the @code{noreturn} attribute.
3822 @item saveall
3823 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3824 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3825 all registers except the stack pointer should be saved in the prologue
3826 regardless of whether they are used or not.
3828 @item save_volatiles
3829 @cindex save volatile registers on the MicroBlaze
3830 Use this attribute on the MicroBlaze to indicate that the function is
3831 an interrupt handler.  All volatile registers (in addition to non-volatile
3832 registers) are saved in the function prologue.  If the function is a leaf
3833 function, only volatiles used by the function are saved.  A normal function
3834 return is generated instead of a return from interrupt.
3836 @item break_handler
3837 @cindex break handler functions
3838 Use this attribute on the MicroBlaze ports to indicate that
3839 the specified function is an break handler.  The compiler generates function
3840 entry and exit sequences suitable for use in an break handler when this
3841 attribute is present. The return from @code{break_handler} is done through
3842 the @code{rtbd} instead of @code{rtsd}.
3844 @smallexample
3845 void f () __attribute__ ((break_handler));
3846 @end smallexample
3848 @item section ("@var{section-name}")
3849 @cindex @code{section} function attribute
3850 Normally, the compiler places the code it generates in the @code{text} section.
3851 Sometimes, however, you need additional sections, or you need certain
3852 particular functions to appear in special sections.  The @code{section}
3853 attribute specifies that a function lives in a particular section.
3854 For example, the declaration:
3856 @smallexample
3857 extern void foobar (void) __attribute__ ((section ("bar")));
3858 @end smallexample
3860 @noindent
3861 puts the function @code{foobar} in the @code{bar} section.
3863 Some file formats do not support arbitrary sections so the @code{section}
3864 attribute is not available on all platforms.
3865 If you need to map the entire contents of a module to a particular
3866 section, consider using the facilities of the linker instead.
3868 @item sentinel
3869 @cindex @code{sentinel} function attribute
3870 This function attribute ensures that a parameter in a function call is
3871 an explicit @code{NULL}.  The attribute is only valid on variadic
3872 functions.  By default, the sentinel is located at position zero, the
3873 last parameter of the function call.  If an optional integer position
3874 argument P is supplied to the attribute, the sentinel must be located at
3875 position P counting backwards from the end of the argument list.
3877 @smallexample
3878 __attribute__ ((sentinel))
3879 is equivalent to
3880 __attribute__ ((sentinel(0)))
3881 @end smallexample
3883 The attribute is automatically set with a position of 0 for the built-in
3884 functions @code{execl} and @code{execlp}.  The built-in function
3885 @code{execle} has the attribute set with a position of 1.
3887 A valid @code{NULL} in this context is defined as zero with any pointer
3888 type.  If your system defines the @code{NULL} macro with an integer type
3889 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3890 with a copy that redefines NULL appropriately.
3892 The warnings for missing or incorrect sentinels are enabled with
3893 @option{-Wformat}.
3895 @item short_call
3896 See @code{long_call/short_call}.
3898 @item shortcall
3899 See @code{longcall/shortcall}.
3901 @item signal
3902 @cindex interrupt handler functions on the AVR processors
3903 Use this attribute on the AVR to indicate that the specified
3904 function is an interrupt handler.  The compiler generates function
3905 entry and exit sequences suitable for use in an interrupt handler when this
3906 attribute is present.
3908 See also the @code{interrupt} function attribute. 
3910 The AVR hardware globally disables interrupts when an interrupt is executed.
3911 Interrupt handler functions defined with the @code{signal} attribute
3912 do not re-enable interrupts.  It is save to enable interrupts in a
3913 @code{signal} handler.  This ``save'' only applies to the code
3914 generated by the compiler and not to the IRQ layout of the
3915 application which is responsibility of the application.
3917 If both @code{signal} and @code{interrupt} are specified for the same
3918 function, @code{signal} is silently ignored.
3920 @item sp_switch
3921 @cindex @code{sp_switch} attribute
3922 Use this attribute on the SH to indicate an @code{interrupt_handler}
3923 function should switch to an alternate stack.  It expects a string
3924 argument that names a global variable holding the address of the
3925 alternate stack.
3927 @smallexample
3928 void *alt_stack;
3929 void f () __attribute__ ((interrupt_handler,
3930                           sp_switch ("alt_stack")));
3931 @end smallexample
3933 @item stdcall
3934 @cindex functions that pop the argument stack on the 386
3935 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3936 assume that the called function pops off the stack space used to
3937 pass arguments, unless it takes a variable number of arguments.
3939 @item syscall_linkage
3940 @cindex @code{syscall_linkage} attribute
3941 This attribute is used to modify the IA-64 calling convention by marking
3942 all input registers as live at all function exits.  This makes it possible
3943 to restart a system call after an interrupt without having to save/restore
3944 the input registers.  This also prevents kernel data from leaking into
3945 application code.
3947 @item target
3948 @cindex @code{target} function attribute
3949 The @code{target} attribute is used to specify that a function is to
3950 be compiled with different target options than specified on the
3951 command line.  This can be used for instance to have functions
3952 compiled with a different ISA (instruction set architecture) than the
3953 default.  You can also use the @samp{#pragma GCC target} pragma to set
3954 more than one function to be compiled with specific target options.
3955 @xref{Function Specific Option Pragmas}, for details about the
3956 @samp{#pragma GCC target} pragma.
3958 For instance on a 386, you could compile one function with
3959 @code{target("sse4.1,arch=core2")} and another with
3960 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3961 compiling the first function with @option{-msse4.1} and
3962 @option{-march=core2} options, and the second function with
3963 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3964 user to make sure that a function is only invoked on a machine that
3965 supports the particular ISA it is compiled for (for example by using
3966 @code{cpuid} on 386 to determine what feature bits and architecture
3967 family are used).
3969 @smallexample
3970 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3971 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3972 @end smallexample
3974 You can either use multiple
3975 strings to specify multiple options, or separate the options
3976 with a comma (@samp{,}).
3978 The @code{target} attribute is presently implemented for
3979 i386/x86_64, PowerPC, and Nios II targets only.
3980 The options supported are specific to each target.
3982 On the 386, the following options are allowed:
3984 @table @samp
3985 @item abm
3986 @itemx no-abm
3987 @cindex @code{target("abm")} attribute
3988 Enable/disable the generation of the advanced bit instructions.
3990 @item aes
3991 @itemx no-aes
3992 @cindex @code{target("aes")} attribute
3993 Enable/disable the generation of the AES instructions.
3995 @item default
3996 @cindex @code{target("default")} attribute
3997 @xref{Function Multiversioning}, where it is used to specify the
3998 default function version.
4000 @item mmx
4001 @itemx no-mmx
4002 @cindex @code{target("mmx")} attribute
4003 Enable/disable the generation of the MMX instructions.
4005 @item pclmul
4006 @itemx no-pclmul
4007 @cindex @code{target("pclmul")} attribute
4008 Enable/disable the generation of the PCLMUL instructions.
4010 @item popcnt
4011 @itemx no-popcnt
4012 @cindex @code{target("popcnt")} attribute
4013 Enable/disable the generation of the POPCNT instruction.
4015 @item sse
4016 @itemx no-sse
4017 @cindex @code{target("sse")} attribute
4018 Enable/disable the generation of the SSE instructions.
4020 @item sse2
4021 @itemx no-sse2
4022 @cindex @code{target("sse2")} attribute
4023 Enable/disable the generation of the SSE2 instructions.
4025 @item sse3
4026 @itemx no-sse3
4027 @cindex @code{target("sse3")} attribute
4028 Enable/disable the generation of the SSE3 instructions.
4030 @item sse4
4031 @itemx no-sse4
4032 @cindex @code{target("sse4")} attribute
4033 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4034 and SSE4.2).
4036 @item sse4.1
4037 @itemx no-sse4.1
4038 @cindex @code{target("sse4.1")} attribute
4039 Enable/disable the generation of the sse4.1 instructions.
4041 @item sse4.2
4042 @itemx no-sse4.2
4043 @cindex @code{target("sse4.2")} attribute
4044 Enable/disable the generation of the sse4.2 instructions.
4046 @item sse4a
4047 @itemx no-sse4a
4048 @cindex @code{target("sse4a")} attribute
4049 Enable/disable the generation of the SSE4A instructions.
4051 @item fma4
4052 @itemx no-fma4
4053 @cindex @code{target("fma4")} attribute
4054 Enable/disable the generation of the FMA4 instructions.
4056 @item xop
4057 @itemx no-xop
4058 @cindex @code{target("xop")} attribute
4059 Enable/disable the generation of the XOP instructions.
4061 @item lwp
4062 @itemx no-lwp
4063 @cindex @code{target("lwp")} attribute
4064 Enable/disable the generation of the LWP instructions.
4066 @item ssse3
4067 @itemx no-ssse3
4068 @cindex @code{target("ssse3")} attribute
4069 Enable/disable the generation of the SSSE3 instructions.
4071 @item cld
4072 @itemx no-cld
4073 @cindex @code{target("cld")} attribute
4074 Enable/disable the generation of the CLD before string moves.
4076 @item fancy-math-387
4077 @itemx no-fancy-math-387
4078 @cindex @code{target("fancy-math-387")} attribute
4079 Enable/disable the generation of the @code{sin}, @code{cos}, and
4080 @code{sqrt} instructions on the 387 floating-point unit.
4082 @item fused-madd
4083 @itemx no-fused-madd
4084 @cindex @code{target("fused-madd")} attribute
4085 Enable/disable the generation of the fused multiply/add instructions.
4087 @item ieee-fp
4088 @itemx no-ieee-fp
4089 @cindex @code{target("ieee-fp")} attribute
4090 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4092 @item inline-all-stringops
4093 @itemx no-inline-all-stringops
4094 @cindex @code{target("inline-all-stringops")} attribute
4095 Enable/disable inlining of string operations.
4097 @item inline-stringops-dynamically
4098 @itemx no-inline-stringops-dynamically
4099 @cindex @code{target("inline-stringops-dynamically")} attribute
4100 Enable/disable the generation of the inline code to do small string
4101 operations and calling the library routines for large operations.
4103 @item align-stringops
4104 @itemx no-align-stringops
4105 @cindex @code{target("align-stringops")} attribute
4106 Do/do not align destination of inlined string operations.
4108 @item recip
4109 @itemx no-recip
4110 @cindex @code{target("recip")} attribute
4111 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4112 instructions followed an additional Newton-Raphson step instead of
4113 doing a floating-point division.
4115 @item arch=@var{ARCH}
4116 @cindex @code{target("arch=@var{ARCH}")} attribute
4117 Specify the architecture to generate code for in compiling the function.
4119 @item tune=@var{TUNE}
4120 @cindex @code{target("tune=@var{TUNE}")} attribute
4121 Specify the architecture to tune for in compiling the function.
4123 @item fpmath=@var{FPMATH}
4124 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4125 Specify which floating-point unit to use.  The
4126 @code{target("fpmath=sse,387")} option must be specified as
4127 @code{target("fpmath=sse+387")} because the comma would separate
4128 different options.
4129 @end table
4131 On the PowerPC, the following options are allowed:
4133 @table @samp
4134 @item altivec
4135 @itemx no-altivec
4136 @cindex @code{target("altivec")} attribute
4137 Generate code that uses (does not use) AltiVec instructions.  In
4138 32-bit code, you cannot enable AltiVec instructions unless
4139 @option{-mabi=altivec} is used on the command line.
4141 @item cmpb
4142 @itemx no-cmpb
4143 @cindex @code{target("cmpb")} attribute
4144 Generate code that uses (does not use) the compare bytes instruction
4145 implemented on the POWER6 processor and other processors that support
4146 the PowerPC V2.05 architecture.
4148 @item dlmzb
4149 @itemx no-dlmzb
4150 @cindex @code{target("dlmzb")} attribute
4151 Generate code that uses (does not use) the string-search @samp{dlmzb}
4152 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4153 generated by default when targeting those processors.
4155 @item fprnd
4156 @itemx no-fprnd
4157 @cindex @code{target("fprnd")} attribute
4158 Generate code that uses (does not use) the FP round to integer
4159 instructions implemented on the POWER5+ processor and other processors
4160 that support the PowerPC V2.03 architecture.
4162 @item hard-dfp
4163 @itemx no-hard-dfp
4164 @cindex @code{target("hard-dfp")} attribute
4165 Generate code that uses (does not use) the decimal floating-point
4166 instructions implemented on some POWER processors.
4168 @item isel
4169 @itemx no-isel
4170 @cindex @code{target("isel")} attribute
4171 Generate code that uses (does not use) ISEL instruction.
4173 @item mfcrf
4174 @itemx no-mfcrf
4175 @cindex @code{target("mfcrf")} attribute
4176 Generate code that uses (does not use) the move from condition
4177 register field instruction implemented on the POWER4 processor and
4178 other processors that support the PowerPC V2.01 architecture.
4180 @item mfpgpr
4181 @itemx no-mfpgpr
4182 @cindex @code{target("mfpgpr")} attribute
4183 Generate code that uses (does not use) the FP move to/from general
4184 purpose register instructions implemented on the POWER6X processor and
4185 other processors that support the extended PowerPC V2.05 architecture.
4187 @item mulhw
4188 @itemx no-mulhw
4189 @cindex @code{target("mulhw")} attribute
4190 Generate code that uses (does not use) the half-word multiply and
4191 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4192 These instructions are generated by default when targeting those
4193 processors.
4195 @item multiple
4196 @itemx no-multiple
4197 @cindex @code{target("multiple")} attribute
4198 Generate code that uses (does not use) the load multiple word
4199 instructions and the store multiple word instructions.
4201 @item update
4202 @itemx no-update
4203 @cindex @code{target("update")} attribute
4204 Generate code that uses (does not use) the load or store instructions
4205 that update the base register to the address of the calculated memory
4206 location.
4208 @item popcntb
4209 @itemx no-popcntb
4210 @cindex @code{target("popcntb")} attribute
4211 Generate code that uses (does not use) the popcount and double-precision
4212 FP reciprocal estimate instruction implemented on the POWER5
4213 processor and other processors that support the PowerPC V2.02
4214 architecture.
4216 @item popcntd
4217 @itemx no-popcntd
4218 @cindex @code{target("popcntd")} attribute
4219 Generate code that uses (does not use) the popcount instruction
4220 implemented on the POWER7 processor and other processors that support
4221 the PowerPC V2.06 architecture.
4223 @item powerpc-gfxopt
4224 @itemx no-powerpc-gfxopt
4225 @cindex @code{target("powerpc-gfxopt")} attribute
4226 Generate code that uses (does not use) the optional PowerPC
4227 architecture instructions in the Graphics group, including
4228 floating-point select.
4230 @item powerpc-gpopt
4231 @itemx no-powerpc-gpopt
4232 @cindex @code{target("powerpc-gpopt")} attribute
4233 Generate code that uses (does not use) the optional PowerPC
4234 architecture instructions in the General Purpose group, including
4235 floating-point square root.
4237 @item recip-precision
4238 @itemx no-recip-precision
4239 @cindex @code{target("recip-precision")} attribute
4240 Assume (do not assume) that the reciprocal estimate instructions
4241 provide higher-precision estimates than is mandated by the powerpc
4242 ABI.
4244 @item string
4245 @itemx no-string
4246 @cindex @code{target("string")} attribute
4247 Generate code that uses (does not use) the load string instructions
4248 and the store string word instructions to save multiple registers and
4249 do small block moves.
4251 @item vsx
4252 @itemx no-vsx
4253 @cindex @code{target("vsx")} attribute
4254 Generate code that uses (does not use) vector/scalar (VSX)
4255 instructions, and also enable the use of built-in functions that allow
4256 more direct access to the VSX instruction set.  In 32-bit code, you
4257 cannot enable VSX or AltiVec instructions unless
4258 @option{-mabi=altivec} is used on the command line.
4260 @item friz
4261 @itemx no-friz
4262 @cindex @code{target("friz")} attribute
4263 Generate (do not generate) the @code{friz} instruction when the
4264 @option{-funsafe-math-optimizations} option is used to optimize
4265 rounding a floating-point value to 64-bit integer and back to floating
4266 point.  The @code{friz} instruction does not return the same value if
4267 the floating-point number is too large to fit in an integer.
4269 @item avoid-indexed-addresses
4270 @itemx no-avoid-indexed-addresses
4271 @cindex @code{target("avoid-indexed-addresses")} attribute
4272 Generate code that tries to avoid (not avoid) the use of indexed load
4273 or store instructions.
4275 @item paired
4276 @itemx no-paired
4277 @cindex @code{target("paired")} attribute
4278 Generate code that uses (does not use) the generation of PAIRED simd
4279 instructions.
4281 @item longcall
4282 @itemx no-longcall
4283 @cindex @code{target("longcall")} attribute
4284 Generate code that assumes (does not assume) that all calls are far
4285 away so that a longer more expensive calling sequence is required.
4287 @item cpu=@var{CPU}
4288 @cindex @code{target("cpu=@var{CPU}")} attribute
4289 Specify the architecture to generate code for when compiling the
4290 function.  If you select the @code{target("cpu=power7")} attribute when
4291 generating 32-bit code, VSX and AltiVec instructions are not generated
4292 unless you use the @option{-mabi=altivec} option on the command line.
4294 @item tune=@var{TUNE}
4295 @cindex @code{target("tune=@var{TUNE}")} attribute
4296 Specify the architecture to tune for when compiling the function.  If
4297 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4298 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4299 compilation tunes for the @var{CPU} architecture, and not the
4300 default tuning specified on the command line.
4301 @end table
4303 When compiling for Nios II, the following options are allowed:
4305 @table @samp
4306 @item custom-@var{insn}=@var{N}
4307 @itemx no-custom-@var{insn}
4308 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4309 @cindex @code{target("no-custom-@var{insn}")} attribute
4310 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4311 custom instruction with encoding @var{N} when generating code that uses 
4312 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4313 the custom instruction @var{insn}.
4314 These target attributes correspond to the
4315 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4316 command-line options, and support the same set of @var{insn} keywords.
4317 @xref{Nios II Options}, for more information.
4319 @item custom-fpu-cfg=@var{name}
4320 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4321 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4322 command-line option, to select a predefined set of custom instructions
4323 named @var{name}.
4324 @xref{Nios II Options}, for more information.
4325 @end table
4327 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4328 function that has different target options than the caller, unless the
4329 callee has a subset of the target options of the caller.  For example
4330 a function declared with @code{target("sse3")} can inline a function
4331 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4333 @item tiny_data
4334 @cindex tiny data section on the H8/300H and H8S
4335 Use this attribute on the H8/300H and H8S to indicate that the specified
4336 variable should be placed into the tiny data section.
4337 The compiler generates more efficient code for loads and stores
4338 on data in the tiny data section.  Note the tiny data area is limited to
4339 slightly under 32KB of data.
4341 @item trap_exit
4342 @cindex @code{trap_exit} attribute
4343 Use this attribute on the SH for an @code{interrupt_handler} to return using
4344 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4345 argument specifying the trap number to be used.
4347 @item trapa_handler
4348 @cindex @code{trapa_handler} attribute
4349 On SH targets this function attribute is similar to @code{interrupt_handler}
4350 but it does not save and restore all registers.
4352 @item unused
4353 @cindex @code{unused} attribute.
4354 This attribute, attached to a function, means that the function is meant
4355 to be possibly unused.  GCC does not produce a warning for this
4356 function.
4358 @item used
4359 @cindex @code{used} attribute.
4360 This attribute, attached to a function, means that code must be emitted
4361 for the function even if it appears that the function is not referenced.
4362 This is useful, for example, when the function is referenced only in
4363 inline assembly.
4365 When applied to a member function of a C++ class template, the
4366 attribute also means that the function is instantiated if the
4367 class itself is instantiated.
4369 @item vector
4370 @cindex @code{vector} attribute
4371 This RX attribute is similar to the @code{interrupt} attribute, including its
4372 parameters, but does not make the function an interrupt-handler type
4373 function (i.e. it retains the normal C function calling ABI).  See the
4374 @code{interrupt} attribute for a description of its arguments.
4376 @item version_id
4377 @cindex @code{version_id} attribute
4378 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4379 symbol to contain a version string, thus allowing for function level
4380 versioning.  HP-UX system header files may use function level versioning
4381 for some system calls.
4383 @smallexample
4384 extern int foo () __attribute__((version_id ("20040821")));
4385 @end smallexample
4387 @noindent
4388 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4390 @item visibility ("@var{visibility_type}")
4391 @cindex @code{visibility} attribute
4392 This attribute affects the linkage of the declaration to which it is attached.
4393 There are four supported @var{visibility_type} values: default,
4394 hidden, protected or internal visibility.
4396 @smallexample
4397 void __attribute__ ((visibility ("protected")))
4398 f () @{ /* @r{Do something.} */; @}
4399 int i __attribute__ ((visibility ("hidden")));
4400 @end smallexample
4402 The possible values of @var{visibility_type} correspond to the
4403 visibility settings in the ELF gABI.
4405 @table @dfn
4406 @c keep this list of visibilities in alphabetical order.
4408 @item default
4409 Default visibility is the normal case for the object file format.
4410 This value is available for the visibility attribute to override other
4411 options that may change the assumed visibility of entities.
4413 On ELF, default visibility means that the declaration is visible to other
4414 modules and, in shared libraries, means that the declared entity may be
4415 overridden.
4417 On Darwin, default visibility means that the declaration is visible to
4418 other modules.
4420 Default visibility corresponds to ``external linkage'' in the language.
4422 @item hidden
4423 Hidden visibility indicates that the entity declared has a new
4424 form of linkage, which we call ``hidden linkage''.  Two
4425 declarations of an object with hidden linkage refer to the same object
4426 if they are in the same shared object.
4428 @item internal
4429 Internal visibility is like hidden visibility, but with additional
4430 processor specific semantics.  Unless otherwise specified by the
4431 psABI, GCC defines internal visibility to mean that a function is
4432 @emph{never} called from another module.  Compare this with hidden
4433 functions which, while they cannot be referenced directly by other
4434 modules, can be referenced indirectly via function pointers.  By
4435 indicating that a function cannot be called from outside the module,
4436 GCC may for instance omit the load of a PIC register since it is known
4437 that the calling function loaded the correct value.
4439 @item protected
4440 Protected visibility is like default visibility except that it
4441 indicates that references within the defining module bind to the
4442 definition in that module.  That is, the declared entity cannot be
4443 overridden by another module.
4445 @end table
4447 All visibilities are supported on many, but not all, ELF targets
4448 (supported when the assembler supports the @samp{.visibility}
4449 pseudo-op).  Default visibility is supported everywhere.  Hidden
4450 visibility is supported on Darwin targets.
4452 The visibility attribute should be applied only to declarations that
4453 would otherwise have external linkage.  The attribute should be applied
4454 consistently, so that the same entity should not be declared with
4455 different settings of the attribute.
4457 In C++, the visibility attribute applies to types as well as functions
4458 and objects, because in C++ types have linkage.  A class must not have
4459 greater visibility than its non-static data member types and bases,
4460 and class members default to the visibility of their class.  Also, a
4461 declaration without explicit visibility is limited to the visibility
4462 of its type.
4464 In C++, you can mark member functions and static member variables of a
4465 class with the visibility attribute.  This is useful if you know a
4466 particular method or static member variable should only be used from
4467 one shared object; then you can mark it hidden while the rest of the
4468 class has default visibility.  Care must be taken to avoid breaking
4469 the One Definition Rule; for example, it is usually not useful to mark
4470 an inline method as hidden without marking the whole class as hidden.
4472 A C++ namespace declaration can also have the visibility attribute.
4474 @smallexample
4475 namespace nspace1 __attribute__ ((visibility ("protected")))
4476 @{ /* @r{Do something.} */; @}
4477 @end smallexample
4479 This attribute applies only to the particular namespace body, not to
4480 other definitions of the same namespace; it is equivalent to using
4481 @samp{#pragma GCC visibility} before and after the namespace
4482 definition (@pxref{Visibility Pragmas}).
4484 In C++, if a template argument has limited visibility, this
4485 restriction is implicitly propagated to the template instantiation.
4486 Otherwise, template instantiations and specializations default to the
4487 visibility of their template.
4489 If both the template and enclosing class have explicit visibility, the
4490 visibility from the template is used.
4492 @item vliw
4493 @cindex @code{vliw} attribute
4494 On MeP, the @code{vliw} attribute tells the compiler to emit
4495 instructions in VLIW mode instead of core mode.  Note that this
4496 attribute is not allowed unless a VLIW coprocessor has been configured
4497 and enabled through command-line options.
4499 @item warn_unused_result
4500 @cindex @code{warn_unused_result} attribute
4501 The @code{warn_unused_result} attribute causes a warning to be emitted
4502 if a caller of the function with this attribute does not use its
4503 return value.  This is useful for functions where not checking
4504 the result is either a security problem or always a bug, such as
4505 @code{realloc}.
4507 @smallexample
4508 int fn () __attribute__ ((warn_unused_result));
4509 int foo ()
4511   if (fn () < 0) return -1;
4512   fn ();
4513   return 0;
4515 @end smallexample
4517 @noindent
4518 results in warning on line 5.
4520 @item weak
4521 @cindex @code{weak} attribute
4522 The @code{weak} attribute causes the declaration to be emitted as a weak
4523 symbol rather than a global.  This is primarily useful in defining
4524 library functions that can be overridden in user code, though it can
4525 also be used with non-function declarations.  Weak symbols are supported
4526 for ELF targets, and also for a.out targets when using the GNU assembler
4527 and linker.
4529 @item weakref
4530 @itemx weakref ("@var{target}")
4531 @cindex @code{weakref} attribute
4532 The @code{weakref} attribute marks a declaration as a weak reference.
4533 Without arguments, it should be accompanied by an @code{alias} attribute
4534 naming the target symbol.  Optionally, the @var{target} may be given as
4535 an argument to @code{weakref} itself.  In either case, @code{weakref}
4536 implicitly marks the declaration as @code{weak}.  Without a
4537 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4538 @code{weakref} is equivalent to @code{weak}.
4540 @smallexample
4541 static int x() __attribute__ ((weakref ("y")));
4542 /* is equivalent to... */
4543 static int x() __attribute__ ((weak, weakref, alias ("y")));
4544 /* and to... */
4545 static int x() __attribute__ ((weakref));
4546 static int x() __attribute__ ((alias ("y")));
4547 @end smallexample
4549 A weak reference is an alias that does not by itself require a
4550 definition to be given for the target symbol.  If the target symbol is
4551 only referenced through weak references, then it becomes a @code{weak}
4552 undefined symbol.  If it is directly referenced, however, then such
4553 strong references prevail, and a definition is required for the
4554 symbol, not necessarily in the same translation unit.
4556 The effect is equivalent to moving all references to the alias to a
4557 separate translation unit, renaming the alias to the aliased symbol,
4558 declaring it as weak, compiling the two separate translation units and
4559 performing a reloadable link on them.
4561 At present, a declaration to which @code{weakref} is attached can
4562 only be @code{static}.
4564 @end table
4566 You can specify multiple attributes in a declaration by separating them
4567 by commas within the double parentheses or by immediately following an
4568 attribute declaration with another attribute declaration.
4570 @cindex @code{#pragma}, reason for not using
4571 @cindex pragma, reason for not using
4572 Some people object to the @code{__attribute__} feature, suggesting that
4573 ISO C's @code{#pragma} should be used instead.  At the time
4574 @code{__attribute__} was designed, there were two reasons for not doing
4575 this.
4577 @enumerate
4578 @item
4579 It is impossible to generate @code{#pragma} commands from a macro.
4581 @item
4582 There is no telling what the same @code{#pragma} might mean in another
4583 compiler.
4584 @end enumerate
4586 These two reasons applied to almost any application that might have been
4587 proposed for @code{#pragma}.  It was basically a mistake to use
4588 @code{#pragma} for @emph{anything}.
4590 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4591 to be generated from macros.  In addition, a @code{#pragma GCC}
4592 namespace is now in use for GCC-specific pragmas.  However, it has been
4593 found convenient to use @code{__attribute__} to achieve a natural
4594 attachment of attributes to their corresponding declarations, whereas
4595 @code{#pragma GCC} is of use for constructs that do not naturally form
4596 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4598 @node Label Attributes
4599 @section Label Attributes
4600 @cindex Label Attributes
4602 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
4603 details of the exact syntax for using attributes.  Other attributes are 
4604 available for functions (@pxref{Function Attributes}), variables 
4605 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4607 This example uses the @code{cold} label attribute to indicate the 
4608 @code{ErrorHandling} branch is unlikely to be taken and that the
4609 @code{ErrorHandling} label is unused:
4611 @smallexample
4613    asm goto ("some asm" : : : : NoError);
4615 /* This branch (the fallthru from the asm) is less commonly used */
4616 ErrorHandling: 
4617    __attribute__((cold, unused)); /* Semi-colon is required here */
4618    printf("error\n");
4619    return 0;
4621 NoError:
4622    printf("no error\n");
4623    return 1;
4624 @end smallexample
4626 @table @code
4627 @item unused
4628 @cindex @code{unused} label attribute
4629 This feature is intended for program-generated code that may contain 
4630 unused labels, but which is compiled with @option{-Wall}.  It is
4631 not normally appropriate to use in it human-written code, though it
4632 could be useful in cases where the code that jumps to the label is
4633 contained within an @code{#ifdef} conditional.
4635 @item hot
4636 @cindex @code{hot} label attribute
4637 The @code{hot} attribute on a label is used to inform the compiler that
4638 the path following the label is more likely than paths that are not so
4639 annotated.  This attribute is used in cases where @code{__builtin_expect}
4640 cannot be used, for instance with computed goto or @code{asm goto}.
4642 The @code{hot} attribute on labels is not implemented in GCC versions
4643 earlier than 4.8.
4645 @item cold
4646 @cindex @code{cold} label attribute
4647 The @code{cold} attribute on labels is used to inform the compiler that
4648 the path following the label is unlikely to be executed.  This attribute
4649 is used in cases where @code{__builtin_expect} cannot be used, for instance
4650 with computed goto or @code{asm goto}.
4652 The @code{cold} attribute on labels is not implemented in GCC versions
4653 earlier than 4.8.
4655 @end table
4657 @node Attribute Syntax
4658 @section Attribute Syntax
4659 @cindex attribute syntax
4661 This section describes the syntax with which @code{__attribute__} may be
4662 used, and the constructs to which attribute specifiers bind, for the C
4663 language.  Some details may vary for C++ and Objective-C@.  Because of
4664 infelicities in the grammar for attributes, some forms described here
4665 may not be successfully parsed in all cases.
4667 There are some problems with the semantics of attributes in C++.  For
4668 example, there are no manglings for attributes, although they may affect
4669 code generation, so problems may arise when attributed types are used in
4670 conjunction with templates or overloading.  Similarly, @code{typeid}
4671 does not distinguish between types with different attributes.  Support
4672 for attributes in C++ may be restricted in future to attributes on
4673 declarations only, but not on nested declarators.
4675 @xref{Function Attributes}, for details of the semantics of attributes
4676 applying to functions.  @xref{Variable Attributes}, for details of the
4677 semantics of attributes applying to variables.  @xref{Type Attributes},
4678 for details of the semantics of attributes applying to structure, union
4679 and enumerated types.
4680 @xref{Label Attributes}, for details of the semantics of attributes 
4681 applying to labels.
4683 An @dfn{attribute specifier} is of the form
4684 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4685 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4686 each attribute is one of the following:
4688 @itemize @bullet
4689 @item
4690 Empty.  Empty attributes are ignored.
4692 @item
4693 A word (which may be an identifier such as @code{unused}, or a reserved
4694 word such as @code{const}).
4696 @item
4697 A word, followed by, in parentheses, parameters for the attribute.
4698 These parameters take one of the following forms:
4700 @itemize @bullet
4701 @item
4702 An identifier.  For example, @code{mode} attributes use this form.
4704 @item
4705 An identifier followed by a comma and a non-empty comma-separated list
4706 of expressions.  For example, @code{format} attributes use this form.
4708 @item
4709 A possibly empty comma-separated list of expressions.  For example,
4710 @code{format_arg} attributes use this form with the list being a single
4711 integer constant expression, and @code{alias} attributes use this form
4712 with the list being a single string constant.
4713 @end itemize
4714 @end itemize
4716 An @dfn{attribute specifier list} is a sequence of one or more attribute
4717 specifiers, not separated by any other tokens.
4719 @subsubheading Label Attributes
4721 In GNU C, an attribute specifier list may appear after the colon following a
4722 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
4723 attributes on labels if the attribute specifier is immediately
4724 followed by a semicolon (i.e., the label applies to an empty
4725 statement).  If the semicolon is missing, C++ label attributes are
4726 ambiguous, as it is permissible for a declaration, which could begin
4727 with an attribute list, to be labelled in C++.  Declarations cannot be
4728 labelled in C90 or C99, so the ambiguity does not arise there.
4730 @subsubheading Type Attributes
4732 An attribute specifier list may appear as part of a @code{struct},
4733 @code{union} or @code{enum} specifier.  It may go either immediately
4734 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4735 the closing brace.  The former syntax is preferred.
4736 Where attribute specifiers follow the closing brace, they are considered
4737 to relate to the structure, union or enumerated type defined, not to any
4738 enclosing declaration the type specifier appears in, and the type
4739 defined is not complete until after the attribute specifiers.
4740 @c Otherwise, there would be the following problems: a shift/reduce
4741 @c conflict between attributes binding the struct/union/enum and
4742 @c binding to the list of specifiers/qualifiers; and "aligned"
4743 @c attributes could use sizeof for the structure, but the size could be
4744 @c changed later by "packed" attributes.
4747 @subsubheading All other attributes
4749 Otherwise, an attribute specifier appears as part of a declaration,
4750 counting declarations of unnamed parameters and type names, and relates
4751 to that declaration (which may be nested in another declaration, for
4752 example in the case of a parameter declaration), or to a particular declarator
4753 within a declaration.  Where an
4754 attribute specifier is applied to a parameter declared as a function or
4755 an array, it should apply to the function or array rather than the
4756 pointer to which the parameter is implicitly converted, but this is not
4757 yet correctly implemented.
4759 Any list of specifiers and qualifiers at the start of a declaration may
4760 contain attribute specifiers, whether or not such a list may in that
4761 context contain storage class specifiers.  (Some attributes, however,
4762 are essentially in the nature of storage class specifiers, and only make
4763 sense where storage class specifiers may be used; for example,
4764 @code{section}.)  There is one necessary limitation to this syntax: the
4765 first old-style parameter declaration in a function definition cannot
4766 begin with an attribute specifier, because such an attribute applies to
4767 the function instead by syntax described below (which, however, is not
4768 yet implemented in this case).  In some other cases, attribute
4769 specifiers are permitted by this grammar but not yet supported by the
4770 compiler.  All attribute specifiers in this place relate to the
4771 declaration as a whole.  In the obsolescent usage where a type of
4772 @code{int} is implied by the absence of type specifiers, such a list of
4773 specifiers and qualifiers may be an attribute specifier list with no
4774 other specifiers or qualifiers.
4776 At present, the first parameter in a function prototype must have some
4777 type specifier that is not an attribute specifier; this resolves an
4778 ambiguity in the interpretation of @code{void f(int
4779 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4780 the parentheses of a function declarator contain only attributes then
4781 those attributes are ignored, rather than yielding an error or warning
4782 or implying a single parameter of type int, but this is subject to
4783 change.
4785 An attribute specifier list may appear immediately before a declarator
4786 (other than the first) in a comma-separated list of declarators in a
4787 declaration of more than one identifier using a single list of
4788 specifiers and qualifiers.  Such attribute specifiers apply
4789 only to the identifier before whose declarator they appear.  For
4790 example, in
4792 @smallexample
4793 __attribute__((noreturn)) void d0 (void),
4794     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4795      d2 (void)
4796 @end smallexample
4798 @noindent
4799 the @code{noreturn} attribute applies to all the functions
4800 declared; the @code{format} attribute only applies to @code{d1}.
4802 An attribute specifier list may appear immediately before the comma,
4803 @code{=} or semicolon terminating the declaration of an identifier other
4804 than a function definition.  Such attribute specifiers apply
4805 to the declared object or function.  Where an
4806 assembler name for an object or function is specified (@pxref{Asm
4807 Labels}), the attribute must follow the @code{asm}
4808 specification.
4810 An attribute specifier list may, in future, be permitted to appear after
4811 the declarator in a function definition (before any old-style parameter
4812 declarations or the function body).
4814 Attribute specifiers may be mixed with type qualifiers appearing inside
4815 the @code{[]} of a parameter array declarator, in the C99 construct by
4816 which such qualifiers are applied to the pointer to which the array is
4817 implicitly converted.  Such attribute specifiers apply to the pointer,
4818 not to the array, but at present this is not implemented and they are
4819 ignored.
4821 An attribute specifier list may appear at the start of a nested
4822 declarator.  At present, there are some limitations in this usage: the
4823 attributes correctly apply to the declarator, but for most individual
4824 attributes the semantics this implies are not implemented.
4825 When attribute specifiers follow the @code{*} of a pointer
4826 declarator, they may be mixed with any type qualifiers present.
4827 The following describes the formal semantics of this syntax.  It makes the
4828 most sense if you are familiar with the formal specification of
4829 declarators in the ISO C standard.
4831 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4832 D1}, where @code{T} contains declaration specifiers that specify a type
4833 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4834 contains an identifier @var{ident}.  The type specified for @var{ident}
4835 for derived declarators whose type does not include an attribute
4836 specifier is as in the ISO C standard.
4838 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4839 and the declaration @code{T D} specifies the type
4840 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4841 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4842 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4844 If @code{D1} has the form @code{*
4845 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4846 declaration @code{T D} specifies the type
4847 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4848 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4849 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4850 @var{ident}.
4852 For example,
4854 @smallexample
4855 void (__attribute__((noreturn)) ****f) (void);
4856 @end smallexample
4858 @noindent
4859 specifies the type ``pointer to pointer to pointer to pointer to
4860 non-returning function returning @code{void}''.  As another example,
4862 @smallexample
4863 char *__attribute__((aligned(8))) *f;
4864 @end smallexample
4866 @noindent
4867 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4868 Note again that this does not work with most attributes; for example,
4869 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4870 is not yet supported.
4872 For compatibility with existing code written for compiler versions that
4873 did not implement attributes on nested declarators, some laxity is
4874 allowed in the placing of attributes.  If an attribute that only applies
4875 to types is applied to a declaration, it is treated as applying to
4876 the type of that declaration.  If an attribute that only applies to
4877 declarations is applied to the type of a declaration, it is treated
4878 as applying to that declaration; and, for compatibility with code
4879 placing the attributes immediately before the identifier declared, such
4880 an attribute applied to a function return type is treated as
4881 applying to the function type, and such an attribute applied to an array
4882 element type is treated as applying to the array type.  If an
4883 attribute that only applies to function types is applied to a
4884 pointer-to-function type, it is treated as applying to the pointer
4885 target type; if such an attribute is applied to a function return type
4886 that is not a pointer-to-function type, it is treated as applying
4887 to the function type.
4889 @node Function Prototypes
4890 @section Prototypes and Old-Style Function Definitions
4891 @cindex function prototype declarations
4892 @cindex old-style function definitions
4893 @cindex promotion of formal parameters
4895 GNU C extends ISO C to allow a function prototype to override a later
4896 old-style non-prototype definition.  Consider the following example:
4898 @smallexample
4899 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4900 #ifdef __STDC__
4901 #define P(x) x
4902 #else
4903 #define P(x) ()
4904 #endif
4906 /* @r{Prototype function declaration.}  */
4907 int isroot P((uid_t));
4909 /* @r{Old-style function definition.}  */
4911 isroot (x)   /* @r{??? lossage here ???} */
4912      uid_t x;
4914   return x == 0;
4916 @end smallexample
4918 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4919 not allow this example, because subword arguments in old-style
4920 non-prototype definitions are promoted.  Therefore in this example the
4921 function definition's argument is really an @code{int}, which does not
4922 match the prototype argument type of @code{short}.
4924 This restriction of ISO C makes it hard to write code that is portable
4925 to traditional C compilers, because the programmer does not know
4926 whether the @code{uid_t} type is @code{short}, @code{int}, or
4927 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4928 to override a later old-style definition.  More precisely, in GNU C, a
4929 function prototype argument type overrides the argument type specified
4930 by a later old-style definition if the former type is the same as the
4931 latter type before promotion.  Thus in GNU C the above example is
4932 equivalent to the following:
4934 @smallexample
4935 int isroot (uid_t);
4938 isroot (uid_t x)
4940   return x == 0;
4942 @end smallexample
4944 @noindent
4945 GNU C++ does not support old-style function definitions, so this
4946 extension is irrelevant.
4948 @node C++ Comments
4949 @section C++ Style Comments
4950 @cindex @code{//}
4951 @cindex C++ comments
4952 @cindex comments, C++ style
4954 In GNU C, you may use C++ style comments, which start with @samp{//} and
4955 continue until the end of the line.  Many other C implementations allow
4956 such comments, and they are included in the 1999 C standard.  However,
4957 C++ style comments are not recognized if you specify an @option{-std}
4958 option specifying a version of ISO C before C99, or @option{-ansi}
4959 (equivalent to @option{-std=c90}).
4961 @node Dollar Signs
4962 @section Dollar Signs in Identifier Names
4963 @cindex $
4964 @cindex dollar signs in identifier names
4965 @cindex identifier names, dollar signs in
4967 In GNU C, you may normally use dollar signs in identifier names.
4968 This is because many traditional C implementations allow such identifiers.
4969 However, dollar signs in identifiers are not supported on a few target
4970 machines, typically because the target assembler does not allow them.
4972 @node Character Escapes
4973 @section The Character @key{ESC} in Constants
4975 You can use the sequence @samp{\e} in a string or character constant to
4976 stand for the ASCII character @key{ESC}.
4978 @node Variable Attributes
4979 @section Specifying Attributes of Variables
4980 @cindex attribute of variables
4981 @cindex variable attributes
4983 The keyword @code{__attribute__} allows you to specify special
4984 attributes of variables or structure fields.  This keyword is followed
4985 by an attribute specification inside double parentheses.  Some
4986 attributes are currently defined generically for variables.
4987 Other attributes are defined for variables on particular target
4988 systems.  Other attributes are available for functions
4989 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
4990 types (@pxref{Type Attributes}).
4991 Other front ends might define more attributes
4992 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4994 You may also specify attributes with @samp{__} preceding and following
4995 each keyword.  This allows you to use them in header files without
4996 being concerned about a possible macro of the same name.  For example,
4997 you may use @code{__aligned__} instead of @code{aligned}.
4999 @xref{Attribute Syntax}, for details of the exact syntax for using
5000 attributes.
5002 @table @code
5003 @cindex @code{aligned} attribute
5004 @item aligned (@var{alignment})
5005 This attribute specifies a minimum alignment for the variable or
5006 structure field, measured in bytes.  For example, the declaration:
5008 @smallexample
5009 int x __attribute__ ((aligned (16))) = 0;
5010 @end smallexample
5012 @noindent
5013 causes the compiler to allocate the global variable @code{x} on a
5014 16-byte boundary.  On a 68040, this could be used in conjunction with
5015 an @code{asm} expression to access the @code{move16} instruction which
5016 requires 16-byte aligned operands.
5018 You can also specify the alignment of structure fields.  For example, to
5019 create a double-word aligned @code{int} pair, you could write:
5021 @smallexample
5022 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5023 @end smallexample
5025 @noindent
5026 This is an alternative to creating a union with a @code{double} member,
5027 which forces the union to be double-word aligned.
5029 As in the preceding examples, you can explicitly specify the alignment
5030 (in bytes) that you wish the compiler to use for a given variable or
5031 structure field.  Alternatively, you can leave out the alignment factor
5032 and just ask the compiler to align a variable or field to the
5033 default alignment for the target architecture you are compiling for.
5034 The default alignment is sufficient for all scalar types, but may not be
5035 enough for all vector types on a target that supports vector operations.
5036 The default alignment is fixed for a particular target ABI.
5038 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5039 which is the largest alignment ever used for any data type on the
5040 target machine you are compiling for.  For example, you could write:
5042 @smallexample
5043 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5044 @end smallexample
5046 The compiler automatically sets the alignment for the declared
5047 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5048 often make copy operations more efficient, because the compiler can
5049 use whatever instructions copy the biggest chunks of memory when
5050 performing copies to or from the variables or fields that you have
5051 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5052 may change depending on command-line options.
5054 When used on a struct, or struct member, the @code{aligned} attribute can
5055 only increase the alignment; in order to decrease it, the @code{packed}
5056 attribute must be specified as well.  When used as part of a typedef, the
5057 @code{aligned} attribute can both increase and decrease alignment, and
5058 specifying the @code{packed} attribute generates a warning.
5060 Note that the effectiveness of @code{aligned} attributes may be limited
5061 by inherent limitations in your linker.  On many systems, the linker is
5062 only able to arrange for variables to be aligned up to a certain maximum
5063 alignment.  (For some linkers, the maximum supported alignment may
5064 be very very small.)  If your linker is only able to align variables
5065 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5066 in an @code{__attribute__} still only provides you with 8-byte
5067 alignment.  See your linker documentation for further information.
5069 The @code{aligned} attribute can also be used for functions
5070 (@pxref{Function Attributes}.)
5072 @item cleanup (@var{cleanup_function})
5073 @cindex @code{cleanup} attribute
5074 The @code{cleanup} attribute runs a function when the variable goes
5075 out of scope.  This attribute can only be applied to auto function
5076 scope variables; it may not be applied to parameters or variables
5077 with static storage duration.  The function must take one parameter,
5078 a pointer to a type compatible with the variable.  The return value
5079 of the function (if any) is ignored.
5081 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5082 is run during the stack unwinding that happens during the
5083 processing of the exception.  Note that the @code{cleanup} attribute
5084 does not allow the exception to be caught, only to perform an action.
5085 It is undefined what happens if @var{cleanup_function} does not
5086 return normally.
5088 @item common
5089 @itemx nocommon
5090 @cindex @code{common} attribute
5091 @cindex @code{nocommon} attribute
5092 @opindex fcommon
5093 @opindex fno-common
5094 The @code{common} attribute requests GCC to place a variable in
5095 ``common'' storage.  The @code{nocommon} attribute requests the
5096 opposite---to allocate space for it directly.
5098 These attributes override the default chosen by the
5099 @option{-fno-common} and @option{-fcommon} flags respectively.
5101 @item deprecated
5102 @itemx deprecated (@var{msg})
5103 @cindex @code{deprecated} attribute
5104 The @code{deprecated} attribute results in a warning if the variable
5105 is used anywhere in the source file.  This is useful when identifying
5106 variables that are expected to be removed in a future version of a
5107 program.  The warning also includes the location of the declaration
5108 of the deprecated variable, to enable users to easily find further
5109 information about why the variable is deprecated, or what they should
5110 do instead.  Note that the warning only occurs for uses:
5112 @smallexample
5113 extern int old_var __attribute__ ((deprecated));
5114 extern int old_var;
5115 int new_fn () @{ return old_var; @}
5116 @end smallexample
5118 @noindent
5119 results in a warning on line 3 but not line 2.  The optional @var{msg}
5120 argument, which must be a string, is printed in the warning if
5121 present.
5123 The @code{deprecated} attribute can also be used for functions and
5124 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5126 @item mode (@var{mode})
5127 @cindex @code{mode} attribute
5128 This attribute specifies the data type for the declaration---whichever
5129 type corresponds to the mode @var{mode}.  This in effect lets you
5130 request an integer or floating-point type according to its width.
5132 You may also specify a mode of @code{byte} or @code{__byte__} to
5133 indicate the mode corresponding to a one-byte integer, @code{word} or
5134 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5135 or @code{__pointer__} for the mode used to represent pointers.
5137 @item packed
5138 @cindex @code{packed} attribute
5139 The @code{packed} attribute specifies that a variable or structure field
5140 should have the smallest possible alignment---one byte for a variable,
5141 and one bit for a field, unless you specify a larger value with the
5142 @code{aligned} attribute.
5144 Here is a structure in which the field @code{x} is packed, so that it
5145 immediately follows @code{a}:
5147 @smallexample
5148 struct foo
5150   char a;
5151   int x[2] __attribute__ ((packed));
5153 @end smallexample
5155 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5156 @code{packed} attribute on bit-fields of type @code{char}.  This has
5157 been fixed in GCC 4.4 but the change can lead to differences in the
5158 structure layout.  See the documentation of
5159 @option{-Wpacked-bitfield-compat} for more information.
5161 @item section ("@var{section-name}")
5162 @cindex @code{section} variable attribute
5163 Normally, the compiler places the objects it generates in sections like
5164 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5165 or you need certain particular variables to appear in special sections,
5166 for example to map to special hardware.  The @code{section}
5167 attribute specifies that a variable (or function) lives in a particular
5168 section.  For example, this small program uses several specific section names:
5170 @smallexample
5171 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5172 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5173 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5174 int init_data __attribute__ ((section ("INITDATA")));
5176 main()
5178   /* @r{Initialize stack pointer} */
5179   init_sp (stack + sizeof (stack));
5181   /* @r{Initialize initialized data} */
5182   memcpy (&init_data, &data, &edata - &data);
5184   /* @r{Turn on the serial ports} */
5185   init_duart (&a);
5186   init_duart (&b);
5188 @end smallexample
5190 @noindent
5191 Use the @code{section} attribute with
5192 @emph{global} variables and not @emph{local} variables,
5193 as shown in the example.
5195 You may use the @code{section} attribute with initialized or
5196 uninitialized global variables but the linker requires
5197 each object be defined once, with the exception that uninitialized
5198 variables tentatively go in the @code{common} (or @code{bss}) section
5199 and can be multiply ``defined''.  Using the @code{section} attribute
5200 changes what section the variable goes into and may cause the
5201 linker to issue an error if an uninitialized variable has multiple
5202 definitions.  You can force a variable to be initialized with the
5203 @option{-fno-common} flag or the @code{nocommon} attribute.
5205 Some file formats do not support arbitrary sections so the @code{section}
5206 attribute is not available on all platforms.
5207 If you need to map the entire contents of a module to a particular
5208 section, consider using the facilities of the linker instead.
5210 @item shared
5211 @cindex @code{shared} variable attribute
5212 On Microsoft Windows, in addition to putting variable definitions in a named
5213 section, the section can also be shared among all running copies of an
5214 executable or DLL@.  For example, this small program defines shared data
5215 by putting it in a named section @code{shared} and marking the section
5216 shareable:
5218 @smallexample
5219 int foo __attribute__((section ("shared"), shared)) = 0;
5222 main()
5224   /* @r{Read and write foo.  All running
5225      copies see the same value.}  */
5226   return 0;
5228 @end smallexample
5230 @noindent
5231 You may only use the @code{shared} attribute along with @code{section}
5232 attribute with a fully-initialized global definition because of the way
5233 linkers work.  See @code{section} attribute for more information.
5235 The @code{shared} attribute is only available on Microsoft Windows@.
5237 @item tls_model ("@var{tls_model}")
5238 @cindex @code{tls_model} attribute
5239 The @code{tls_model} attribute sets thread-local storage model
5240 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5241 overriding @option{-ftls-model=} command-line switch on a per-variable
5242 basis.
5243 The @var{tls_model} argument should be one of @code{global-dynamic},
5244 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5246 Not all targets support this attribute.
5248 @item unused
5249 This attribute, attached to a variable, means that the variable is meant
5250 to be possibly unused.  GCC does not produce a warning for this
5251 variable.
5253 @item used
5254 This attribute, attached to a variable with the static storage, means that
5255 the variable must be emitted even if it appears that the variable is not
5256 referenced.
5258 When applied to a static data member of a C++ class template, the
5259 attribute also means that the member is instantiated if the
5260 class itself is instantiated.
5262 @item vector_size (@var{bytes})
5263 This attribute specifies the vector size for the variable, measured in
5264 bytes.  For example, the declaration:
5266 @smallexample
5267 int foo __attribute__ ((vector_size (16)));
5268 @end smallexample
5270 @noindent
5271 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5272 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5273 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5275 This attribute is only applicable to integral and float scalars,
5276 although arrays, pointers, and function return values are allowed in
5277 conjunction with this construct.
5279 Aggregates with this attribute are invalid, even if they are of the same
5280 size as a corresponding scalar.  For example, the declaration:
5282 @smallexample
5283 struct S @{ int a; @};
5284 struct S  __attribute__ ((vector_size (16))) foo;
5285 @end smallexample
5287 @noindent
5288 is invalid even if the size of the structure is the same as the size of
5289 the @code{int}.
5291 @item selectany
5292 The @code{selectany} attribute causes an initialized global variable to
5293 have link-once semantics.  When multiple definitions of the variable are
5294 encountered by the linker, the first is selected and the remainder are
5295 discarded.  Following usage by the Microsoft compiler, the linker is told
5296 @emph{not} to warn about size or content differences of the multiple
5297 definitions.
5299 Although the primary usage of this attribute is for POD types, the
5300 attribute can also be applied to global C++ objects that are initialized
5301 by a constructor.  In this case, the static initialization and destruction
5302 code for the object is emitted in each translation defining the object,
5303 but the calls to the constructor and destructor are protected by a
5304 link-once guard variable.
5306 The @code{selectany} attribute is only available on Microsoft Windows
5307 targets.  You can use @code{__declspec (selectany)} as a synonym for
5308 @code{__attribute__ ((selectany))} for compatibility with other
5309 compilers.
5311 @item weak
5312 The @code{weak} attribute is described in @ref{Function Attributes}.
5314 @item dllimport
5315 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5317 @item dllexport
5318 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5320 @end table
5322 @anchor{AVR Variable Attributes}
5323 @subsection AVR Variable Attributes
5325 @table @code
5326 @item progmem
5327 @cindex @code{progmem} AVR variable attribute
5328 The @code{progmem} attribute is used on the AVR to place read-only
5329 data in the non-volatile program memory (flash). The @code{progmem}
5330 attribute accomplishes this by putting respective variables into a
5331 section whose name starts with @code{.progmem}.
5333 This attribute works similar to the @code{section} attribute
5334 but adds additional checking. Notice that just like the
5335 @code{section} attribute, @code{progmem} affects the location
5336 of the data but not how this data is accessed.
5338 In order to read data located with the @code{progmem} attribute
5339 (inline) assembler must be used.
5340 @smallexample
5341 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5342 #include <avr/pgmspace.h> 
5344 /* Locate var in flash memory */
5345 const int var[2] PROGMEM = @{ 1, 2 @};
5347 int read_var (int i)
5349     /* Access var[] by accessor macro from avr/pgmspace.h */
5350     return (int) pgm_read_word (& var[i]);
5352 @end smallexample
5354 AVR is a Harvard architecture processor and data and read-only data
5355 normally resides in the data memory (RAM).
5357 See also the @ref{AVR Named Address Spaces} section for
5358 an alternate way to locate and access data in flash memory.
5360 @item io
5361 @itemx io (@var{addr})
5362 Variables with the @code{io} attribute are used to address
5363 memory-mapped peripherals in the io address range.
5364 If an address is specified, the variable
5365 is assigned that address, and the value is interpreted as an
5366 address in the data address space.
5367 Example:
5369 @smallexample
5370 volatile int porta __attribute__((io (0x22)));
5371 @end smallexample
5373 The address specified in the address in the data address range.
5375 Otherwise, the variable it is not assigned an address, but the
5376 compiler will still use in/out instructions where applicable,
5377 assuming some other module assigns an address in the io address range.
5378 Example:
5380 @smallexample
5381 extern volatile int porta __attribute__((io));
5382 @end smallexample
5384 @item io_low
5385 @itemx io_low (@var{addr})
5386 This is like the @code{io} attribute, but additionally it informs the
5387 compiler that the object lies in the lower half of the I/O area,
5388 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5389 instructions.
5391 @item address
5392 @itemx address (@var{addr})
5393 Variables with the @code{address} attribute are used to address
5394 memory-mapped peripherals that may lie outside the io address range.
5396 @smallexample
5397 volatile int porta __attribute__((address (0x600)));
5398 @end smallexample
5400 @end table
5402 @subsection Blackfin Variable Attributes
5404 Three attributes are currently defined for the Blackfin.
5406 @table @code
5407 @item l1_data
5408 @itemx l1_data_A
5409 @itemx l1_data_B
5410 @cindex @code{l1_data} variable attribute
5411 @cindex @code{l1_data_A} variable attribute
5412 @cindex @code{l1_data_B} variable attribute
5413 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5414 Variables with @code{l1_data} attribute are put into the specific section
5415 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5416 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5417 attribute are put into the specific section named @code{.l1.data.B}.
5419 @item l2
5420 @cindex @code{l2} variable attribute
5421 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5422 Variables with @code{l2} attribute are put into the specific section
5423 named @code{.l2.data}.
5424 @end table
5426 @subsection M32R/D Variable Attributes
5428 One attribute is currently defined for the M32R/D@.
5430 @table @code
5431 @item model (@var{model-name})
5432 @cindex variable addressability on the M32R/D
5433 Use this attribute on the M32R/D to set the addressability of an object.
5434 The identifier @var{model-name} is one of @code{small}, @code{medium},
5435 or @code{large}, representing each of the code models.
5437 Small model objects live in the lower 16MB of memory (so that their
5438 addresses can be loaded with the @code{ld24} instruction).
5440 Medium and large model objects may live anywhere in the 32-bit address space
5441 (the compiler generates @code{seth/add3} instructions to load their
5442 addresses).
5443 @end table
5445 @anchor{MeP Variable Attributes}
5446 @subsection MeP Variable Attributes
5448 The MeP target has a number of addressing modes and busses.  The
5449 @code{near} space spans the standard memory space's first 16 megabytes
5450 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5451 The @code{based} space is a 128-byte region in the memory space that
5452 is addressed relative to the @code{$tp} register.  The @code{tiny}
5453 space is a 65536-byte region relative to the @code{$gp} register.  In
5454 addition to these memory regions, the MeP target has a separate 16-bit
5455 control bus which is specified with @code{cb} attributes.
5457 @table @code
5459 @item based
5460 Any variable with the @code{based} attribute is assigned to the
5461 @code{.based} section, and is accessed with relative to the
5462 @code{$tp} register.
5464 @item tiny
5465 Likewise, the @code{tiny} attribute assigned variables to the
5466 @code{.tiny} section, relative to the @code{$gp} register.
5468 @item near
5469 Variables with the @code{near} attribute are assumed to have addresses
5470 that fit in a 24-bit addressing mode.  This is the default for large
5471 variables (@code{-mtiny=4} is the default) but this attribute can
5472 override @code{-mtiny=} for small variables, or override @code{-ml}.
5474 @item far
5475 Variables with the @code{far} attribute are addressed using a full
5476 32-bit address.  Since this covers the entire memory space, this
5477 allows modules to make no assumptions about where variables might be
5478 stored.
5480 @item io
5481 @itemx io (@var{addr})
5482 Variables with the @code{io} attribute are used to address
5483 memory-mapped peripherals.  If an address is specified, the variable
5484 is assigned that address, else it is not assigned an address (it is
5485 assumed some other module assigns an address).  Example:
5487 @smallexample
5488 int timer_count __attribute__((io(0x123)));
5489 @end smallexample
5491 @item cb
5492 @itemx cb (@var{addr})
5493 Variables with the @code{cb} attribute are used to access the control
5494 bus, using special instructions.  @code{addr} indicates the control bus
5495 address.  Example:
5497 @smallexample
5498 int cpu_clock __attribute__((cb(0x123)));
5499 @end smallexample
5501 @end table
5503 @anchor{i386 Variable Attributes}
5504 @subsection i386 Variable Attributes
5506 Two attributes are currently defined for i386 configurations:
5507 @code{ms_struct} and @code{gcc_struct}
5509 @table @code
5510 @item ms_struct
5511 @itemx gcc_struct
5512 @cindex @code{ms_struct} attribute
5513 @cindex @code{gcc_struct} attribute
5515 If @code{packed} is used on a structure, or if bit-fields are used,
5516 it may be that the Microsoft ABI lays out the structure differently
5517 than the way GCC normally does.  Particularly when moving packed
5518 data between functions compiled with GCC and the native Microsoft compiler
5519 (either via function call or as data in a file), it may be necessary to access
5520 either format.
5522 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5523 compilers to match the native Microsoft compiler.
5525 The Microsoft structure layout algorithm is fairly simple with the exception
5526 of the bit-field packing.  
5527 The padding and alignment of members of structures and whether a bit-field 
5528 can straddle a storage-unit boundary are determine by these rules:
5530 @enumerate
5531 @item Structure members are stored sequentially in the order in which they are
5532 declared: the first member has the lowest memory address and the last member
5533 the highest.
5535 @item Every data object has an alignment requirement.  The alignment requirement
5536 for all data except structures, unions, and arrays is either the size of the
5537 object or the current packing size (specified with either the
5538 @code{aligned} attribute or the @code{pack} pragma),
5539 whichever is less.  For structures, unions, and arrays,
5540 the alignment requirement is the largest alignment requirement of its members.
5541 Every object is allocated an offset so that:
5543 @smallexample
5544 offset % alignment_requirement == 0
5545 @end smallexample
5547 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5548 unit if the integral types are the same size and if the next bit-field fits
5549 into the current allocation unit without crossing the boundary imposed by the
5550 common alignment requirements of the bit-fields.
5551 @end enumerate
5553 MSVC interprets zero-length bit-fields in the following ways:
5555 @enumerate
5556 @item If a zero-length bit-field is inserted between two bit-fields that
5557 are normally coalesced, the bit-fields are not coalesced.
5559 For example:
5561 @smallexample
5562 struct
5563  @{
5564    unsigned long bf_1 : 12;
5565    unsigned long : 0;
5566    unsigned long bf_2 : 12;
5567  @} t1;
5568 @end smallexample
5570 @noindent
5571 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5572 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5574 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5575 alignment of the zero-length bit-field is greater than the member that follows it,
5576 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5578 For example:
5580 @smallexample
5581 struct
5582  @{
5583    char foo : 4;
5584    short : 0;
5585    char bar;
5586  @} t2;
5588 struct
5589  @{
5590    char foo : 4;
5591    short : 0;
5592    double bar;
5593  @} t3;
5594 @end smallexample
5596 @noindent
5597 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5598 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5599 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5600 of the structure.
5602 Taking this into account, it is important to note the following:
5604 @enumerate
5605 @item If a zero-length bit-field follows a normal bit-field, the type of the
5606 zero-length bit-field may affect the alignment of the structure as whole. For
5607 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5608 normal bit-field, and is of type short.
5610 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5611 still affect the alignment of the structure:
5613 @smallexample
5614 struct
5615  @{
5616    char foo : 6;
5617    long : 0;
5618  @} t4;
5619 @end smallexample
5621 @noindent
5622 Here, @code{t4} takes up 4 bytes.
5623 @end enumerate
5625 @item Zero-length bit-fields following non-bit-field members are ignored:
5627 @smallexample
5628 struct
5629  @{
5630    char foo;
5631    long : 0;
5632    char bar;
5633  @} t5;
5634 @end smallexample
5636 @noindent
5637 Here, @code{t5} takes up 2 bytes.
5638 @end enumerate
5639 @end table
5641 @subsection PowerPC Variable Attributes
5643 Three attributes currently are defined for PowerPC configurations:
5644 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5646 For full documentation of the struct attributes please see the
5647 documentation in @ref{i386 Variable Attributes}.
5649 For documentation of @code{altivec} attribute please see the
5650 documentation in @ref{PowerPC Type Attributes}.
5652 @subsection SPU Variable Attributes
5654 The SPU supports the @code{spu_vector} attribute for variables.  For
5655 documentation of this attribute please see the documentation in
5656 @ref{SPU Type Attributes}.
5658 @subsection Xstormy16 Variable Attributes
5660 One attribute is currently defined for xstormy16 configurations:
5661 @code{below100}.
5663 @table @code
5664 @item below100
5665 @cindex @code{below100} attribute
5667 If a variable has the @code{below100} attribute (@code{BELOW100} is
5668 allowed also), GCC places the variable in the first 0x100 bytes of
5669 memory and use special opcodes to access it.  Such variables are
5670 placed in either the @code{.bss_below100} section or the
5671 @code{.data_below100} section.
5673 @end table
5675 @node Type Attributes
5676 @section Specifying Attributes of Types
5677 @cindex attribute of types
5678 @cindex type attributes
5680 The keyword @code{__attribute__} allows you to specify special
5681 attributes of @code{struct} and @code{union} types when you define
5682 such types.  This keyword is followed by an attribute specification
5683 inside double parentheses.  Eight attributes are currently defined for
5684 types: @code{aligned}, @code{packed}, @code{transparent_union},
5685 @code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias}
5686 and @code{bnd_variable_size}.  Other attributes are defined for
5687 functions (@pxref{Function Attributes}), labels (@pxref{Label 
5688 Attributes}) and for variables (@pxref{Variable Attributes}).
5690 You may also specify any one of these attributes with @samp{__}
5691 preceding and following its keyword.  This allows you to use these
5692 attributes in header files without being concerned about a possible
5693 macro of the same name.  For example, you may use @code{__aligned__}
5694 instead of @code{aligned}.
5696 You may specify type attributes in an enum, struct or union type
5697 declaration or definition, or for other types in a @code{typedef}
5698 declaration.
5700 For an enum, struct or union type, you may specify attributes either
5701 between the enum, struct or union tag and the name of the type, or
5702 just past the closing curly brace of the @emph{definition}.  The
5703 former syntax is preferred.
5705 @xref{Attribute Syntax}, for details of the exact syntax for using
5706 attributes.
5708 @table @code
5709 @cindex @code{aligned} attribute
5710 @item aligned (@var{alignment})
5711 This attribute specifies a minimum alignment (in bytes) for variables
5712 of the specified type.  For example, the declarations:
5714 @smallexample
5715 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5716 typedef int more_aligned_int __attribute__ ((aligned (8)));
5717 @end smallexample
5719 @noindent
5720 force the compiler to ensure (as far as it can) that each variable whose
5721 type is @code{struct S} or @code{more_aligned_int} is allocated and
5722 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5723 variables of type @code{struct S} aligned to 8-byte boundaries allows
5724 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5725 store) instructions when copying one variable of type @code{struct S} to
5726 another, thus improving run-time efficiency.
5728 Note that the alignment of any given @code{struct} or @code{union} type
5729 is required by the ISO C standard to be at least a perfect multiple of
5730 the lowest common multiple of the alignments of all of the members of
5731 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5732 effectively adjust the alignment of a @code{struct} or @code{union}
5733 type by attaching an @code{aligned} attribute to any one of the members
5734 of such a type, but the notation illustrated in the example above is a
5735 more obvious, intuitive, and readable way to request the compiler to
5736 adjust the alignment of an entire @code{struct} or @code{union} type.
5738 As in the preceding example, you can explicitly specify the alignment
5739 (in bytes) that you wish the compiler to use for a given @code{struct}
5740 or @code{union} type.  Alternatively, you can leave out the alignment factor
5741 and just ask the compiler to align a type to the maximum
5742 useful alignment for the target machine you are compiling for.  For
5743 example, you could write:
5745 @smallexample
5746 struct S @{ short f[3]; @} __attribute__ ((aligned));
5747 @end smallexample
5749 Whenever you leave out the alignment factor in an @code{aligned}
5750 attribute specification, the compiler automatically sets the alignment
5751 for the type to the largest alignment that is ever used for any data
5752 type on the target machine you are compiling for.  Doing this can often
5753 make copy operations more efficient, because the compiler can use
5754 whatever instructions copy the biggest chunks of memory when performing
5755 copies to or from the variables that have types that you have aligned
5756 this way.
5758 In the example above, if the size of each @code{short} is 2 bytes, then
5759 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5760 power of two that is greater than or equal to that is 8, so the
5761 compiler sets the alignment for the entire @code{struct S} type to 8
5762 bytes.
5764 Note that although you can ask the compiler to select a time-efficient
5765 alignment for a given type and then declare only individual stand-alone
5766 objects of that type, the compiler's ability to select a time-efficient
5767 alignment is primarily useful only when you plan to create arrays of
5768 variables having the relevant (efficiently aligned) type.  If you
5769 declare or use arrays of variables of an efficiently-aligned type, then
5770 it is likely that your program also does pointer arithmetic (or
5771 subscripting, which amounts to the same thing) on pointers to the
5772 relevant type, and the code that the compiler generates for these
5773 pointer arithmetic operations is often more efficient for
5774 efficiently-aligned types than for other types.
5776 The @code{aligned} attribute can only increase the alignment; but you
5777 can decrease it by specifying @code{packed} as well.  See below.
5779 Note that the effectiveness of @code{aligned} attributes may be limited
5780 by inherent limitations in your linker.  On many systems, the linker is
5781 only able to arrange for variables to be aligned up to a certain maximum
5782 alignment.  (For some linkers, the maximum supported alignment may
5783 be very very small.)  If your linker is only able to align variables
5784 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5785 in an @code{__attribute__} still only provides you with 8-byte
5786 alignment.  See your linker documentation for further information.
5788 @item packed
5789 This attribute, attached to @code{struct} or @code{union} type
5790 definition, specifies that each member (other than zero-width bit-fields)
5791 of the structure or union is placed to minimize the memory required.  When
5792 attached to an @code{enum} definition, it indicates that the smallest
5793 integral type should be used.
5795 @opindex fshort-enums
5796 Specifying this attribute for @code{struct} and @code{union} types is
5797 equivalent to specifying the @code{packed} attribute on each of the
5798 structure or union members.  Specifying the @option{-fshort-enums}
5799 flag on the line is equivalent to specifying the @code{packed}
5800 attribute on all @code{enum} definitions.
5802 In the following example @code{struct my_packed_struct}'s members are
5803 packed closely together, but the internal layout of its @code{s} member
5804 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5805 be packed too.
5807 @smallexample
5808 struct my_unpacked_struct
5809  @{
5810     char c;
5811     int i;
5812  @};
5814 struct __attribute__ ((__packed__)) my_packed_struct
5815   @{
5816      char c;
5817      int  i;
5818      struct my_unpacked_struct s;
5819   @};
5820 @end smallexample
5822 You may only specify this attribute on the definition of an @code{enum},
5823 @code{struct} or @code{union}, not on a @code{typedef} that does not
5824 also define the enumerated type, structure or union.
5826 @item transparent_union
5827 @cindex @code{transparent_union} attribute
5829 This attribute, attached to a @code{union} type definition, indicates
5830 that any function parameter having that union type causes calls to that
5831 function to be treated in a special way.
5833 First, the argument corresponding to a transparent union type can be of
5834 any type in the union; no cast is required.  Also, if the union contains
5835 a pointer type, the corresponding argument can be a null pointer
5836 constant or a void pointer expression; and if the union contains a void
5837 pointer type, the corresponding argument can be any pointer expression.
5838 If the union member type is a pointer, qualifiers like @code{const} on
5839 the referenced type must be respected, just as with normal pointer
5840 conversions.
5842 Second, the argument is passed to the function using the calling
5843 conventions of the first member of the transparent union, not the calling
5844 conventions of the union itself.  All members of the union must have the
5845 same machine representation; this is necessary for this argument passing
5846 to work properly.
5848 Transparent unions are designed for library functions that have multiple
5849 interfaces for compatibility reasons.  For example, suppose the
5850 @code{wait} function must accept either a value of type @code{int *} to
5851 comply with POSIX, or a value of type @code{union wait *} to comply with
5852 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5853 @code{wait} would accept both kinds of arguments, but it would also
5854 accept any other pointer type and this would make argument type checking
5855 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5856 as follows:
5858 @smallexample
5859 typedef union __attribute__ ((__transparent_union__))
5860   @{
5861     int *__ip;
5862     union wait *__up;
5863   @} wait_status_ptr_t;
5865 pid_t wait (wait_status_ptr_t);
5866 @end smallexample
5868 @noindent
5869 This interface allows either @code{int *} or @code{union wait *}
5870 arguments to be passed, using the @code{int *} calling convention.
5871 The program can call @code{wait} with arguments of either type:
5873 @smallexample
5874 int w1 () @{ int w; return wait (&w); @}
5875 int w2 () @{ union wait w; return wait (&w); @}
5876 @end smallexample
5878 @noindent
5879 With this interface, @code{wait}'s implementation might look like this:
5881 @smallexample
5882 pid_t wait (wait_status_ptr_t p)
5884   return waitpid (-1, p.__ip, 0);
5886 @end smallexample
5888 @item unused
5889 When attached to a type (including a @code{union} or a @code{struct}),
5890 this attribute means that variables of that type are meant to appear
5891 possibly unused.  GCC does not produce a warning for any variables of
5892 that type, even if the variable appears to do nothing.  This is often
5893 the case with lock or thread classes, which are usually defined and then
5894 not referenced, but contain constructors and destructors that have
5895 nontrivial bookkeeping functions.
5897 @item deprecated
5898 @itemx deprecated (@var{msg})
5899 The @code{deprecated} attribute results in a warning if the type
5900 is used anywhere in the source file.  This is useful when identifying
5901 types that are expected to be removed in a future version of a program.
5902 If possible, the warning also includes the location of the declaration
5903 of the deprecated type, to enable users to easily find further
5904 information about why the type is deprecated, or what they should do
5905 instead.  Note that the warnings only occur for uses and then only
5906 if the type is being applied to an identifier that itself is not being
5907 declared as deprecated.
5909 @smallexample
5910 typedef int T1 __attribute__ ((deprecated));
5911 T1 x;
5912 typedef T1 T2;
5913 T2 y;
5914 typedef T1 T3 __attribute__ ((deprecated));
5915 T3 z __attribute__ ((deprecated));
5916 @end smallexample
5918 @noindent
5919 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5920 warning is issued for line 4 because T2 is not explicitly
5921 deprecated.  Line 5 has no warning because T3 is explicitly
5922 deprecated.  Similarly for line 6.  The optional @var{msg}
5923 argument, which must be a string, is printed in the warning if
5924 present.
5926 The @code{deprecated} attribute can also be used for functions and
5927 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5929 @item may_alias
5930 Accesses through pointers to types with this attribute are not subject
5931 to type-based alias analysis, but are instead assumed to be able to alias
5932 any other type of objects.
5933 In the context of section 6.5 paragraph 7 of the C99 standard,
5934 an lvalue expression
5935 dereferencing such a pointer is treated like having a character type.
5936 See @option{-fstrict-aliasing} for more information on aliasing issues.
5937 This extension exists to support some vector APIs, in which pointers to
5938 one vector type are permitted to alias pointers to a different vector type.
5940 Note that an object of a type with this attribute does not have any
5941 special semantics.
5943 Example of use:
5945 @smallexample
5946 typedef short __attribute__((__may_alias__)) short_a;
5949 main (void)
5951   int a = 0x12345678;
5952   short_a *b = (short_a *) &a;
5954   b[1] = 0;
5956   if (a == 0x12345678)
5957     abort();
5959   exit(0);
5961 @end smallexample
5963 @noindent
5964 If you replaced @code{short_a} with @code{short} in the variable
5965 declaration, the above program would abort when compiled with
5966 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5967 above in recent GCC versions.
5969 @item visibility
5970 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5971 applied to class, struct, union and enum types.  Unlike other type
5972 attributes, the attribute must appear between the initial keyword and
5973 the name of the type; it cannot appear after the body of the type.
5975 Note that the type visibility is applied to vague linkage entities
5976 associated with the class (vtable, typeinfo node, etc.).  In
5977 particular, if a class is thrown as an exception in one shared object
5978 and caught in another, the class must have default visibility.
5979 Otherwise the two shared objects are unable to use the same
5980 typeinfo node and exception handling will break.
5982 @item designated_init
5983 This attribute may only be applied to structure types.  It indicates
5984 that any initialization of an object of this type must use designated
5985 initializers rather than positional initializers.  The intent of this
5986 attribute is to allow the programmer to indicate that a structure's
5987 layout may change, and that therefore relying on positional
5988 initialization will result in future breakage.
5990 GCC emits warnings based on this attribute by default; use
5991 @option{-Wno-designated-init} to suppress them.
5993 @item bnd_variable_size
5994 When applied to a structure field, this attribute tells Pointer
5995 Bounds Checker that the size of this field should not be computed
5996 using static type information.  It may be used to mark variable
5997 sized static array fields placed at the end of a structure.
5999 @smallexample
6000 struct S
6002   int size;
6003   char data[1];
6005 S *p = (S *)malloc (sizeof(S) + 100);
6006 p->data[10] = 0; //Bounds violation
6007 @end smallexample
6009 By using an attribute for a field we may avoid bound violation
6010 we most probably do not want to see:
6012 @smallexample
6013 struct S
6015   int size;
6016   char data[1] __attribute__((bnd_variable_size));
6018 S *p = (S *)malloc (sizeof(S) + 100);
6019 p->data[10] = 0; //OK
6020 @end smallexample
6022 @end table
6024 To specify multiple attributes, separate them by commas within the
6025 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6026 packed))}.
6028 @subsection ARM Type Attributes
6030 On those ARM targets that support @code{dllimport} (such as Symbian
6031 OS), you can use the @code{notshared} attribute to indicate that the
6032 virtual table and other similar data for a class should not be
6033 exported from a DLL@.  For example:
6035 @smallexample
6036 class __declspec(notshared) C @{
6037 public:
6038   __declspec(dllimport) C();
6039   virtual void f();
6042 __declspec(dllexport)
6043 C::C() @{@}
6044 @end smallexample
6046 @noindent
6047 In this code, @code{C::C} is exported from the current DLL, but the
6048 virtual table for @code{C} is not exported.  (You can use
6049 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6050 most Symbian OS code uses @code{__declspec}.)
6052 @anchor{MeP Type Attributes}
6053 @subsection MeP Type Attributes
6055 Many of the MeP variable attributes may be applied to types as well.
6056 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6057 @code{far} attributes may be applied to either.  The @code{io} and
6058 @code{cb} attributes may not be applied to types.
6060 @anchor{i386 Type Attributes}
6061 @subsection i386 Type Attributes
6063 Two attributes are currently defined for i386 configurations:
6064 @code{ms_struct} and @code{gcc_struct}.
6066 @table @code
6068 @item ms_struct
6069 @itemx gcc_struct
6070 @cindex @code{ms_struct}
6071 @cindex @code{gcc_struct}
6073 If @code{packed} is used on a structure, or if bit-fields are used
6074 it may be that the Microsoft ABI packs them differently
6075 than GCC normally packs them.  Particularly when moving packed
6076 data between functions compiled with GCC and the native Microsoft compiler
6077 (either via function call or as data in a file), it may be necessary to access
6078 either format.
6080 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
6081 compilers to match the native Microsoft compiler.
6082 @end table
6084 @anchor{PowerPC Type Attributes}
6085 @subsection PowerPC Type Attributes
6087 Three attributes currently are defined for PowerPC configurations:
6088 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6090 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6091 attributes please see the documentation in @ref{i386 Type Attributes}.
6093 The @code{altivec} attribute allows one to declare AltiVec vector data
6094 types supported by the AltiVec Programming Interface Manual.  The
6095 attribute requires an argument to specify one of three vector types:
6096 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6097 and @code{bool__} (always followed by unsigned).
6099 @smallexample
6100 __attribute__((altivec(vector__)))
6101 __attribute__((altivec(pixel__))) unsigned short
6102 __attribute__((altivec(bool__))) unsigned
6103 @end smallexample
6105 These attributes mainly are intended to support the @code{__vector},
6106 @code{__pixel}, and @code{__bool} AltiVec keywords.
6108 @anchor{SPU Type Attributes}
6109 @subsection SPU Type Attributes
6111 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6112 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6113 Language Extensions Specification.  It is intended to support the
6114 @code{__vector} keyword.
6116 @node Alignment
6117 @section Inquiring on Alignment of Types or Variables
6118 @cindex alignment
6119 @cindex type alignment
6120 @cindex variable alignment
6122 The keyword @code{__alignof__} allows you to inquire about how an object
6123 is aligned, or the minimum alignment usually required by a type.  Its
6124 syntax is just like @code{sizeof}.
6126 For example, if the target machine requires a @code{double} value to be
6127 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6128 This is true on many RISC machines.  On more traditional machine
6129 designs, @code{__alignof__ (double)} is 4 or even 2.
6131 Some machines never actually require alignment; they allow reference to any
6132 data type even at an odd address.  For these machines, @code{__alignof__}
6133 reports the smallest alignment that GCC gives the data type, usually as
6134 mandated by the target ABI.
6136 If the operand of @code{__alignof__} is an lvalue rather than a type,
6137 its value is the required alignment for its type, taking into account
6138 any minimum alignment specified with GCC's @code{__attribute__}
6139 extension (@pxref{Variable Attributes}).  For example, after this
6140 declaration:
6142 @smallexample
6143 struct foo @{ int x; char y; @} foo1;
6144 @end smallexample
6146 @noindent
6147 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6148 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6150 It is an error to ask for the alignment of an incomplete type.
6153 @node Inline
6154 @section An Inline Function is As Fast As a Macro
6155 @cindex inline functions
6156 @cindex integrating function code
6157 @cindex open coding
6158 @cindex macros, inline alternative
6160 By declaring a function inline, you can direct GCC to make
6161 calls to that function faster.  One way GCC can achieve this is to
6162 integrate that function's code into the code for its callers.  This
6163 makes execution faster by eliminating the function-call overhead; in
6164 addition, if any of the actual argument values are constant, their
6165 known values may permit simplifications at compile time so that not
6166 all of the inline function's code needs to be included.  The effect on
6167 code size is less predictable; object code may be larger or smaller
6168 with function inlining, depending on the particular case.  You can
6169 also direct GCC to try to integrate all ``simple enough'' functions
6170 into their callers with the option @option{-finline-functions}.
6172 GCC implements three different semantics of declaring a function
6173 inline.  One is available with @option{-std=gnu89} or
6174 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6175 on all inline declarations, another when
6176 @option{-std=c99}, @option{-std=c11},
6177 @option{-std=gnu99} or @option{-std=gnu11}
6178 (without @option{-fgnu89-inline}), and the third
6179 is used when compiling C++.
6181 To declare a function inline, use the @code{inline} keyword in its
6182 declaration, like this:
6184 @smallexample
6185 static inline int
6186 inc (int *a)
6188   return (*a)++;
6190 @end smallexample
6192 If you are writing a header file to be included in ISO C90 programs, write
6193 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6195 The three types of inlining behave similarly in two important cases:
6196 when the @code{inline} keyword is used on a @code{static} function,
6197 like the example above, and when a function is first declared without
6198 using the @code{inline} keyword and then is defined with
6199 @code{inline}, like this:
6201 @smallexample
6202 extern int inc (int *a);
6203 inline int
6204 inc (int *a)
6206   return (*a)++;
6208 @end smallexample
6210 In both of these common cases, the program behaves the same as if you
6211 had not used the @code{inline} keyword, except for its speed.
6213 @cindex inline functions, omission of
6214 @opindex fkeep-inline-functions
6215 When a function is both inline and @code{static}, if all calls to the
6216 function are integrated into the caller, and the function's address is
6217 never used, then the function's own assembler code is never referenced.
6218 In this case, GCC does not actually output assembler code for the
6219 function, unless you specify the option @option{-fkeep-inline-functions}.
6220 Some calls cannot be integrated for various reasons (in particular,
6221 calls that precede the function's definition cannot be integrated, and
6222 neither can recursive calls within the definition).  If there is a
6223 nonintegrated call, then the function is compiled to assembler code as
6224 usual.  The function must also be compiled as usual if the program
6225 refers to its address, because that can't be inlined.
6227 @opindex Winline
6228 Note that certain usages in a function definition can make it unsuitable
6229 for inline substitution.  Among these usages are: variadic functions, use of
6230 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6231 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6232 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6233 warns when a function marked @code{inline} could not be substituted,
6234 and gives the reason for the failure.
6236 @cindex automatic @code{inline} for C++ member fns
6237 @cindex @code{inline} automatic for C++ member fns
6238 @cindex member fns, automatically @code{inline}
6239 @cindex C++ member fns, automatically @code{inline}
6240 @opindex fno-default-inline
6241 As required by ISO C++, GCC considers member functions defined within
6242 the body of a class to be marked inline even if they are
6243 not explicitly declared with the @code{inline} keyword.  You can
6244 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6245 Options,,Options Controlling C++ Dialect}.
6247 GCC does not inline any functions when not optimizing unless you specify
6248 the @samp{always_inline} attribute for the function, like this:
6250 @smallexample
6251 /* @r{Prototype.}  */
6252 inline void foo (const char) __attribute__((always_inline));
6253 @end smallexample
6255 The remainder of this section is specific to GNU C90 inlining.
6257 @cindex non-static inline function
6258 When an inline function is not @code{static}, then the compiler must assume
6259 that there may be calls from other source files; since a global symbol can
6260 be defined only once in any program, the function must not be defined in
6261 the other source files, so the calls therein cannot be integrated.
6262 Therefore, a non-@code{static} inline function is always compiled on its
6263 own in the usual fashion.
6265 If you specify both @code{inline} and @code{extern} in the function
6266 definition, then the definition is used only for inlining.  In no case
6267 is the function compiled on its own, not even if you refer to its
6268 address explicitly.  Such an address becomes an external reference, as
6269 if you had only declared the function, and had not defined it.
6271 This combination of @code{inline} and @code{extern} has almost the
6272 effect of a macro.  The way to use it is to put a function definition in
6273 a header file with these keywords, and put another copy of the
6274 definition (lacking @code{inline} and @code{extern}) in a library file.
6275 The definition in the header file causes most calls to the function
6276 to be inlined.  If any uses of the function remain, they refer to
6277 the single copy in the library.
6279 @node Volatiles
6280 @section When is a Volatile Object Accessed?
6281 @cindex accessing volatiles
6282 @cindex volatile read
6283 @cindex volatile write
6284 @cindex volatile access
6286 C has the concept of volatile objects.  These are normally accessed by
6287 pointers and used for accessing hardware or inter-thread
6288 communication.  The standard encourages compilers to refrain from
6289 optimizations concerning accesses to volatile objects, but leaves it
6290 implementation defined as to what constitutes a volatile access.  The
6291 minimum requirement is that at a sequence point all previous accesses
6292 to volatile objects have stabilized and no subsequent accesses have
6293 occurred.  Thus an implementation is free to reorder and combine
6294 volatile accesses that occur between sequence points, but cannot do
6295 so for accesses across a sequence point.  The use of volatile does
6296 not allow you to violate the restriction on updating objects multiple
6297 times between two sequence points.
6299 Accesses to non-volatile objects are not ordered with respect to
6300 volatile accesses.  You cannot use a volatile object as a memory
6301 barrier to order a sequence of writes to non-volatile memory.  For
6302 instance:
6304 @smallexample
6305 int *ptr = @var{something};
6306 volatile int vobj;
6307 *ptr = @var{something};
6308 vobj = 1;
6309 @end smallexample
6311 @noindent
6312 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6313 that the write to @var{*ptr} occurs by the time the update
6314 of @var{vobj} happens.  If you need this guarantee, you must use
6315 a stronger memory barrier such as:
6317 @smallexample
6318 int *ptr = @var{something};
6319 volatile int vobj;
6320 *ptr = @var{something};
6321 asm volatile ("" : : : "memory");
6322 vobj = 1;
6323 @end smallexample
6325 A scalar volatile object is read when it is accessed in a void context:
6327 @smallexample
6328 volatile int *src = @var{somevalue};
6329 *src;
6330 @end smallexample
6332 Such expressions are rvalues, and GCC implements this as a
6333 read of the volatile object being pointed to.
6335 Assignments are also expressions and have an rvalue.  However when
6336 assigning to a scalar volatile, the volatile object is not reread,
6337 regardless of whether the assignment expression's rvalue is used or
6338 not.  If the assignment's rvalue is used, the value is that assigned
6339 to the volatile object.  For instance, there is no read of @var{vobj}
6340 in all the following cases:
6342 @smallexample
6343 int obj;
6344 volatile int vobj;
6345 vobj = @var{something};
6346 obj = vobj = @var{something};
6347 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6348 obj = (@var{something}, vobj = @var{anotherthing});
6349 @end smallexample
6351 If you need to read the volatile object after an assignment has
6352 occurred, you must use a separate expression with an intervening
6353 sequence point.
6355 As bit-fields are not individually addressable, volatile bit-fields may
6356 be implicitly read when written to, or when adjacent bit-fields are
6357 accessed.  Bit-field operations may be optimized such that adjacent
6358 bit-fields are only partially accessed, if they straddle a storage unit
6359 boundary.  For these reasons it is unwise to use volatile bit-fields to
6360 access hardware.
6362 @node Using Assembly Language with C
6363 @section How to Use Inline Assembly Language in C Code
6365 GCC provides various extensions that allow you to embed assembler within 
6366 C code.
6368 @menu
6369 * Basic Asm::          Inline assembler with no operands.
6370 * Extended Asm::       Inline assembler with operands.
6371 * Constraints::        Constraints for @code{asm} operands
6372 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6373 * Explicit Reg Vars::  Defining variables residing in specified registers.
6374 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6375 @end menu
6377 @node Basic Asm
6378 @subsection Basic Asm --- Assembler Instructions with No Operands
6379 @cindex basic @code{asm}
6381 The @code{asm} keyword allows you to embed assembler instructions within 
6382 C code.
6384 @example
6385 asm [ volatile ] ( AssemblerInstructions )
6386 @end example
6388 To create headers compatible with ISO C, write @code{__asm__} instead of 
6389 @code{asm} (@pxref{Alternate Keywords}).
6391 By definition, a Basic @code{asm} statement is one with no operands. 
6392 @code{asm} statements that contain one or more colons (used to delineate 
6393 operands) are considered to be Extended (for example, @code{asm("int $3")} 
6394 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6396 @subsubheading Qualifiers
6397 @emph{volatile}
6399 This optional qualifier has no effect. All Basic @code{asm} blocks are 
6400 implicitly volatile.
6402 @subsubheading Parameters
6403 @emph{AssemblerInstructions}
6405 This is a literal string that specifies the assembler code. The string can 
6406 contain any instructions recognized by the assembler, including directives. 
6407 GCC does not parse the assembler instructions themselves and 
6408 does not know what they mean or even whether they are valid assembler input. 
6409 The compiler copies it verbatim to the assembly language output file, without 
6410 processing dialects or any of the "%" operators that are available with
6411 Extended @code{asm}. This results in minor differences between Basic 
6412 @code{asm} strings and Extended @code{asm} templates. For example, to refer to 
6413 registers you might use %%eax in Extended @code{asm} and %eax in Basic 
6414 @code{asm}.
6416 You may place multiple assembler instructions together in a single @code{asm} 
6417 string, separated by the characters normally used in assembly code for the 
6418 system. A combination that works in most places is a newline to break the 
6419 line, plus a tab character (written as "\n\t").
6420 Some assemblers allow semicolons as a line separator. However, 
6421 note that some assembler dialects use semicolons to start a comment. 
6423 Do not expect a sequence of @code{asm} statements to remain perfectly 
6424 consecutive after compilation. If certain instructions need to remain 
6425 consecutive in the output, put them in a single multi-instruction asm 
6426 statement. Note that GCC's optimizers can move @code{asm} statements 
6427 relative to other code, including across jumps.
6429 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6430 GCC does not know about these jumps, and therefore cannot take 
6431 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6432 labels are only supported in Extended @code{asm}.
6434 @subsubheading Remarks
6435 Using Extended @code{asm} will typically produce smaller, safer, and more 
6436 efficient code, and in most cases it is a better solution. When writing 
6437 inline assembly language outside of C functions, however, you must use Basic 
6438 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6439 Functions declared with the @code{naked} attribute also require Basic 
6440 @code{asm} (@pxref{Function Attributes}).
6442 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6443 assembly code when optimizing. This can lead to unexpected duplicate 
6444 symbol errors during compilation if your assembly code defines symbols or 
6445 labels.
6447 Safely accessing C data and calling functions from Basic @code{asm} is more 
6448 complex than it may appear. To access C data, it is better to use Extended 
6449 @code{asm}.
6451 Since GCC does not parse the AssemblerInstructions, it has no 
6452 visibility of any symbols it references. This may result in GCC discarding 
6453 those symbols as unreferenced.
6455 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly 
6456 volatile. @xref{Volatile}.  Similarly, Basic @code{asm} blocks are not treated 
6457 as though they used a "memory" clobber (@pxref{Clobbers}).
6459 All Basic @code{asm} blocks use the assembler dialect specified by the 
6460 @option{-masm} command-line option. Basic @code{asm} provides no
6461 mechanism to provide different assembler strings for different dialects.
6463 Here is an example of Basic @code{asm} for i386:
6465 @example
6466 /* Note that this code will not compile with -masm=intel */
6467 #define DebugBreak() asm("int $3")
6468 @end example
6470 @node Extended Asm
6471 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6472 @cindex @code{asm} keyword
6473 @cindex extended @code{asm}
6474 @cindex assembler instructions
6476 The @code{asm} keyword allows you to embed assembler instructions within C 
6477 code. With Extended @code{asm} you can read and write C variables from 
6478 assembler and perform jumps from assembler code to C labels.
6480 @example
6481 @ifhtml
6482 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6484 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6485 @end ifhtml
6486 @ifnothtml
6487 asm [volatile] ( AssemblerTemplate 
6488                  : [OutputOperands] 
6489                  [ : [InputOperands] 
6490                  [ : [Clobbers] ] ])
6492 asm [volatile] goto ( AssemblerTemplate 
6493                       : 
6494                       : [InputOperands] 
6495                       : [Clobbers] 
6496                       : GotoLabels)
6497 @end ifnothtml
6498 @end example
6500 To create headers compatible with ISO C, write @code{__asm__} instead of 
6501 @code{asm} and @code{__volatile__} instead of @code{volatile} 
6502 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6504 By definition, Extended @code{asm} is an @code{asm} statement that contains 
6505 operands. To separate the classes of operands, you use colons. Basic 
6506 @code{asm} statements contain no colons. (So, for example, 
6507 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is 
6508 Extended @code{asm}. @pxref{Basic Asm}.)
6510 @subsubheading Qualifiers
6511 @emph{volatile}
6513 The typical use of Extended @code{asm} statements is to manipulate input 
6514 values to produce output values. However, your @code{asm} statements may 
6515 also produce side effects. If so, you may need to use the @code{volatile} 
6516 qualifier to disable certain optimizations. @xref{Volatile}.
6518 @emph{goto}
6520 This qualifier informs the compiler that the @code{asm} statement may 
6521 perform a jump to one of the labels listed in the GotoLabels section. 
6522 @xref{GotoLabels}.
6524 @subsubheading Parameters
6525 @emph{AssemblerTemplate}
6527 This is a literal string that contains the assembler code. It is a 
6528 combination of fixed text and tokens that refer to the input, output, 
6529 and goto parameters. @xref{AssemblerTemplate}.
6531 @emph{OutputOperands}
6533 A comma-separated list of the C variables modified by the instructions in the 
6534 AssemblerTemplate. @xref{OutputOperands}.
6536 @emph{InputOperands}
6538 A comma-separated list of C expressions read by the instructions in the 
6539 AssemblerTemplate. @xref{InputOperands}.
6541 @emph{Clobbers}
6543 A comma-separated list of registers or other values changed by the 
6544 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6546 @emph{GotoLabels}
6548 When you are using the @code{goto} form of @code{asm}, this section contains 
6549 the list of all C labels to which the AssemblerTemplate may jump. 
6550 @xref{GotoLabels}.
6552 @subsubheading Remarks
6553 The @code{asm} statement allows you to include assembly instructions directly 
6554 within C code. This may help you to maximize performance in time-sensitive 
6555 code or to access assembly instructions that are not readily available to C 
6556 programs.
6558 Note that Extended @code{asm} statements must be inside a function. Only 
6559 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6560 Functions declared with the @code{naked} attribute also require Basic 
6561 @code{asm} (@pxref{Function Attributes}).
6563 While the uses of @code{asm} are many and varied, it may help to think of an 
6564 @code{asm} statement as a series of low-level instructions that convert input 
6565 parameters to output parameters. So a simple (if not particularly useful) 
6566 example for i386 using @code{asm} might look like this:
6568 @example
6569 int src = 1;
6570 int dst;   
6572 asm ("mov %1, %0\n\t"
6573     "add $1, %0"
6574     : "=r" (dst) 
6575     : "r" (src));
6577 printf("%d\n", dst);
6578 @end example
6580 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6582 @anchor{Volatile}
6583 @subsubsection Volatile
6584 @cindex volatile @code{asm}
6585 @cindex @code{asm} volatile
6587 GCC's optimizers sometimes discard @code{asm} statements if they determine 
6588 there is no need for the output variables. Also, the optimizers may move 
6589 code out of loops if they believe that the code will always return the same 
6590 result (i.e. none of its input values change between calls). Using the 
6591 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
6592 that have no output operands are implicitly volatile.
6594 Examples:
6596 This i386 code demonstrates a case that does not use (or require) the 
6597 @code{volatile} qualifier. If it is performing assertion checking, this code 
6598 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is 
6599 unreferenced by any code. As a result, the optimizers can discard the 
6600 @code{asm} statement, which in turn removes the need for the entire 
6601 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
6602 isn't needed you allow the optimizers to produce the most efficient code 
6603 possible.
6605 @example
6606 void DoCheck(uint32_t dwSomeValue)
6608    uint32_t dwRes;
6610    // Assumes dwSomeValue is not zero.
6611    asm ("bsfl %1,%0"
6612      : "=r" (dwRes)
6613      : "r" (dwSomeValue)
6614      : "cc");
6616    assert(dwRes > 3);
6618 @end example
6620 The next example shows a case where the optimizers can recognize that the input 
6621 (@var{dwSomeValue}) never changes during the execution of the function and can 
6622 therefore move the @code{asm} outside the loop to produce more efficient code. 
6623 Again, using @code{volatile} disables this type of optimization.
6625 @example
6626 void do_print(uint32_t dwSomeValue)
6628    uint32_t dwRes;
6630    for (uint32_t x=0; x < 5; x++)
6631    @{
6632       // Assumes dwSomeValue is not zero.
6633       asm ("bsfl %1,%0"
6634         : "=r" (dwRes)
6635         : "r" (dwSomeValue)
6636         : "cc");
6638       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6639    @}
6641 @end example
6643 The following example demonstrates a case where you need to use the 
6644 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads 
6645 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
6646 the optimizers might assume that the @code{asm} block will always return the 
6647 same value and therefore optimize away the second call.
6649 @example
6650 uint64_t msr;
6652 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6653         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6654         "or %%rdx, %0"        // 'Or' in the lower bits.
6655         : "=a" (msr)
6656         : 
6657         : "rdx");
6659 printf("msr: %llx\n", msr);
6661 // Do other work...
6663 // Reprint the timestamp
6664 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6665         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6666         "or %%rdx, %0"        // 'Or' in the lower bits.
6667         : "=a" (msr)
6668         : 
6669         : "rdx");
6671 printf("msr: %llx\n", msr);
6672 @end example
6674 GCC's optimizers will not treat this code like the non-volatile code in the 
6675 earlier examples. They do not move it out of loops or omit it on the 
6676 assumption that the result from a previous call is still valid.
6678 Note that the compiler can move even volatile @code{asm} instructions relative 
6679 to other code, including across jump instructions. For example, on many 
6680 targets there is a system register that controls the rounding mode of 
6681 floating-point operations. Setting it with a volatile @code{asm}, as in the 
6682 following PowerPC example, will not work reliably.
6684 @example
6685 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6686 sum = x + y;
6687 @end example
6689 The compiler may move the addition back before the volatile @code{asm}. To 
6690 make it work as expected, add an artificial dependency to the @code{asm} by 
6691 referencing a variable in the subsequent code, for example: 
6693 @example
6694 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6695 sum = x + y;
6696 @end example
6698 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6699 assembly code when optimizing. This can lead to unexpected duplicate symbol 
6700 errors during compilation if your asm code defines symbols or labels. Using %= 
6701 (@pxref{AssemblerTemplate}) may help resolve this problem.
6703 @anchor{AssemblerTemplate}
6704 @subsubsection Assembler Template
6705 @cindex @code{asm} assembler template
6707 An assembler template is a literal string containing assembler instructions. 
6708 The compiler will replace any references to inputs, outputs, and goto labels 
6709 in the template, and then output the resulting string to the assembler. The 
6710 string can contain any instructions recognized by the assembler, including 
6711 directives. GCC does not parse the assembler instructions 
6712 themselves and does not know what they mean or even whether they are valid 
6713 assembler input. However, it does count the statements 
6714 (@pxref{Size of an asm}).
6716 You may place multiple assembler instructions together in a single @code{asm} 
6717 string, separated by the characters normally used in assembly code for the 
6718 system. A combination that works in most places is a newline to break the 
6719 line, plus a tab character to move to the instruction field (written as 
6720 "\n\t"). Some assemblers allow semicolons as a line separator. However, note 
6721 that some assembler dialects use semicolons to start a comment. 
6723 Do not expect a sequence of @code{asm} statements to remain perfectly 
6724 consecutive after compilation, even when you are using the @code{volatile} 
6725 qualifier. If certain instructions need to remain consecutive in the output, 
6726 put them in a single multi-instruction asm statement.
6728 Accessing data from C programs without using input/output operands (such as 
6729 by using global symbols directly from the assembler template) may not work as 
6730 expected. Similarly, calling functions directly from an assembler template 
6731 requires a detailed understanding of the target assembler and ABI.
6733 Since GCC does not parse the AssemblerTemplate, it has no visibility of any 
6734 symbols it references. This may result in GCC discarding those symbols as 
6735 unreferenced unless they are also listed as input, output, or goto operands.
6737 GCC can support multiple assembler dialects (for example, GCC for i386 
6738 supports "att" and "intel" dialects) for inline assembler. In builds that 
6739 support this capability, the @option{-masm} option controls which dialect 
6740 GCC uses as its default. The hardware-specific documentation for the 
6741 @option{-masm} option contains the list of supported dialects, as well as the 
6742 default dialect if the option is not specified. This information may be 
6743 important to understand, since assembler code that works correctly when 
6744 compiled using one dialect will likely fail if compiled using another.
6746 @subsubheading Using braces in @code{asm} templates
6748 If your code needs to support multiple assembler dialects (for example, if 
6749 you are writing public headers that need to support a variety of compilation 
6750 options), use constructs of this form:
6752 @example
6753 @{ dialect0 | dialect1 | dialect2... @}
6754 @end example
6756 This construct outputs 'dialect0' when using dialect #0 to compile the code, 
6757 'dialect1' for dialect #1, etc. If there are fewer alternatives within the 
6758 braces than the number of dialects the compiler supports, the construct 
6759 outputs nothing.
6761 For example, if an i386 compiler supports two dialects (att, intel), an 
6762 assembler template such as this:
6764 @example
6765 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6766 @end example
6768 would produce the output:
6770 @example
6771 For att: "btl %[Offset],%[Base] ; jc %l2"
6772 For intel: "bt %[Base],%[Offset]; jc %l2"
6773 @end example
6775 Using that same compiler, this code:
6777 @example
6778 "xchg@{l@}\t@{%%@}ebx, %1"
6779 @end example
6781 would produce 
6783 @example
6784 For att: "xchgl\t%%ebx, %1"
6785 For intel: "xchg\tebx, %1"
6786 @end example
6788 There is no support for nesting dialect alternatives. Also, there is no 
6789 ``escape'' for an open brace (@{), so do not use open braces in an Extended 
6790 @code{asm} template other than as a dialect indicator.
6792 @subsubheading Other format strings
6794 In addition to the tokens described by the input, output, and goto operands, 
6795 there are a few special cases:
6797 @itemize
6798 @item
6799 "%%" outputs a single "%" into the assembler code.
6801 @item
6802 "%=" outputs a number that is unique to each instance of the @code{asm} 
6803 statement in the entire compilation. This option is useful when creating local 
6804 labels and referring to them multiple times in a single template that 
6805 generates multiple assembler instructions. 
6807 @end itemize
6809 @anchor{OutputOperands}
6810 @subsubsection Output Operands
6811 @cindex @code{asm} output operands
6813 An @code{asm} statement has zero or more output operands indicating the names
6814 of C variables modified by the assembler code.
6816 In this i386 example, @var{old} (referred to in the template string as 
6817 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset} 
6818 (@code{%2}) is an input:
6820 @example
6821 bool old;
6823 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6824          "sbb %0,%0"      // Use the CF to calculate old.
6825    : "=r" (old), "+rm" (*Base)
6826    : "Ir" (Offset)
6827    : "cc");
6829 return old;
6830 @end example
6832 Operands use this format:
6834 @example
6835 [ [asmSymbolicName] ] "constraint" (cvariablename)
6836 @end example
6838 @emph{asmSymbolicName}
6841 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6842 in the list of operands in the assembler template. For example if there are 
6843 three output operands, use @code{%0} in the template to refer to the first, 
6844 @code{%1} for the second, and @code{%2} for the third. When using an 
6845 asmSymbolicName, reference it by enclosing the name in square brackets 
6846 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement 
6847 that contains the definition. Any valid C variable name is acceptable, 
6848 including names already defined in the surrounding code. No two operands 
6849 within the same @code{asm} statement can use the same symbolic name.
6851 @emph{constraint}
6853 Output constraints must begin with either @code{"="} (a variable overwriting an 
6854 existing value) or @code{"+"} (when reading and writing). When using 
6855 @code{"="}, do not assume the location will contain the existing value (except 
6856 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6858 After the prefix, there must be one or more additional constraints 
6859 (@pxref{Constraints}) that describe where the value resides. Common 
6860 constraints include @code{"r"} for register and @code{"m"} for memory. 
6861 When you list more than one possible location (for example @code{"=rm"}), the 
6862 compiler chooses the most efficient one based on the current context. If you 
6863 list as many alternates as the @code{asm} statement allows, you will permit 
6864 the optimizers to produce the best possible code. If you must use a specific
6865 register, but your Machine Constraints do not provide sufficient 
6866 control to select the specific register you want, Local Reg Vars may provide 
6867 a solution (@pxref{Local Reg Vars}).
6869 @emph{cvariablename}
6871 Specifies the C variable name of the output (enclosed by parentheses). Accepts 
6872 any (non-constant) variable within scope.
6874 Remarks:
6876 The total number of input + output + goto operands has a limit of 30. Commas 
6877 separate the operands. When the compiler selects the registers to use to 
6878 represent the output operands, it will not use any of the clobbered registers 
6879 (@pxref{Clobbers}).
6881 Output operand expressions must be lvalues. The compiler cannot check whether 
6882 the operands have data types that are reasonable for the instruction being 
6883 executed. For output expressions that are not directly addressable (for 
6884 example a bit-field), the constraint must allow a register. In that case, GCC 
6885 uses the register as the output of the @code{asm}, and then stores that 
6886 register into the output. 
6888 Unless an output operand has the '@code{&}' constraint modifier 
6889 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated 
6890 input operand, on the assumption that the assembler code will consume its 
6891 inputs before producing outputs. This assumption may be false if the assembler 
6892 code actually consists of more than one instruction. In this case, use 
6893 '@code{&}' on each output operand that must not overlap an input.
6895 The same problem can occur if one output parameter (@var{a}) allows a register 
6896 constraint and another output parameter (@var{b}) allows a memory constraint.
6897 The code generated by GCC to access the memory address in @var{b} can contain
6898 registers which @emph{might} be shared by @var{a}, and GCC considers those 
6899 registers to be inputs to the asm. As above, GCC assumes that such input
6900 registers are consumed before any outputs are written. This assumption may 
6901 result in incorrect behavior if the asm writes to @var{a} before using 
6902 @var{b}. Combining the `@code{&}' constraint with the register constraint 
6903 ensures that modifying @var{a} will not affect what address is referenced by 
6904 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b} 
6905 will be undefined if @var{a} is modified before using @var{b}.
6907 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6908 instead of simply @code{%2}). Typically these qualifiers are hardware 
6909 dependent. The list of supported modifiers for i386 is found at 
6910 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6912 If the C code that follows the @code{asm} makes no use of any of the output 
6913 operands, use @code{volatile} for the @code{asm} statement to prevent the 
6914 optimizers from discarding the @code{asm} statement as unneeded 
6915 (see @ref{Volatile}).
6917 Examples:
6919 This code makes no use of the optional asmSymbolicName. Therefore it 
6920 references the first output operand as @code{%0} (were there a second, it 
6921 would be @code{%1}, etc). The number of the first input operand is one greater 
6922 than that of the last output operand. In this i386 example, that makes 
6923 @var{Mask} @code{%1}:
6925 @example
6926 uint32_t Mask = 1234;
6927 uint32_t Index;
6929   asm ("bsfl %1, %0"
6930      : "=r" (Index)
6931      : "r" (Mask)
6932      : "cc");
6933 @end example
6935 That code overwrites the variable Index ("="), placing the value in a register 
6936 ("r"). The generic "r" constraint instead of a constraint for a specific 
6937 register allows the compiler to pick the register to use, which can result 
6938 in more efficient code. This may not be possible if an assembler instruction 
6939 requires a specific register.
6941 The following i386 example uses the asmSymbolicName operand. It produces the 
6942 same result as the code above, but some may consider it more readable or more 
6943 maintainable since reordering index numbers is not necessary when adding or 
6944 removing operands. The names aIndex and aMask are only used to emphasize which 
6945 names get used where. It is acceptable to reuse the names Index and Mask.
6947 @example
6948 uint32_t Mask = 1234;
6949 uint32_t Index;
6951   asm ("bsfl %[aMask], %[aIndex]"
6952      : [aIndex] "=r" (Index)
6953      : [aMask] "r" (Mask)
6954      : "cc");
6955 @end example
6957 Here are some more examples of output operands.
6959 @example
6960 uint32_t c = 1;
6961 uint32_t d;
6962 uint32_t *e = &c;
6964 asm ("mov %[e], %[d]"
6965    : [d] "=rm" (d)
6966    : [e] "rm" (*e));
6967 @end example
6969 Here, @var{d} may either be in a register or in memory. Since the compiler 
6970 might already have the current value of the uint32_t pointed to by @var{e} 
6971 in a register, you can enable it to choose the best location
6972 for @var{d} by specifying both constraints.
6974 @anchor{InputOperands}
6975 @subsubsection Input Operands
6976 @cindex @code{asm} input operands
6977 @cindex @code{asm} expressions
6979 Input operands make inputs from C variables and expressions available to the 
6980 assembly code.
6982 Specify input operands by using the format:
6984 @example
6985 [ [asmSymbolicName] ] "constraint" (cexpression)
6986 @end example
6988 @emph{asmSymbolicName}
6990 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6991 in the list of operands, including outputs, in the assembler template. For 
6992 example, if there are two output parameters and three inputs, @code{%2} refers 
6993 to the first input, @code{%3} to the second, and @code{%4} to the third.
6994 When using an asmSymbolicName, reference it by enclosing the name in square 
6995 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm} 
6996 statement that contains the definition. Any valid C variable name is 
6997 acceptable, including names already defined in the surrounding code. No two 
6998 operands within the same @code{asm} statement can use the same symbolic name.
7000 @emph{constraint}
7002 Input constraints must be a string containing one or more constraints 
7003 (@pxref{Constraints}). When you give more than one possible constraint 
7004 (for example, @code{"irm"}), the compiler will choose the most efficient 
7005 method based on the current context. Input constraints may not begin with 
7006 either "=" or "+". If you must use a specific register, but your Machine
7007 Constraints do not provide sufficient control to select the specific 
7008 register you want, Local Reg Vars may provide a solution 
7009 (@pxref{Local Reg Vars}).
7011 Input constraints can also be digits (for example, @code{"0"}). This indicates 
7012 that the specified input will be in the same place as the output constraint 
7013 at the (zero-based) index in the output constraint list. When using 
7014 asmSymbolicNames for the output operands, you may use these names (enclosed 
7015 in brackets []) instead of digits.
7017 @emph{cexpression}
7019 This is the C variable or expression being passed to the @code{asm} statement 
7020 as input.
7022 When the compiler selects the registers to use to represent the input 
7023 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
7025 If there are no output operands but there are input operands, place two 
7026 consecutive colons where the output operands would go:
7028 @example
7029 __asm__ ("some instructions"
7030    : /* No outputs. */
7031    : "r" (Offset / 8);
7032 @end example
7034 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7035 (except for inputs tied to outputs). The compiler assumes that on exit from 
7036 the @code{asm} statement these operands will contain the same values as they 
7037 had before executing the assembler. It is @emph{not} possible to use Clobbers 
7038 to inform the compiler that the values in these inputs are changing. One 
7039 common work-around is to tie the changing input variable to an output variable 
7040 that never gets used. Note, however, that if the code that follows the 
7041 @code{asm} statement makes no use of any of the output operands, the GCC 
7042 optimizers may discard the @code{asm} statement as unneeded 
7043 (see @ref{Volatile}).
7045 Remarks:
7047 The total number of input + output + goto operands has a limit of 30.
7049 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
7050 instead of simply @code{%2}). Typically these qualifiers are hardware 
7051 dependent. The list of supported modifiers for i386 is found at 
7052 @ref{i386Operandmodifiers,i386 Operand modifiers}.
7054 Examples:
7056 In this example using the fictitious @code{combine} instruction, the 
7057 constraint @code{"0"} for input operand 1 says that it must occupy the same 
7058 location as output operand 0. Only input operands may use numbers in 
7059 constraints, and they must each refer to an output operand. Only a number (or 
7060 the symbolic assembler name) in the constraint can guarantee that one operand 
7061 is in the same place as another. The mere fact that @var{foo} is the value of 
7062 both operands is not enough to guarantee that they are in the same place in 
7063 the generated assembler code.
7065 @example
7066 asm ("combine %2, %0" 
7067    : "=r" (foo) 
7068    : "0" (foo), "g" (bar));
7069 @end example
7071 Here is an example using symbolic names.
7073 @example
7074 asm ("cmoveq %1, %2, %[result]" 
7075    : [result] "=r"(result) 
7076    : "r" (test), "r" (new), "[result]" (old));
7077 @end example
7079 @anchor{Clobbers}
7080 @subsubsection Clobbers
7081 @cindex @code{asm} clobbers
7083 While the compiler is aware of changes to entries listed in the output 
7084 operands, the assembler code may modify more than just the outputs. For 
7085 example, calculations may require additional registers, or the processor may 
7086 overwrite a register as a side effect of a particular assembler instruction. 
7087 In order to inform the compiler of these changes, list them in the clobber 
7088 list. Clobber list items are either register names or the special clobbers 
7089 (listed below). Each clobber list item is enclosed in double quotes and 
7090 separated by commas.
7092 Clobber descriptions may not in any way overlap with an input or output 
7093 operand. For example, you may not have an operand describing a register class 
7094 with one member when listing that register in the clobber list. Variables 
7095 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used 
7096 as @code{asm} input or output operands, must have no part mentioned in the 
7097 clobber description. In particular, there is no way to specify that input 
7098 operands get modified without also specifying them as output operands.
7100 When the compiler selects which registers to use to represent input and output 
7101 operands, it will not use any of the clobbered registers. As a result, 
7102 clobbered registers are available for any use in the assembler code.
7104 Here is a realistic example for the VAX showing the use of clobbered 
7105 registers: 
7107 @example
7108 asm volatile ("movc3 %0, %1, %2"
7109                    : /* No outputs. */
7110                    : "g" (from), "g" (to), "g" (count)
7111                    : "r0", "r1", "r2", "r3", "r4", "r5");
7112 @end example
7114 Also, there are two special clobber arguments:
7116 @enumerate
7117 @item
7118 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7119 register. On some machines, GCC represents the condition codes as a specific 
7120 hardware register; "cc" serves to name this register. On other machines, 
7121 condition code handling is different, and specifying "cc" has no effect. But 
7122 it is valid no matter what the machine.
7124 @item
7125 The "memory" clobber tells the compiler that the assembly code performs memory 
7126 reads or writes to items other than those listed in the input and output 
7127 operands (for example accessing the memory pointed to by one of the input 
7128 parameters). To ensure memory contains correct values, GCC may need to flush 
7129 specific register values to memory before executing the @code{asm}. Further, 
7130 the compiler will not assume that any values read from memory before an 
7131 @code{asm} will remain unchanged after that @code{asm}; it will reload them as 
7132 needed. This effectively forms a read/write memory barrier for the compiler.
7134 Note that this clobber does not prevent the @emph{processor} from doing 
7135 speculative reads past the @code{asm} statement. To prevent that, you need 
7136 processor-specific fence instructions.
7138 Flushing registers to memory has performance implications and may be an issue 
7139 for time-sensitive code. One trick to avoid this is available if the size of 
7140 the memory being accessed is known at compile time. For example, if accessing 
7141 ten bytes of a string, use a memory input like: 
7143 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7145 @end enumerate
7147 @anchor{GotoLabels}
7148 @subsubsection Goto Labels
7149 @cindex @code{asm} goto labels
7151 @code{asm goto} allows assembly code to jump to one or more C labels. The 
7152 GotoLabels section in an @code{asm goto} statement contains a comma-separated 
7153 list of all C labels to which the assembler code may jump. GCC assumes that 
7154 @code{asm} execution falls through to the next statement (if this is not the 
7155 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7156 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7157 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7158 Attributes}). The total number of input + output + goto operands has 
7159 a limit of 30.
7161 An @code{asm goto} statement can not have outputs (which means that the 
7162 statement is implicitly volatile). This is due to an internal restriction of 
7163 the compiler: control transfer instructions cannot have outputs. If the 
7164 assembler code does modify anything, use the "memory" clobber to force the 
7165 optimizers to flush all register values to memory, and reload them if 
7166 necessary, after the @code{asm} statement.
7168 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed 
7169 by its (zero-based) position in GotoLabels plus the number of input 
7170 arguments.  For example, if the @code{asm} has three inputs and references two 
7171 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7173 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7174 GCC's optimizers do not know about these jumps; therefore they cannot take 
7175 account of them when deciding how to optimize.
7177 Example code for i386 might look like:
7179 @example
7180 asm goto (
7181     "btl %1, %0\n\t"
7182     "jc %l2"
7183     : /* No outputs. */
7184     : "r" (p1), "r" (p2) 
7185     : "cc" 
7186     : carry);
7188 return 0;
7190 carry:
7191 return 1;
7192 @end example
7194 The following example shows an @code{asm goto} that uses the memory clobber.
7196 @example
7197 int frob(int x)
7199   int y;
7200   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7201             : /* No outputs. */
7202             : "r"(x), "r"(&y)
7203             : "r5", "memory" 
7204             : error);
7205   return y;
7206 error:
7207   return -1;
7209 @end example
7211 @anchor{i386Operandmodifiers}
7212 @subsubsection i386 Operand modifiers
7214 Input, output, and goto operands for extended @code{asm} statements can use 
7215 modifiers to affect the code output to the assembler. For example, the 
7216 following code uses the "h" and "b" modifiers for i386:
7218 @example
7219 uint16_t  num;
7220 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7221 @end example
7223 These modifiers generate this assembler code:
7225 @example
7226 xchg %ah, %al
7227 @end example
7229 The rest of this discussion uses the following code for illustrative purposes.
7231 @example
7232 int main()
7234    int iInt = 1;
7236 top:
7238    asm volatile goto ("some assembler instructions here"
7239    : /* No outputs. */
7240    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7241    : /* No clobbers. */
7242    : top);
7244 @end example
7246 With no modifiers, this is what the output from the operands would be for the 
7247 att and intel dialects of assembler:
7249 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7250 @headitem Operand @tab masm=att @tab masm=intel
7251 @item @code{%0}
7252 @tab @code{%eax}
7253 @tab @code{eax}
7254 @item @code{%1}
7255 @tab @code{$2}
7256 @tab @code{2}
7257 @item @code{%2}
7258 @tab @code{$.L2}
7259 @tab @code{OFFSET FLAT:.L2}
7260 @end multitable
7262 The table below shows the list of supported modifiers and their effects.
7264 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7265 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7266 @item @code{z}
7267 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7268 @tab @code{%z0}
7269 @tab @code{l}
7270 @tab 
7271 @item @code{b}
7272 @tab Print the QImode name of the register.
7273 @tab @code{%b0}
7274 @tab @code{%al}
7275 @tab @code{al}
7276 @item @code{h}
7277 @tab Print the QImode name for a ``high'' register.
7278 @tab @code{%h0}
7279 @tab @code{%ah}
7280 @tab @code{ah}
7281 @item @code{w}
7282 @tab Print the HImode name of the register.
7283 @tab @code{%w0}
7284 @tab @code{%ax}
7285 @tab @code{ax}
7286 @item @code{k}
7287 @tab Print the SImode name of the register.
7288 @tab @code{%k0}
7289 @tab @code{%eax}
7290 @tab @code{eax}
7291 @item @code{q}
7292 @tab Print the DImode name of the register.
7293 @tab @code{%q0}
7294 @tab @code{%rax}
7295 @tab @code{rax}
7296 @item @code{l}
7297 @tab Print the label name with no punctuation.
7298 @tab @code{%l2}
7299 @tab @code{.L2}
7300 @tab @code{.L2}
7301 @item @code{c}
7302 @tab Require a constant operand and print the constant expression with no punctuation.
7303 @tab @code{%c1}
7304 @tab @code{2}
7305 @tab @code{2}
7306 @end multitable
7308 @anchor{i386floatingpointasmoperands}
7309 @subsubsection i386 floating-point asm operands
7311 On i386 targets, there are several rules on the usage of stack-like registers
7312 in the operands of an @code{asm}.  These rules apply only to the operands
7313 that are stack-like registers:
7315 @enumerate
7316 @item
7317 Given a set of input registers that die in an @code{asm}, it is
7318 necessary to know which are implicitly popped by the @code{asm}, and
7319 which must be explicitly popped by GCC@.
7321 An input register that is implicitly popped by the @code{asm} must be
7322 explicitly clobbered, unless it is constrained to match an
7323 output operand.
7325 @item
7326 For any input register that is implicitly popped by an @code{asm}, it is
7327 necessary to know how to adjust the stack to compensate for the pop.
7328 If any non-popped input is closer to the top of the reg-stack than
7329 the implicitly popped register, it would not be possible to know what the
7330 stack looked like---it's not clear how the rest of the stack ``slides
7331 up''.
7333 All implicitly popped input registers must be closer to the top of
7334 the reg-stack than any input that is not implicitly popped.
7336 It is possible that if an input dies in an @code{asm}, the compiler might
7337 use the input register for an output reload.  Consider this example:
7339 @smallexample
7340 asm ("foo" : "=t" (a) : "f" (b));
7341 @end smallexample
7343 @noindent
7344 This code says that input @code{b} is not popped by the @code{asm}, and that
7345 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7346 deeper after the @code{asm} than it was before.  But, it is possible that
7347 reload may think that it can use the same register for both the input and
7348 the output.
7350 To prevent this from happening,
7351 if any input operand uses the @code{f} constraint, all output register
7352 constraints must use the @code{&} early-clobber modifier.
7354 The example above would be correctly written as:
7356 @smallexample
7357 asm ("foo" : "=&t" (a) : "f" (b));
7358 @end smallexample
7360 @item
7361 Some operands need to be in particular places on the stack.  All
7362 output operands fall in this category---GCC has no other way to
7363 know which registers the outputs appear in unless you indicate
7364 this in the constraints.
7366 Output operands must specifically indicate which register an output
7367 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
7368 constraints must select a class with a single register.
7370 @item
7371 Output operands may not be ``inserted'' between existing stack registers.
7372 Since no 387 opcode uses a read/write operand, all output operands
7373 are dead before the @code{asm}, and are pushed by the @code{asm}.
7374 It makes no sense to push anywhere but the top of the reg-stack.
7376 Output operands must start at the top of the reg-stack: output
7377 operands may not ``skip'' a register.
7379 @item
7380 Some @code{asm} statements may need extra stack space for internal
7381 calculations.  This can be guaranteed by clobbering stack registers
7382 unrelated to the inputs and outputs.
7384 @end enumerate
7386 Here are a couple of reasonable @code{asm}s to want to write.  This
7387 @code{asm}
7388 takes one input, which is internally popped, and produces two outputs.
7390 @smallexample
7391 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7392 @end smallexample
7394 @noindent
7395 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7396 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7397 for the compiler to know that @code{fyl2xp1} pops both inputs.
7399 @smallexample
7400 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7401 @end smallexample
7403 @lowersections
7404 @include md.texi
7405 @raisesections
7407 @node Asm Labels
7408 @subsection Controlling Names Used in Assembler Code
7409 @cindex assembler names for identifiers
7410 @cindex names used in assembler code
7411 @cindex identifiers, names in assembler code
7413 You can specify the name to be used in the assembler code for a C
7414 function or variable by writing the @code{asm} (or @code{__asm__})
7415 keyword after the declarator as follows:
7417 @smallexample
7418 int foo asm ("myfoo") = 2;
7419 @end smallexample
7421 @noindent
7422 This specifies that the name to be used for the variable @code{foo} in
7423 the assembler code should be @samp{myfoo} rather than the usual
7424 @samp{_foo}.
7426 On systems where an underscore is normally prepended to the name of a C
7427 function or variable, this feature allows you to define names for the
7428 linker that do not start with an underscore.
7430 It does not make sense to use this feature with a non-static local
7431 variable since such variables do not have assembler names.  If you are
7432 trying to put the variable in a particular register, see @ref{Explicit
7433 Reg Vars}.  GCC presently accepts such code with a warning, but will
7434 probably be changed to issue an error, rather than a warning, in the
7435 future.
7437 You cannot use @code{asm} in this way in a function @emph{definition}; but
7438 you can get the same effect by writing a declaration for the function
7439 before its definition and putting @code{asm} there, like this:
7441 @smallexample
7442 extern func () asm ("FUNC");
7444 func (x, y)
7445      int x, y;
7446 /* @r{@dots{}} */
7447 @end smallexample
7449 It is up to you to make sure that the assembler names you choose do not
7450 conflict with any other assembler symbols.  Also, you must not use a
7451 register name; that would produce completely invalid assembler code.  GCC
7452 does not as yet have the ability to store static variables in registers.
7453 Perhaps that will be added.
7455 @node Explicit Reg Vars
7456 @subsection Variables in Specified Registers
7457 @cindex explicit register variables
7458 @cindex variables in specified registers
7459 @cindex specified registers
7460 @cindex registers, global allocation
7462 GNU C allows you to put a few global variables into specified hardware
7463 registers.  You can also specify the register in which an ordinary
7464 register variable should be allocated.
7466 @itemize @bullet
7467 @item
7468 Global register variables reserve registers throughout the program.
7469 This may be useful in programs such as programming language
7470 interpreters that have a couple of global variables that are accessed
7471 very often.
7473 @item
7474 Local register variables in specific registers do not reserve the
7475 registers, except at the point where they are used as input or output
7476 operands in an @code{asm} statement and the @code{asm} statement itself is
7477 not deleted.  The compiler's data flow analysis is capable of determining
7478 where the specified registers contain live values, and where they are
7479 available for other uses.  Stores into local register variables may be deleted
7480 when they appear to be dead according to dataflow analysis.  References
7481 to local register variables may be deleted or moved or simplified.
7483 These local variables are sometimes convenient for use with the extended
7484 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7485 output of the assembler instruction directly into a particular register.
7486 (This works provided the register you specify fits the constraints
7487 specified for that operand in the @code{asm}.)
7488 @end itemize
7490 @menu
7491 * Global Reg Vars::
7492 * Local Reg Vars::
7493 @end menu
7495 @node Global Reg Vars
7496 @subsubsection Defining Global Register Variables
7497 @cindex global register variables
7498 @cindex registers, global variables in
7500 You can define a global register variable in GNU C like this:
7502 @smallexample
7503 register int *foo asm ("a5");
7504 @end smallexample
7506 @noindent
7507 Here @code{a5} is the name of the register that should be used.  Choose a
7508 register that is normally saved and restored by function calls on your
7509 machine, so that library routines will not clobber it.
7511 Naturally the register name is cpu-dependent, so you need to
7512 conditionalize your program according to cpu type.  The register
7513 @code{a5} is a good choice on a 68000 for a variable of pointer
7514 type.  On machines with register windows, be sure to choose a ``global''
7515 register that is not affected magically by the function call mechanism.
7517 In addition, different operating systems on the same CPU may differ in how they
7518 name the registers; then you need additional conditionals.  For
7519 example, some 68000 operating systems call this register @code{%a5}.
7521 Eventually there may be a way of asking the compiler to choose a register
7522 automatically, but first we need to figure out how it should choose and
7523 how to enable you to guide the choice.  No solution is evident.
7525 Defining a global register variable in a certain register reserves that
7526 register entirely for this use, at least within the current compilation.
7527 The register is not allocated for any other purpose in the functions
7528 in the current compilation, and is not saved and restored by
7529 these functions.  Stores into this register are never deleted even if they
7530 appear to be dead, but references may be deleted or moved or
7531 simplified.
7533 It is not safe to access the global register variables from signal
7534 handlers, or from more than one thread of control, because the system
7535 library routines may temporarily use the register for other things (unless
7536 you recompile them specially for the task at hand).
7538 @cindex @code{qsort}, and global register variables
7539 It is not safe for one function that uses a global register variable to
7540 call another such function @code{foo} by way of a third function
7541 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7542 different source file in which the variable isn't declared).  This is
7543 because @code{lose} might save the register and put some other value there.
7544 For example, you can't expect a global register variable to be available in
7545 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7546 might have put something else in that register.  (If you are prepared to
7547 recompile @code{qsort} with the same global register variable, you can
7548 solve this problem.)
7550 If you want to recompile @code{qsort} or other source files that do not
7551 actually use your global register variable, so that they do not use that
7552 register for any other purpose, then it suffices to specify the compiler
7553 option @option{-ffixed-@var{reg}}.  You need not actually add a global
7554 register declaration to their source code.
7556 A function that can alter the value of a global register variable cannot
7557 safely be called from a function compiled without this variable, because it
7558 could clobber the value the caller expects to find there on return.
7559 Therefore, the function that is the entry point into the part of the
7560 program that uses the global register variable must explicitly save and
7561 restore the value that belongs to its caller.
7563 @cindex register variable after @code{longjmp}
7564 @cindex global register after @code{longjmp}
7565 @cindex value after @code{longjmp}
7566 @findex longjmp
7567 @findex setjmp
7568 On most machines, @code{longjmp} restores to each global register
7569 variable the value it had at the time of the @code{setjmp}.  On some
7570 machines, however, @code{longjmp} does not change the value of global
7571 register variables.  To be portable, the function that called @code{setjmp}
7572 should make other arrangements to save the values of the global register
7573 variables, and to restore them in a @code{longjmp}.  This way, the same
7574 thing happens regardless of what @code{longjmp} does.
7576 All global register variable declarations must precede all function
7577 definitions.  If such a declaration could appear after function
7578 definitions, the declaration would be too late to prevent the register from
7579 being used for other purposes in the preceding functions.
7581 Global register variables may not have initial values, because an
7582 executable file has no means to supply initial contents for a register.
7584 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7585 registers, but certain library functions, such as @code{getwd}, as well
7586 as the subroutines for division and remainder, modify g3 and g4.  g1 and
7587 g2 are local temporaries.
7589 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7590 Of course, it does not do to use more than a few of those.
7592 @node Local Reg Vars
7593 @subsubsection Specifying Registers for Local Variables
7594 @cindex local variables, specifying registers
7595 @cindex specifying registers for local variables
7596 @cindex registers for local variables
7598 You can define a local register variable with a specified register
7599 like this:
7601 @smallexample
7602 register int *foo asm ("a5");
7603 @end smallexample
7605 @noindent
7606 Here @code{a5} is the name of the register that should be used.  Note
7607 that this is the same syntax used for defining global register
7608 variables, but for a local variable it appears within a function.
7610 Naturally the register name is cpu-dependent, but this is not a
7611 problem, since specific registers are most often useful with explicit
7612 assembler instructions (@pxref{Extended Asm}).  Both of these things
7613 generally require that you conditionalize your program according to
7614 cpu type.
7616 In addition, operating systems on one type of cpu may differ in how they
7617 name the registers; then you need additional conditionals.  For
7618 example, some 68000 operating systems call this register @code{%a5}.
7620 Defining such a register variable does not reserve the register; it
7621 remains available for other uses in places where flow control determines
7622 the variable's value is not live.
7624 This option does not guarantee that GCC generates code that has
7625 this variable in the register you specify at all times.  You may not
7626 code an explicit reference to this register in the @emph{assembler
7627 instruction template} part of an @code{asm} statement and assume it
7628 always refers to this variable.  However, using the variable as an
7629 @code{asm} @emph{operand} guarantees that the specified register is used
7630 for the operand.
7632 Stores into local register variables may be deleted when they appear to be dead
7633 according to dataflow analysis.  References to local register variables may
7634 be deleted or moved or simplified.
7636 As with global register variables, it is recommended that you choose a
7637 register that is normally saved and restored by function calls on
7638 your machine, so that library routines will not clobber it.  
7640 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
7641 specific register, but there's no matching constraint letter for that 
7642 register. To force the operand into that register, create a local variable 
7643 and specify the register in the variable's declaration. Then use the local 
7644 variable for the asm operand and specify any constraint letter that matches 
7645 the register:
7647 @smallexample
7648 register int *p1 asm ("r0") = @dots{};
7649 register int *p2 asm ("r1") = @dots{};
7650 register int *result asm ("r0");
7651 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7652 @end smallexample
7654 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
7655 call-clobbered by subsequent code, including function calls and library calls 
7656 for arithmetic operators on other variables (for example the initialization 
7657 of p2). In this case, use temporary variables for expressions between the 
7658 register assignments:
7660 @smallexample
7661 int t1 = @dots{};
7662 register int *p1 asm ("r0") = @dots{};
7663 register int *p2 asm ("r1") = t1;
7664 register int *result asm ("r0");
7665 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7666 @end smallexample
7668 @node Size of an asm
7669 @subsection Size of an @code{asm}
7671 Some targets require that GCC track the size of each instruction used
7672 in order to generate correct code.  Because the final length of the
7673 code produced by an @code{asm} statement is only known by the
7674 assembler, GCC must make an estimate as to how big it will be.  It
7675 does this by counting the number of instructions in the pattern of the
7676 @code{asm} and multiplying that by the length of the longest
7677 instruction supported by that processor.  (When working out the number
7678 of instructions, it assumes that any occurrence of a newline or of
7679 whatever statement separator character is supported by the assembler --
7680 typically @samp{;} --- indicates the end of an instruction.)
7682 Normally, GCC's estimate is adequate to ensure that correct
7683 code is generated, but it is possible to confuse the compiler if you use
7684 pseudo instructions or assembler macros that expand into multiple real
7685 instructions, or if you use assembler directives that expand to more
7686 space in the object file than is needed for a single instruction.
7687 If this happens then the assembler may produce a diagnostic saying that
7688 a label is unreachable.
7690 @node Alternate Keywords
7691 @section Alternate Keywords
7692 @cindex alternate keywords
7693 @cindex keywords, alternate
7695 @option{-ansi} and the various @option{-std} options disable certain
7696 keywords.  This causes trouble when you want to use GNU C extensions, or
7697 a general-purpose header file that should be usable by all programs,
7698 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
7699 @code{inline} are not available in programs compiled with
7700 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7701 program compiled with @option{-std=c99} or @option{-std=c11}).  The
7702 ISO C99 keyword
7703 @code{restrict} is only available when @option{-std=gnu99} (which will
7704 eventually be the default) or @option{-std=c99} (or the equivalent
7705 @option{-std=iso9899:1999}), or an option for a later standard
7706 version, is used.
7708 The way to solve these problems is to put @samp{__} at the beginning and
7709 end of each problematical keyword.  For example, use @code{__asm__}
7710 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7712 Other C compilers won't accept these alternative keywords; if you want to
7713 compile with another compiler, you can define the alternate keywords as
7714 macros to replace them with the customary keywords.  It looks like this:
7716 @smallexample
7717 #ifndef __GNUC__
7718 #define __asm__ asm
7719 #endif
7720 @end smallexample
7722 @findex __extension__
7723 @opindex pedantic
7724 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7725 You can
7726 prevent such warnings within one expression by writing
7727 @code{__extension__} before the expression.  @code{__extension__} has no
7728 effect aside from this.
7730 @node Incomplete Enums
7731 @section Incomplete @code{enum} Types
7733 You can define an @code{enum} tag without specifying its possible values.
7734 This results in an incomplete type, much like what you get if you write
7735 @code{struct foo} without describing the elements.  A later declaration
7736 that does specify the possible values completes the type.
7738 You can't allocate variables or storage using the type while it is
7739 incomplete.  However, you can work with pointers to that type.
7741 This extension may not be very useful, but it makes the handling of
7742 @code{enum} more consistent with the way @code{struct} and @code{union}
7743 are handled.
7745 This extension is not supported by GNU C++.
7747 @node Function Names
7748 @section Function Names as Strings
7749 @cindex @code{__func__} identifier
7750 @cindex @code{__FUNCTION__} identifier
7751 @cindex @code{__PRETTY_FUNCTION__} identifier
7753 GCC provides three magic variables that hold the name of the current
7754 function, as a string.  The first of these is @code{__func__}, which
7755 is part of the C99 standard:
7757 The identifier @code{__func__} is implicitly declared by the translator
7758 as if, immediately following the opening brace of each function
7759 definition, the declaration
7761 @smallexample
7762 static const char __func__[] = "function-name";
7763 @end smallexample
7765 @noindent
7766 appeared, where function-name is the name of the lexically-enclosing
7767 function.  This name is the unadorned name of the function.
7769 @code{__FUNCTION__} is another name for @code{__func__}.  Older
7770 versions of GCC recognize only this name.  However, it is not
7771 standardized.  For maximum portability, we recommend you use
7772 @code{__func__}, but provide a fallback definition with the
7773 preprocessor:
7775 @smallexample
7776 #if __STDC_VERSION__ < 199901L
7777 # if __GNUC__ >= 2
7778 #  define __func__ __FUNCTION__
7779 # else
7780 #  define __func__ "<unknown>"
7781 # endif
7782 #endif
7783 @end smallexample
7785 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7786 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
7787 the type signature of the function as well as its bare name.  For
7788 example, this program:
7790 @smallexample
7791 extern "C" @{
7792 extern int printf (char *, ...);
7795 class a @{
7796  public:
7797   void sub (int i)
7798     @{
7799       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7800       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7801     @}
7805 main (void)
7807   a ax;
7808   ax.sub (0);
7809   return 0;
7811 @end smallexample
7813 @noindent
7814 gives this output:
7816 @smallexample
7817 __FUNCTION__ = sub
7818 __PRETTY_FUNCTION__ = void a::sub(int)
7819 @end smallexample
7821 These identifiers are not preprocessor macros.  In GCC 3.3 and
7822 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7823 were treated as string literals; they could be used to initialize
7824 @code{char} arrays, and they could be concatenated with other string
7825 literals.  GCC 3.4 and later treat them as variables, like
7826 @code{__func__}.  In C++, @code{__FUNCTION__} and
7827 @code{__PRETTY_FUNCTION__} have always been variables.
7829 @node Return Address
7830 @section Getting the Return or Frame Address of a Function
7832 These functions may be used to get information about the callers of a
7833 function.
7835 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7836 This function returns the return address of the current function, or of
7837 one of its callers.  The @var{level} argument is number of frames to
7838 scan up the call stack.  A value of @code{0} yields the return address
7839 of the current function, a value of @code{1} yields the return address
7840 of the caller of the current function, and so forth.  When inlining
7841 the expected behavior is that the function returns the address of
7842 the function that is returned to.  To work around this behavior use
7843 the @code{noinline} function attribute.
7845 The @var{level} argument must be a constant integer.
7847 On some machines it may be impossible to determine the return address of
7848 any function other than the current one; in such cases, or when the top
7849 of the stack has been reached, this function returns @code{0} or a
7850 random value.  In addition, @code{__builtin_frame_address} may be used
7851 to determine if the top of the stack has been reached.
7853 Additional post-processing of the returned value may be needed, see
7854 @code{__builtin_extract_return_addr}.
7856 This function should only be used with a nonzero argument for debugging
7857 purposes.
7858 @end deftypefn
7860 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7861 The address as returned by @code{__builtin_return_address} may have to be fed
7862 through this function to get the actual encoded address.  For example, on the
7863 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7864 platforms an offset has to be added for the true next instruction to be
7865 executed.
7867 If no fixup is needed, this function simply passes through @var{addr}.
7868 @end deftypefn
7870 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7871 This function does the reverse of @code{__builtin_extract_return_addr}.
7872 @end deftypefn
7874 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7875 This function is similar to @code{__builtin_return_address}, but it
7876 returns the address of the function frame rather than the return address
7877 of the function.  Calling @code{__builtin_frame_address} with a value of
7878 @code{0} yields the frame address of the current function, a value of
7879 @code{1} yields the frame address of the caller of the current function,
7880 and so forth.
7882 The frame is the area on the stack that holds local variables and saved
7883 registers.  The frame address is normally the address of the first word
7884 pushed on to the stack by the function.  However, the exact definition
7885 depends upon the processor and the calling convention.  If the processor
7886 has a dedicated frame pointer register, and the function has a frame,
7887 then @code{__builtin_frame_address} returns the value of the frame
7888 pointer register.
7890 On some machines it may be impossible to determine the frame address of
7891 any function other than the current one; in such cases, or when the top
7892 of the stack has been reached, this function returns @code{0} if
7893 the first frame pointer is properly initialized by the startup code.
7895 This function should only be used with a nonzero argument for debugging
7896 purposes.
7897 @end deftypefn
7899 @node Vector Extensions
7900 @section Using Vector Instructions through Built-in Functions
7902 On some targets, the instruction set contains SIMD vector instructions which
7903 operate on multiple values contained in one large register at the same time.
7904 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7905 this way.
7907 The first step in using these extensions is to provide the necessary data
7908 types.  This should be done using an appropriate @code{typedef}:
7910 @smallexample
7911 typedef int v4si __attribute__ ((vector_size (16)));
7912 @end smallexample
7914 @noindent
7915 The @code{int} type specifies the base type, while the attribute specifies
7916 the vector size for the variable, measured in bytes.  For example, the
7917 declaration above causes the compiler to set the mode for the @code{v4si}
7918 type to be 16 bytes wide and divided into @code{int} sized units.  For
7919 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7920 corresponding mode of @code{foo} is @acronym{V4SI}.
7922 The @code{vector_size} attribute is only applicable to integral and
7923 float scalars, although arrays, pointers, and function return values
7924 are allowed in conjunction with this construct. Only sizes that are
7925 a power of two are currently allowed.
7927 All the basic integer types can be used as base types, both as signed
7928 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7929 @code{long long}.  In addition, @code{float} and @code{double} can be
7930 used to build floating-point vector types.
7932 Specifying a combination that is not valid for the current architecture
7933 causes GCC to synthesize the instructions using a narrower mode.
7934 For example, if you specify a variable of type @code{V4SI} and your
7935 architecture does not allow for this specific SIMD type, GCC
7936 produces code that uses 4 @code{SIs}.
7938 The types defined in this manner can be used with a subset of normal C
7939 operations.  Currently, GCC allows using the following operators
7940 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7942 The operations behave like C++ @code{valarrays}.  Addition is defined as
7943 the addition of the corresponding elements of the operands.  For
7944 example, in the code below, each of the 4 elements in @var{a} is
7945 added to the corresponding 4 elements in @var{b} and the resulting
7946 vector is stored in @var{c}.
7948 @smallexample
7949 typedef int v4si __attribute__ ((vector_size (16)));
7951 v4si a, b, c;
7953 c = a + b;
7954 @end smallexample
7956 Subtraction, multiplication, division, and the logical operations
7957 operate in a similar manner.  Likewise, the result of using the unary
7958 minus or complement operators on a vector type is a vector whose
7959 elements are the negative or complemented values of the corresponding
7960 elements in the operand.
7962 It is possible to use shifting operators @code{<<}, @code{>>} on
7963 integer-type vectors. The operation is defined as following: @code{@{a0,
7964 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7965 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7966 elements. 
7968 For convenience, it is allowed to use a binary vector operation
7969 where one operand is a scalar. In that case the compiler transforms
7970 the scalar operand into a vector where each element is the scalar from
7971 the operation. The transformation happens only if the scalar could be
7972 safely converted to the vector-element type.
7973 Consider the following code.
7975 @smallexample
7976 typedef int v4si __attribute__ ((vector_size (16)));
7978 v4si a, b, c;
7979 long l;
7981 a = b + 1;    /* a = b + @{1,1,1,1@}; */
7982 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
7984 a = l + a;    /* Error, cannot convert long to int. */
7985 @end smallexample
7987 Vectors can be subscripted as if the vector were an array with
7988 the same number of elements and base type.  Out of bound accesses
7989 invoke undefined behavior at run time.  Warnings for out of bound
7990 accesses for vector subscription can be enabled with
7991 @option{-Warray-bounds}.
7993 Vector comparison is supported with standard comparison
7994 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7995 vector expressions of integer-type or real-type. Comparison between
7996 integer-type vectors and real-type vectors are not supported.  The
7997 result of the comparison is a vector of the same width and number of
7998 elements as the comparison operands with a signed integral element
7999 type.
8001 Vectors are compared element-wise producing 0 when comparison is false
8002 and -1 (constant of the appropriate type where all bits are set)
8003 otherwise. Consider the following example.
8005 @smallexample
8006 typedef int v4si __attribute__ ((vector_size (16)));
8008 v4si a = @{1,2,3,4@};
8009 v4si b = @{3,2,1,4@};
8010 v4si c;
8012 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
8013 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
8014 @end smallexample
8016 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8017 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8018 integer vector with the same number of elements of the same size as @code{b}
8019 and @code{c}, computes all three arguments and creates a vector
8020 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
8021 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8022 As in the case of binary operations, this syntax is also accepted when
8023 one of @code{b} or @code{c} is a scalar that is then transformed into a
8024 vector. If both @code{b} and @code{c} are scalars and the type of
8025 @code{true?b:c} has the same size as the element type of @code{a}, then
8026 @code{b} and @code{c} are converted to a vector type whose elements have
8027 this type and with the same number of elements as @code{a}.
8029 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8030 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8031 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8032 For mixed operations between a scalar @code{s} and a vector @code{v},
8033 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8034 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8036 Vector shuffling is available using functions
8037 @code{__builtin_shuffle (vec, mask)} and
8038 @code{__builtin_shuffle (vec0, vec1, mask)}.
8039 Both functions construct a permutation of elements from one or two
8040 vectors and return a vector of the same type as the input vector(s).
8041 The @var{mask} is an integral vector with the same width (@var{W})
8042 and element count (@var{N}) as the output vector.
8044 The elements of the input vectors are numbered in memory ordering of
8045 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8046 elements of @var{mask} are considered modulo @var{N} in the single-operand
8047 case and modulo @math{2*@var{N}} in the two-operand case.
8049 Consider the following example,
8051 @smallexample
8052 typedef int v4si __attribute__ ((vector_size (16)));
8054 v4si a = @{1,2,3,4@};
8055 v4si b = @{5,6,7,8@};
8056 v4si mask1 = @{0,1,1,3@};
8057 v4si mask2 = @{0,4,2,5@};
8058 v4si res;
8060 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
8061 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
8062 @end smallexample
8064 Note that @code{__builtin_shuffle} is intentionally semantically
8065 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8067 You can declare variables and use them in function calls and returns, as
8068 well as in assignments and some casts.  You can specify a vector type as
8069 a return type for a function.  Vector types can also be used as function
8070 arguments.  It is possible to cast from one vector type to another,
8071 provided they are of the same size (in fact, you can also cast vectors
8072 to and from other datatypes of the same size).
8074 You cannot operate between vectors of different lengths or different
8075 signedness without a cast.
8077 @node Offsetof
8078 @section Offsetof
8079 @findex __builtin_offsetof
8081 GCC implements for both C and C++ a syntactic extension to implement
8082 the @code{offsetof} macro.
8084 @smallexample
8085 primary:
8086         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8088 offsetof_member_designator:
8089           @code{identifier}
8090         | offsetof_member_designator "." @code{identifier}
8091         | offsetof_member_designator "[" @code{expr} "]"
8092 @end smallexample
8094 This extension is sufficient such that
8096 @smallexample
8097 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8098 @end smallexample
8100 @noindent
8101 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8102 may be dependent.  In either case, @var{member} may consist of a single
8103 identifier, or a sequence of member accesses and array references.
8105 @node __sync Builtins
8106 @section Legacy __sync Built-in Functions for Atomic Memory Access
8108 The following built-in functions
8109 are intended to be compatible with those described
8110 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8111 section 7.4.  As such, they depart from the normal GCC practice of using
8112 the @samp{__builtin_} prefix, and further that they are overloaded such that
8113 they work on multiple types.
8115 The definition given in the Intel documentation allows only for the use of
8116 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
8117 counterparts.  GCC allows any integral scalar or pointer type that is
8118 1, 2, 4 or 8 bytes in length.
8120 Not all operations are supported by all target processors.  If a particular
8121 operation cannot be implemented on the target processor, a warning is
8122 generated and a call an external function is generated.  The external
8123 function carries the same name as the built-in version,
8124 with an additional suffix
8125 @samp{_@var{n}} where @var{n} is the size of the data type.
8127 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8128 @c useful for implementing the operation under the control of an external
8129 @c mutex.
8131 In most cases, these built-in functions are considered a @dfn{full barrier}.
8132 That is,
8133 no memory operand is moved across the operation, either forward or
8134 backward.  Further, instructions are issued as necessary to prevent the
8135 processor from speculating loads across the operation and from queuing stores
8136 after the operation.
8138 All of the routines are described in the Intel documentation to take
8139 ``an optional list of variables protected by the memory barrier''.  It's
8140 not clear what is meant by that; it could mean that @emph{only} the
8141 following variables are protected, or it could mean that these variables
8142 should in addition be protected.  At present GCC ignores this list and
8143 protects all variables that are globally accessible.  If in the future
8144 we make some use of this list, an empty list will continue to mean all
8145 globally accessible variables.
8147 @table @code
8148 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8149 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8150 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8151 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8152 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8153 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8154 @findex __sync_fetch_and_add
8155 @findex __sync_fetch_and_sub
8156 @findex __sync_fetch_and_or
8157 @findex __sync_fetch_and_and
8158 @findex __sync_fetch_and_xor
8159 @findex __sync_fetch_and_nand
8160 These built-in functions perform the operation suggested by the name, and
8161 returns the value that had previously been in memory.  That is,
8163 @smallexample
8164 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8165 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8166 @end smallexample
8168 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8169 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8171 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8172 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8173 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8174 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8175 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8176 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8177 @findex __sync_add_and_fetch
8178 @findex __sync_sub_and_fetch
8179 @findex __sync_or_and_fetch
8180 @findex __sync_and_and_fetch
8181 @findex __sync_xor_and_fetch
8182 @findex __sync_nand_and_fetch
8183 These built-in functions perform the operation suggested by the name, and
8184 return the new value.  That is,
8186 @smallexample
8187 @{ *ptr @var{op}= value; return *ptr; @}
8188 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8189 @end smallexample
8191 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8192 as @code{*ptr = ~(*ptr & value)} instead of
8193 @code{*ptr = ~*ptr & value}.
8195 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8196 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8197 @findex __sync_bool_compare_and_swap
8198 @findex __sync_val_compare_and_swap
8199 These built-in functions perform an atomic compare and swap.
8200 That is, if the current
8201 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8202 @code{*@var{ptr}}.
8204 The ``bool'' version returns true if the comparison is successful and
8205 @var{newval} is written.  The ``val'' version returns the contents
8206 of @code{*@var{ptr}} before the operation.
8208 @item __sync_synchronize (...)
8209 @findex __sync_synchronize
8210 This built-in function issues a full memory barrier.
8212 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8213 @findex __sync_lock_test_and_set
8214 This built-in function, as described by Intel, is not a traditional test-and-set
8215 operation, but rather an atomic exchange operation.  It writes @var{value}
8216 into @code{*@var{ptr}}, and returns the previous contents of
8217 @code{*@var{ptr}}.
8219 Many targets have only minimal support for such locks, and do not support
8220 a full exchange operation.  In this case, a target may support reduced
8221 functionality here by which the @emph{only} valid value to store is the
8222 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8223 is implementation defined.
8225 This built-in function is not a full barrier,
8226 but rather an @dfn{acquire barrier}.
8227 This means that references after the operation cannot move to (or be
8228 speculated to) before the operation, but previous memory stores may not
8229 be globally visible yet, and previous memory loads may not yet be
8230 satisfied.
8232 @item void __sync_lock_release (@var{type} *ptr, ...)
8233 @findex __sync_lock_release
8234 This built-in function releases the lock acquired by
8235 @code{__sync_lock_test_and_set}.
8236 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8238 This built-in function is not a full barrier,
8239 but rather a @dfn{release barrier}.
8240 This means that all previous memory stores are globally visible, and all
8241 previous memory loads have been satisfied, but following memory reads
8242 are not prevented from being speculated to before the barrier.
8243 @end table
8245 @node __atomic Builtins
8246 @section Built-in functions for memory model aware atomic operations
8248 The following built-in functions approximately match the requirements for
8249 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8250 functions, but all also have a memory model parameter.  These are all
8251 identified by being prefixed with @samp{__atomic}, and most are overloaded
8252 such that they work with multiple types.
8254 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8255 bytes in length. 16-byte integral types are also allowed if
8256 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8258 Target architectures are encouraged to provide their own patterns for
8259 each of these built-in functions.  If no target is provided, the original 
8260 non-memory model set of @samp{__sync} atomic built-in functions are
8261 utilized, along with any required synchronization fences surrounding it in
8262 order to achieve the proper behavior.  Execution in this case is subject
8263 to the same restrictions as those built-in functions.
8265 If there is no pattern or mechanism to provide a lock free instruction
8266 sequence, a call is made to an external routine with the same parameters
8267 to be resolved at run time.
8269 The four non-arithmetic functions (load, store, exchange, and 
8270 compare_exchange) all have a generic version as well.  This generic
8271 version works on any data type.  If the data type size maps to one
8272 of the integral sizes that may have lock free support, the generic
8273 version utilizes the lock free built-in function.  Otherwise an
8274 external call is left to be resolved at run time.  This external call is
8275 the same format with the addition of a @samp{size_t} parameter inserted
8276 as the first parameter indicating the size of the object being pointed to.
8277 All objects must be the same size.
8279 There are 6 different memory models that can be specified.  These map
8280 to the same names in the C++11 standard.  Refer there or to the
8281 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8282 atomic synchronization} for more detailed definitions.  These memory
8283 models integrate both barriers to code motion as well as synchronization
8284 requirements with other threads. These are listed in approximately
8285 ascending order of strength. It is also possible to use target specific
8286 flags for memory model flags, like Hardware Lock Elision.
8288 @table  @code
8289 @item __ATOMIC_RELAXED
8290 No barriers or synchronization.
8291 @item __ATOMIC_CONSUME
8292 Data dependency only for both barrier and synchronization with another
8293 thread.
8294 @item __ATOMIC_ACQUIRE
8295 Barrier to hoisting of code and synchronizes with release (or stronger)
8296 semantic stores from another thread.
8297 @item __ATOMIC_RELEASE
8298 Barrier to sinking of code and synchronizes with acquire (or stronger)
8299 semantic loads from another thread.
8300 @item __ATOMIC_ACQ_REL
8301 Full barrier in both directions and synchronizes with acquire loads and
8302 release stores in another thread.
8303 @item __ATOMIC_SEQ_CST
8304 Full barrier in both directions and synchronizes with acquire loads and
8305 release stores in all threads.
8306 @end table
8308 When implementing patterns for these built-in functions, the memory model
8309 parameter can be ignored as long as the pattern implements the most
8310 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8311 execute correctly with this memory model but they may not execute as
8312 efficiently as they could with a more appropriate implementation of the
8313 relaxed requirements.
8315 Note that the C++11 standard allows for the memory model parameter to be
8316 determined at run time rather than at compile time.  These built-in
8317 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8318 than invoke a runtime library call or inline a switch statement.  This is
8319 standard compliant, safe, and the simplest approach for now.
8321 The memory model parameter is a signed int, but only the lower 8 bits are
8322 reserved for the memory model.  The remainder of the signed int is reserved
8323 for future use and should be 0.  Use of the predefined atomic values
8324 ensures proper usage.
8326 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8327 This built-in function implements an atomic load operation.  It returns the
8328 contents of @code{*@var{ptr}}.
8330 The valid memory model variants are
8331 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8332 and @code{__ATOMIC_CONSUME}.
8334 @end deftypefn
8336 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8337 This is the generic version of an atomic load.  It returns the
8338 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8340 @end deftypefn
8342 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8343 This built-in function implements an atomic store operation.  It writes 
8344 @code{@var{val}} into @code{*@var{ptr}}.  
8346 The valid memory model variants are
8347 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8349 @end deftypefn
8351 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8352 This is the generic version of an atomic store.  It stores the value
8353 of @code{*@var{val}} into @code{*@var{ptr}}.
8355 @end deftypefn
8357 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8358 This built-in function implements an atomic exchange operation.  It writes
8359 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8360 @code{*@var{ptr}}.
8362 The valid memory model variants are
8363 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8364 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8366 @end deftypefn
8368 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8369 This is the generic version of an atomic exchange.  It stores the
8370 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8371 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8373 @end deftypefn
8375 @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)
8376 This built-in function implements an atomic compare and exchange operation.
8377 This compares the contents of @code{*@var{ptr}} with the contents of
8378 @code{*@var{expected}} and if equal, writes @var{desired} into
8379 @code{*@var{ptr}}.  If they are not equal, the current contents of
8380 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8381 for weak compare_exchange, and false for the strong variation.  Many targets 
8382 only offer the strong variation and ignore the parameter.  When in doubt, use
8383 the strong variation.
8385 True is returned if @var{desired} is written into
8386 @code{*@var{ptr}} and the execution is considered to conform to the
8387 memory model specified by @var{success_memmodel}.  There are no
8388 restrictions on what memory model can be used here.
8390 False is returned otherwise, and the execution is considered to conform
8391 to @var{failure_memmodel}. This memory model cannot be
8392 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8393 stronger model than that specified by @var{success_memmodel}.
8395 @end deftypefn
8397 @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)
8398 This built-in function implements the generic version of
8399 @code{__atomic_compare_exchange}.  The function is virtually identical to
8400 @code{__atomic_compare_exchange_n}, except the desired value is also a
8401 pointer.
8403 @end deftypefn
8405 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8406 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8407 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8408 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8409 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8410 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8411 These built-in functions perform the operation suggested by the name, and
8412 return the result of the operation. That is,
8414 @smallexample
8415 @{ *ptr @var{op}= val; return *ptr; @}
8416 @end smallexample
8418 All memory models are valid.
8420 @end deftypefn
8422 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8423 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8424 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8425 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8426 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8427 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8428 These built-in functions perform the operation suggested by the name, and
8429 return the value that had previously been in @code{*@var{ptr}}.  That is,
8431 @smallexample
8432 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8433 @end smallexample
8435 All memory models are valid.
8437 @end deftypefn
8439 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8441 This built-in function performs an atomic test-and-set operation on
8442 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
8443 defined nonzero ``set'' value and the return value is @code{true} if and only
8444 if the previous contents were ``set''.
8445 It should be only used for operands of type @code{bool} or @code{char}. For 
8446 other types only part of the value may be set.
8448 All memory models are valid.
8450 @end deftypefn
8452 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8454 This built-in function performs an atomic clear operation on
8455 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
8456 It should be only used for operands of type @code{bool} or @code{char} and 
8457 in conjunction with @code{__atomic_test_and_set}.
8458 For other types it may only clear partially. If the type is not @code{bool}
8459 prefer using @code{__atomic_store}.
8461 The valid memory model variants are
8462 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8463 @code{__ATOMIC_RELEASE}.
8465 @end deftypefn
8467 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8469 This built-in function acts as a synchronization fence between threads
8470 based on the specified memory model.
8472 All memory orders are valid.
8474 @end deftypefn
8476 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8478 This built-in function acts as a synchronization fence between a thread
8479 and signal handlers based in the same thread.
8481 All memory orders are valid.
8483 @end deftypefn
8485 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
8487 This built-in function returns true if objects of @var{size} bytes always
8488 generate lock free atomic instructions for the target architecture.  
8489 @var{size} must resolve to a compile-time constant and the result also
8490 resolves to a compile-time constant.
8492 @var{ptr} is an optional pointer to the object that may be used to determine
8493 alignment.  A value of 0 indicates typical alignment should be used.  The 
8494 compiler may also ignore this parameter.
8496 @smallexample
8497 if (_atomic_always_lock_free (sizeof (long long), 0))
8498 @end smallexample
8500 @end deftypefn
8502 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8504 This built-in function returns true if objects of @var{size} bytes always
8505 generate lock free atomic instructions for the target architecture.  If
8506 it is not known to be lock free a call is made to a runtime routine named
8507 @code{__atomic_is_lock_free}.
8509 @var{ptr} is an optional pointer to the object that may be used to determine
8510 alignment.  A value of 0 indicates typical alignment should be used.  The 
8511 compiler may also ignore this parameter.
8512 @end deftypefn
8514 @node Integer Overflow Builtins
8515 @section Built-in functions to perform arithmetics and arithmetic overflow checking.
8517 The following built-in functions allow performing simple arithmetic operations
8518 together with checking whether the operations overflowed.
8520 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8521 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
8522 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
8523 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
8524 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
8525 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8526 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8528 These built-in functions promote the first two operands into infinite precision signed
8529 type and perform addition on those promoted operands.  The result is then
8530 cast to the type the third pointer argument points to and stored there.
8531 If the stored result is equal to the infinite precision result, the built-in
8532 functions return false, otherwise they return true.  As the addition is
8533 performed in infinite signed precision, these built-in functions have fully defined
8534 behavior for all argument values.
8536 The first built-in function allows arbitrary integral types for operands and
8537 the result type must be pointer to some integer type, the rest of the built-in
8538 functions have explicit integer types.
8540 The compiler will attempt to use hardware instructions to implement
8541 these built-in functions where possible, like conditional jump on overflow
8542 after addition, conditional jump on carry etc.
8544 @end deftypefn
8546 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8547 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
8548 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
8549 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
8550 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
8551 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8552 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8554 These built-in functions are similar to the add overflow checking built-in
8555 functions above, except they perform subtraction, subtract the second argument
8556 from the first one, instead of addition.
8558 @end deftypefn
8560 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8561 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
8562 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
8563 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
8564 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
8565 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8566 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8568 These built-in functions are similar to the add overflow checking built-in
8569 functions above, except they perform multiplication, instead of addition.
8571 @end deftypefn
8573 @node x86 specific memory model extensions for transactional memory
8574 @section x86 specific memory model extensions for transactional memory
8576 The i386 architecture supports additional memory ordering flags
8577 to mark lock critical sections for hardware lock elision. 
8578 These must be specified in addition to an existing memory model to 
8579 atomic intrinsics.
8581 @table @code
8582 @item __ATOMIC_HLE_ACQUIRE
8583 Start lock elision on a lock variable.
8584 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8585 @item __ATOMIC_HLE_RELEASE
8586 End lock elision on a lock variable.
8587 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8588 @end table
8590 When a lock acquire fails it is required for good performance to abort
8591 the transaction quickly. This can be done with a @code{_mm_pause}
8593 @smallexample
8594 #include <immintrin.h> // For _mm_pause
8596 int lockvar;
8598 /* Acquire lock with lock elision */
8599 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8600     _mm_pause(); /* Abort failed transaction */
8602 /* Free lock with lock elision */
8603 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8604 @end smallexample
8606 @node Object Size Checking
8607 @section Object Size Checking Built-in Functions
8608 @findex __builtin_object_size
8609 @findex __builtin___memcpy_chk
8610 @findex __builtin___mempcpy_chk
8611 @findex __builtin___memmove_chk
8612 @findex __builtin___memset_chk
8613 @findex __builtin___strcpy_chk
8614 @findex __builtin___stpcpy_chk
8615 @findex __builtin___strncpy_chk
8616 @findex __builtin___strcat_chk
8617 @findex __builtin___strncat_chk
8618 @findex __builtin___sprintf_chk
8619 @findex __builtin___snprintf_chk
8620 @findex __builtin___vsprintf_chk
8621 @findex __builtin___vsnprintf_chk
8622 @findex __builtin___printf_chk
8623 @findex __builtin___vprintf_chk
8624 @findex __builtin___fprintf_chk
8625 @findex __builtin___vfprintf_chk
8627 GCC implements a limited buffer overflow protection mechanism
8628 that can prevent some buffer overflow attacks.
8630 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8631 is a built-in construct that returns a constant number of bytes from
8632 @var{ptr} to the end of the object @var{ptr} pointer points to
8633 (if known at compile time).  @code{__builtin_object_size} never evaluates
8634 its arguments for side-effects.  If there are any side-effects in them, it
8635 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8636 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
8637 point to and all of them are known at compile time, the returned number
8638 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8639 0 and minimum if nonzero.  If it is not possible to determine which objects
8640 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8641 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8642 for @var{type} 2 or 3.
8644 @var{type} is an integer constant from 0 to 3.  If the least significant
8645 bit is clear, objects are whole variables, if it is set, a closest
8646 surrounding subobject is considered the object a pointer points to.
8647 The second bit determines if maximum or minimum of remaining bytes
8648 is computed.
8650 @smallexample
8651 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8652 char *p = &var.buf1[1], *q = &var.b;
8654 /* Here the object p points to is var.  */
8655 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8656 /* The subobject p points to is var.buf1.  */
8657 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8658 /* The object q points to is var.  */
8659 assert (__builtin_object_size (q, 0)
8660         == (char *) (&var + 1) - (char *) &var.b);
8661 /* The subobject q points to is var.b.  */
8662 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8663 @end smallexample
8664 @end deftypefn
8666 There are built-in functions added for many common string operation
8667 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8668 built-in is provided.  This built-in has an additional last argument,
8669 which is the number of bytes remaining in object the @var{dest}
8670 argument points to or @code{(size_t) -1} if the size is not known.
8672 The built-in functions are optimized into the normal string functions
8673 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8674 it is known at compile time that the destination object will not
8675 be overflown.  If the compiler can determine at compile time the
8676 object will be always overflown, it issues a warning.
8678 The intended use can be e.g.@:
8680 @smallexample
8681 #undef memcpy
8682 #define bos0(dest) __builtin_object_size (dest, 0)
8683 #define memcpy(dest, src, n) \
8684   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8686 char *volatile p;
8687 char buf[10];
8688 /* It is unknown what object p points to, so this is optimized
8689    into plain memcpy - no checking is possible.  */
8690 memcpy (p, "abcde", n);
8691 /* Destination is known and length too.  It is known at compile
8692    time there will be no overflow.  */
8693 memcpy (&buf[5], "abcde", 5);
8694 /* Destination is known, but the length is not known at compile time.
8695    This will result in __memcpy_chk call that can check for overflow
8696    at run time.  */
8697 memcpy (&buf[5], "abcde", n);
8698 /* Destination is known and it is known at compile time there will
8699    be overflow.  There will be a warning and __memcpy_chk call that
8700    will abort the program at run time.  */
8701 memcpy (&buf[6], "abcde", 5);
8702 @end smallexample
8704 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8705 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8706 @code{strcat} and @code{strncat}.
8708 There are also checking built-in functions for formatted output functions.
8709 @smallexample
8710 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8711 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8712                               const char *fmt, ...);
8713 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8714                               va_list ap);
8715 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8716                                const char *fmt, va_list ap);
8717 @end smallexample
8719 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8720 etc.@: functions and can contain implementation specific flags on what
8721 additional security measures the checking function might take, such as
8722 handling @code{%n} differently.
8724 The @var{os} argument is the object size @var{s} points to, like in the
8725 other built-in functions.  There is a small difference in the behavior
8726 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8727 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8728 the checking function is called with @var{os} argument set to
8729 @code{(size_t) -1}.
8731 In addition to this, there are checking built-in functions
8732 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8733 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8734 These have just one additional argument, @var{flag}, right before
8735 format string @var{fmt}.  If the compiler is able to optimize them to
8736 @code{fputc} etc.@: functions, it does, otherwise the checking function
8737 is called and the @var{flag} argument passed to it.
8739 @node Pointer Bounds Checker builtins
8740 @section Pointer Bounds Checker Built-in Functions
8741 @findex __builtin___bnd_set_ptr_bounds
8742 @findex __builtin___bnd_narrow_ptr_bounds
8743 @findex __builtin___bnd_copy_ptr_bounds
8744 @findex __builtin___bnd_init_ptr_bounds
8745 @findex __builtin___bnd_null_ptr_bounds
8746 @findex __builtin___bnd_store_ptr_bounds
8747 @findex __builtin___bnd_chk_ptr_lbounds
8748 @findex __builtin___bnd_chk_ptr_ubounds
8749 @findex __builtin___bnd_chk_ptr_bounds
8750 @findex __builtin___bnd_get_ptr_lbound
8751 @findex __builtin___bnd_get_ptr_ubound
8753 GCC provides a set of built-in functions to control Pointer Bounds Checker
8754 instrumentation.  Note that all Pointer Bounds Checker builtins are allowed
8755 to use even if you compile with Pointer Bounds Checker off.  The builtins
8756 behavior may differ in such case as documented below.
8758 @deftypefn {Built-in Function} void * __builtin___bnd_set_ptr_bounds (const void * @var{q}, size_t @var{size})
8760 This built-in function returns a new pointer with the value of @var{q}, and
8761 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
8762 Bounds Checker off built-in function just returns the first argument.
8764 @smallexample
8765 extern void *__wrap_malloc (size_t n)
8767   void *p = (void *)__real_malloc (n);
8768   if (!p) return __builtin___bnd_null_ptr_bounds (p);
8769   return __builtin___bnd_set_ptr_bounds (p, n);
8771 @end smallexample
8773 @end deftypefn
8775 @deftypefn {Built-in Function} void * __builtin___bnd_narrow_ptr_bounds (const void * @var{p}, const void * @var{q}, size_t  @var{size})
8777 This built-in function returns a new pointer with the value of @var{p}
8778 and associate it with the narrowed bounds formed by the intersection
8779 of bounds associated with @var{q} and the [@var{p}, @var{p} + @var{size} - 1].
8780 With Pointer Bounds Checker off built-in function just returns the first
8781 argument.
8783 @smallexample
8784 void init_objects (object *objs, size_t size)
8786   size_t i;
8787   /* Initialize objects one-by-one passing pointers with bounds of an object,
8788      not the full array of objects.  */
8789   for (i = 0; i < size; i++)
8790     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, sizeof(object)));
8792 @end smallexample
8794 @end deftypefn
8796 @deftypefn {Built-in Function} void * __builtin___bnd_copy_ptr_bounds (const void * @var{q}, const void * @var{r})
8798 This built-in function returns a new pointer with the value of @var{q},
8799 and associate it with the bounds already associated with pointer @var{r}.
8800 With Pointer Bounds Checker off built-in function just returns the first
8801 argument.
8803 @smallexample
8804 /* Here is a way to get pointer to object's field but
8805    still with the full object's bounds.  */
8806 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_filed, objptr);
8807 @end smallexample
8809 @end deftypefn
8811 @deftypefn {Built-in Function} void * __builtin___bnd_init_ptr_bounds (const void * @var{q})
8813 This built-in function returns a new pointer with the value of @var{q}, and
8814 associate it with INIT (allowing full memory access) bounds. With Pointer
8815 Bounds Checker off built-in function just returns the first argument.
8817 @end deftypefn
8819 @deftypefn {Built-in Function} void * __builtin___bnd_null_ptr_bounds (const void * @var{q})
8821 This built-in function returns a new pointer with the value of @var{q}, and
8822 associate it with NULL (allowing no memory access) bounds. With Pointer
8823 Bounds Checker off built-in function just returns the first argument.
8825 @end deftypefn
8827 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void ** @var{ptr_addr}, const void * @var{ptr_val})
8829 This built-in function stores the bounds associated with pointer @var{ptr_val}
8830 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
8831 bounds from legacy code without touching the associated pointer's memory when
8832 pointers were copied as integers.  With Pointer Bounds Checker off built-in
8833 function call is ignored.
8835 @end deftypefn
8837 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void * @var{q})
8839 This built-in function checks if the pointer @var{q} is within the lower
8840 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8841 function call is ignored.
8843 @smallexample
8844 extern void *__wrap_memset (void *dst, int c, size_t len)
8846   if (len > 0)
8847     @{
8848       __builtin___bnd_chk_ptr_lbounds (dst);
8849       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
8850       __real_memset (dst, c, len);
8851     @}
8852   return dst;
8854 @end smallexample
8856 @end deftypefn
8858 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void * @var{q})
8860 This built-in function checks if the pointer @var{q} is within the upper
8861 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8862 function call is ignored.
8864 @end deftypefn
8866 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void * @var{q}, size_t @var{size})
8868 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
8869 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
8870 off built-in function call is ignored.
8872 @smallexample
8873 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
8875   if (n > 0)
8876     @{
8877       __bnd_chk_ptr_bounds (dst, n);
8878       __bnd_chk_ptr_bounds (src, n);
8879       __real_memcpy (dst, src, n);
8880     @}
8881   return dst;
8883 @end smallexample
8885 @end deftypefn
8887 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_lbound (const void * @var{q})
8889 This built-in function returns the lower bound (which is a pointer) associated
8890 with the pointer @var{q}.  This is at least useful for debugging using printf.
8891 With Pointer Bounds Checker off built-in function returns 0.
8893 @smallexample
8894 void *lb = __builtin___bnd_get_ptr_lbound (q);
8895 void *ub = __builtin___bnd_get_ptr_ubound (q);
8896 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
8897 @end smallexample
8899 @end deftypefn
8901 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_ubound (const void * @var{q})
8903 This built-in function returns the upper bound (which is a pointer) associated
8904 with the pointer @var{q}.  With Pointer Bounds Checker off built-in function
8905 returns -1.
8907 @end deftypefn
8909 @node Cilk Plus Builtins
8910 @section Cilk Plus C/C++ language extension Built-in Functions.
8912 GCC provides support for the following built-in reduction funtions if Cilk Plus
8913 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8915 @itemize @bullet
8916 @item __sec_implicit_index
8917 @item __sec_reduce
8918 @item __sec_reduce_add
8919 @item __sec_reduce_all_nonzero
8920 @item __sec_reduce_all_zero
8921 @item __sec_reduce_any_nonzero
8922 @item __sec_reduce_any_zero
8923 @item __sec_reduce_max
8924 @item __sec_reduce_min
8925 @item __sec_reduce_max_ind
8926 @item __sec_reduce_min_ind
8927 @item __sec_reduce_mul
8928 @item __sec_reduce_mutating
8929 @end itemize
8931 Further details and examples about these built-in functions are described 
8932 in the Cilk Plus language manual which can be found at 
8933 @uref{http://www.cilkplus.org}.
8935 @node Other Builtins
8936 @section Other Built-in Functions Provided by GCC
8937 @cindex built-in functions
8938 @findex __builtin_call_with_static_chain
8939 @findex __builtin_fpclassify
8940 @findex __builtin_isfinite
8941 @findex __builtin_isnormal
8942 @findex __builtin_isgreater
8943 @findex __builtin_isgreaterequal
8944 @findex __builtin_isinf_sign
8945 @findex __builtin_isless
8946 @findex __builtin_islessequal
8947 @findex __builtin_islessgreater
8948 @findex __builtin_isunordered
8949 @findex __builtin_powi
8950 @findex __builtin_powif
8951 @findex __builtin_powil
8952 @findex _Exit
8953 @findex _exit
8954 @findex abort
8955 @findex abs
8956 @findex acos
8957 @findex acosf
8958 @findex acosh
8959 @findex acoshf
8960 @findex acoshl
8961 @findex acosl
8962 @findex alloca
8963 @findex asin
8964 @findex asinf
8965 @findex asinh
8966 @findex asinhf
8967 @findex asinhl
8968 @findex asinl
8969 @findex atan
8970 @findex atan2
8971 @findex atan2f
8972 @findex atan2l
8973 @findex atanf
8974 @findex atanh
8975 @findex atanhf
8976 @findex atanhl
8977 @findex atanl
8978 @findex bcmp
8979 @findex bzero
8980 @findex cabs
8981 @findex cabsf
8982 @findex cabsl
8983 @findex cacos
8984 @findex cacosf
8985 @findex cacosh
8986 @findex cacoshf
8987 @findex cacoshl
8988 @findex cacosl
8989 @findex calloc
8990 @findex carg
8991 @findex cargf
8992 @findex cargl
8993 @findex casin
8994 @findex casinf
8995 @findex casinh
8996 @findex casinhf
8997 @findex casinhl
8998 @findex casinl
8999 @findex catan
9000 @findex catanf
9001 @findex catanh
9002 @findex catanhf
9003 @findex catanhl
9004 @findex catanl
9005 @findex cbrt
9006 @findex cbrtf
9007 @findex cbrtl
9008 @findex ccos
9009 @findex ccosf
9010 @findex ccosh
9011 @findex ccoshf
9012 @findex ccoshl
9013 @findex ccosl
9014 @findex ceil
9015 @findex ceilf
9016 @findex ceill
9017 @findex cexp
9018 @findex cexpf
9019 @findex cexpl
9020 @findex cimag
9021 @findex cimagf
9022 @findex cimagl
9023 @findex clog
9024 @findex clogf
9025 @findex clogl
9026 @findex conj
9027 @findex conjf
9028 @findex conjl
9029 @findex copysign
9030 @findex copysignf
9031 @findex copysignl
9032 @findex cos
9033 @findex cosf
9034 @findex cosh
9035 @findex coshf
9036 @findex coshl
9037 @findex cosl
9038 @findex cpow
9039 @findex cpowf
9040 @findex cpowl
9041 @findex cproj
9042 @findex cprojf
9043 @findex cprojl
9044 @findex creal
9045 @findex crealf
9046 @findex creall
9047 @findex csin
9048 @findex csinf
9049 @findex csinh
9050 @findex csinhf
9051 @findex csinhl
9052 @findex csinl
9053 @findex csqrt
9054 @findex csqrtf
9055 @findex csqrtl
9056 @findex ctan
9057 @findex ctanf
9058 @findex ctanh
9059 @findex ctanhf
9060 @findex ctanhl
9061 @findex ctanl
9062 @findex dcgettext
9063 @findex dgettext
9064 @findex drem
9065 @findex dremf
9066 @findex dreml
9067 @findex erf
9068 @findex erfc
9069 @findex erfcf
9070 @findex erfcl
9071 @findex erff
9072 @findex erfl
9073 @findex exit
9074 @findex exp
9075 @findex exp10
9076 @findex exp10f
9077 @findex exp10l
9078 @findex exp2
9079 @findex exp2f
9080 @findex exp2l
9081 @findex expf
9082 @findex expl
9083 @findex expm1
9084 @findex expm1f
9085 @findex expm1l
9086 @findex fabs
9087 @findex fabsf
9088 @findex fabsl
9089 @findex fdim
9090 @findex fdimf
9091 @findex fdiml
9092 @findex ffs
9093 @findex floor
9094 @findex floorf
9095 @findex floorl
9096 @findex fma
9097 @findex fmaf
9098 @findex fmal
9099 @findex fmax
9100 @findex fmaxf
9101 @findex fmaxl
9102 @findex fmin
9103 @findex fminf
9104 @findex fminl
9105 @findex fmod
9106 @findex fmodf
9107 @findex fmodl
9108 @findex fprintf
9109 @findex fprintf_unlocked
9110 @findex fputs
9111 @findex fputs_unlocked
9112 @findex frexp
9113 @findex frexpf
9114 @findex frexpl
9115 @findex fscanf
9116 @findex gamma
9117 @findex gammaf
9118 @findex gammal
9119 @findex gamma_r
9120 @findex gammaf_r
9121 @findex gammal_r
9122 @findex gettext
9123 @findex hypot
9124 @findex hypotf
9125 @findex hypotl
9126 @findex ilogb
9127 @findex ilogbf
9128 @findex ilogbl
9129 @findex imaxabs
9130 @findex index
9131 @findex isalnum
9132 @findex isalpha
9133 @findex isascii
9134 @findex isblank
9135 @findex iscntrl
9136 @findex isdigit
9137 @findex isgraph
9138 @findex islower
9139 @findex isprint
9140 @findex ispunct
9141 @findex isspace
9142 @findex isupper
9143 @findex iswalnum
9144 @findex iswalpha
9145 @findex iswblank
9146 @findex iswcntrl
9147 @findex iswdigit
9148 @findex iswgraph
9149 @findex iswlower
9150 @findex iswprint
9151 @findex iswpunct
9152 @findex iswspace
9153 @findex iswupper
9154 @findex iswxdigit
9155 @findex isxdigit
9156 @findex j0
9157 @findex j0f
9158 @findex j0l
9159 @findex j1
9160 @findex j1f
9161 @findex j1l
9162 @findex jn
9163 @findex jnf
9164 @findex jnl
9165 @findex labs
9166 @findex ldexp
9167 @findex ldexpf
9168 @findex ldexpl
9169 @findex lgamma
9170 @findex lgammaf
9171 @findex lgammal
9172 @findex lgamma_r
9173 @findex lgammaf_r
9174 @findex lgammal_r
9175 @findex llabs
9176 @findex llrint
9177 @findex llrintf
9178 @findex llrintl
9179 @findex llround
9180 @findex llroundf
9181 @findex llroundl
9182 @findex log
9183 @findex log10
9184 @findex log10f
9185 @findex log10l
9186 @findex log1p
9187 @findex log1pf
9188 @findex log1pl
9189 @findex log2
9190 @findex log2f
9191 @findex log2l
9192 @findex logb
9193 @findex logbf
9194 @findex logbl
9195 @findex logf
9196 @findex logl
9197 @findex lrint
9198 @findex lrintf
9199 @findex lrintl
9200 @findex lround
9201 @findex lroundf
9202 @findex lroundl
9203 @findex malloc
9204 @findex memchr
9205 @findex memcmp
9206 @findex memcpy
9207 @findex mempcpy
9208 @findex memset
9209 @findex modf
9210 @findex modff
9211 @findex modfl
9212 @findex nearbyint
9213 @findex nearbyintf
9214 @findex nearbyintl
9215 @findex nextafter
9216 @findex nextafterf
9217 @findex nextafterl
9218 @findex nexttoward
9219 @findex nexttowardf
9220 @findex nexttowardl
9221 @findex pow
9222 @findex pow10
9223 @findex pow10f
9224 @findex pow10l
9225 @findex powf
9226 @findex powl
9227 @findex printf
9228 @findex printf_unlocked
9229 @findex putchar
9230 @findex puts
9231 @findex remainder
9232 @findex remainderf
9233 @findex remainderl
9234 @findex remquo
9235 @findex remquof
9236 @findex remquol
9237 @findex rindex
9238 @findex rint
9239 @findex rintf
9240 @findex rintl
9241 @findex round
9242 @findex roundf
9243 @findex roundl
9244 @findex scalb
9245 @findex scalbf
9246 @findex scalbl
9247 @findex scalbln
9248 @findex scalblnf
9249 @findex scalblnf
9250 @findex scalbn
9251 @findex scalbnf
9252 @findex scanfnl
9253 @findex signbit
9254 @findex signbitf
9255 @findex signbitl
9256 @findex signbitd32
9257 @findex signbitd64
9258 @findex signbitd128
9259 @findex significand
9260 @findex significandf
9261 @findex significandl
9262 @findex sin
9263 @findex sincos
9264 @findex sincosf
9265 @findex sincosl
9266 @findex sinf
9267 @findex sinh
9268 @findex sinhf
9269 @findex sinhl
9270 @findex sinl
9271 @findex snprintf
9272 @findex sprintf
9273 @findex sqrt
9274 @findex sqrtf
9275 @findex sqrtl
9276 @findex sscanf
9277 @findex stpcpy
9278 @findex stpncpy
9279 @findex strcasecmp
9280 @findex strcat
9281 @findex strchr
9282 @findex strcmp
9283 @findex strcpy
9284 @findex strcspn
9285 @findex strdup
9286 @findex strfmon
9287 @findex strftime
9288 @findex strlen
9289 @findex strncasecmp
9290 @findex strncat
9291 @findex strncmp
9292 @findex strncpy
9293 @findex strndup
9294 @findex strpbrk
9295 @findex strrchr
9296 @findex strspn
9297 @findex strstr
9298 @findex tan
9299 @findex tanf
9300 @findex tanh
9301 @findex tanhf
9302 @findex tanhl
9303 @findex tanl
9304 @findex tgamma
9305 @findex tgammaf
9306 @findex tgammal
9307 @findex toascii
9308 @findex tolower
9309 @findex toupper
9310 @findex towlower
9311 @findex towupper
9312 @findex trunc
9313 @findex truncf
9314 @findex truncl
9315 @findex vfprintf
9316 @findex vfscanf
9317 @findex vprintf
9318 @findex vscanf
9319 @findex vsnprintf
9320 @findex vsprintf
9321 @findex vsscanf
9322 @findex y0
9323 @findex y0f
9324 @findex y0l
9325 @findex y1
9326 @findex y1f
9327 @findex y1l
9328 @findex yn
9329 @findex ynf
9330 @findex ynl
9332 GCC provides a large number of built-in functions other than the ones
9333 mentioned above.  Some of these are for internal use in the processing
9334 of exceptions or variable-length argument lists and are not
9335 documented here because they may change from time to time; we do not
9336 recommend general use of these functions.
9338 The remaining functions are provided for optimization purposes.
9340 @opindex fno-builtin
9341 GCC includes built-in versions of many of the functions in the standard
9342 C library.  The versions prefixed with @code{__builtin_} are always
9343 treated as having the same meaning as the C library function even if you
9344 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
9345 Many of these functions are only optimized in certain cases; if they are
9346 not optimized in a particular case, a call to the library function is
9347 emitted.
9349 @opindex ansi
9350 @opindex std
9351 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9352 @option{-std=c99} or @option{-std=c11}), the functions
9353 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9354 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9355 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9356 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9357 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9358 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9359 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9360 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9361 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9362 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9363 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9364 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9365 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9366 @code{significandl}, @code{significand}, @code{sincosf},
9367 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9368 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9369 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9370 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9371 @code{yn}
9372 may be handled as built-in functions.
9373 All these functions have corresponding versions
9374 prefixed with @code{__builtin_}, which may be used even in strict C90
9375 mode.
9377 The ISO C99 functions
9378 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9379 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9380 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9381 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9382 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9383 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9384 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9385 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9386 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9387 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9388 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9389 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9390 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9391 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9392 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9393 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9394 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9395 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9396 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9397 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9398 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9399 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9400 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9401 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9402 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9403 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9404 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9405 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9406 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9407 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9408 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9409 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9410 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9411 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9412 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9413 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9414 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9415 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9416 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9417 are handled as built-in functions
9418 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9420 There are also built-in versions of the ISO C99 functions
9421 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9422 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9423 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9424 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9425 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9426 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9427 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9428 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9429 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9430 that are recognized in any mode since ISO C90 reserves these names for
9431 the purpose to which ISO C99 puts them.  All these functions have
9432 corresponding versions prefixed with @code{__builtin_}.
9434 The ISO C94 functions
9435 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9436 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9437 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9438 @code{towupper}
9439 are handled as built-in functions
9440 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9442 The ISO C90 functions
9443 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9444 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9445 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9446 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9447 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9448 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9449 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9450 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9451 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9452 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9453 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9454 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9455 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9456 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9457 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9458 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9459 are all recognized as built-in functions unless
9460 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9461 is specified for an individual function).  All of these functions have
9462 corresponding versions prefixed with @code{__builtin_}.
9464 GCC provides built-in versions of the ISO C99 floating-point comparison
9465 macros that avoid raising exceptions for unordered operands.  They have
9466 the same names as the standard macros ( @code{isgreater},
9467 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9468 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9469 prefixed.  We intend for a library implementor to be able to simply
9470 @code{#define} each standard macro to its built-in equivalent.
9471 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9472 @code{isinf_sign} and @code{isnormal} built-ins used with
9473 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
9474 built-in functions appear both with and without the @code{__builtin_} prefix.
9476 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9478 You can use the built-in function @code{__builtin_types_compatible_p} to
9479 determine whether two types are the same.
9481 This built-in function returns 1 if the unqualified versions of the
9482 types @var{type1} and @var{type2} (which are types, not expressions) are
9483 compatible, 0 otherwise.  The result of this built-in function can be
9484 used in integer constant expressions.
9486 This built-in function ignores top level qualifiers (e.g., @code{const},
9487 @code{volatile}).  For example, @code{int} is equivalent to @code{const
9488 int}.
9490 The type @code{int[]} and @code{int[5]} are compatible.  On the other
9491 hand, @code{int} and @code{char *} are not compatible, even if the size
9492 of their types, on the particular architecture are the same.  Also, the
9493 amount of pointer indirection is taken into account when determining
9494 similarity.  Consequently, @code{short *} is not similar to
9495 @code{short **}.  Furthermore, two types that are typedefed are
9496 considered compatible if their underlying types are compatible.
9498 An @code{enum} type is not considered to be compatible with another
9499 @code{enum} type even if both are compatible with the same integer
9500 type; this is what the C standard specifies.
9501 For example, @code{enum @{foo, bar@}} is not similar to
9502 @code{enum @{hot, dog@}}.
9504 You typically use this function in code whose execution varies
9505 depending on the arguments' types.  For example:
9507 @smallexample
9508 #define foo(x)                                                  \
9509   (@{                                                           \
9510     typeof (x) tmp = (x);                                       \
9511     if (__builtin_types_compatible_p (typeof (x), long double)) \
9512       tmp = foo_long_double (tmp);                              \
9513     else if (__builtin_types_compatible_p (typeof (x), double)) \
9514       tmp = foo_double (tmp);                                   \
9515     else if (__builtin_types_compatible_p (typeof (x), float))  \
9516       tmp = foo_float (tmp);                                    \
9517     else                                                        \
9518       abort ();                                                 \
9519     tmp;                                                        \
9520   @})
9521 @end smallexample
9523 @emph{Note:} This construct is only available for C@.
9525 @end deftypefn
9527 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
9529 The @var{call_exp} expression must be a function call, and the
9530 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
9531 is passed to the function call in the target's static chain location.
9532 The result of builtin is the result of the function call.
9534 @emph{Note:} This builtin is only available for C@.
9535 This builtin can be used to call Go closures from C.
9537 @end deftypefn
9539 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9541 You can use the built-in function @code{__builtin_choose_expr} to
9542 evaluate code depending on the value of a constant expression.  This
9543 built-in function returns @var{exp1} if @var{const_exp}, which is an
9544 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
9546 This built-in function is analogous to the @samp{? :} operator in C,
9547 except that the expression returned has its type unaltered by promotion
9548 rules.  Also, the built-in function does not evaluate the expression
9549 that is not chosen.  For example, if @var{const_exp} evaluates to true,
9550 @var{exp2} is not evaluated even if it has side-effects.
9552 This built-in function can return an lvalue if the chosen argument is an
9553 lvalue.
9555 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9556 type.  Similarly, if @var{exp2} is returned, its return type is the same
9557 as @var{exp2}.
9559 Example:
9561 @smallexample
9562 #define foo(x)                                                    \
9563   __builtin_choose_expr (                                         \
9564     __builtin_types_compatible_p (typeof (x), double),            \
9565     foo_double (x),                                               \
9566     __builtin_choose_expr (                                       \
9567       __builtin_types_compatible_p (typeof (x), float),           \
9568       foo_float (x),                                              \
9569       /* @r{The void expression results in a compile-time error}  \
9570          @r{when assigning the result to something.}  */          \
9571       (void)0))
9572 @end smallexample
9574 @emph{Note:} This construct is only available for C@.  Furthermore, the
9575 unused expression (@var{exp1} or @var{exp2} depending on the value of
9576 @var{const_exp}) may still generate syntax errors.  This may change in
9577 future revisions.
9579 @end deftypefn
9581 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9583 The built-in function @code{__builtin_complex} is provided for use in
9584 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9585 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
9586 real binary floating-point type, and the result has the corresponding
9587 complex type with real and imaginary parts @var{real} and @var{imag}.
9588 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9589 infinities, NaNs and negative zeros are involved.
9591 @end deftypefn
9593 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9594 You can use the built-in function @code{__builtin_constant_p} to
9595 determine if a value is known to be constant at compile time and hence
9596 that GCC can perform constant-folding on expressions involving that
9597 value.  The argument of the function is the value to test.  The function
9598 returns the integer 1 if the argument is known to be a compile-time
9599 constant and 0 if it is not known to be a compile-time constant.  A
9600 return of 0 does not indicate that the value is @emph{not} a constant,
9601 but merely that GCC cannot prove it is a constant with the specified
9602 value of the @option{-O} option.
9604 You typically use this function in an embedded application where
9605 memory is a critical resource.  If you have some complex calculation,
9606 you may want it to be folded if it involves constants, but need to call
9607 a function if it does not.  For example:
9609 @smallexample
9610 #define Scale_Value(X)      \
9611   (__builtin_constant_p (X) \
9612   ? ((X) * SCALE + OFFSET) : Scale (X))
9613 @end smallexample
9615 You may use this built-in function in either a macro or an inline
9616 function.  However, if you use it in an inlined function and pass an
9617 argument of the function as the argument to the built-in, GCC 
9618 never returns 1 when you call the inline function with a string constant
9619 or compound literal (@pxref{Compound Literals}) and does not return 1
9620 when you pass a constant numeric value to the inline function unless you
9621 specify the @option{-O} option.
9623 You may also use @code{__builtin_constant_p} in initializers for static
9624 data.  For instance, you can write
9626 @smallexample
9627 static const int table[] = @{
9628    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9629    /* @r{@dots{}} */
9631 @end smallexample
9633 @noindent
9634 This is an acceptable initializer even if @var{EXPRESSION} is not a
9635 constant expression, including the case where
9636 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9637 folded to a constant but @var{EXPRESSION} contains operands that are
9638 not otherwise permitted in a static initializer (for example,
9639 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
9640 built-in in this case, because it has no opportunity to perform
9641 optimization.
9643 Previous versions of GCC did not accept this built-in in data
9644 initializers.  The earliest version where it is completely safe is
9645 3.0.1.
9646 @end deftypefn
9648 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9649 @opindex fprofile-arcs
9650 You may use @code{__builtin_expect} to provide the compiler with
9651 branch prediction information.  In general, you should prefer to
9652 use actual profile feedback for this (@option{-fprofile-arcs}), as
9653 programmers are notoriously bad at predicting how their programs
9654 actually perform.  However, there are applications in which this
9655 data is hard to collect.
9657 The return value is the value of @var{exp}, which should be an integral
9658 expression.  The semantics of the built-in are that it is expected that
9659 @var{exp} == @var{c}.  For example:
9661 @smallexample
9662 if (__builtin_expect (x, 0))
9663   foo ();
9664 @end smallexample
9666 @noindent
9667 indicates that we do not expect to call @code{foo}, since
9668 we expect @code{x} to be zero.  Since you are limited to integral
9669 expressions for @var{exp}, you should use constructions such as
9671 @smallexample
9672 if (__builtin_expect (ptr != NULL, 1))
9673   foo (*ptr);
9674 @end smallexample
9676 @noindent
9677 when testing pointer or floating-point values.
9678 @end deftypefn
9680 @deftypefn {Built-in Function} void __builtin_trap (void)
9681 This function causes the program to exit abnormally.  GCC implements
9682 this function by using a target-dependent mechanism (such as
9683 intentionally executing an illegal instruction) or by calling
9684 @code{abort}.  The mechanism used may vary from release to release so
9685 you should not rely on any particular implementation.
9686 @end deftypefn
9688 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9689 If control flow reaches the point of the @code{__builtin_unreachable},
9690 the program is undefined.  It is useful in situations where the
9691 compiler cannot deduce the unreachability of the code.
9693 One such case is immediately following an @code{asm} statement that
9694 either never terminates, or one that transfers control elsewhere
9695 and never returns.  In this example, without the
9696 @code{__builtin_unreachable}, GCC issues a warning that control
9697 reaches the end of a non-void function.  It also generates code
9698 to return after the @code{asm}.
9700 @smallexample
9701 int f (int c, int v)
9703   if (c)
9704     @{
9705       return v;
9706     @}
9707   else
9708     @{
9709       asm("jmp error_handler");
9710       __builtin_unreachable ();
9711     @}
9713 @end smallexample
9715 @noindent
9716 Because the @code{asm} statement unconditionally transfers control out
9717 of the function, control never reaches the end of the function
9718 body.  The @code{__builtin_unreachable} is in fact unreachable and
9719 communicates this fact to the compiler.
9721 Another use for @code{__builtin_unreachable} is following a call a
9722 function that never returns but that is not declared
9723 @code{__attribute__((noreturn))}, as in this example:
9725 @smallexample
9726 void function_that_never_returns (void);
9728 int g (int c)
9730   if (c)
9731     @{
9732       return 1;
9733     @}
9734   else
9735     @{
9736       function_that_never_returns ();
9737       __builtin_unreachable ();
9738     @}
9740 @end smallexample
9742 @end deftypefn
9744 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9745 This function returns its first argument, and allows the compiler
9746 to assume that the returned pointer is at least @var{align} bytes
9747 aligned.  This built-in can have either two or three arguments,
9748 if it has three, the third argument should have integer type, and
9749 if it is nonzero means misalignment offset.  For example:
9751 @smallexample
9752 void *x = __builtin_assume_aligned (arg, 16);
9753 @end smallexample
9755 @noindent
9756 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9757 16-byte aligned, while:
9759 @smallexample
9760 void *x = __builtin_assume_aligned (arg, 32, 8);
9761 @end smallexample
9763 @noindent
9764 means that the compiler can assume for @code{x}, set to @code{arg}, that
9765 @code{(char *) x - 8} is 32-byte aligned.
9766 @end deftypefn
9768 @deftypefn {Built-in Function} int __builtin_LINE ()
9769 This function is the equivalent to the preprocessor @code{__LINE__}
9770 macro and returns the line number of the invocation of the built-in.
9771 In a C++ default argument for a function @var{F}, it gets the line number of
9772 the call to @var{F}.
9773 @end deftypefn
9775 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9776 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9777 macro and returns the function name the invocation of the built-in is in.
9778 @end deftypefn
9780 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9781 This function is the equivalent to the preprocessor @code{__FILE__}
9782 macro and returns the file name the invocation of the built-in is in.
9783 In a C++ default argument for a function @var{F}, it gets the file name of
9784 the call to @var{F}.
9785 @end deftypefn
9787 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9788 This function is used to flush the processor's instruction cache for
9789 the region of memory between @var{begin} inclusive and @var{end}
9790 exclusive.  Some targets require that the instruction cache be
9791 flushed, after modifying memory containing code, in order to obtain
9792 deterministic behavior.
9794 If the target does not require instruction cache flushes,
9795 @code{__builtin___clear_cache} has no effect.  Otherwise either
9796 instructions are emitted in-line to clear the instruction cache or a
9797 call to the @code{__clear_cache} function in libgcc is made.
9798 @end deftypefn
9800 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9801 This function is used to minimize cache-miss latency by moving data into
9802 a cache before it is accessed.
9803 You can insert calls to @code{__builtin_prefetch} into code for which
9804 you know addresses of data in memory that is likely to be accessed soon.
9805 If the target supports them, data prefetch instructions are generated.
9806 If the prefetch is done early enough before the access then the data will
9807 be in the cache by the time it is accessed.
9809 The value of @var{addr} is the address of the memory to prefetch.
9810 There are two optional arguments, @var{rw} and @var{locality}.
9811 The value of @var{rw} is a compile-time constant one or zero; one
9812 means that the prefetch is preparing for a write to the memory address
9813 and zero, the default, means that the prefetch is preparing for a read.
9814 The value @var{locality} must be a compile-time constant integer between
9815 zero and three.  A value of zero means that the data has no temporal
9816 locality, so it need not be left in the cache after the access.  A value
9817 of three means that the data has a high degree of temporal locality and
9818 should be left in all levels of cache possible.  Values of one and two
9819 mean, respectively, a low or moderate degree of temporal locality.  The
9820 default is three.
9822 @smallexample
9823 for (i = 0; i < n; i++)
9824   @{
9825     a[i] = a[i] + b[i];
9826     __builtin_prefetch (&a[i+j], 1, 1);
9827     __builtin_prefetch (&b[i+j], 0, 1);
9828     /* @r{@dots{}} */
9829   @}
9830 @end smallexample
9832 Data prefetch does not generate faults if @var{addr} is invalid, but
9833 the address expression itself must be valid.  For example, a prefetch
9834 of @code{p->next} does not fault if @code{p->next} is not a valid
9835 address, but evaluation faults if @code{p} is not a valid address.
9837 If the target does not support data prefetch, the address expression
9838 is evaluated if it includes side effects but no other code is generated
9839 and GCC does not issue a warning.
9840 @end deftypefn
9842 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9843 Returns a positive infinity, if supported by the floating-point format,
9844 else @code{DBL_MAX}.  This function is suitable for implementing the
9845 ISO C macro @code{HUGE_VAL}.
9846 @end deftypefn
9848 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9849 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9850 @end deftypefn
9852 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9853 Similar to @code{__builtin_huge_val}, except the return
9854 type is @code{long double}.
9855 @end deftypefn
9857 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9858 This built-in implements the C99 fpclassify functionality.  The first
9859 five int arguments should be the target library's notion of the
9860 possible FP classes and are used for return values.  They must be
9861 constant values and they must appear in this order: @code{FP_NAN},
9862 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9863 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
9864 to classify.  GCC treats the last argument as type-generic, which
9865 means it does not do default promotion from float to double.
9866 @end deftypefn
9868 @deftypefn {Built-in Function} double __builtin_inf (void)
9869 Similar to @code{__builtin_huge_val}, except a warning is generated
9870 if the target floating-point format does not support infinities.
9871 @end deftypefn
9873 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9874 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9875 @end deftypefn
9877 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9878 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9879 @end deftypefn
9881 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9882 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9883 @end deftypefn
9885 @deftypefn {Built-in Function} float __builtin_inff (void)
9886 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9887 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9888 @end deftypefn
9890 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9891 Similar to @code{__builtin_inf}, except the return
9892 type is @code{long double}.
9893 @end deftypefn
9895 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9896 Similar to @code{isinf}, except the return value is -1 for
9897 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9898 Note while the parameter list is an
9899 ellipsis, this function only accepts exactly one floating-point
9900 argument.  GCC treats this parameter as type-generic, which means it
9901 does not do default promotion from float to double.
9902 @end deftypefn
9904 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9905 This is an implementation of the ISO C99 function @code{nan}.
9907 Since ISO C99 defines this function in terms of @code{strtod}, which we
9908 do not implement, a description of the parsing is in order.  The string
9909 is parsed as by @code{strtol}; that is, the base is recognized by
9910 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
9911 in the significand such that the least significant bit of the number
9912 is at the least significant bit of the significand.  The number is
9913 truncated to fit the significand field provided.  The significand is
9914 forced to be a quiet NaN@.
9916 This function, if given a string literal all of which would have been
9917 consumed by @code{strtol}, is evaluated early enough that it is considered a
9918 compile-time constant.
9919 @end deftypefn
9921 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9922 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9923 @end deftypefn
9925 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9926 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9927 @end deftypefn
9929 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9930 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9931 @end deftypefn
9933 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9934 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9935 @end deftypefn
9937 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9938 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9939 @end deftypefn
9941 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9942 Similar to @code{__builtin_nan}, except the significand is forced
9943 to be a signaling NaN@.  The @code{nans} function is proposed by
9944 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9945 @end deftypefn
9947 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9948 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9949 @end deftypefn
9951 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9952 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9953 @end deftypefn
9955 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9956 Returns one plus the index of the least significant 1-bit of @var{x}, or
9957 if @var{x} is zero, returns zero.
9958 @end deftypefn
9960 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9961 Returns the number of leading 0-bits in @var{x}, starting at the most
9962 significant bit position.  If @var{x} is 0, the result is undefined.
9963 @end deftypefn
9965 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9966 Returns the number of trailing 0-bits in @var{x}, starting at the least
9967 significant bit position.  If @var{x} is 0, the result is undefined.
9968 @end deftypefn
9970 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9971 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9972 number of bits following the most significant bit that are identical
9973 to it.  There are no special cases for 0 or other values. 
9974 @end deftypefn
9976 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9977 Returns the number of 1-bits in @var{x}.
9978 @end deftypefn
9980 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9981 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9982 modulo 2.
9983 @end deftypefn
9985 @deftypefn {Built-in Function} int __builtin_ffsl (long)
9986 Similar to @code{__builtin_ffs}, except the argument type is
9987 @code{long}.
9988 @end deftypefn
9990 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9991 Similar to @code{__builtin_clz}, except the argument type is
9992 @code{unsigned long}.
9993 @end deftypefn
9995 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9996 Similar to @code{__builtin_ctz}, except the argument type is
9997 @code{unsigned long}.
9998 @end deftypefn
10000 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
10001 Similar to @code{__builtin_clrsb}, except the argument type is
10002 @code{long}.
10003 @end deftypefn
10005 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
10006 Similar to @code{__builtin_popcount}, except the argument type is
10007 @code{unsigned long}.
10008 @end deftypefn
10010 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
10011 Similar to @code{__builtin_parity}, except the argument type is
10012 @code{unsigned long}.
10013 @end deftypefn
10015 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
10016 Similar to @code{__builtin_ffs}, except the argument type is
10017 @code{long long}.
10018 @end deftypefn
10020 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
10021 Similar to @code{__builtin_clz}, except the argument type is
10022 @code{unsigned long long}.
10023 @end deftypefn
10025 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
10026 Similar to @code{__builtin_ctz}, except the argument type is
10027 @code{unsigned long long}.
10028 @end deftypefn
10030 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
10031 Similar to @code{__builtin_clrsb}, except the argument type is
10032 @code{long long}.
10033 @end deftypefn
10035 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10036 Similar to @code{__builtin_popcount}, except the argument type is
10037 @code{unsigned long long}.
10038 @end deftypefn
10040 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10041 Similar to @code{__builtin_parity}, except the argument type is
10042 @code{unsigned long long}.
10043 @end deftypefn
10045 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10046 Returns the first argument raised to the power of the second.  Unlike the
10047 @code{pow} function no guarantees about precision and rounding are made.
10048 @end deftypefn
10050 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10051 Similar to @code{__builtin_powi}, except the argument and return types
10052 are @code{float}.
10053 @end deftypefn
10055 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10056 Similar to @code{__builtin_powi}, except the argument and return types
10057 are @code{long double}.
10058 @end deftypefn
10060 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10061 Returns @var{x} with the order of the bytes reversed; for example,
10062 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
10063 exactly 8 bits.
10064 @end deftypefn
10066 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10067 Similar to @code{__builtin_bswap16}, except the argument and return types
10068 are 32 bit.
10069 @end deftypefn
10071 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10072 Similar to @code{__builtin_bswap32}, except the argument and return types
10073 are 64 bit.
10074 @end deftypefn
10076 @node Target Builtins
10077 @section Built-in Functions Specific to Particular Target Machines
10079 On some target machines, GCC supports many built-in functions specific
10080 to those machines.  Generally these generate calls to specific machine
10081 instructions, but allow the compiler to schedule those calls.
10083 @menu
10084 * AArch64 Built-in Functions::
10085 * Alpha Built-in Functions::
10086 * Altera Nios II Built-in Functions::
10087 * ARC Built-in Functions::
10088 * ARC SIMD Built-in Functions::
10089 * ARM iWMMXt Built-in Functions::
10090 * ARM C Language Extensions (ACLE)::
10091 * ARM Floating Point Status and Control Intrinsics::
10092 * AVR Built-in Functions::
10093 * Blackfin Built-in Functions::
10094 * FR-V Built-in Functions::
10095 * X86 Built-in Functions::
10096 * X86 transactional memory intrinsics::
10097 * MIPS DSP Built-in Functions::
10098 * MIPS Paired-Single Support::
10099 * MIPS Loongson Built-in Functions::
10100 * Other MIPS Built-in Functions::
10101 * MSP430 Built-in Functions::
10102 * NDS32 Built-in Functions::
10103 * picoChip Built-in Functions::
10104 * PowerPC Built-in Functions::
10105 * PowerPC AltiVec/VSX Built-in Functions::
10106 * PowerPC Hardware Transactional Memory Built-in Functions::
10107 * RX Built-in Functions::
10108 * S/390 System z Built-in Functions::
10109 * SH Built-in Functions::
10110 * SPARC VIS Built-in Functions::
10111 * SPU Built-in Functions::
10112 * TI C6X Built-in Functions::
10113 * TILE-Gx Built-in Functions::
10114 * TILEPro Built-in Functions::
10115 @end menu
10117 @node AArch64 Built-in Functions
10118 @subsection AArch64 Built-in Functions
10120 These built-in functions are available for the AArch64 family of
10121 processors.
10122 @smallexample
10123 unsigned int __builtin_aarch64_get_fpcr ()
10124 void __builtin_aarch64_set_fpcr (unsigned int)
10125 unsigned int __builtin_aarch64_get_fpsr ()
10126 void __builtin_aarch64_set_fpsr (unsigned int)
10127 @end smallexample
10129 @node Alpha Built-in Functions
10130 @subsection Alpha Built-in Functions
10132 These built-in functions are available for the Alpha family of
10133 processors, depending on the command-line switches used.
10135 The following built-in functions are always available.  They
10136 all generate the machine instruction that is part of the name.
10138 @smallexample
10139 long __builtin_alpha_implver (void)
10140 long __builtin_alpha_rpcc (void)
10141 long __builtin_alpha_amask (long)
10142 long __builtin_alpha_cmpbge (long, long)
10143 long __builtin_alpha_extbl (long, long)
10144 long __builtin_alpha_extwl (long, long)
10145 long __builtin_alpha_extll (long, long)
10146 long __builtin_alpha_extql (long, long)
10147 long __builtin_alpha_extwh (long, long)
10148 long __builtin_alpha_extlh (long, long)
10149 long __builtin_alpha_extqh (long, long)
10150 long __builtin_alpha_insbl (long, long)
10151 long __builtin_alpha_inswl (long, long)
10152 long __builtin_alpha_insll (long, long)
10153 long __builtin_alpha_insql (long, long)
10154 long __builtin_alpha_inswh (long, long)
10155 long __builtin_alpha_inslh (long, long)
10156 long __builtin_alpha_insqh (long, long)
10157 long __builtin_alpha_mskbl (long, long)
10158 long __builtin_alpha_mskwl (long, long)
10159 long __builtin_alpha_mskll (long, long)
10160 long __builtin_alpha_mskql (long, long)
10161 long __builtin_alpha_mskwh (long, long)
10162 long __builtin_alpha_msklh (long, long)
10163 long __builtin_alpha_mskqh (long, long)
10164 long __builtin_alpha_umulh (long, long)
10165 long __builtin_alpha_zap (long, long)
10166 long __builtin_alpha_zapnot (long, long)
10167 @end smallexample
10169 The following built-in functions are always with @option{-mmax}
10170 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10171 later.  They all generate the machine instruction that is part
10172 of the name.
10174 @smallexample
10175 long __builtin_alpha_pklb (long)
10176 long __builtin_alpha_pkwb (long)
10177 long __builtin_alpha_unpkbl (long)
10178 long __builtin_alpha_unpkbw (long)
10179 long __builtin_alpha_minub8 (long, long)
10180 long __builtin_alpha_minsb8 (long, long)
10181 long __builtin_alpha_minuw4 (long, long)
10182 long __builtin_alpha_minsw4 (long, long)
10183 long __builtin_alpha_maxub8 (long, long)
10184 long __builtin_alpha_maxsb8 (long, long)
10185 long __builtin_alpha_maxuw4 (long, long)
10186 long __builtin_alpha_maxsw4 (long, long)
10187 long __builtin_alpha_perr (long, long)
10188 @end smallexample
10190 The following built-in functions are always with @option{-mcix}
10191 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10192 later.  They all generate the machine instruction that is part
10193 of the name.
10195 @smallexample
10196 long __builtin_alpha_cttz (long)
10197 long __builtin_alpha_ctlz (long)
10198 long __builtin_alpha_ctpop (long)
10199 @end smallexample
10201 The following built-in functions are available on systems that use the OSF/1
10202 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
10203 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10204 @code{rdval} and @code{wrval}.
10206 @smallexample
10207 void *__builtin_thread_pointer (void)
10208 void __builtin_set_thread_pointer (void *)
10209 @end smallexample
10211 @node Altera Nios II Built-in Functions
10212 @subsection Altera Nios II Built-in Functions
10214 These built-in functions are available for the Altera Nios II
10215 family of processors.
10217 The following built-in functions are always available.  They
10218 all generate the machine instruction that is part of the name.
10220 @example
10221 int __builtin_ldbio (volatile const void *)
10222 int __builtin_ldbuio (volatile const void *)
10223 int __builtin_ldhio (volatile const void *)
10224 int __builtin_ldhuio (volatile const void *)
10225 int __builtin_ldwio (volatile const void *)
10226 void __builtin_stbio (volatile void *, int)
10227 void __builtin_sthio (volatile void *, int)
10228 void __builtin_stwio (volatile void *, int)
10229 void __builtin_sync (void)
10230 int __builtin_rdctl (int) 
10231 void __builtin_wrctl (int, int)
10232 @end example
10234 The following built-in functions are always available.  They
10235 all generate a Nios II Custom Instruction. The name of the
10236 function represents the types that the function takes and
10237 returns. The letter before the @code{n} is the return type
10238 or void if absent. The @code{n} represents the first parameter
10239 to all the custom instructions, the custom instruction number.
10240 The two letters after the @code{n} represent the up to two
10241 parameters to the function.
10243 The letters represent the following data types:
10244 @table @code
10245 @item <no letter>
10246 @code{void} for return type and no parameter for parameter types.
10248 @item i
10249 @code{int} for return type and parameter type
10251 @item f
10252 @code{float} for return type and parameter type
10254 @item p
10255 @code{void *} for return type and parameter type
10257 @end table
10259 And the function names are:
10260 @example
10261 void __builtin_custom_n (void)
10262 void __builtin_custom_ni (int)
10263 void __builtin_custom_nf (float)
10264 void __builtin_custom_np (void *)
10265 void __builtin_custom_nii (int, int)
10266 void __builtin_custom_nif (int, float)
10267 void __builtin_custom_nip (int, void *)
10268 void __builtin_custom_nfi (float, int)
10269 void __builtin_custom_nff (float, float)
10270 void __builtin_custom_nfp (float, void *)
10271 void __builtin_custom_npi (void *, int)
10272 void __builtin_custom_npf (void *, float)
10273 void __builtin_custom_npp (void *, void *)
10274 int __builtin_custom_in (void)
10275 int __builtin_custom_ini (int)
10276 int __builtin_custom_inf (float)
10277 int __builtin_custom_inp (void *)
10278 int __builtin_custom_inii (int, int)
10279 int __builtin_custom_inif (int, float)
10280 int __builtin_custom_inip (int, void *)
10281 int __builtin_custom_infi (float, int)
10282 int __builtin_custom_inff (float, float)
10283 int __builtin_custom_infp (float, void *)
10284 int __builtin_custom_inpi (void *, int)
10285 int __builtin_custom_inpf (void *, float)
10286 int __builtin_custom_inpp (void *, void *)
10287 float __builtin_custom_fn (void)
10288 float __builtin_custom_fni (int)
10289 float __builtin_custom_fnf (float)
10290 float __builtin_custom_fnp (void *)
10291 float __builtin_custom_fnii (int, int)
10292 float __builtin_custom_fnif (int, float)
10293 float __builtin_custom_fnip (int, void *)
10294 float __builtin_custom_fnfi (float, int)
10295 float __builtin_custom_fnff (float, float)
10296 float __builtin_custom_fnfp (float, void *)
10297 float __builtin_custom_fnpi (void *, int)
10298 float __builtin_custom_fnpf (void *, float)
10299 float __builtin_custom_fnpp (void *, void *)
10300 void * __builtin_custom_pn (void)
10301 void * __builtin_custom_pni (int)
10302 void * __builtin_custom_pnf (float)
10303 void * __builtin_custom_pnp (void *)
10304 void * __builtin_custom_pnii (int, int)
10305 void * __builtin_custom_pnif (int, float)
10306 void * __builtin_custom_pnip (int, void *)
10307 void * __builtin_custom_pnfi (float, int)
10308 void * __builtin_custom_pnff (float, float)
10309 void * __builtin_custom_pnfp (float, void *)
10310 void * __builtin_custom_pnpi (void *, int)
10311 void * __builtin_custom_pnpf (void *, float)
10312 void * __builtin_custom_pnpp (void *, void *)
10313 @end example
10315 @node ARC Built-in Functions
10316 @subsection ARC Built-in Functions
10318 The following built-in functions are provided for ARC targets.  The
10319 built-ins generate the corresponding assembly instructions.  In the
10320 examples given below, the generated code often requires an operand or
10321 result to be in a register.  Where necessary further code will be
10322 generated to ensure this is true, but for brevity this is not
10323 described in each case.
10325 @emph{Note:} Using a built-in to generate an instruction not supported
10326 by a target may cause problems. At present the compiler is not
10327 guaranteed to detect such misuse, and as a result an internal compiler
10328 error may be generated.
10330 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10331 Return 1 if @var{val} is known to have the byte alignment given
10332 by @var{alignval}, otherwise return 0.
10333 Note that this is different from
10334 @smallexample
10335 __alignof__(*(char *)@var{val}) >= alignval
10336 @end smallexample
10337 because __alignof__ sees only the type of the dereference, whereas
10338 __builtin_arc_align uses alignment information from the pointer
10339 as well as from the pointed-to type.
10340 The information available will depend on optimization level.
10341 @end deftypefn
10343 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10344 Generates
10345 @example
10347 @end example
10348 @end deftypefn
10350 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10351 The operand is the number of a register to be read.  Generates:
10352 @example
10353 mov  @var{dest}, r@var{regno}
10354 @end example
10355 where the value in @var{dest} will be the result returned from the
10356 built-in.
10357 @end deftypefn
10359 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10360 The first operand is the number of a register to be written, the
10361 second operand is a compile time constant to write into that
10362 register.  Generates:
10363 @example
10364 mov  r@var{regno}, @var{val}
10365 @end example
10366 @end deftypefn
10368 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10369 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10370 Generates:
10371 @example
10372 divaw  @var{dest}, @var{a}, @var{b}
10373 @end example
10374 where the value in @var{dest} will be the result returned from the
10375 built-in.
10376 @end deftypefn
10378 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10379 Generates
10380 @example
10381 flag  @var{a}
10382 @end example
10383 @end deftypefn
10385 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10386 The operand, @var{auxv}, is the address of an auxiliary register and
10387 must be a compile time constant.  Generates:
10388 @example
10389 lr  @var{dest}, [@var{auxr}]
10390 @end example
10391 Where the value in @var{dest} will be the result returned from the
10392 built-in.
10393 @end deftypefn
10395 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10396 Only available with @option{-mmul64}.  Generates:
10397 @example
10398 mul64  @var{a}, @var{b}
10399 @end example
10400 @end deftypefn
10402 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10403 Only available with @option{-mmul64}.  Generates:
10404 @example
10405 mulu64  @var{a}, @var{b}
10406 @end example
10407 @end deftypefn
10409 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10410 Generates:
10411 @example
10413 @end example
10414 @end deftypefn
10416 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10417 Only valid if the @samp{norm} instruction is available through the
10418 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10419 Generates:
10420 @example
10421 norm  @var{dest}, @var{src}
10422 @end example
10423 Where the value in @var{dest} will be the result returned from the
10424 built-in.
10425 @end deftypefn
10427 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
10428 Only valid if the @samp{normw} instruction is available through the
10429 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10430 Generates:
10431 @example
10432 normw  @var{dest}, @var{src}
10433 @end example
10434 Where the value in @var{dest} will be the result returned from the
10435 built-in.
10436 @end deftypefn
10438 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
10439 Generates:
10440 @example
10441 rtie
10442 @end example
10443 @end deftypefn
10445 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
10446 Generates:
10447 @example
10448 sleep  @var{a}
10449 @end example
10450 @end deftypefn
10452 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10453 The first argument, @var{auxv}, is the address of an auxiliary
10454 register, the second argument, @var{val}, is a compile time constant
10455 to be written to the register.  Generates:
10456 @example
10457 sr  @var{auxr}, [@var{val}]
10458 @end example
10459 @end deftypefn
10461 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
10462 Only valid with @option{-mswap}.  Generates:
10463 @example
10464 swap  @var{dest}, @var{src}
10465 @end example
10466 Where the value in @var{dest} will be the result returned from the
10467 built-in.
10468 @end deftypefn
10470 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
10471 Generates:
10472 @example
10474 @end example
10475 @end deftypefn
10477 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
10478 Only available with @option{-mcpu=ARC700}.  Generates:
10479 @example
10480 sync
10481 @end example
10482 @end deftypefn
10484 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
10485 Only available with @option{-mcpu=ARC700}.  Generates:
10486 @example
10487 trap_s  @var{c}
10488 @end example
10489 @end deftypefn
10491 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
10492 Only available with @option{-mcpu=ARC700}.  Generates:
10493 @example
10494 unimp_s
10495 @end example
10496 @end deftypefn
10498 The instructions generated by the following builtins are not
10499 considered as candidates for scheduling.  They are not moved around by
10500 the compiler during scheduling, and thus can be expected to appear
10501 where they are put in the C code:
10502 @example
10503 __builtin_arc_brk()
10504 __builtin_arc_core_read()
10505 __builtin_arc_core_write()
10506 __builtin_arc_flag()
10507 __builtin_arc_lr()
10508 __builtin_arc_sleep()
10509 __builtin_arc_sr()
10510 __builtin_arc_swi()
10511 @end example
10513 @node ARC SIMD Built-in Functions
10514 @subsection ARC SIMD Built-in Functions
10516 SIMD builtins provided by the compiler can be used to generate the
10517 vector instructions.  This section describes the available builtins
10518 and their usage in programs.  With the @option{-msimd} option, the
10519 compiler provides 128-bit vector types, which can be specified using
10520 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
10521 can be included to use the following predefined types:
10522 @example
10523 typedef int __v4si   __attribute__((vector_size(16)));
10524 typedef short __v8hi __attribute__((vector_size(16)));
10525 @end example
10527 These types can be used to define 128-bit variables.  The built-in
10528 functions listed in the following section can be used on these
10529 variables to generate the vector operations.
10531 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10532 @file{arc-simd.h} also provides equivalent macros called
10533 @code{_@var{someinsn}} that can be used for programming ease and
10534 improved readability.  The following macros for DMA control are also
10535 provided:
10536 @example
10537 #define _setup_dma_in_channel_reg _vdiwr
10538 #define _setup_dma_out_channel_reg _vdowr
10539 @end example
10541 The following is a complete list of all the SIMD built-ins provided
10542 for ARC, grouped by calling signature.
10544 The following take two @code{__v8hi} arguments and return a
10545 @code{__v8hi} result:
10546 @example
10547 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10548 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10549 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10550 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10551 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10552 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10553 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10554 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10555 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10556 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10557 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10558 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10559 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10560 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10561 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10562 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10563 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10564 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10565 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10566 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10567 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10568 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10569 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10570 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10571 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10572 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10573 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10574 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10575 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10576 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10577 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10578 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10579 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10580 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10581 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10582 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10583 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10584 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10585 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10586 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10587 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10588 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10589 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10590 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10591 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10592 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10593 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10594 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10595 @end example
10597 The following take one @code{__v8hi} and one @code{int} argument and return a
10598 @code{__v8hi} result:
10600 @example
10601 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10602 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10603 __v8hi __builtin_arc_vbminw (__v8hi, int)
10604 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10605 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10606 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10607 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10608 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10609 @end example
10611 The following take one @code{__v8hi} argument and one @code{int} argument which
10612 must be a 3-bit compile time constant indicating a register number
10613 I0-I7.  They return a @code{__v8hi} result.
10614 @example
10615 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10616 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10617 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10618 @end example
10620 The following take one @code{__v8hi} argument and one @code{int}
10621 argument which must be a 6-bit compile time constant.  They return a
10622 @code{__v8hi} result.
10623 @example
10624 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10625 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10626 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10627 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10628 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10629 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10630 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10631 @end example
10633 The following take one @code{__v8hi} argument and one @code{int} argument which
10634 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10635 result.
10636 @example
10637 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10638 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10639 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10640 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10641 @end example
10643 The following take two @code{int} arguments, the second of which which
10644 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10645 result:
10646 @example
10647 __v8hi __builtin_arc_vmovaw (int, const int)
10648 __v8hi __builtin_arc_vmovw (int, const int)
10649 __v8hi __builtin_arc_vmovzw (int, const int)
10650 @end example
10652 The following take a single @code{__v8hi} argument and return a
10653 @code{__v8hi} result:
10654 @example
10655 __v8hi __builtin_arc_vabsaw (__v8hi)
10656 __v8hi __builtin_arc_vabsw (__v8hi)
10657 __v8hi __builtin_arc_vaddsuw (__v8hi)
10658 __v8hi __builtin_arc_vexch1 (__v8hi)
10659 __v8hi __builtin_arc_vexch2 (__v8hi)
10660 __v8hi __builtin_arc_vexch4 (__v8hi)
10661 __v8hi __builtin_arc_vsignw (__v8hi)
10662 __v8hi __builtin_arc_vupbaw (__v8hi)
10663 __v8hi __builtin_arc_vupbw (__v8hi)
10664 __v8hi __builtin_arc_vupsbaw (__v8hi)
10665 __v8hi __builtin_arc_vupsbw (__v8hi)
10666 @end example
10668 The followign take two @code{int} arguments and return no result:
10669 @example
10670 void __builtin_arc_vdirun (int, int)
10671 void __builtin_arc_vdorun (int, int)
10672 @end example
10674 The following take two @code{int} arguments and return no result.  The
10675 first argument must a 3-bit compile time constant indicating one of
10676 the DR0-DR7 DMA setup channels:
10677 @example
10678 void __builtin_arc_vdiwr (const int, int)
10679 void __builtin_arc_vdowr (const int, int)
10680 @end example
10682 The following take an @code{int} argument and return no result:
10683 @example
10684 void __builtin_arc_vendrec (int)
10685 void __builtin_arc_vrec (int)
10686 void __builtin_arc_vrecrun (int)
10687 void __builtin_arc_vrun (int)
10688 @end example
10690 The following take a @code{__v8hi} argument and two @code{int}
10691 arguments and return a @code{__v8hi} result.  The second argument must
10692 be a 3-bit compile time constants, indicating one the registers I0-I7,
10693 and the third argument must be an 8-bit compile time constant.
10695 @emph{Note:} Although the equivalent hardware instructions do not take
10696 an SIMD register as an operand, these builtins overwrite the relevant
10697 bits of the @code{__v8hi} register provided as the first argument with
10698 the value loaded from the @code{[Ib, u8]} location in the SDM.
10700 @example
10701 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10702 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10703 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10704 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10705 @end example
10707 The following take two @code{int} arguments and return a @code{__v8hi}
10708 result.  The first argument must be a 3-bit compile time constants,
10709 indicating one the registers I0-I7, and the second argument must be an
10710 8-bit compile time constant.
10712 @example
10713 __v8hi __builtin_arc_vld128 (const int, const int)
10714 __v8hi __builtin_arc_vld64w (const int, const int)
10715 @end example
10717 The following take a @code{__v8hi} argument and two @code{int}
10718 arguments and return no result.  The second argument must be a 3-bit
10719 compile time constants, indicating one the registers I0-I7, and the
10720 third argument must be an 8-bit compile time constant.
10722 @example
10723 void __builtin_arc_vst128 (__v8hi, const int, const int)
10724 void __builtin_arc_vst64 (__v8hi, const int, const int)
10725 @end example
10727 The following take a @code{__v8hi} argument and three @code{int}
10728 arguments and return no result.  The second argument must be a 3-bit
10729 compile-time constant, identifying the 16-bit sub-register to be
10730 stored, the third argument must be a 3-bit compile time constants,
10731 indicating one the registers I0-I7, and the fourth argument must be an
10732 8-bit compile time constant.
10734 @example
10735 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10736 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10737 @end example
10739 @node ARM iWMMXt Built-in Functions
10740 @subsection ARM iWMMXt Built-in Functions
10742 These built-in functions are available for the ARM family of
10743 processors when the @option{-mcpu=iwmmxt} switch is used:
10745 @smallexample
10746 typedef int v2si __attribute__ ((vector_size (8)));
10747 typedef short v4hi __attribute__ ((vector_size (8)));
10748 typedef char v8qi __attribute__ ((vector_size (8)));
10750 int __builtin_arm_getwcgr0 (void)
10751 void __builtin_arm_setwcgr0 (int)
10752 int __builtin_arm_getwcgr1 (void)
10753 void __builtin_arm_setwcgr1 (int)
10754 int __builtin_arm_getwcgr2 (void)
10755 void __builtin_arm_setwcgr2 (int)
10756 int __builtin_arm_getwcgr3 (void)
10757 void __builtin_arm_setwcgr3 (int)
10758 int __builtin_arm_textrmsb (v8qi, int)
10759 int __builtin_arm_textrmsh (v4hi, int)
10760 int __builtin_arm_textrmsw (v2si, int)
10761 int __builtin_arm_textrmub (v8qi, int)
10762 int __builtin_arm_textrmuh (v4hi, int)
10763 int __builtin_arm_textrmuw (v2si, int)
10764 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10765 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10766 v2si __builtin_arm_tinsrw (v2si, int, int)
10767 long long __builtin_arm_tmia (long long, int, int)
10768 long long __builtin_arm_tmiabb (long long, int, int)
10769 long long __builtin_arm_tmiabt (long long, int, int)
10770 long long __builtin_arm_tmiaph (long long, int, int)
10771 long long __builtin_arm_tmiatb (long long, int, int)
10772 long long __builtin_arm_tmiatt (long long, int, int)
10773 int __builtin_arm_tmovmskb (v8qi)
10774 int __builtin_arm_tmovmskh (v4hi)
10775 int __builtin_arm_tmovmskw (v2si)
10776 long long __builtin_arm_waccb (v8qi)
10777 long long __builtin_arm_wacch (v4hi)
10778 long long __builtin_arm_waccw (v2si)
10779 v8qi __builtin_arm_waddb (v8qi, v8qi)
10780 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10781 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10782 v4hi __builtin_arm_waddh (v4hi, v4hi)
10783 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10784 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10785 v2si __builtin_arm_waddw (v2si, v2si)
10786 v2si __builtin_arm_waddwss (v2si, v2si)
10787 v2si __builtin_arm_waddwus (v2si, v2si)
10788 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10789 long long __builtin_arm_wand(long long, long long)
10790 long long __builtin_arm_wandn (long long, long long)
10791 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10792 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10793 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10794 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10795 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10796 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10797 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10798 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10799 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10800 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10801 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10802 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10803 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10804 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10805 long long __builtin_arm_wmacsz (v4hi, v4hi)
10806 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10807 long long __builtin_arm_wmacuz (v4hi, v4hi)
10808 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10809 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10810 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10811 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10812 v2si __builtin_arm_wmaxsw (v2si, v2si)
10813 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10814 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10815 v2si __builtin_arm_wmaxuw (v2si, v2si)
10816 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10817 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10818 v2si __builtin_arm_wminsw (v2si, v2si)
10819 v8qi __builtin_arm_wminub (v8qi, v8qi)
10820 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10821 v2si __builtin_arm_wminuw (v2si, v2si)
10822 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10823 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10824 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10825 long long __builtin_arm_wor (long long, long long)
10826 v2si __builtin_arm_wpackdss (long long, long long)
10827 v2si __builtin_arm_wpackdus (long long, long long)
10828 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10829 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10830 v4hi __builtin_arm_wpackwss (v2si, v2si)
10831 v4hi __builtin_arm_wpackwus (v2si, v2si)
10832 long long __builtin_arm_wrord (long long, long long)
10833 long long __builtin_arm_wrordi (long long, int)
10834 v4hi __builtin_arm_wrorh (v4hi, long long)
10835 v4hi __builtin_arm_wrorhi (v4hi, int)
10836 v2si __builtin_arm_wrorw (v2si, long long)
10837 v2si __builtin_arm_wrorwi (v2si, int)
10838 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10839 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10840 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10841 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10842 v4hi __builtin_arm_wshufh (v4hi, int)
10843 long long __builtin_arm_wslld (long long, long long)
10844 long long __builtin_arm_wslldi (long long, int)
10845 v4hi __builtin_arm_wsllh (v4hi, long long)
10846 v4hi __builtin_arm_wsllhi (v4hi, int)
10847 v2si __builtin_arm_wsllw (v2si, long long)
10848 v2si __builtin_arm_wsllwi (v2si, int)
10849 long long __builtin_arm_wsrad (long long, long long)
10850 long long __builtin_arm_wsradi (long long, int)
10851 v4hi __builtin_arm_wsrah (v4hi, long long)
10852 v4hi __builtin_arm_wsrahi (v4hi, int)
10853 v2si __builtin_arm_wsraw (v2si, long long)
10854 v2si __builtin_arm_wsrawi (v2si, int)
10855 long long __builtin_arm_wsrld (long long, long long)
10856 long long __builtin_arm_wsrldi (long long, int)
10857 v4hi __builtin_arm_wsrlh (v4hi, long long)
10858 v4hi __builtin_arm_wsrlhi (v4hi, int)
10859 v2si __builtin_arm_wsrlw (v2si, long long)
10860 v2si __builtin_arm_wsrlwi (v2si, int)
10861 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10862 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10863 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10864 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10865 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10866 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10867 v2si __builtin_arm_wsubw (v2si, v2si)
10868 v2si __builtin_arm_wsubwss (v2si, v2si)
10869 v2si __builtin_arm_wsubwus (v2si, v2si)
10870 v4hi __builtin_arm_wunpckehsb (v8qi)
10871 v2si __builtin_arm_wunpckehsh (v4hi)
10872 long long __builtin_arm_wunpckehsw (v2si)
10873 v4hi __builtin_arm_wunpckehub (v8qi)
10874 v2si __builtin_arm_wunpckehuh (v4hi)
10875 long long __builtin_arm_wunpckehuw (v2si)
10876 v4hi __builtin_arm_wunpckelsb (v8qi)
10877 v2si __builtin_arm_wunpckelsh (v4hi)
10878 long long __builtin_arm_wunpckelsw (v2si)
10879 v4hi __builtin_arm_wunpckelub (v8qi)
10880 v2si __builtin_arm_wunpckeluh (v4hi)
10881 long long __builtin_arm_wunpckeluw (v2si)
10882 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10883 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10884 v2si __builtin_arm_wunpckihw (v2si, v2si)
10885 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10886 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10887 v2si __builtin_arm_wunpckilw (v2si, v2si)
10888 long long __builtin_arm_wxor (long long, long long)
10889 long long __builtin_arm_wzero ()
10890 @end smallexample
10893 @node ARM C Language Extensions (ACLE)
10894 @subsection ARM C Language Extensions (ACLE)
10896 GCC implements extensions for C as described in the ARM C Language
10897 Extensions (ACLE) specification, which can be found at
10898 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
10900 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
10901 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
10902 intrinsics can be found at
10903 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
10904 The built-in intrinsics for the Advanced SIMD extension are available when
10905 NEON is enabled.
10907 Currently, ARM and AArch64 back-ends do not support ACLE 2.0 fully.  Both
10908 back-ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM backend's
10909 16-bit floating-point Advanded SIMD Intrinsics currently comply to ACLE v1.1.
10910 AArch64's backend does not have support for 16-bit floating point Advanced SIMD
10911 Intrinsics yet.
10913 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
10914 availability of extensions.
10916 @node ARM Floating Point Status and Control Intrinsics
10917 @subsection ARM Floating Point Status and Control Intrinsics
10919 These built-in functions are available for the ARM family of
10920 processors with floating-point unit.
10922 @smallexample
10923 unsigned int __builtin_arm_get_fpscr ()
10924 void __builtin_arm_set_fpscr (unsigned int)
10925 @end smallexample
10927 @node AVR Built-in Functions
10928 @subsection AVR Built-in Functions
10930 For each built-in function for AVR, there is an equally named,
10931 uppercase built-in macro defined. That way users can easily query if
10932 or if not a specific built-in is implemented or not. For example, if
10933 @code{__builtin_avr_nop} is available the macro
10934 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10936 The following built-in functions map to the respective machine
10937 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10938 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10939 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10940 as library call if no hardware multiplier is available.
10942 @smallexample
10943 void __builtin_avr_nop (void)
10944 void __builtin_avr_sei (void)
10945 void __builtin_avr_cli (void)
10946 void __builtin_avr_sleep (void)
10947 void __builtin_avr_wdr (void)
10948 unsigned char __builtin_avr_swap (unsigned char)
10949 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10950 int __builtin_avr_fmuls (char, char)
10951 int __builtin_avr_fmulsu (char, unsigned char)
10952 @end smallexample
10954 In order to delay execution for a specific number of cycles, GCC
10955 implements
10956 @smallexample
10957 void __builtin_avr_delay_cycles (unsigned long ticks)
10958 @end smallexample
10960 @noindent
10961 @code{ticks} is the number of ticks to delay execution. Note that this
10962 built-in does not take into account the effect of interrupts that
10963 might increase delay time. @code{ticks} must be a compile-time
10964 integer constant; delays with a variable number of cycles are not supported.
10966 @smallexample
10967 char __builtin_avr_flash_segment (const __memx void*)
10968 @end smallexample
10970 @noindent
10971 This built-in takes a byte address to the 24-bit
10972 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10973 the number of the flash segment (the 64 KiB chunk) where the address
10974 points to.  Counting starts at @code{0}.
10975 If the address does not point to flash memory, return @code{-1}.
10977 @smallexample
10978 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10979 @end smallexample
10981 @noindent
10982 Insert bits from @var{bits} into @var{val} and return the resulting
10983 value. The nibbles of @var{map} determine how the insertion is
10984 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
10985 @enumerate
10986 @item If @var{X} is @code{0xf},
10987 then the @var{n}-th bit of @var{val} is returned unaltered.
10989 @item If X is in the range 0@dots{}7,
10990 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
10992 @item If X is in the range 8@dots{}@code{0xe},
10993 then the @var{n}-th result bit is undefined.
10994 @end enumerate
10996 @noindent
10997 One typical use case for this built-in is adjusting input and
10998 output values to non-contiguous port layouts. Some examples:
11000 @smallexample
11001 // same as val, bits is unused
11002 __builtin_avr_insert_bits (0xffffffff, bits, val)
11003 @end smallexample
11005 @smallexample
11006 // same as bits, val is unused
11007 __builtin_avr_insert_bits (0x76543210, bits, val)
11008 @end smallexample
11010 @smallexample
11011 // same as rotating bits by 4
11012 __builtin_avr_insert_bits (0x32107654, bits, 0)
11013 @end smallexample
11015 @smallexample
11016 // high nibble of result is the high nibble of val
11017 // low nibble of result is the low nibble of bits
11018 __builtin_avr_insert_bits (0xffff3210, bits, val)
11019 @end smallexample
11021 @smallexample
11022 // reverse the bit order of bits
11023 __builtin_avr_insert_bits (0x01234567, bits, 0)
11024 @end smallexample
11026 @node Blackfin Built-in Functions
11027 @subsection Blackfin Built-in Functions
11029 Currently, there are two Blackfin-specific built-in functions.  These are
11030 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
11031 using inline assembly; by using these built-in functions the compiler can
11032 automatically add workarounds for hardware errata involving these
11033 instructions.  These functions are named as follows:
11035 @smallexample
11036 void __builtin_bfin_csync (void)
11037 void __builtin_bfin_ssync (void)
11038 @end smallexample
11040 @node FR-V Built-in Functions
11041 @subsection FR-V Built-in Functions
11043 GCC provides many FR-V-specific built-in functions.  In general,
11044 these functions are intended to be compatible with those described
11045 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11046 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
11047 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11048 pointer rather than by value.
11050 Most of the functions are named after specific FR-V instructions.
11051 Such functions are said to be ``directly mapped'' and are summarized
11052 here in tabular form.
11054 @menu
11055 * Argument Types::
11056 * Directly-mapped Integer Functions::
11057 * Directly-mapped Media Functions::
11058 * Raw read/write Functions::
11059 * Other Built-in Functions::
11060 @end menu
11062 @node Argument Types
11063 @subsubsection Argument Types
11065 The arguments to the built-in functions can be divided into three groups:
11066 register numbers, compile-time constants and run-time values.  In order
11067 to make this classification clear at a glance, the arguments and return
11068 values are given the following pseudo types:
11070 @multitable @columnfractions .20 .30 .15 .35
11071 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11072 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11073 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11074 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11075 @item @code{uw2} @tab @code{unsigned long long} @tab No
11076 @tab an unsigned doubleword
11077 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11078 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11079 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11080 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11081 @end multitable
11083 These pseudo types are not defined by GCC, they are simply a notational
11084 convenience used in this manual.
11086 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11087 and @code{sw2} are evaluated at run time.  They correspond to
11088 register operands in the underlying FR-V instructions.
11090 @code{const} arguments represent immediate operands in the underlying
11091 FR-V instructions.  They must be compile-time constants.
11093 @code{acc} arguments are evaluated at compile time and specify the number
11094 of an accumulator register.  For example, an @code{acc} argument of 2
11095 selects the ACC2 register.
11097 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11098 number of an IACC register.  See @pxref{Other Built-in Functions}
11099 for more details.
11101 @node Directly-mapped Integer Functions
11102 @subsubsection Directly-mapped Integer Functions
11104 The functions listed below map directly to FR-V I-type instructions.
11106 @multitable @columnfractions .45 .32 .23
11107 @item Function prototype @tab Example usage @tab Assembly output
11108 @item @code{sw1 __ADDSS (sw1, sw1)}
11109 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11110 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11111 @item @code{sw1 __SCAN (sw1, sw1)}
11112 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11113 @tab @code{SCAN @var{a},@var{b},@var{c}}
11114 @item @code{sw1 __SCUTSS (sw1)}
11115 @tab @code{@var{b} = __SCUTSS (@var{a})}
11116 @tab @code{SCUTSS @var{a},@var{b}}
11117 @item @code{sw1 __SLASS (sw1, sw1)}
11118 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11119 @tab @code{SLASS @var{a},@var{b},@var{c}}
11120 @item @code{void __SMASS (sw1, sw1)}
11121 @tab @code{__SMASS (@var{a}, @var{b})}
11122 @tab @code{SMASS @var{a},@var{b}}
11123 @item @code{void __SMSSS (sw1, sw1)}
11124 @tab @code{__SMSSS (@var{a}, @var{b})}
11125 @tab @code{SMSSS @var{a},@var{b}}
11126 @item @code{void __SMU (sw1, sw1)}
11127 @tab @code{__SMU (@var{a}, @var{b})}
11128 @tab @code{SMU @var{a},@var{b}}
11129 @item @code{sw2 __SMUL (sw1, sw1)}
11130 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11131 @tab @code{SMUL @var{a},@var{b},@var{c}}
11132 @item @code{sw1 __SUBSS (sw1, sw1)}
11133 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11134 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11135 @item @code{uw2 __UMUL (uw1, uw1)}
11136 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11137 @tab @code{UMUL @var{a},@var{b},@var{c}}
11138 @end multitable
11140 @node Directly-mapped Media Functions
11141 @subsubsection Directly-mapped Media Functions
11143 The functions listed below map directly to FR-V M-type instructions.
11145 @multitable @columnfractions .45 .32 .23
11146 @item Function prototype @tab Example usage @tab Assembly output
11147 @item @code{uw1 __MABSHS (sw1)}
11148 @tab @code{@var{b} = __MABSHS (@var{a})}
11149 @tab @code{MABSHS @var{a},@var{b}}
11150 @item @code{void __MADDACCS (acc, acc)}
11151 @tab @code{__MADDACCS (@var{b}, @var{a})}
11152 @tab @code{MADDACCS @var{a},@var{b}}
11153 @item @code{sw1 __MADDHSS (sw1, sw1)}
11154 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11155 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11156 @item @code{uw1 __MADDHUS (uw1, uw1)}
11157 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11158 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11159 @item @code{uw1 __MAND (uw1, uw1)}
11160 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11161 @tab @code{MAND @var{a},@var{b},@var{c}}
11162 @item @code{void __MASACCS (acc, acc)}
11163 @tab @code{__MASACCS (@var{b}, @var{a})}
11164 @tab @code{MASACCS @var{a},@var{b}}
11165 @item @code{uw1 __MAVEH (uw1, uw1)}
11166 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11167 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11168 @item @code{uw2 __MBTOH (uw1)}
11169 @tab @code{@var{b} = __MBTOH (@var{a})}
11170 @tab @code{MBTOH @var{a},@var{b}}
11171 @item @code{void __MBTOHE (uw1 *, uw1)}
11172 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11173 @tab @code{MBTOHE @var{a},@var{b}}
11174 @item @code{void __MCLRACC (acc)}
11175 @tab @code{__MCLRACC (@var{a})}
11176 @tab @code{MCLRACC @var{a}}
11177 @item @code{void __MCLRACCA (void)}
11178 @tab @code{__MCLRACCA ()}
11179 @tab @code{MCLRACCA}
11180 @item @code{uw1 __Mcop1 (uw1, uw1)}
11181 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11182 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11183 @item @code{uw1 __Mcop2 (uw1, uw1)}
11184 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11185 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11186 @item @code{uw1 __MCPLHI (uw2, const)}
11187 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11188 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11189 @item @code{uw1 __MCPLI (uw2, const)}
11190 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11191 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11192 @item @code{void __MCPXIS (acc, sw1, sw1)}
11193 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11194 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11195 @item @code{void __MCPXIU (acc, uw1, uw1)}
11196 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11197 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11198 @item @code{void __MCPXRS (acc, sw1, sw1)}
11199 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11200 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11201 @item @code{void __MCPXRU (acc, uw1, uw1)}
11202 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11203 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11204 @item @code{uw1 __MCUT (acc, uw1)}
11205 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11206 @tab @code{MCUT @var{a},@var{b},@var{c}}
11207 @item @code{uw1 __MCUTSS (acc, sw1)}
11208 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11209 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11210 @item @code{void __MDADDACCS (acc, acc)}
11211 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11212 @tab @code{MDADDACCS @var{a},@var{b}}
11213 @item @code{void __MDASACCS (acc, acc)}
11214 @tab @code{__MDASACCS (@var{b}, @var{a})}
11215 @tab @code{MDASACCS @var{a},@var{b}}
11216 @item @code{uw2 __MDCUTSSI (acc, const)}
11217 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11218 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11219 @item @code{uw2 __MDPACKH (uw2, uw2)}
11220 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11221 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11222 @item @code{uw2 __MDROTLI (uw2, const)}
11223 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11224 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11225 @item @code{void __MDSUBACCS (acc, acc)}
11226 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11227 @tab @code{MDSUBACCS @var{a},@var{b}}
11228 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11229 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11230 @tab @code{MDUNPACKH @var{a},@var{b}}
11231 @item @code{uw2 __MEXPDHD (uw1, const)}
11232 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11233 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11234 @item @code{uw1 __MEXPDHW (uw1, const)}
11235 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11236 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11237 @item @code{uw1 __MHDSETH (uw1, const)}
11238 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11239 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11240 @item @code{sw1 __MHDSETS (const)}
11241 @tab @code{@var{b} = __MHDSETS (@var{a})}
11242 @tab @code{MHDSETS #@var{a},@var{b}}
11243 @item @code{uw1 __MHSETHIH (uw1, const)}
11244 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11245 @tab @code{MHSETHIH #@var{a},@var{b}}
11246 @item @code{sw1 __MHSETHIS (sw1, const)}
11247 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11248 @tab @code{MHSETHIS #@var{a},@var{b}}
11249 @item @code{uw1 __MHSETLOH (uw1, const)}
11250 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11251 @tab @code{MHSETLOH #@var{a},@var{b}}
11252 @item @code{sw1 __MHSETLOS (sw1, const)}
11253 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11254 @tab @code{MHSETLOS #@var{a},@var{b}}
11255 @item @code{uw1 __MHTOB (uw2)}
11256 @tab @code{@var{b} = __MHTOB (@var{a})}
11257 @tab @code{MHTOB @var{a},@var{b}}
11258 @item @code{void __MMACHS (acc, sw1, sw1)}
11259 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11260 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11261 @item @code{void __MMACHU (acc, uw1, uw1)}
11262 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11263 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11264 @item @code{void __MMRDHS (acc, sw1, sw1)}
11265 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11266 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11267 @item @code{void __MMRDHU (acc, uw1, uw1)}
11268 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11269 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11270 @item @code{void __MMULHS (acc, sw1, sw1)}
11271 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11272 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11273 @item @code{void __MMULHU (acc, uw1, uw1)}
11274 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11275 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11276 @item @code{void __MMULXHS (acc, sw1, sw1)}
11277 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11278 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11279 @item @code{void __MMULXHU (acc, uw1, uw1)}
11280 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11281 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11282 @item @code{uw1 __MNOT (uw1)}
11283 @tab @code{@var{b} = __MNOT (@var{a})}
11284 @tab @code{MNOT @var{a},@var{b}}
11285 @item @code{uw1 __MOR (uw1, uw1)}
11286 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11287 @tab @code{MOR @var{a},@var{b},@var{c}}
11288 @item @code{uw1 __MPACKH (uh, uh)}
11289 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11290 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11291 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11292 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11293 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11294 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11295 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11296 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11297 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11298 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11299 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11300 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11301 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11302 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11303 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11304 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11305 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11306 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11307 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11308 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11309 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11310 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11311 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11312 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11313 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11314 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11315 @item @code{void __MQMACHS (acc, sw2, sw2)}
11316 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11317 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11318 @item @code{void __MQMACHU (acc, uw2, uw2)}
11319 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11320 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11321 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11322 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11323 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11324 @item @code{void __MQMULHS (acc, sw2, sw2)}
11325 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11326 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11327 @item @code{void __MQMULHU (acc, uw2, uw2)}
11328 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11329 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11330 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11331 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11332 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11333 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11334 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11335 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11336 @item @code{sw2 __MQSATHS (sw2, sw2)}
11337 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11338 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11339 @item @code{uw2 __MQSLLHI (uw2, int)}
11340 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11341 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11342 @item @code{sw2 __MQSRAHI (sw2, int)}
11343 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11344 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11345 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11346 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11347 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11348 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11349 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11350 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11351 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11352 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11353 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11354 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11355 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11356 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11357 @item @code{uw1 __MRDACC (acc)}
11358 @tab @code{@var{b} = __MRDACC (@var{a})}
11359 @tab @code{MRDACC @var{a},@var{b}}
11360 @item @code{uw1 __MRDACCG (acc)}
11361 @tab @code{@var{b} = __MRDACCG (@var{a})}
11362 @tab @code{MRDACCG @var{a},@var{b}}
11363 @item @code{uw1 __MROTLI (uw1, const)}
11364 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11365 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11366 @item @code{uw1 __MROTRI (uw1, const)}
11367 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11368 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11369 @item @code{sw1 __MSATHS (sw1, sw1)}
11370 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11371 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11372 @item @code{uw1 __MSATHU (uw1, uw1)}
11373 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11374 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11375 @item @code{uw1 __MSLLHI (uw1, const)}
11376 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11377 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11378 @item @code{sw1 __MSRAHI (sw1, const)}
11379 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11380 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11381 @item @code{uw1 __MSRLHI (uw1, const)}
11382 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11383 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11384 @item @code{void __MSUBACCS (acc, acc)}
11385 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11386 @tab @code{MSUBACCS @var{a},@var{b}}
11387 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11388 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11389 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11390 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11391 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11392 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11393 @item @code{void __MTRAP (void)}
11394 @tab @code{__MTRAP ()}
11395 @tab @code{MTRAP}
11396 @item @code{uw2 __MUNPACKH (uw1)}
11397 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11398 @tab @code{MUNPACKH @var{a},@var{b}}
11399 @item @code{uw1 __MWCUT (uw2, uw1)}
11400 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11401 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11402 @item @code{void __MWTACC (acc, uw1)}
11403 @tab @code{__MWTACC (@var{b}, @var{a})}
11404 @tab @code{MWTACC @var{a},@var{b}}
11405 @item @code{void __MWTACCG (acc, uw1)}
11406 @tab @code{__MWTACCG (@var{b}, @var{a})}
11407 @tab @code{MWTACCG @var{a},@var{b}}
11408 @item @code{uw1 __MXOR (uw1, uw1)}
11409 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11410 @tab @code{MXOR @var{a},@var{b},@var{c}}
11411 @end multitable
11413 @node Raw read/write Functions
11414 @subsubsection Raw read/write Functions
11416 This sections describes built-in functions related to read and write
11417 instructions to access memory.  These functions generate
11418 @code{membar} instructions to flush the I/O load and stores where
11419 appropriate, as described in Fujitsu's manual described above.
11421 @table @code
11423 @item unsigned char __builtin_read8 (void *@var{data})
11424 @item unsigned short __builtin_read16 (void *@var{data})
11425 @item unsigned long __builtin_read32 (void *@var{data})
11426 @item unsigned long long __builtin_read64 (void *@var{data})
11428 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11429 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11430 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11431 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11432 @end table
11434 @node Other Built-in Functions
11435 @subsubsection Other Built-in Functions
11437 This section describes built-in functions that are not named after
11438 a specific FR-V instruction.
11440 @table @code
11441 @item sw2 __IACCreadll (iacc @var{reg})
11442 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
11443 for future expansion and must be 0.
11445 @item sw1 __IACCreadl (iacc @var{reg})
11446 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11447 Other values of @var{reg} are rejected as invalid.
11449 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11450 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
11451 is reserved for future expansion and must be 0.
11453 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11454 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11455 is 1.  Other values of @var{reg} are rejected as invalid.
11457 @item void __data_prefetch0 (const void *@var{x})
11458 Use the @code{dcpl} instruction to load the contents of address @var{x}
11459 into the data cache.
11461 @item void __data_prefetch (const void *@var{x})
11462 Use the @code{nldub} instruction to load the contents of address @var{x}
11463 into the data cache.  The instruction is issued in slot I1@.
11464 @end table
11466 @node X86 Built-in Functions
11467 @subsection X86 Built-in Functions
11469 These built-in functions are available for the i386 and x86-64 family
11470 of computers, depending on the command-line switches used.
11472 If you specify command-line switches such as @option{-msse},
11473 the compiler could use the extended instruction sets even if the built-ins
11474 are not used explicitly in the program.  For this reason, applications
11475 that perform run-time CPU detection must compile separate files for each
11476 supported architecture, using the appropriate flags.  In particular,
11477 the file containing the CPU detection code should be compiled without
11478 these options.
11480 The following machine modes are available for use with MMX built-in functions
11481 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11482 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11483 vector of eight 8-bit integers.  Some of the built-in functions operate on
11484 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11486 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11487 of two 32-bit floating-point values.
11489 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11490 floating-point values.  Some instructions use a vector of four 32-bit
11491 integers, these use @code{V4SI}.  Finally, some instructions operate on an
11492 entire vector register, interpreting it as a 128-bit integer, these use mode
11493 @code{TI}.
11495 In 64-bit mode, the x86-64 family of processors uses additional built-in
11496 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11497 floating point and @code{TC} 128-bit complex floating-point values.
11499 The following floating-point built-in functions are available in 64-bit
11500 mode.  All of them implement the function that is part of the name.
11502 @smallexample
11503 __float128 __builtin_fabsq (__float128)
11504 __float128 __builtin_copysignq (__float128, __float128)
11505 @end smallexample
11507 The following built-in function is always available.
11509 @table @code
11510 @item void __builtin_ia32_pause (void)
11511 Generates the @code{pause} machine instruction with a compiler memory
11512 barrier.
11513 @end table
11515 The following floating-point built-in functions are made available in the
11516 64-bit mode.
11518 @table @code
11519 @item __float128 __builtin_infq (void)
11520 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11521 @findex __builtin_infq
11523 @item __float128 __builtin_huge_valq (void)
11524 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11525 @findex __builtin_huge_valq
11526 @end table
11528 The following built-in functions are always available and can be used to
11529 check the target platform type.
11531 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11532 This function runs the CPU detection code to check the type of CPU and the
11533 features supported.  This built-in function needs to be invoked along with the built-in functions
11534 to check CPU type and features, @code{__builtin_cpu_is} and
11535 @code{__builtin_cpu_supports}, only when used in a function that is
11536 executed before any constructors are called.  The CPU detection code is
11537 automatically executed in a very high priority constructor.
11539 For example, this function has to be used in @code{ifunc} resolvers that
11540 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11541 and @code{__builtin_cpu_supports}, or in constructors on targets that
11542 don't support constructor priority.
11543 @smallexample
11545 static void (*resolve_memcpy (void)) (void)
11547   // ifunc resolvers fire before constructors, explicitly call the init
11548   // function.
11549   __builtin_cpu_init ();
11550   if (__builtin_cpu_supports ("ssse3"))
11551     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11552   else
11553     return default_memcpy;
11556 void *memcpy (void *, const void *, size_t)
11557      __attribute__ ((ifunc ("resolve_memcpy")));
11558 @end smallexample
11560 @end deftypefn
11562 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11563 This function returns a positive integer if the run-time CPU
11564 is of type @var{cpuname}
11565 and returns @code{0} otherwise. The following CPU names can be detected:
11567 @table @samp
11568 @item intel
11569 Intel CPU.
11571 @item atom
11572 Intel Atom CPU.
11574 @item core2
11575 Intel Core 2 CPU.
11577 @item corei7
11578 Intel Core i7 CPU.
11580 @item nehalem
11581 Intel Core i7 Nehalem CPU.
11583 @item westmere
11584 Intel Core i7 Westmere CPU.
11586 @item sandybridge
11587 Intel Core i7 Sandy Bridge CPU.
11589 @item amd
11590 AMD CPU.
11592 @item amdfam10h
11593 AMD Family 10h CPU.
11595 @item barcelona
11596 AMD Family 10h Barcelona CPU.
11598 @item shanghai
11599 AMD Family 10h Shanghai CPU.
11601 @item istanbul
11602 AMD Family 10h Istanbul CPU.
11604 @item btver1
11605 AMD Family 14h CPU.
11607 @item amdfam15h
11608 AMD Family 15h CPU.
11610 @item bdver1
11611 AMD Family 15h Bulldozer version 1.
11613 @item bdver2
11614 AMD Family 15h Bulldozer version 2.
11616 @item bdver3
11617 AMD Family 15h Bulldozer version 3.
11619 @item bdver4
11620 AMD Family 15h Bulldozer version 4.
11622 @item btver2
11623 AMD Family 16h CPU.
11624 @end table
11626 Here is an example:
11627 @smallexample
11628 if (__builtin_cpu_is ("corei7"))
11629   @{
11630      do_corei7 (); // Core i7 specific implementation.
11631   @}
11632 else
11633   @{
11634      do_generic (); // Generic implementation.
11635   @}
11636 @end smallexample
11637 @end deftypefn
11639 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11640 This function returns a positive integer if the run-time CPU
11641 supports @var{feature}
11642 and returns @code{0} otherwise. The following features can be detected:
11644 @table @samp
11645 @item cmov
11646 CMOV instruction.
11647 @item mmx
11648 MMX instructions.
11649 @item popcnt
11650 POPCNT instruction.
11651 @item sse
11652 SSE instructions.
11653 @item sse2
11654 SSE2 instructions.
11655 @item sse3
11656 SSE3 instructions.
11657 @item ssse3
11658 SSSE3 instructions.
11659 @item sse4.1
11660 SSE4.1 instructions.
11661 @item sse4.2
11662 SSE4.2 instructions.
11663 @item avx
11664 AVX instructions.
11665 @item avx2
11666 AVX2 instructions.
11667 @item avx512f
11668 AVX512F instructions.
11669 @end table
11671 Here is an example:
11672 @smallexample
11673 if (__builtin_cpu_supports ("popcnt"))
11674   @{
11675      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11676   @}
11677 else
11678   @{
11679      count = generic_countbits (n); //generic implementation.
11680   @}
11681 @end smallexample
11682 @end deftypefn
11685 The following built-in functions are made available by @option{-mmmx}.
11686 All of them generate the machine instruction that is part of the name.
11688 @smallexample
11689 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11690 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11691 v2si __builtin_ia32_paddd (v2si, v2si)
11692 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11693 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11694 v2si __builtin_ia32_psubd (v2si, v2si)
11695 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11696 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11697 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11698 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11699 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11700 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11701 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11702 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11703 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11704 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11705 di __builtin_ia32_pand (di, di)
11706 di __builtin_ia32_pandn (di,di)
11707 di __builtin_ia32_por (di, di)
11708 di __builtin_ia32_pxor (di, di)
11709 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11710 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11711 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11712 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11713 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11714 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11715 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11716 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11717 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11718 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11719 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11720 v2si __builtin_ia32_punpckldq (v2si, v2si)
11721 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11722 v4hi __builtin_ia32_packssdw (v2si, v2si)
11723 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11725 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11726 v2si __builtin_ia32_pslld (v2si, v2si)
11727 v1di __builtin_ia32_psllq (v1di, v1di)
11728 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11729 v2si __builtin_ia32_psrld (v2si, v2si)
11730 v1di __builtin_ia32_psrlq (v1di, v1di)
11731 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11732 v2si __builtin_ia32_psrad (v2si, v2si)
11733 v4hi __builtin_ia32_psllwi (v4hi, int)
11734 v2si __builtin_ia32_pslldi (v2si, int)
11735 v1di __builtin_ia32_psllqi (v1di, int)
11736 v4hi __builtin_ia32_psrlwi (v4hi, int)
11737 v2si __builtin_ia32_psrldi (v2si, int)
11738 v1di __builtin_ia32_psrlqi (v1di, int)
11739 v4hi __builtin_ia32_psrawi (v4hi, int)
11740 v2si __builtin_ia32_psradi (v2si, int)
11742 @end smallexample
11744 The following built-in functions are made available either with
11745 @option{-msse}, or with a combination of @option{-m3dnow} and
11746 @option{-march=athlon}.  All of them generate the machine
11747 instruction that is part of the name.
11749 @smallexample
11750 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11751 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11752 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11753 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11754 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11755 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11756 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11757 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11758 int __builtin_ia32_pmovmskb (v8qi)
11759 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11760 void __builtin_ia32_movntq (di *, di)
11761 void __builtin_ia32_sfence (void)
11762 @end smallexample
11764 The following built-in functions are available when @option{-msse} is used.
11765 All of them generate the machine instruction that is part of the name.
11767 @smallexample
11768 int __builtin_ia32_comieq (v4sf, v4sf)
11769 int __builtin_ia32_comineq (v4sf, v4sf)
11770 int __builtin_ia32_comilt (v4sf, v4sf)
11771 int __builtin_ia32_comile (v4sf, v4sf)
11772 int __builtin_ia32_comigt (v4sf, v4sf)
11773 int __builtin_ia32_comige (v4sf, v4sf)
11774 int __builtin_ia32_ucomieq (v4sf, v4sf)
11775 int __builtin_ia32_ucomineq (v4sf, v4sf)
11776 int __builtin_ia32_ucomilt (v4sf, v4sf)
11777 int __builtin_ia32_ucomile (v4sf, v4sf)
11778 int __builtin_ia32_ucomigt (v4sf, v4sf)
11779 int __builtin_ia32_ucomige (v4sf, v4sf)
11780 v4sf __builtin_ia32_addps (v4sf, v4sf)
11781 v4sf __builtin_ia32_subps (v4sf, v4sf)
11782 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11783 v4sf __builtin_ia32_divps (v4sf, v4sf)
11784 v4sf __builtin_ia32_addss (v4sf, v4sf)
11785 v4sf __builtin_ia32_subss (v4sf, v4sf)
11786 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11787 v4sf __builtin_ia32_divss (v4sf, v4sf)
11788 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11789 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11790 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11791 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11792 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11793 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11794 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11795 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11796 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11797 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11798 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11799 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11800 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11801 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11802 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11803 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11804 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11805 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11806 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11807 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11808 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11809 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11810 v4sf __builtin_ia32_minps (v4sf, v4sf)
11811 v4sf __builtin_ia32_minss (v4sf, v4sf)
11812 v4sf __builtin_ia32_andps (v4sf, v4sf)
11813 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11814 v4sf __builtin_ia32_orps (v4sf, v4sf)
11815 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11816 v4sf __builtin_ia32_movss (v4sf, v4sf)
11817 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11818 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11819 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11820 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11821 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11822 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11823 v2si __builtin_ia32_cvtps2pi (v4sf)
11824 int __builtin_ia32_cvtss2si (v4sf)
11825 v2si __builtin_ia32_cvttps2pi (v4sf)
11826 int __builtin_ia32_cvttss2si (v4sf)
11827 v4sf __builtin_ia32_rcpps (v4sf)
11828 v4sf __builtin_ia32_rsqrtps (v4sf)
11829 v4sf __builtin_ia32_sqrtps (v4sf)
11830 v4sf __builtin_ia32_rcpss (v4sf)
11831 v4sf __builtin_ia32_rsqrtss (v4sf)
11832 v4sf __builtin_ia32_sqrtss (v4sf)
11833 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11834 void __builtin_ia32_movntps (float *, v4sf)
11835 int __builtin_ia32_movmskps (v4sf)
11836 @end smallexample
11838 The following built-in functions are available when @option{-msse} is used.
11840 @table @code
11841 @item v4sf __builtin_ia32_loadups (float *)
11842 Generates the @code{movups} machine instruction as a load from memory.
11843 @item void __builtin_ia32_storeups (float *, v4sf)
11844 Generates the @code{movups} machine instruction as a store to memory.
11845 @item v4sf __builtin_ia32_loadss (float *)
11846 Generates the @code{movss} machine instruction as a load from memory.
11847 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11848 Generates the @code{movhps} machine instruction as a load from memory.
11849 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11850 Generates the @code{movlps} machine instruction as a load from memory
11851 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11852 Generates the @code{movhps} machine instruction as a store to memory.
11853 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11854 Generates the @code{movlps} machine instruction as a store to memory.
11855 @end table
11857 The following built-in functions are available when @option{-msse2} is used.
11858 All of them generate the machine instruction that is part of the name.
11860 @smallexample
11861 int __builtin_ia32_comisdeq (v2df, v2df)
11862 int __builtin_ia32_comisdlt (v2df, v2df)
11863 int __builtin_ia32_comisdle (v2df, v2df)
11864 int __builtin_ia32_comisdgt (v2df, v2df)
11865 int __builtin_ia32_comisdge (v2df, v2df)
11866 int __builtin_ia32_comisdneq (v2df, v2df)
11867 int __builtin_ia32_ucomisdeq (v2df, v2df)
11868 int __builtin_ia32_ucomisdlt (v2df, v2df)
11869 int __builtin_ia32_ucomisdle (v2df, v2df)
11870 int __builtin_ia32_ucomisdgt (v2df, v2df)
11871 int __builtin_ia32_ucomisdge (v2df, v2df)
11872 int __builtin_ia32_ucomisdneq (v2df, v2df)
11873 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11874 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11875 v2df __builtin_ia32_cmplepd (v2df, v2df)
11876 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11877 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11878 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11879 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11880 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11881 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11882 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11883 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11884 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11885 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11886 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11887 v2df __builtin_ia32_cmplesd (v2df, v2df)
11888 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11889 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11890 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11891 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11892 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11893 v2di __builtin_ia32_paddq (v2di, v2di)
11894 v2di __builtin_ia32_psubq (v2di, v2di)
11895 v2df __builtin_ia32_addpd (v2df, v2df)
11896 v2df __builtin_ia32_subpd (v2df, v2df)
11897 v2df __builtin_ia32_mulpd (v2df, v2df)
11898 v2df __builtin_ia32_divpd (v2df, v2df)
11899 v2df __builtin_ia32_addsd (v2df, v2df)
11900 v2df __builtin_ia32_subsd (v2df, v2df)
11901 v2df __builtin_ia32_mulsd (v2df, v2df)
11902 v2df __builtin_ia32_divsd (v2df, v2df)
11903 v2df __builtin_ia32_minpd (v2df, v2df)
11904 v2df __builtin_ia32_maxpd (v2df, v2df)
11905 v2df __builtin_ia32_minsd (v2df, v2df)
11906 v2df __builtin_ia32_maxsd (v2df, v2df)
11907 v2df __builtin_ia32_andpd (v2df, v2df)
11908 v2df __builtin_ia32_andnpd (v2df, v2df)
11909 v2df __builtin_ia32_orpd (v2df, v2df)
11910 v2df __builtin_ia32_xorpd (v2df, v2df)
11911 v2df __builtin_ia32_movsd (v2df, v2df)
11912 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11913 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11914 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11915 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11916 v4si __builtin_ia32_paddd128 (v4si, v4si)
11917 v2di __builtin_ia32_paddq128 (v2di, v2di)
11918 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11919 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11920 v4si __builtin_ia32_psubd128 (v4si, v4si)
11921 v2di __builtin_ia32_psubq128 (v2di, v2di)
11922 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11923 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11924 v2di __builtin_ia32_pand128 (v2di, v2di)
11925 v2di __builtin_ia32_pandn128 (v2di, v2di)
11926 v2di __builtin_ia32_por128 (v2di, v2di)
11927 v2di __builtin_ia32_pxor128 (v2di, v2di)
11928 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11929 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11930 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11931 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11932 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11933 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11934 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11935 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11936 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11937 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11938 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11939 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11940 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11941 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11942 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11943 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11944 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11945 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11946 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11947 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11948 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11949 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11950 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11951 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11952 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11953 v2df __builtin_ia32_loadupd (double *)
11954 void __builtin_ia32_storeupd (double *, v2df)
11955 v2df __builtin_ia32_loadhpd (v2df, double const *)
11956 v2df __builtin_ia32_loadlpd (v2df, double const *)
11957 int __builtin_ia32_movmskpd (v2df)
11958 int __builtin_ia32_pmovmskb128 (v16qi)
11959 void __builtin_ia32_movnti (int *, int)
11960 void __builtin_ia32_movnti64 (long long int *, long long int)
11961 void __builtin_ia32_movntpd (double *, v2df)
11962 void __builtin_ia32_movntdq (v2df *, v2df)
11963 v4si __builtin_ia32_pshufd (v4si, int)
11964 v8hi __builtin_ia32_pshuflw (v8hi, int)
11965 v8hi __builtin_ia32_pshufhw (v8hi, int)
11966 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11967 v2df __builtin_ia32_sqrtpd (v2df)
11968 v2df __builtin_ia32_sqrtsd (v2df)
11969 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11970 v2df __builtin_ia32_cvtdq2pd (v4si)
11971 v4sf __builtin_ia32_cvtdq2ps (v4si)
11972 v4si __builtin_ia32_cvtpd2dq (v2df)
11973 v2si __builtin_ia32_cvtpd2pi (v2df)
11974 v4sf __builtin_ia32_cvtpd2ps (v2df)
11975 v4si __builtin_ia32_cvttpd2dq (v2df)
11976 v2si __builtin_ia32_cvttpd2pi (v2df)
11977 v2df __builtin_ia32_cvtpi2pd (v2si)
11978 int __builtin_ia32_cvtsd2si (v2df)
11979 int __builtin_ia32_cvttsd2si (v2df)
11980 long long __builtin_ia32_cvtsd2si64 (v2df)
11981 long long __builtin_ia32_cvttsd2si64 (v2df)
11982 v4si __builtin_ia32_cvtps2dq (v4sf)
11983 v2df __builtin_ia32_cvtps2pd (v4sf)
11984 v4si __builtin_ia32_cvttps2dq (v4sf)
11985 v2df __builtin_ia32_cvtsi2sd (v2df, int)
11986 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
11987 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
11988 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
11989 void __builtin_ia32_clflush (const void *)
11990 void __builtin_ia32_lfence (void)
11991 void __builtin_ia32_mfence (void)
11992 v16qi __builtin_ia32_loaddqu (const char *)
11993 void __builtin_ia32_storedqu (char *, v16qi)
11994 v1di __builtin_ia32_pmuludq (v2si, v2si)
11995 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
11996 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
11997 v4si __builtin_ia32_pslld128 (v4si, v4si)
11998 v2di __builtin_ia32_psllq128 (v2di, v2di)
11999 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
12000 v4si __builtin_ia32_psrld128 (v4si, v4si)
12001 v2di __builtin_ia32_psrlq128 (v2di, v2di)
12002 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
12003 v4si __builtin_ia32_psrad128 (v4si, v4si)
12004 v2di __builtin_ia32_pslldqi128 (v2di, int)
12005 v8hi __builtin_ia32_psllwi128 (v8hi, int)
12006 v4si __builtin_ia32_pslldi128 (v4si, int)
12007 v2di __builtin_ia32_psllqi128 (v2di, int)
12008 v2di __builtin_ia32_psrldqi128 (v2di, int)
12009 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
12010 v4si __builtin_ia32_psrldi128 (v4si, int)
12011 v2di __builtin_ia32_psrlqi128 (v2di, int)
12012 v8hi __builtin_ia32_psrawi128 (v8hi, int)
12013 v4si __builtin_ia32_psradi128 (v4si, int)
12014 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
12015 v2di __builtin_ia32_movq128 (v2di)
12016 @end smallexample
12018 The following built-in functions are available when @option{-msse3} is used.
12019 All of them generate the machine instruction that is part of the name.
12021 @smallexample
12022 v2df __builtin_ia32_addsubpd (v2df, v2df)
12023 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
12024 v2df __builtin_ia32_haddpd (v2df, v2df)
12025 v4sf __builtin_ia32_haddps (v4sf, v4sf)
12026 v2df __builtin_ia32_hsubpd (v2df, v2df)
12027 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
12028 v16qi __builtin_ia32_lddqu (char const *)
12029 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
12030 v4sf __builtin_ia32_movshdup (v4sf)
12031 v4sf __builtin_ia32_movsldup (v4sf)
12032 void __builtin_ia32_mwait (unsigned int, unsigned int)
12033 @end smallexample
12035 The following built-in functions are available when @option{-mssse3} is used.
12036 All of them generate the machine instruction that is part of the name.
12038 @smallexample
12039 v2si __builtin_ia32_phaddd (v2si, v2si)
12040 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
12041 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
12042 v2si __builtin_ia32_phsubd (v2si, v2si)
12043 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
12044 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
12045 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
12046 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
12047 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
12048 v8qi __builtin_ia32_psignb (v8qi, v8qi)
12049 v2si __builtin_ia32_psignd (v2si, v2si)
12050 v4hi __builtin_ia32_psignw (v4hi, v4hi)
12051 v1di __builtin_ia32_palignr (v1di, v1di, int)
12052 v8qi __builtin_ia32_pabsb (v8qi)
12053 v2si __builtin_ia32_pabsd (v2si)
12054 v4hi __builtin_ia32_pabsw (v4hi)
12055 @end smallexample
12057 The following built-in functions are available when @option{-mssse3} is used.
12058 All of them generate the machine instruction that is part of the name.
12060 @smallexample
12061 v4si __builtin_ia32_phaddd128 (v4si, v4si)
12062 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
12063 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
12064 v4si __builtin_ia32_phsubd128 (v4si, v4si)
12065 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
12066 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
12067 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
12068 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
12069 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
12070 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
12071 v4si __builtin_ia32_psignd128 (v4si, v4si)
12072 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
12073 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
12074 v16qi __builtin_ia32_pabsb128 (v16qi)
12075 v4si __builtin_ia32_pabsd128 (v4si)
12076 v8hi __builtin_ia32_pabsw128 (v8hi)
12077 @end smallexample
12079 The following built-in functions are available when @option{-msse4.1} is
12080 used.  All of them generate the machine instruction that is part of the
12081 name.
12083 @smallexample
12084 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
12085 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
12086 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
12087 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
12088 v2df __builtin_ia32_dppd (v2df, v2df, const int)
12089 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
12090 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
12091 v2di __builtin_ia32_movntdqa (v2di *);
12092 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
12093 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
12094 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
12095 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
12096 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
12097 v8hi __builtin_ia32_phminposuw128 (v8hi)
12098 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
12099 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
12100 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
12101 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
12102 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
12103 v4si __builtin_ia32_pminsd128 (v4si, v4si)
12104 v4si __builtin_ia32_pminud128 (v4si, v4si)
12105 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
12106 v4si __builtin_ia32_pmovsxbd128 (v16qi)
12107 v2di __builtin_ia32_pmovsxbq128 (v16qi)
12108 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
12109 v2di __builtin_ia32_pmovsxdq128 (v4si)
12110 v4si __builtin_ia32_pmovsxwd128 (v8hi)
12111 v2di __builtin_ia32_pmovsxwq128 (v8hi)
12112 v4si __builtin_ia32_pmovzxbd128 (v16qi)
12113 v2di __builtin_ia32_pmovzxbq128 (v16qi)
12114 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
12115 v2di __builtin_ia32_pmovzxdq128 (v4si)
12116 v4si __builtin_ia32_pmovzxwd128 (v8hi)
12117 v2di __builtin_ia32_pmovzxwq128 (v8hi)
12118 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
12119 v4si __builtin_ia32_pmulld128 (v4si, v4si)
12120 int __builtin_ia32_ptestc128 (v2di, v2di)
12121 int __builtin_ia32_ptestnzc128 (v2di, v2di)
12122 int __builtin_ia32_ptestz128 (v2di, v2di)
12123 v2df __builtin_ia32_roundpd (v2df, const int)
12124 v4sf __builtin_ia32_roundps (v4sf, const int)
12125 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
12126 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
12127 @end smallexample
12129 The following built-in functions are available when @option{-msse4.1} is
12130 used.
12132 @table @code
12133 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
12134 Generates the @code{insertps} machine instruction.
12135 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
12136 Generates the @code{pextrb} machine instruction.
12137 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
12138 Generates the @code{pinsrb} machine instruction.
12139 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
12140 Generates the @code{pinsrd} machine instruction.
12141 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
12142 Generates the @code{pinsrq} machine instruction in 64bit mode.
12143 @end table
12145 The following built-in functions are changed to generate new SSE4.1
12146 instructions when @option{-msse4.1} is used.
12148 @table @code
12149 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
12150 Generates the @code{extractps} machine instruction.
12151 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
12152 Generates the @code{pextrd} machine instruction.
12153 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
12154 Generates the @code{pextrq} machine instruction in 64bit mode.
12155 @end table
12157 The following built-in functions are available when @option{-msse4.2} is
12158 used.  All of them generate the machine instruction that is part of the
12159 name.
12161 @smallexample
12162 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
12163 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
12164 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
12165 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
12166 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
12167 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
12168 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
12169 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
12170 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
12171 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
12172 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
12173 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
12174 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
12175 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
12176 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
12177 @end smallexample
12179 The following built-in functions are available when @option{-msse4.2} is
12180 used.
12182 @table @code
12183 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
12184 Generates the @code{crc32b} machine instruction.
12185 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
12186 Generates the @code{crc32w} machine instruction.
12187 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
12188 Generates the @code{crc32l} machine instruction.
12189 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
12190 Generates the @code{crc32q} machine instruction.
12191 @end table
12193 The following built-in functions are changed to generate new SSE4.2
12194 instructions when @option{-msse4.2} is used.
12196 @table @code
12197 @item int __builtin_popcount (unsigned int)
12198 Generates the @code{popcntl} machine instruction.
12199 @item int __builtin_popcountl (unsigned long)
12200 Generates the @code{popcntl} or @code{popcntq} machine instruction,
12201 depending on the size of @code{unsigned long}.
12202 @item int __builtin_popcountll (unsigned long long)
12203 Generates the @code{popcntq} machine instruction.
12204 @end table
12206 The following built-in functions are available when @option{-mavx} is
12207 used. All of them generate the machine instruction that is part of the
12208 name.
12210 @smallexample
12211 v4df __builtin_ia32_addpd256 (v4df,v4df)
12212 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
12213 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
12214 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
12215 v4df __builtin_ia32_andnpd256 (v4df,v4df)
12216 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
12217 v4df __builtin_ia32_andpd256 (v4df,v4df)
12218 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
12219 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
12220 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
12221 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
12222 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
12223 v2df __builtin_ia32_cmppd (v2df,v2df,int)
12224 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
12225 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
12226 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
12227 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
12228 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
12229 v4df __builtin_ia32_cvtdq2pd256 (v4si)
12230 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
12231 v4si __builtin_ia32_cvtpd2dq256 (v4df)
12232 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
12233 v8si __builtin_ia32_cvtps2dq256 (v8sf)
12234 v4df __builtin_ia32_cvtps2pd256 (v4sf)
12235 v4si __builtin_ia32_cvttpd2dq256 (v4df)
12236 v8si __builtin_ia32_cvttps2dq256 (v8sf)
12237 v4df __builtin_ia32_divpd256 (v4df,v4df)
12238 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
12239 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
12240 v4df __builtin_ia32_haddpd256 (v4df,v4df)
12241 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
12242 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
12243 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
12244 v32qi __builtin_ia32_lddqu256 (pcchar)
12245 v32qi __builtin_ia32_loaddqu256 (pcchar)
12246 v4df __builtin_ia32_loadupd256 (pcdouble)
12247 v8sf __builtin_ia32_loadups256 (pcfloat)
12248 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
12249 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
12250 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
12251 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
12252 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
12253 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
12254 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
12255 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
12256 v4df __builtin_ia32_maxpd256 (v4df,v4df)
12257 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
12258 v4df __builtin_ia32_minpd256 (v4df,v4df)
12259 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
12260 v4df __builtin_ia32_movddup256 (v4df)
12261 int __builtin_ia32_movmskpd256 (v4df)
12262 int __builtin_ia32_movmskps256 (v8sf)
12263 v8sf __builtin_ia32_movshdup256 (v8sf)
12264 v8sf __builtin_ia32_movsldup256 (v8sf)
12265 v4df __builtin_ia32_mulpd256 (v4df,v4df)
12266 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
12267 v4df __builtin_ia32_orpd256 (v4df,v4df)
12268 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
12269 v2df __builtin_ia32_pd_pd256 (v4df)
12270 v4df __builtin_ia32_pd256_pd (v2df)
12271 v4sf __builtin_ia32_ps_ps256 (v8sf)
12272 v8sf __builtin_ia32_ps256_ps (v4sf)
12273 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
12274 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
12275 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
12276 v8sf __builtin_ia32_rcpps256 (v8sf)
12277 v4df __builtin_ia32_roundpd256 (v4df,int)
12278 v8sf __builtin_ia32_roundps256 (v8sf,int)
12279 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
12280 v8sf __builtin_ia32_rsqrtps256 (v8sf)
12281 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
12282 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
12283 v4si __builtin_ia32_si_si256 (v8si)
12284 v8si __builtin_ia32_si256_si (v4si)
12285 v4df __builtin_ia32_sqrtpd256 (v4df)
12286 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
12287 v8sf __builtin_ia32_sqrtps256 (v8sf)
12288 void __builtin_ia32_storedqu256 (pchar,v32qi)
12289 void __builtin_ia32_storeupd256 (pdouble,v4df)
12290 void __builtin_ia32_storeups256 (pfloat,v8sf)
12291 v4df __builtin_ia32_subpd256 (v4df,v4df)
12292 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
12293 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
12294 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
12295 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
12296 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
12297 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
12298 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
12299 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
12300 v4sf __builtin_ia32_vbroadcastss (pcfloat)
12301 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
12302 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
12303 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
12304 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
12305 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
12306 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
12307 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
12308 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
12309 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
12310 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
12311 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
12312 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
12313 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
12314 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
12315 v2df __builtin_ia32_vpermilpd (v2df,int)
12316 v4df __builtin_ia32_vpermilpd256 (v4df,int)
12317 v4sf __builtin_ia32_vpermilps (v4sf,int)
12318 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
12319 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
12320 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
12321 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
12322 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
12323 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
12324 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
12325 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
12326 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
12327 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
12328 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
12329 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
12330 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
12331 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
12332 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
12333 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
12334 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
12335 void __builtin_ia32_vzeroall (void)
12336 void __builtin_ia32_vzeroupper (void)
12337 v4df __builtin_ia32_xorpd256 (v4df,v4df)
12338 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
12339 @end smallexample
12341 The following built-in functions are available when @option{-mavx2} is
12342 used. All of them generate the machine instruction that is part of the
12343 name.
12345 @smallexample
12346 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
12347 v32qi __builtin_ia32_pabsb256 (v32qi)
12348 v16hi __builtin_ia32_pabsw256 (v16hi)
12349 v8si __builtin_ia32_pabsd256 (v8si)
12350 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
12351 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
12352 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
12353 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
12354 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
12355 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
12356 v8si __builtin_ia32_paddd256 (v8si,v8si)
12357 v4di __builtin_ia32_paddq256 (v4di,v4di)
12358 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
12359 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
12360 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
12361 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
12362 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
12363 v4di __builtin_ia32_andsi256 (v4di,v4di)
12364 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
12365 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
12366 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
12367 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
12368 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
12369 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
12370 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
12371 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
12372 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
12373 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
12374 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
12375 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
12376 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
12377 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
12378 v8si __builtin_ia32_phaddd256 (v8si,v8si)
12379 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
12380 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
12381 v8si __builtin_ia32_phsubd256 (v8si,v8si)
12382 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
12383 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
12384 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
12385 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
12386 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
12387 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
12388 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
12389 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
12390 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
12391 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
12392 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
12393 v8si __builtin_ia32_pminsd256 (v8si,v8si)
12394 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
12395 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
12396 v8si __builtin_ia32_pminud256 (v8si,v8si)
12397 int __builtin_ia32_pmovmskb256 (v32qi)
12398 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
12399 v8si __builtin_ia32_pmovsxbd256 (v16qi)
12400 v4di __builtin_ia32_pmovsxbq256 (v16qi)
12401 v8si __builtin_ia32_pmovsxwd256 (v8hi)
12402 v4di __builtin_ia32_pmovsxwq256 (v8hi)
12403 v4di __builtin_ia32_pmovsxdq256 (v4si)
12404 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
12405 v8si __builtin_ia32_pmovzxbd256 (v16qi)
12406 v4di __builtin_ia32_pmovzxbq256 (v16qi)
12407 v8si __builtin_ia32_pmovzxwd256 (v8hi)
12408 v4di __builtin_ia32_pmovzxwq256 (v8hi)
12409 v4di __builtin_ia32_pmovzxdq256 (v4si)
12410 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12411 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12412 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12413 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12414 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12415 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12416 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12417 v4di __builtin_ia32_por256 (v4di,v4di)
12418 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12419 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12420 v8si __builtin_ia32_pshufd256 (v8si,int)
12421 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12422 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12423 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12424 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12425 v8si __builtin_ia32_psignd256 (v8si,v8si)
12426 v4di __builtin_ia32_pslldqi256 (v4di,int)
12427 v16hi __builtin_ia32_psllwi256 (16hi,int)
12428 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12429 v8si __builtin_ia32_pslldi256 (v8si,int)
12430 v8si __builtin_ia32_pslld256(v8si,v4si)
12431 v4di __builtin_ia32_psllqi256 (v4di,int)
12432 v4di __builtin_ia32_psllq256(v4di,v2di)
12433 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12434 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12435 v8si __builtin_ia32_psradi256 (v8si,int)
12436 v8si __builtin_ia32_psrad256 (v8si,v4si)
12437 v4di __builtin_ia32_psrldqi256 (v4di, int)
12438 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12439 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12440 v8si __builtin_ia32_psrldi256 (v8si,int)
12441 v8si __builtin_ia32_psrld256 (v8si,v4si)
12442 v4di __builtin_ia32_psrlqi256 (v4di,int)
12443 v4di __builtin_ia32_psrlq256(v4di,v2di)
12444 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12445 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12446 v8si __builtin_ia32_psubd256 (v8si,v8si)
12447 v4di __builtin_ia32_psubq256 (v4di,v4di)
12448 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12449 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12450 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12451 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12452 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12453 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12454 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12455 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12456 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12457 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12458 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12459 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12460 v4di __builtin_ia32_pxor256 (v4di,v4di)
12461 v4di __builtin_ia32_movntdqa256 (pv4di)
12462 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12463 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12464 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12465 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12466 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12467 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12468 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12469 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12470 v8si __builtin_ia32_pbroadcastd256 (v4si)
12471 v4di __builtin_ia32_pbroadcastq256 (v2di)
12472 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12473 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12474 v4si __builtin_ia32_pbroadcastd128 (v4si)
12475 v2di __builtin_ia32_pbroadcastq128 (v2di)
12476 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12477 v4df __builtin_ia32_permdf256 (v4df,int)
12478 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12479 v4di __builtin_ia32_permdi256 (v4di,int)
12480 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12481 v4di __builtin_ia32_extract128i256 (v4di,int)
12482 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12483 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12484 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12485 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12486 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12487 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12488 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12489 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12490 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12491 v8si __builtin_ia32_psllv8si (v8si,v8si)
12492 v4si __builtin_ia32_psllv4si (v4si,v4si)
12493 v4di __builtin_ia32_psllv4di (v4di,v4di)
12494 v2di __builtin_ia32_psllv2di (v2di,v2di)
12495 v8si __builtin_ia32_psrav8si (v8si,v8si)
12496 v4si __builtin_ia32_psrav4si (v4si,v4si)
12497 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12498 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12499 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12500 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12501 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12502 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12503 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12504 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12505 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12506 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12507 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12508 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12509 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12510 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12511 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12512 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12513 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12514 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12515 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12516 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12517 @end smallexample
12519 The following built-in functions are available when @option{-maes} is
12520 used.  All of them generate the machine instruction that is part of the
12521 name.
12523 @smallexample
12524 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12525 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12526 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12527 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12528 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12529 v2di __builtin_ia32_aesimc128 (v2di)
12530 @end smallexample
12532 The following built-in function is available when @option{-mpclmul} is
12533 used.
12535 @table @code
12536 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12537 Generates the @code{pclmulqdq} machine instruction.
12538 @end table
12540 The following built-in function is available when @option{-mfsgsbase} is
12541 used.  All of them generate the machine instruction that is part of the
12542 name.
12544 @smallexample
12545 unsigned int __builtin_ia32_rdfsbase32 (void)
12546 unsigned long long __builtin_ia32_rdfsbase64 (void)
12547 unsigned int __builtin_ia32_rdgsbase32 (void)
12548 unsigned long long __builtin_ia32_rdgsbase64 (void)
12549 void _writefsbase_u32 (unsigned int)
12550 void _writefsbase_u64 (unsigned long long)
12551 void _writegsbase_u32 (unsigned int)
12552 void _writegsbase_u64 (unsigned long long)
12553 @end smallexample
12555 The following built-in function is available when @option{-mrdrnd} is
12556 used.  All of them generate the machine instruction that is part of the
12557 name.
12559 @smallexample
12560 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12561 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12562 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12563 @end smallexample
12565 The following built-in functions are available when @option{-msse4a} is used.
12566 All of them generate the machine instruction that is part of the name.
12568 @smallexample
12569 void __builtin_ia32_movntsd (double *, v2df)
12570 void __builtin_ia32_movntss (float *, v4sf)
12571 v2di __builtin_ia32_extrq  (v2di, v16qi)
12572 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12573 v2di __builtin_ia32_insertq (v2di, v2di)
12574 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12575 @end smallexample
12577 The following built-in functions are available when @option{-mxop} is used.
12578 @smallexample
12579 v2df __builtin_ia32_vfrczpd (v2df)
12580 v4sf __builtin_ia32_vfrczps (v4sf)
12581 v2df __builtin_ia32_vfrczsd (v2df)
12582 v4sf __builtin_ia32_vfrczss (v4sf)
12583 v4df __builtin_ia32_vfrczpd256 (v4df)
12584 v8sf __builtin_ia32_vfrczps256 (v8sf)
12585 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12586 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12587 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12588 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12589 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12590 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12591 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12592 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12593 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12594 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12595 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12596 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12597 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12598 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12599 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12600 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12601 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12602 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12603 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12604 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12605 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12606 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12607 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12608 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12609 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12610 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12611 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12612 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12613 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12614 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12615 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12616 v4si __builtin_ia32_vpcomged (v4si, v4si)
12617 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12618 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12619 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12620 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12621 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12622 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12623 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12624 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12625 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12626 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12627 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12628 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12629 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12630 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12631 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12632 v4si __builtin_ia32_vpcomled (v4si, v4si)
12633 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12634 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12635 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12636 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12637 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12638 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12639 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12640 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12641 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12642 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12643 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12644 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12645 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12646 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12647 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12648 v4si __builtin_ia32_vpcomned (v4si, v4si)
12649 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12650 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12651 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12652 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12653 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12654 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12655 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12656 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12657 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12658 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12659 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12660 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12661 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12662 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12663 v4si __builtin_ia32_vphaddbd (v16qi)
12664 v2di __builtin_ia32_vphaddbq (v16qi)
12665 v8hi __builtin_ia32_vphaddbw (v16qi)
12666 v2di __builtin_ia32_vphadddq (v4si)
12667 v4si __builtin_ia32_vphaddubd (v16qi)
12668 v2di __builtin_ia32_vphaddubq (v16qi)
12669 v8hi __builtin_ia32_vphaddubw (v16qi)
12670 v2di __builtin_ia32_vphaddudq (v4si)
12671 v4si __builtin_ia32_vphadduwd (v8hi)
12672 v2di __builtin_ia32_vphadduwq (v8hi)
12673 v4si __builtin_ia32_vphaddwd (v8hi)
12674 v2di __builtin_ia32_vphaddwq (v8hi)
12675 v8hi __builtin_ia32_vphsubbw (v16qi)
12676 v2di __builtin_ia32_vphsubdq (v4si)
12677 v4si __builtin_ia32_vphsubwd (v8hi)
12678 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12679 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12680 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12681 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12682 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12683 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12684 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12685 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12686 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12687 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12688 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12689 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12690 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12691 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12692 v4si __builtin_ia32_vprotd (v4si, v4si)
12693 v2di __builtin_ia32_vprotq (v2di, v2di)
12694 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12695 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12696 v4si __builtin_ia32_vpshad (v4si, v4si)
12697 v2di __builtin_ia32_vpshaq (v2di, v2di)
12698 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12699 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12700 v4si __builtin_ia32_vpshld (v4si, v4si)
12701 v2di __builtin_ia32_vpshlq (v2di, v2di)
12702 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12703 @end smallexample
12705 The following built-in functions are available when @option{-mfma4} is used.
12706 All of them generate the machine instruction that is part of the name.
12708 @smallexample
12709 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12710 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12711 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12712 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12713 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12714 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12715 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12716 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12717 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12718 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12719 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12720 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12721 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12722 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12723 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12724 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12725 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
12726 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
12727 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
12728 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
12729 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12730 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12731 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12732 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12733 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12734 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12735 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12736 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12737 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12738 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12739 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12740 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12742 @end smallexample
12744 The following built-in functions are available when @option{-mlwp} is used.
12746 @smallexample
12747 void __builtin_ia32_llwpcb16 (void *);
12748 void __builtin_ia32_llwpcb32 (void *);
12749 void __builtin_ia32_llwpcb64 (void *);
12750 void * __builtin_ia32_llwpcb16 (void);
12751 void * __builtin_ia32_llwpcb32 (void);
12752 void * __builtin_ia32_llwpcb64 (void);
12753 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12754 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12755 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12756 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12757 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12758 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12759 @end smallexample
12761 The following built-in functions are available when @option{-mbmi} is used.
12762 All of them generate the machine instruction that is part of the name.
12763 @smallexample
12764 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12765 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12766 @end smallexample
12768 The following built-in functions are available when @option{-mbmi2} is used.
12769 All of them generate the machine instruction that is part of the name.
12770 @smallexample
12771 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12772 unsigned int _pdep_u32 (unsigned int, unsigned int)
12773 unsigned int _pext_u32 (unsigned int, unsigned int)
12774 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12775 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12776 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12777 @end smallexample
12779 The following built-in functions are available when @option{-mlzcnt} is used.
12780 All of them generate the machine instruction that is part of the name.
12781 @smallexample
12782 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12783 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12784 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12785 @end smallexample
12787 The following built-in functions are available when @option{-mfxsr} is used.
12788 All of them generate the machine instruction that is part of the name.
12789 @smallexample
12790 void __builtin_ia32_fxsave (void *)
12791 void __builtin_ia32_fxrstor (void *)
12792 void __builtin_ia32_fxsave64 (void *)
12793 void __builtin_ia32_fxrstor64 (void *)
12794 @end smallexample
12796 The following built-in functions are available when @option{-mxsave} is used.
12797 All of them generate the machine instruction that is part of the name.
12798 @smallexample
12799 void __builtin_ia32_xsave (void *, long long)
12800 void __builtin_ia32_xrstor (void *, long long)
12801 void __builtin_ia32_xsave64 (void *, long long)
12802 void __builtin_ia32_xrstor64 (void *, long long)
12803 @end smallexample
12805 The following built-in functions are available when @option{-mxsaveopt} is used.
12806 All of them generate the machine instruction that is part of the name.
12807 @smallexample
12808 void __builtin_ia32_xsaveopt (void *, long long)
12809 void __builtin_ia32_xsaveopt64 (void *, long long)
12810 @end smallexample
12812 The following built-in functions are available when @option{-mtbm} is used.
12813 Both of them generate the immediate form of the bextr machine instruction.
12814 @smallexample
12815 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12816 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12817 @end smallexample
12820 The following built-in functions are available when @option{-m3dnow} is used.
12821 All of them generate the machine instruction that is part of the name.
12823 @smallexample
12824 void __builtin_ia32_femms (void)
12825 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12826 v2si __builtin_ia32_pf2id (v2sf)
12827 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12828 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12829 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12830 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12831 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12832 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12833 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12834 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12835 v2sf __builtin_ia32_pfrcp (v2sf)
12836 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12837 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12838 v2sf __builtin_ia32_pfrsqrt (v2sf)
12839 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12840 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12841 v2sf __builtin_ia32_pi2fd (v2si)
12842 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12843 @end smallexample
12845 The following built-in functions are available when both @option{-m3dnow}
12846 and @option{-march=athlon} are used.  All of them generate the machine
12847 instruction that is part of the name.
12849 @smallexample
12850 v2si __builtin_ia32_pf2iw (v2sf)
12851 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12852 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12853 v2sf __builtin_ia32_pi2fw (v2si)
12854 v2sf __builtin_ia32_pswapdsf (v2sf)
12855 v2si __builtin_ia32_pswapdsi (v2si)
12856 @end smallexample
12858 The following built-in functions are available when @option{-mrtm} is used
12859 They are used for restricted transactional memory. These are the internal
12860 low level functions. Normally the functions in 
12861 @ref{X86 transactional memory intrinsics} should be used instead.
12863 @smallexample
12864 int __builtin_ia32_xbegin ()
12865 void __builtin_ia32_xend ()
12866 void __builtin_ia32_xabort (status)
12867 int __builtin_ia32_xtest ()
12868 @end smallexample
12870 @node X86 transactional memory intrinsics
12871 @subsection X86 transaction memory intrinsics
12873 Hardware transactional memory intrinsics for i386. These allow to use
12874 memory transactions with RTM (Restricted Transactional Memory).
12875 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12876 This support is enabled with the @option{-mrtm} option.
12878 A memory transaction commits all changes to memory in an atomic way,
12879 as visible to other threads. If the transaction fails it is rolled back
12880 and all side effects discarded.
12882 Generally there is no guarantee that a memory transaction ever succeeds
12883 and suitable fallback code always needs to be supplied.
12885 @deftypefn {RTM Function} {unsigned} _xbegin ()
12886 Start a RTM (Restricted Transactional Memory) transaction. 
12887 Returns _XBEGIN_STARTED when the transaction
12888 started successfully (note this is not 0, so the constant has to be 
12889 explicitely tested). When the transaction aborts all side effects
12890 are undone and an abort code is returned. There is no guarantee
12891 any transaction ever succeeds, so there always needs to be a valid
12892 tested fallback path.
12893 @end deftypefn
12895 @smallexample
12896 #include <immintrin.h>
12898 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12899     ... transaction code...
12900     _xend ();
12901 @} else @{
12902     ... non transactional fallback path...
12904 @end smallexample
12906 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12908 @table @code
12909 @item _XABORT_EXPLICIT
12910 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12911 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12912 @item _XABORT_RETRY
12913 Transaction retry is possible.
12914 @item _XABORT_CONFLICT
12915 Transaction abort due to a memory conflict with another thread
12916 @item _XABORT_CAPACITY
12917 Transaction abort due to the transaction using too much memory
12918 @item _XABORT_DEBUG
12919 Transaction abort due to a debug trap
12920 @item _XABORT_NESTED
12921 Transaction abort in a inner nested transaction
12922 @end table
12924 @deftypefn {RTM Function} {void} _xend ()
12925 Commit the current transaction. When no transaction is active this will
12926 fault. All memory side effects of the transactions will become visible
12927 to other threads in an atomic matter.
12928 @end deftypefn
12930 @deftypefn {RTM Function} {int} _xtest ()
12931 Return a value not zero when a transaction is currently active, otherwise 0.
12932 @end deftypefn
12934 @deftypefn {RTM Function} {void} _xabort (status)
12935 Abort the current transaction. When no transaction is active this is a no-op.
12936 status must be a 8bit constant, that is included in the status code returned
12937 by @code{_xbegin}
12938 @end deftypefn
12940 @node MIPS DSP Built-in Functions
12941 @subsection MIPS DSP Built-in Functions
12943 The MIPS DSP Application-Specific Extension (ASE) includes new
12944 instructions that are designed to improve the performance of DSP and
12945 media applications.  It provides instructions that operate on packed
12946 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12948 GCC supports MIPS DSP operations using both the generic
12949 vector extensions (@pxref{Vector Extensions}) and a collection of
12950 MIPS-specific built-in functions.  Both kinds of support are
12951 enabled by the @option{-mdsp} command-line option.
12953 Revision 2 of the ASE was introduced in the second half of 2006.
12954 This revision adds extra instructions to the original ASE, but is
12955 otherwise backwards-compatible with it.  You can select revision 2
12956 using the command-line option @option{-mdspr2}; this option implies
12957 @option{-mdsp}.
12959 The SCOUNT and POS bits of the DSP control register are global.  The
12960 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12961 POS bits.  During optimization, the compiler does not delete these
12962 instructions and it does not delete calls to functions containing
12963 these instructions.
12965 At present, GCC only provides support for operations on 32-bit
12966 vectors.  The vector type associated with 8-bit integer data is
12967 usually called @code{v4i8}, the vector type associated with Q7
12968 is usually called @code{v4q7}, the vector type associated with 16-bit
12969 integer data is usually called @code{v2i16}, and the vector type
12970 associated with Q15 is usually called @code{v2q15}.  They can be
12971 defined in C as follows:
12973 @smallexample
12974 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12975 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12976 typedef short v2i16 __attribute__ ((vector_size(4)));
12977 typedef short v2q15 __attribute__ ((vector_size(4)));
12978 @end smallexample
12980 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12981 initialized in the same way as aggregates.  For example:
12983 @smallexample
12984 v4i8 a = @{1, 2, 3, 4@};
12985 v4i8 b;
12986 b = (v4i8) @{5, 6, 7, 8@};
12988 v2q15 c = @{0x0fcb, 0x3a75@};
12989 v2q15 d;
12990 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12991 @end smallexample
12993 @emph{Note:} The CPU's endianness determines the order in which values
12994 are packed.  On little-endian targets, the first value is the least
12995 significant and the last value is the most significant.  The opposite
12996 order applies to big-endian targets.  For example, the code above
12997 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12998 and @code{4} on big-endian targets.
13000 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13001 representation.  As shown in this example, the integer representation
13002 of a Q7 value can be obtained by multiplying the fractional value by
13003 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
13004 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
13005 @code{0x1.0p31}.
13007 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13008 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
13009 and @code{c} and @code{d} are @code{v2q15} values.
13011 @multitable @columnfractions .50 .50
13012 @item C code @tab MIPS instruction
13013 @item @code{a + b} @tab @code{addu.qb}
13014 @item @code{c + d} @tab @code{addq.ph}
13015 @item @code{a - b} @tab @code{subu.qb}
13016 @item @code{c - d} @tab @code{subq.ph}
13017 @end multitable
13019 The table below lists the @code{v2i16} operation for which
13020 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
13021 @code{v2i16} values.
13023 @multitable @columnfractions .50 .50
13024 @item C code @tab MIPS instruction
13025 @item @code{e * f} @tab @code{mul.ph}
13026 @end multitable
13028 It is easier to describe the DSP built-in functions if we first define
13029 the following types:
13031 @smallexample
13032 typedef int q31;
13033 typedef int i32;
13034 typedef unsigned int ui32;
13035 typedef long long a64;
13036 @end smallexample
13038 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13039 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13040 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13041 @code{long long}, but we use @code{a64} to indicate values that are
13042 placed in one of the four DSP accumulators (@code{$ac0},
13043 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13045 Also, some built-in functions prefer or require immediate numbers as
13046 parameters, because the corresponding DSP instructions accept both immediate
13047 numbers and register operands, or accept immediate numbers only.  The
13048 immediate parameters are listed as follows.
13050 @smallexample
13051 imm0_3: 0 to 3.
13052 imm0_7: 0 to 7.
13053 imm0_15: 0 to 15.
13054 imm0_31: 0 to 31.
13055 imm0_63: 0 to 63.
13056 imm0_255: 0 to 255.
13057 imm_n32_31: -32 to 31.
13058 imm_n512_511: -512 to 511.
13059 @end smallexample
13061 The following built-in functions map directly to a particular MIPS DSP
13062 instruction.  Please refer to the architecture specification
13063 for details on what each instruction does.
13065 @smallexample
13066 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13067 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13068 q31 __builtin_mips_addq_s_w (q31, q31)
13069 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13070 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13071 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13072 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13073 q31 __builtin_mips_subq_s_w (q31, q31)
13074 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13075 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13076 i32 __builtin_mips_addsc (i32, i32)
13077 i32 __builtin_mips_addwc (i32, i32)
13078 i32 __builtin_mips_modsub (i32, i32)
13079 i32 __builtin_mips_raddu_w_qb (v4i8)
13080 v2q15 __builtin_mips_absq_s_ph (v2q15)
13081 q31 __builtin_mips_absq_s_w (q31)
13082 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13083 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13084 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13085 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13086 q31 __builtin_mips_preceq_w_phl (v2q15)
13087 q31 __builtin_mips_preceq_w_phr (v2q15)
13088 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13089 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13090 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13091 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13092 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13093 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13094 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13095 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13096 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13097 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13098 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13099 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13100 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13101 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13102 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13103 q31 __builtin_mips_shll_s_w (q31, i32)
13104 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13105 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13106 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13107 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13108 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13109 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13110 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13111 q31 __builtin_mips_shra_r_w (q31, i32)
13112 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13113 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13114 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13115 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13116 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13117 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13118 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13119 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13120 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13121 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13122 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13123 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13124 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13125 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13126 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13127 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13128 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13129 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13130 i32 __builtin_mips_bitrev (i32)
13131 i32 __builtin_mips_insv (i32, i32)
13132 v4i8 __builtin_mips_repl_qb (imm0_255)
13133 v4i8 __builtin_mips_repl_qb (i32)
13134 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13135 v2q15 __builtin_mips_repl_ph (i32)
13136 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13137 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13138 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13139 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13140 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13141 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13142 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13143 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13144 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13145 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13146 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13147 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13148 i32 __builtin_mips_extr_w (a64, imm0_31)
13149 i32 __builtin_mips_extr_w (a64, i32)
13150 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13151 i32 __builtin_mips_extr_s_h (a64, i32)
13152 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13153 i32 __builtin_mips_extr_rs_w (a64, i32)
13154 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13155 i32 __builtin_mips_extr_r_w (a64, i32)
13156 i32 __builtin_mips_extp (a64, imm0_31)
13157 i32 __builtin_mips_extp (a64, i32)
13158 i32 __builtin_mips_extpdp (a64, imm0_31)
13159 i32 __builtin_mips_extpdp (a64, i32)
13160 a64 __builtin_mips_shilo (a64, imm_n32_31)
13161 a64 __builtin_mips_shilo (a64, i32)
13162 a64 __builtin_mips_mthlip (a64, i32)
13163 void __builtin_mips_wrdsp (i32, imm0_63)
13164 i32 __builtin_mips_rddsp (imm0_63)
13165 i32 __builtin_mips_lbux (void *, i32)
13166 i32 __builtin_mips_lhx (void *, i32)
13167 i32 __builtin_mips_lwx (void *, i32)
13168 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13169 i32 __builtin_mips_bposge32 (void)
13170 a64 __builtin_mips_madd (a64, i32, i32);
13171 a64 __builtin_mips_maddu (a64, ui32, ui32);
13172 a64 __builtin_mips_msub (a64, i32, i32);
13173 a64 __builtin_mips_msubu (a64, ui32, ui32);
13174 a64 __builtin_mips_mult (i32, i32);
13175 a64 __builtin_mips_multu (ui32, ui32);
13176 @end smallexample
13178 The following built-in functions map directly to a particular MIPS DSP REV 2
13179 instruction.  Please refer to the architecture specification
13180 for details on what each instruction does.
13182 @smallexample
13183 v4q7 __builtin_mips_absq_s_qb (v4q7);
13184 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13185 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13186 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13187 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13188 i32 __builtin_mips_append (i32, i32, imm0_31);
13189 i32 __builtin_mips_balign (i32, i32, imm0_3);
13190 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13191 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13192 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13193 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13194 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13195 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13196 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13197 q31 __builtin_mips_mulq_rs_w (q31, q31);
13198 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13199 q31 __builtin_mips_mulq_s_w (q31, q31);
13200 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13201 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13202 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13203 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13204 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13205 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13206 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13207 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13208 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13209 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13210 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13211 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13212 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13213 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13214 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13215 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13216 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13217 q31 __builtin_mips_addqh_w (q31, q31);
13218 q31 __builtin_mips_addqh_r_w (q31, q31);
13219 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13220 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13221 q31 __builtin_mips_subqh_w (q31, q31);
13222 q31 __builtin_mips_subqh_r_w (q31, q31);
13223 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13224 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13225 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13226 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13227 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13228 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13229 @end smallexample
13232 @node MIPS Paired-Single Support
13233 @subsection MIPS Paired-Single Support
13235 The MIPS64 architecture includes a number of instructions that
13236 operate on pairs of single-precision floating-point values.
13237 Each pair is packed into a 64-bit floating-point register,
13238 with one element being designated the ``upper half'' and
13239 the other being designated the ``lower half''.
13241 GCC supports paired-single operations using both the generic
13242 vector extensions (@pxref{Vector Extensions}) and a collection of
13243 MIPS-specific built-in functions.  Both kinds of support are
13244 enabled by the @option{-mpaired-single} command-line option.
13246 The vector type associated with paired-single values is usually
13247 called @code{v2sf}.  It can be defined in C as follows:
13249 @smallexample
13250 typedef float v2sf __attribute__ ((vector_size (8)));
13251 @end smallexample
13253 @code{v2sf} values are initialized in the same way as aggregates.
13254 For example:
13256 @smallexample
13257 v2sf a = @{1.5, 9.1@};
13258 v2sf b;
13259 float e, f;
13260 b = (v2sf) @{e, f@};
13261 @end smallexample
13263 @emph{Note:} The CPU's endianness determines which value is stored in
13264 the upper half of a register and which value is stored in the lower half.
13265 On little-endian targets, the first value is the lower one and the second
13266 value is the upper one.  The opposite order applies to big-endian targets.
13267 For example, the code above sets the lower half of @code{a} to
13268 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13270 @node MIPS Loongson Built-in Functions
13271 @subsection MIPS Loongson Built-in Functions
13273 GCC provides intrinsics to access the SIMD instructions provided by the
13274 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
13275 available after inclusion of the @code{loongson.h} header file,
13276 operate on the following 64-bit vector types:
13278 @itemize
13279 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13280 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13281 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13282 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13283 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13284 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13285 @end itemize
13287 The intrinsics provided are listed below; each is named after the
13288 machine instruction to which it corresponds, with suffixes added as
13289 appropriate to distinguish intrinsics that expand to the same machine
13290 instruction yet have different argument types.  Refer to the architecture
13291 documentation for a description of the functionality of each
13292 instruction.
13294 @smallexample
13295 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13296 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13297 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13298 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13299 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13300 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13301 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13302 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13303 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13304 uint64_t paddd_u (uint64_t s, uint64_t t);
13305 int64_t paddd_s (int64_t s, int64_t t);
13306 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13307 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13308 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13309 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13310 uint64_t pandn_ud (uint64_t s, uint64_t t);
13311 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13312 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13313 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13314 int64_t pandn_sd (int64_t s, int64_t t);
13315 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13316 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13317 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13318 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13319 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13320 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13321 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13322 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13323 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13324 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13325 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13326 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13327 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13328 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13329 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13330 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13331 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13332 uint16x4_t pextrh_u (uint16x4_t s, int field);
13333 int16x4_t pextrh_s (int16x4_t s, int field);
13334 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13335 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13336 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13337 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13338 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13339 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13340 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13341 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13342 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13343 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13344 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13345 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13346 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13347 uint8x8_t pmovmskb_u (uint8x8_t s);
13348 int8x8_t pmovmskb_s (int8x8_t s);
13349 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13350 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13351 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13352 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13353 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13354 uint16x4_t biadd (uint8x8_t s);
13355 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13356 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13357 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13358 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13359 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13360 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13361 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13362 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13363 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13364 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13365 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13366 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13367 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13368 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13369 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13370 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13371 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13372 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13373 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13374 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13375 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13376 uint64_t psubd_u (uint64_t s, uint64_t t);
13377 int64_t psubd_s (int64_t s, int64_t t);
13378 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13379 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13380 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13381 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13382 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13383 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13384 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13385 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13386 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13387 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13388 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13389 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13390 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13391 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13392 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13393 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13394 @end smallexample
13396 @menu
13397 * Paired-Single Arithmetic::
13398 * Paired-Single Built-in Functions::
13399 * MIPS-3D Built-in Functions::
13400 @end menu
13402 @node Paired-Single Arithmetic
13403 @subsubsection Paired-Single Arithmetic
13405 The table below lists the @code{v2sf} operations for which hardware
13406 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
13407 values and @code{x} is an integral value.
13409 @multitable @columnfractions .50 .50
13410 @item C code @tab MIPS instruction
13411 @item @code{a + b} @tab @code{add.ps}
13412 @item @code{a - b} @tab @code{sub.ps}
13413 @item @code{-a} @tab @code{neg.ps}
13414 @item @code{a * b} @tab @code{mul.ps}
13415 @item @code{a * b + c} @tab @code{madd.ps}
13416 @item @code{a * b - c} @tab @code{msub.ps}
13417 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13418 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13419 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13420 @end multitable
13422 Note that the multiply-accumulate instructions can be disabled
13423 using the command-line option @code{-mno-fused-madd}.
13425 @node Paired-Single Built-in Functions
13426 @subsubsection Paired-Single Built-in Functions
13428 The following paired-single functions map directly to a particular
13429 MIPS instruction.  Please refer to the architecture specification
13430 for details on what each instruction does.
13432 @table @code
13433 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13434 Pair lower lower (@code{pll.ps}).
13436 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13437 Pair upper lower (@code{pul.ps}).
13439 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13440 Pair lower upper (@code{plu.ps}).
13442 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13443 Pair upper upper (@code{puu.ps}).
13445 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13446 Convert pair to paired single (@code{cvt.ps.s}).
13448 @item float __builtin_mips_cvt_s_pl (v2sf)
13449 Convert pair lower to single (@code{cvt.s.pl}).
13451 @item float __builtin_mips_cvt_s_pu (v2sf)
13452 Convert pair upper to single (@code{cvt.s.pu}).
13454 @item v2sf __builtin_mips_abs_ps (v2sf)
13455 Absolute value (@code{abs.ps}).
13457 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13458 Align variable (@code{alnv.ps}).
13460 @emph{Note:} The value of the third parameter must be 0 or 4
13461 modulo 8, otherwise the result is unpredictable.  Please read the
13462 instruction description for details.
13463 @end table
13465 The following multi-instruction functions are also available.
13466 In each case, @var{cond} can be any of the 16 floating-point conditions:
13467 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13468 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13469 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13471 @table @code
13472 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13473 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13474 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13475 @code{movt.ps}/@code{movf.ps}).
13477 The @code{movt} functions return the value @var{x} computed by:
13479 @smallexample
13480 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13481 mov.ps @var{x},@var{c}
13482 movt.ps @var{x},@var{d},@var{cc}
13483 @end smallexample
13485 The @code{movf} functions are similar but use @code{movf.ps} instead
13486 of @code{movt.ps}.
13488 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13489 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13490 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13491 @code{bc1t}/@code{bc1f}).
13493 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13494 and return either the upper or lower half of the result.  For example:
13496 @smallexample
13497 v2sf a, b;
13498 if (__builtin_mips_upper_c_eq_ps (a, b))
13499   upper_halves_are_equal ();
13500 else
13501   upper_halves_are_unequal ();
13503 if (__builtin_mips_lower_c_eq_ps (a, b))
13504   lower_halves_are_equal ();
13505 else
13506   lower_halves_are_unequal ();
13507 @end smallexample
13508 @end table
13510 @node MIPS-3D Built-in Functions
13511 @subsubsection MIPS-3D Built-in Functions
13513 The MIPS-3D Application-Specific Extension (ASE) includes additional
13514 paired-single instructions that are designed to improve the performance
13515 of 3D graphics operations.  Support for these instructions is controlled
13516 by the @option{-mips3d} command-line option.
13518 The functions listed below map directly to a particular MIPS-3D
13519 instruction.  Please refer to the architecture specification for
13520 more details on what each instruction does.
13522 @table @code
13523 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13524 Reduction add (@code{addr.ps}).
13526 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13527 Reduction multiply (@code{mulr.ps}).
13529 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13530 Convert paired single to paired word (@code{cvt.pw.ps}).
13532 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13533 Convert paired word to paired single (@code{cvt.ps.pw}).
13535 @item float __builtin_mips_recip1_s (float)
13536 @itemx double __builtin_mips_recip1_d (double)
13537 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13538 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13540 @item float __builtin_mips_recip2_s (float, float)
13541 @itemx double __builtin_mips_recip2_d (double, double)
13542 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13543 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13545 @item float __builtin_mips_rsqrt1_s (float)
13546 @itemx double __builtin_mips_rsqrt1_d (double)
13547 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13548 Reduced-precision reciprocal square root (sequence step 1)
13549 (@code{rsqrt1.@var{fmt}}).
13551 @item float __builtin_mips_rsqrt2_s (float, float)
13552 @itemx double __builtin_mips_rsqrt2_d (double, double)
13553 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13554 Reduced-precision reciprocal square root (sequence step 2)
13555 (@code{rsqrt2.@var{fmt}}).
13556 @end table
13558 The following multi-instruction functions are also available.
13559 In each case, @var{cond} can be any of the 16 floating-point conditions:
13560 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13561 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13562 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13564 @table @code
13565 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13566 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13567 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13568 @code{bc1t}/@code{bc1f}).
13570 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13571 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13572 For example:
13574 @smallexample
13575 float a, b;
13576 if (__builtin_mips_cabs_eq_s (a, b))
13577   true ();
13578 else
13579   false ();
13580 @end smallexample
13582 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13583 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13584 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13585 @code{bc1t}/@code{bc1f}).
13587 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13588 and return either the upper or lower half of the result.  For example:
13590 @smallexample
13591 v2sf a, b;
13592 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13593   upper_halves_are_equal ();
13594 else
13595   upper_halves_are_unequal ();
13597 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13598   lower_halves_are_equal ();
13599 else
13600   lower_halves_are_unequal ();
13601 @end smallexample
13603 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13604 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13605 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13606 @code{movt.ps}/@code{movf.ps}).
13608 The @code{movt} functions return the value @var{x} computed by:
13610 @smallexample
13611 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13612 mov.ps @var{x},@var{c}
13613 movt.ps @var{x},@var{d},@var{cc}
13614 @end smallexample
13616 The @code{movf} functions are similar but use @code{movf.ps} instead
13617 of @code{movt.ps}.
13619 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13620 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13621 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13622 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13623 Comparison of two paired-single values
13624 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13625 @code{bc1any2t}/@code{bc1any2f}).
13627 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13628 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13629 result is true and the @code{all} forms return true if both results are true.
13630 For example:
13632 @smallexample
13633 v2sf a, b;
13634 if (__builtin_mips_any_c_eq_ps (a, b))
13635   one_is_true ();
13636 else
13637   both_are_false ();
13639 if (__builtin_mips_all_c_eq_ps (a, b))
13640   both_are_true ();
13641 else
13642   one_is_false ();
13643 @end smallexample
13645 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13646 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13647 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13648 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13649 Comparison of four paired-single values
13650 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13651 @code{bc1any4t}/@code{bc1any4f}).
13653 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13654 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13655 The @code{any} forms return true if any of the four results are true
13656 and the @code{all} forms return true if all four results are true.
13657 For example:
13659 @smallexample
13660 v2sf a, b, c, d;
13661 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13662   some_are_true ();
13663 else
13664   all_are_false ();
13666 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13667   all_are_true ();
13668 else
13669   some_are_false ();
13670 @end smallexample
13671 @end table
13673 @node Other MIPS Built-in Functions
13674 @subsection Other MIPS Built-in Functions
13676 GCC provides other MIPS-specific built-in functions:
13678 @table @code
13679 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13680 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13681 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13682 when this function is available.
13684 @item unsigned int __builtin_mips_get_fcsr (void)
13685 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13686 Get and set the contents of the floating-point control and status register
13687 (FPU control register 31).  These functions are only available in hard-float
13688 code but can be called in both MIPS16 and non-MIPS16 contexts.
13690 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13691 register except the condition codes, which GCC assumes are preserved.
13692 @end table
13694 @node MSP430 Built-in Functions
13695 @subsection MSP430 Built-in Functions
13697 GCC provides a couple of special builtin functions to aid in the
13698 writing of interrupt handlers in C.
13700 @table @code
13701 @item __bic_SR_register_on_exit (int @var{mask})
13702 This clears the indicated bits in the saved copy of the status register
13703 currently residing on the stack.  This only works inside interrupt
13704 handlers and the changes to the status register will only take affect
13705 once the handler returns.
13707 @item __bis_SR_register_on_exit (int @var{mask})
13708 This sets the indicated bits in the saved copy of the status register
13709 currently residing on the stack.  This only works inside interrupt
13710 handlers and the changes to the status register will only take affect
13711 once the handler returns.
13713 @item __delay_cycles (long long @var{cycles})
13714 This inserts an instruction sequence that takes exactly @var{cycles}
13715 cycles (between 0 and about 17E9) to complete.  The inserted sequence
13716 may use jumps, loops, or no-ops, and does not interfere with any other
13717 instructions.  Note that @var{cycles} must be a compile-time constant
13718 integer - that is, you must pass a number, not a variable that may be
13719 optimized to a constant later.  The number of cycles delayed by this
13720 builtin is exact.
13721 @end table
13723 @node NDS32 Built-in Functions
13724 @subsection NDS32 Built-in Functions
13726 These built-in functions are available for the NDS32 target:
13728 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13729 Insert an ISYNC instruction into the instruction stream where
13730 @var{addr} is an instruction address for serialization.
13731 @end deftypefn
13733 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13734 Insert an ISB instruction into the instruction stream.
13735 @end deftypefn
13737 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13738 Return the content of a system register which is mapped by @var{sr}.
13739 @end deftypefn
13741 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13742 Return the content of a user space register which is mapped by @var{usr}.
13743 @end deftypefn
13745 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13746 Move the @var{value} to a system register which is mapped by @var{sr}.
13747 @end deftypefn
13749 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13750 Move the @var{value} to a user space register which is mapped by @var{usr}.
13751 @end deftypefn
13753 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13754 Enable global interrupt.
13755 @end deftypefn
13757 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13758 Disable global interrupt.
13759 @end deftypefn
13761 @node picoChip Built-in Functions
13762 @subsection picoChip Built-in Functions
13764 GCC provides an interface to selected machine instructions from the
13765 picoChip instruction set.
13767 @table @code
13768 @item int __builtin_sbc (int @var{value})
13769 Sign bit count.  Return the number of consecutive bits in @var{value}
13770 that have the same value as the sign bit.  The result is the number of
13771 leading sign bits minus one, giving the number of redundant sign bits in
13772 @var{value}.
13774 @item int __builtin_byteswap (int @var{value})
13775 Byte swap.  Return the result of swapping the upper and lower bytes of
13776 @var{value}.
13778 @item int __builtin_brev (int @var{value})
13779 Bit reversal.  Return the result of reversing the bits in
13780 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13781 and so on.
13783 @item int __builtin_adds (int @var{x}, int @var{y})
13784 Saturating addition.  Return the result of adding @var{x} and @var{y},
13785 storing the value 32767 if the result overflows.
13787 @item int __builtin_subs (int @var{x}, int @var{y})
13788 Saturating subtraction.  Return the result of subtracting @var{y} from
13789 @var{x}, storing the value @minus{}32768 if the result overflows.
13791 @item void __builtin_halt (void)
13792 Halt.  The processor stops execution.  This built-in is useful for
13793 implementing assertions.
13795 @end table
13797 @node PowerPC Built-in Functions
13798 @subsection PowerPC Built-in Functions
13800 These built-in functions are available for the PowerPC family of
13801 processors:
13802 @smallexample
13803 float __builtin_recipdivf (float, float);
13804 float __builtin_rsqrtf (float);
13805 double __builtin_recipdiv (double, double);
13806 double __builtin_rsqrt (double);
13807 uint64_t __builtin_ppc_get_timebase ();
13808 unsigned long __builtin_ppc_mftb ();
13809 double __builtin_unpack_longdouble (long double, int);
13810 long double __builtin_pack_longdouble (double, double);
13811 @end smallexample
13813 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13814 @code{__builtin_rsqrtf} functions generate multiple instructions to
13815 implement the reciprocal sqrt functionality using reciprocal sqrt
13816 estimate instructions.
13818 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13819 functions generate multiple instructions to implement division using
13820 the reciprocal estimate instructions.
13822 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13823 functions generate instructions to read the Time Base Register.  The
13824 @code{__builtin_ppc_get_timebase} function may generate multiple
13825 instructions and always returns the 64 bits of the Time Base Register.
13826 The @code{__builtin_ppc_mftb} function always generates one instruction and
13827 returns the Time Base Register value as an unsigned long, throwing away
13828 the most significant word on 32-bit environments.
13830 The following built-in functions are available for the PowerPC family
13831 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13832 or @option{-mpopcntd}):
13833 @smallexample
13834 long __builtin_bpermd (long, long);
13835 int __builtin_divwe (int, int);
13836 int __builtin_divweo (int, int);
13837 unsigned int __builtin_divweu (unsigned int, unsigned int);
13838 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13839 long __builtin_divde (long, long);
13840 long __builtin_divdeo (long, long);
13841 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13842 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13843 unsigned int cdtbcd (unsigned int);
13844 unsigned int cbcdtd (unsigned int);
13845 unsigned int addg6s (unsigned int, unsigned int);
13846 @end smallexample
13848 The @code{__builtin_divde}, @code{__builtin_divdeo},
13849 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13850 64-bit environment support ISA 2.06 or later.
13852 The following built-in functions are available for the PowerPC family
13853 of processors when hardware decimal floating point
13854 (@option{-mhard-dfp}) is available:
13855 @smallexample
13856 _Decimal64 __builtin_dxex (_Decimal64);
13857 _Decimal128 __builtin_dxexq (_Decimal128);
13858 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13859 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13860 _Decimal64 __builtin_denbcd (int, _Decimal64);
13861 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13862 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13863 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13864 _Decimal64 __builtin_dscli (_Decimal64, int);
13865 _Decimal128 __builitn_dscliq (_Decimal128, int);
13866 _Decimal64 __builtin_dscri (_Decimal64, int);
13867 _Decimal128 __builitn_dscriq (_Decimal128, int);
13868 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13869 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13870 @end smallexample
13872 The following built-in functions are available for the PowerPC family
13873 of processors when the Vector Scalar (vsx) instruction set is
13874 available:
13875 @smallexample
13876 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13877 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13878                                                 unsigned long long);
13879 @end smallexample
13881 @node PowerPC AltiVec/VSX Built-in Functions
13882 @subsection PowerPC AltiVec Built-in Functions
13884 GCC provides an interface for the PowerPC family of processors to access
13885 the AltiVec operations described in Motorola's AltiVec Programming
13886 Interface Manual.  The interface is made available by including
13887 @code{<altivec.h>} and using @option{-maltivec} and
13888 @option{-mabi=altivec}.  The interface supports the following vector
13889 types.
13891 @smallexample
13892 vector unsigned char
13893 vector signed char
13894 vector bool char
13896 vector unsigned short
13897 vector signed short
13898 vector bool short
13899 vector pixel
13901 vector unsigned int
13902 vector signed int
13903 vector bool int
13904 vector float
13905 @end smallexample
13907 If @option{-mvsx} is used the following additional vector types are
13908 implemented.
13910 @smallexample
13911 vector unsigned long
13912 vector signed long
13913 vector double
13914 @end smallexample
13916 The long types are only implemented for 64-bit code generation, and
13917 the long type is only used in the floating point/integer conversion
13918 instructions.
13920 GCC's implementation of the high-level language interface available from
13921 C and C++ code differs from Motorola's documentation in several ways.
13923 @itemize @bullet
13925 @item
13926 A vector constant is a list of constant expressions within curly braces.
13928 @item
13929 A vector initializer requires no cast if the vector constant is of the
13930 same type as the variable it is initializing.
13932 @item
13933 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13934 vector type is the default signedness of the base type.  The default
13935 varies depending on the operating system, so a portable program should
13936 always specify the signedness.
13938 @item
13939 Compiling with @option{-maltivec} adds keywords @code{__vector},
13940 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13941 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13942 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13943 disabled.  To use them, you must include @code{<altivec.h>} instead.
13945 @item
13946 GCC allows using a @code{typedef} name as the type specifier for a
13947 vector type.
13949 @item
13950 For C, overloaded functions are implemented with macros so the following
13951 does not work:
13953 @smallexample
13954   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13955 @end smallexample
13957 @noindent
13958 Since @code{vec_add} is a macro, the vector constant in the example
13959 is treated as four separate arguments.  Wrap the entire argument in
13960 parentheses for this to work.
13961 @end itemize
13963 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13964 Internally, GCC uses built-in functions to achieve the functionality in
13965 the aforementioned header file, but they are not supported and are
13966 subject to change without notice.
13968 The following interfaces are supported for the generic and specific
13969 AltiVec operations and the AltiVec predicates.  In cases where there
13970 is a direct mapping between generic and specific operations, only the
13971 generic names are shown here, although the specific operations can also
13972 be used.
13974 Arguments that are documented as @code{const int} require literal
13975 integral values within the range required for that operation.
13977 @smallexample
13978 vector signed char vec_abs (vector signed char);
13979 vector signed short vec_abs (vector signed short);
13980 vector signed int vec_abs (vector signed int);
13981 vector float vec_abs (vector float);
13983 vector signed char vec_abss (vector signed char);
13984 vector signed short vec_abss (vector signed short);
13985 vector signed int vec_abss (vector signed int);
13987 vector signed char vec_add (vector bool char, vector signed char);
13988 vector signed char vec_add (vector signed char, vector bool char);
13989 vector signed char vec_add (vector signed char, vector signed char);
13990 vector unsigned char vec_add (vector bool char, vector unsigned char);
13991 vector unsigned char vec_add (vector unsigned char, vector bool char);
13992 vector unsigned char vec_add (vector unsigned char,
13993                               vector unsigned char);
13994 vector signed short vec_add (vector bool short, vector signed short);
13995 vector signed short vec_add (vector signed short, vector bool short);
13996 vector signed short vec_add (vector signed short, vector signed short);
13997 vector unsigned short vec_add (vector bool short,
13998                                vector unsigned short);
13999 vector unsigned short vec_add (vector unsigned short,
14000                                vector bool short);
14001 vector unsigned short vec_add (vector unsigned short,
14002                                vector unsigned short);
14003 vector signed int vec_add (vector bool int, vector signed int);
14004 vector signed int vec_add (vector signed int, vector bool int);
14005 vector signed int vec_add (vector signed int, vector signed int);
14006 vector unsigned int vec_add (vector bool int, vector unsigned int);
14007 vector unsigned int vec_add (vector unsigned int, vector bool int);
14008 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
14009 vector float vec_add (vector float, vector float);
14011 vector float vec_vaddfp (vector float, vector float);
14013 vector signed int vec_vadduwm (vector bool int, vector signed int);
14014 vector signed int vec_vadduwm (vector signed int, vector bool int);
14015 vector signed int vec_vadduwm (vector signed int, vector signed int);
14016 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
14017 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
14018 vector unsigned int vec_vadduwm (vector unsigned int,
14019                                  vector unsigned int);
14021 vector signed short vec_vadduhm (vector bool short,
14022                                  vector signed short);
14023 vector signed short vec_vadduhm (vector signed short,
14024                                  vector bool short);
14025 vector signed short vec_vadduhm (vector signed short,
14026                                  vector signed short);
14027 vector unsigned short vec_vadduhm (vector bool short,
14028                                    vector unsigned short);
14029 vector unsigned short vec_vadduhm (vector unsigned short,
14030                                    vector bool short);
14031 vector unsigned short vec_vadduhm (vector unsigned short,
14032                                    vector unsigned short);
14034 vector signed char vec_vaddubm (vector bool char, vector signed char);
14035 vector signed char vec_vaddubm (vector signed char, vector bool char);
14036 vector signed char vec_vaddubm (vector signed char, vector signed char);
14037 vector unsigned char vec_vaddubm (vector bool char,
14038                                   vector unsigned char);
14039 vector unsigned char vec_vaddubm (vector unsigned char,
14040                                   vector bool char);
14041 vector unsigned char vec_vaddubm (vector unsigned char,
14042                                   vector unsigned char);
14044 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14046 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14047 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14048 vector unsigned char vec_adds (vector unsigned char,
14049                                vector unsigned char);
14050 vector signed char vec_adds (vector bool char, vector signed char);
14051 vector signed char vec_adds (vector signed char, vector bool char);
14052 vector signed char vec_adds (vector signed char, vector signed char);
14053 vector unsigned short vec_adds (vector bool short,
14054                                 vector unsigned short);
14055 vector unsigned short vec_adds (vector unsigned short,
14056                                 vector bool short);
14057 vector unsigned short vec_adds (vector unsigned short,
14058                                 vector unsigned short);
14059 vector signed short vec_adds (vector bool short, vector signed short);
14060 vector signed short vec_adds (vector signed short, vector bool short);
14061 vector signed short vec_adds (vector signed short, vector signed short);
14062 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14063 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14064 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14065 vector signed int vec_adds (vector bool int, vector signed int);
14066 vector signed int vec_adds (vector signed int, vector bool int);
14067 vector signed int vec_adds (vector signed int, vector signed int);
14069 vector signed int vec_vaddsws (vector bool int, vector signed int);
14070 vector signed int vec_vaddsws (vector signed int, vector bool int);
14071 vector signed int vec_vaddsws (vector signed int, vector signed int);
14073 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14074 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14075 vector unsigned int vec_vadduws (vector unsigned int,
14076                                  vector unsigned int);
14078 vector signed short vec_vaddshs (vector bool short,
14079                                  vector signed short);
14080 vector signed short vec_vaddshs (vector signed short,
14081                                  vector bool short);
14082 vector signed short vec_vaddshs (vector signed short,
14083                                  vector signed short);
14085 vector unsigned short vec_vadduhs (vector bool short,
14086                                    vector unsigned short);
14087 vector unsigned short vec_vadduhs (vector unsigned short,
14088                                    vector bool short);
14089 vector unsigned short vec_vadduhs (vector unsigned short,
14090                                    vector unsigned short);
14092 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14093 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14094 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14096 vector unsigned char vec_vaddubs (vector bool char,
14097                                   vector unsigned char);
14098 vector unsigned char vec_vaddubs (vector unsigned char,
14099                                   vector bool char);
14100 vector unsigned char vec_vaddubs (vector unsigned char,
14101                                   vector unsigned char);
14103 vector float vec_and (vector float, vector float);
14104 vector float vec_and (vector float, vector bool int);
14105 vector float vec_and (vector bool int, vector float);
14106 vector bool int vec_and (vector bool int, vector bool int);
14107 vector signed int vec_and (vector bool int, vector signed int);
14108 vector signed int vec_and (vector signed int, vector bool int);
14109 vector signed int vec_and (vector signed int, vector signed int);
14110 vector unsigned int vec_and (vector bool int, vector unsigned int);
14111 vector unsigned int vec_and (vector unsigned int, vector bool int);
14112 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14113 vector bool short vec_and (vector bool short, vector bool short);
14114 vector signed short vec_and (vector bool short, vector signed short);
14115 vector signed short vec_and (vector signed short, vector bool short);
14116 vector signed short vec_and (vector signed short, vector signed short);
14117 vector unsigned short vec_and (vector bool short,
14118                                vector unsigned short);
14119 vector unsigned short vec_and (vector unsigned short,
14120                                vector bool short);
14121 vector unsigned short vec_and (vector unsigned short,
14122                                vector unsigned short);
14123 vector signed char vec_and (vector bool char, vector signed char);
14124 vector bool char vec_and (vector bool char, vector bool char);
14125 vector signed char vec_and (vector signed char, vector bool char);
14126 vector signed char vec_and (vector signed char, vector signed char);
14127 vector unsigned char vec_and (vector bool char, vector unsigned char);
14128 vector unsigned char vec_and (vector unsigned char, vector bool char);
14129 vector unsigned char vec_and (vector unsigned char,
14130                               vector unsigned char);
14132 vector float vec_andc (vector float, vector float);
14133 vector float vec_andc (vector float, vector bool int);
14134 vector float vec_andc (vector bool int, vector float);
14135 vector bool int vec_andc (vector bool int, vector bool int);
14136 vector signed int vec_andc (vector bool int, vector signed int);
14137 vector signed int vec_andc (vector signed int, vector bool int);
14138 vector signed int vec_andc (vector signed int, vector signed int);
14139 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14140 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14141 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14142 vector bool short vec_andc (vector bool short, vector bool short);
14143 vector signed short vec_andc (vector bool short, vector signed short);
14144 vector signed short vec_andc (vector signed short, vector bool short);
14145 vector signed short vec_andc (vector signed short, vector signed short);
14146 vector unsigned short vec_andc (vector bool short,
14147                                 vector unsigned short);
14148 vector unsigned short vec_andc (vector unsigned short,
14149                                 vector bool short);
14150 vector unsigned short vec_andc (vector unsigned short,
14151                                 vector unsigned short);
14152 vector signed char vec_andc (vector bool char, vector signed char);
14153 vector bool char vec_andc (vector bool char, vector bool char);
14154 vector signed char vec_andc (vector signed char, vector bool char);
14155 vector signed char vec_andc (vector signed char, vector signed char);
14156 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14157 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14158 vector unsigned char vec_andc (vector unsigned char,
14159                                vector unsigned char);
14161 vector unsigned char vec_avg (vector unsigned char,
14162                               vector unsigned char);
14163 vector signed char vec_avg (vector signed char, vector signed char);
14164 vector unsigned short vec_avg (vector unsigned short,
14165                                vector unsigned short);
14166 vector signed short vec_avg (vector signed short, vector signed short);
14167 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14168 vector signed int vec_avg (vector signed int, vector signed int);
14170 vector signed int vec_vavgsw (vector signed int, vector signed int);
14172 vector unsigned int vec_vavguw (vector unsigned int,
14173                                 vector unsigned int);
14175 vector signed short vec_vavgsh (vector signed short,
14176                                 vector signed short);
14178 vector unsigned short vec_vavguh (vector unsigned short,
14179                                   vector unsigned short);
14181 vector signed char vec_vavgsb (vector signed char, vector signed char);
14183 vector unsigned char vec_vavgub (vector unsigned char,
14184                                  vector unsigned char);
14186 vector float vec_copysign (vector float);
14188 vector float vec_ceil (vector float);
14190 vector signed int vec_cmpb (vector float, vector float);
14192 vector bool char vec_cmpeq (vector signed char, vector signed char);
14193 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14194 vector bool short vec_cmpeq (vector signed short, vector signed short);
14195 vector bool short vec_cmpeq (vector unsigned short,
14196                              vector unsigned short);
14197 vector bool int vec_cmpeq (vector signed int, vector signed int);
14198 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14199 vector bool int vec_cmpeq (vector float, vector float);
14201 vector bool int vec_vcmpeqfp (vector float, vector float);
14203 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14204 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14206 vector bool short vec_vcmpequh (vector signed short,
14207                                 vector signed short);
14208 vector bool short vec_vcmpequh (vector unsigned short,
14209                                 vector unsigned short);
14211 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14212 vector bool char vec_vcmpequb (vector unsigned char,
14213                                vector unsigned char);
14215 vector bool int vec_cmpge (vector float, vector float);
14217 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14218 vector bool char vec_cmpgt (vector signed char, vector signed char);
14219 vector bool short vec_cmpgt (vector unsigned short,
14220                              vector unsigned short);
14221 vector bool short vec_cmpgt (vector signed short, vector signed short);
14222 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14223 vector bool int vec_cmpgt (vector signed int, vector signed int);
14224 vector bool int vec_cmpgt (vector float, vector float);
14226 vector bool int vec_vcmpgtfp (vector float, vector float);
14228 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14230 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14232 vector bool short vec_vcmpgtsh (vector signed short,
14233                                 vector signed short);
14235 vector bool short vec_vcmpgtuh (vector unsigned short,
14236                                 vector unsigned short);
14238 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14240 vector bool char vec_vcmpgtub (vector unsigned char,
14241                                vector unsigned char);
14243 vector bool int vec_cmple (vector float, vector float);
14245 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14246 vector bool char vec_cmplt (vector signed char, vector signed char);
14247 vector bool short vec_cmplt (vector unsigned short,
14248                              vector unsigned short);
14249 vector bool short vec_cmplt (vector signed short, vector signed short);
14250 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14251 vector bool int vec_cmplt (vector signed int, vector signed int);
14252 vector bool int vec_cmplt (vector float, vector float);
14254 vector float vec_cpsgn (vector float, vector float);
14256 vector float vec_ctf (vector unsigned int, const int);
14257 vector float vec_ctf (vector signed int, const int);
14258 vector double vec_ctf (vector unsigned long, const int);
14259 vector double vec_ctf (vector signed long, const int);
14261 vector float vec_vcfsx (vector signed int, const int);
14263 vector float vec_vcfux (vector unsigned int, const int);
14265 vector signed int vec_cts (vector float, const int);
14266 vector signed long vec_cts (vector double, const int);
14268 vector unsigned int vec_ctu (vector float, const int);
14269 vector unsigned long vec_ctu (vector double, const int);
14271 void vec_dss (const int);
14273 void vec_dssall (void);
14275 void vec_dst (const vector unsigned char *, int, const int);
14276 void vec_dst (const vector signed char *, int, const int);
14277 void vec_dst (const vector bool char *, int, const int);
14278 void vec_dst (const vector unsigned short *, int, const int);
14279 void vec_dst (const vector signed short *, int, const int);
14280 void vec_dst (const vector bool short *, int, const int);
14281 void vec_dst (const vector pixel *, int, const int);
14282 void vec_dst (const vector unsigned int *, int, const int);
14283 void vec_dst (const vector signed int *, int, const int);
14284 void vec_dst (const vector bool int *, int, const int);
14285 void vec_dst (const vector float *, int, const int);
14286 void vec_dst (const unsigned char *, int, const int);
14287 void vec_dst (const signed char *, int, const int);
14288 void vec_dst (const unsigned short *, int, const int);
14289 void vec_dst (const short *, int, const int);
14290 void vec_dst (const unsigned int *, int, const int);
14291 void vec_dst (const int *, int, const int);
14292 void vec_dst (const unsigned long *, int, const int);
14293 void vec_dst (const long *, int, const int);
14294 void vec_dst (const float *, int, const int);
14296 void vec_dstst (const vector unsigned char *, int, const int);
14297 void vec_dstst (const vector signed char *, int, const int);
14298 void vec_dstst (const vector bool char *, int, const int);
14299 void vec_dstst (const vector unsigned short *, int, const int);
14300 void vec_dstst (const vector signed short *, int, const int);
14301 void vec_dstst (const vector bool short *, int, const int);
14302 void vec_dstst (const vector pixel *, int, const int);
14303 void vec_dstst (const vector unsigned int *, int, const int);
14304 void vec_dstst (const vector signed int *, int, const int);
14305 void vec_dstst (const vector bool int *, int, const int);
14306 void vec_dstst (const vector float *, int, const int);
14307 void vec_dstst (const unsigned char *, int, const int);
14308 void vec_dstst (const signed char *, int, const int);
14309 void vec_dstst (const unsigned short *, int, const int);
14310 void vec_dstst (const short *, int, const int);
14311 void vec_dstst (const unsigned int *, int, const int);
14312 void vec_dstst (const int *, int, const int);
14313 void vec_dstst (const unsigned long *, int, const int);
14314 void vec_dstst (const long *, int, const int);
14315 void vec_dstst (const float *, int, const int);
14317 void vec_dststt (const vector unsigned char *, int, const int);
14318 void vec_dststt (const vector signed char *, int, const int);
14319 void vec_dststt (const vector bool char *, int, const int);
14320 void vec_dststt (const vector unsigned short *, int, const int);
14321 void vec_dststt (const vector signed short *, int, const int);
14322 void vec_dststt (const vector bool short *, int, const int);
14323 void vec_dststt (const vector pixel *, int, const int);
14324 void vec_dststt (const vector unsigned int *, int, const int);
14325 void vec_dststt (const vector signed int *, int, const int);
14326 void vec_dststt (const vector bool int *, int, const int);
14327 void vec_dststt (const vector float *, int, const int);
14328 void vec_dststt (const unsigned char *, int, const int);
14329 void vec_dststt (const signed char *, int, const int);
14330 void vec_dststt (const unsigned short *, int, const int);
14331 void vec_dststt (const short *, int, const int);
14332 void vec_dststt (const unsigned int *, int, const int);
14333 void vec_dststt (const int *, int, const int);
14334 void vec_dststt (const unsigned long *, int, const int);
14335 void vec_dststt (const long *, int, const int);
14336 void vec_dststt (const float *, int, const int);
14338 void vec_dstt (const vector unsigned char *, int, const int);
14339 void vec_dstt (const vector signed char *, int, const int);
14340 void vec_dstt (const vector bool char *, int, const int);
14341 void vec_dstt (const vector unsigned short *, int, const int);
14342 void vec_dstt (const vector signed short *, int, const int);
14343 void vec_dstt (const vector bool short *, int, const int);
14344 void vec_dstt (const vector pixel *, int, const int);
14345 void vec_dstt (const vector unsigned int *, int, const int);
14346 void vec_dstt (const vector signed int *, int, const int);
14347 void vec_dstt (const vector bool int *, int, const int);
14348 void vec_dstt (const vector float *, int, const int);
14349 void vec_dstt (const unsigned char *, int, const int);
14350 void vec_dstt (const signed char *, int, const int);
14351 void vec_dstt (const unsigned short *, int, const int);
14352 void vec_dstt (const short *, int, const int);
14353 void vec_dstt (const unsigned int *, int, const int);
14354 void vec_dstt (const int *, int, const int);
14355 void vec_dstt (const unsigned long *, int, const int);
14356 void vec_dstt (const long *, int, const int);
14357 void vec_dstt (const float *, int, const int);
14359 vector float vec_expte (vector float);
14361 vector float vec_floor (vector float);
14363 vector float vec_ld (int, const vector float *);
14364 vector float vec_ld (int, const float *);
14365 vector bool int vec_ld (int, const vector bool int *);
14366 vector signed int vec_ld (int, const vector signed int *);
14367 vector signed int vec_ld (int, const int *);
14368 vector signed int vec_ld (int, const long *);
14369 vector unsigned int vec_ld (int, const vector unsigned int *);
14370 vector unsigned int vec_ld (int, const unsigned int *);
14371 vector unsigned int vec_ld (int, const unsigned long *);
14372 vector bool short vec_ld (int, const vector bool short *);
14373 vector pixel vec_ld (int, const vector pixel *);
14374 vector signed short vec_ld (int, const vector signed short *);
14375 vector signed short vec_ld (int, const short *);
14376 vector unsigned short vec_ld (int, const vector unsigned short *);
14377 vector unsigned short vec_ld (int, const unsigned short *);
14378 vector bool char vec_ld (int, const vector bool char *);
14379 vector signed char vec_ld (int, const vector signed char *);
14380 vector signed char vec_ld (int, const signed char *);
14381 vector unsigned char vec_ld (int, const vector unsigned char *);
14382 vector unsigned char vec_ld (int, const unsigned char *);
14384 vector signed char vec_lde (int, const signed char *);
14385 vector unsigned char vec_lde (int, const unsigned char *);
14386 vector signed short vec_lde (int, const short *);
14387 vector unsigned short vec_lde (int, const unsigned short *);
14388 vector float vec_lde (int, const float *);
14389 vector signed int vec_lde (int, const int *);
14390 vector unsigned int vec_lde (int, const unsigned int *);
14391 vector signed int vec_lde (int, const long *);
14392 vector unsigned int vec_lde (int, const unsigned long *);
14394 vector float vec_lvewx (int, float *);
14395 vector signed int vec_lvewx (int, int *);
14396 vector unsigned int vec_lvewx (int, unsigned int *);
14397 vector signed int vec_lvewx (int, long *);
14398 vector unsigned int vec_lvewx (int, unsigned long *);
14400 vector signed short vec_lvehx (int, short *);
14401 vector unsigned short vec_lvehx (int, unsigned short *);
14403 vector signed char vec_lvebx (int, char *);
14404 vector unsigned char vec_lvebx (int, unsigned char *);
14406 vector float vec_ldl (int, const vector float *);
14407 vector float vec_ldl (int, const float *);
14408 vector bool int vec_ldl (int, const vector bool int *);
14409 vector signed int vec_ldl (int, const vector signed int *);
14410 vector signed int vec_ldl (int, const int *);
14411 vector signed int vec_ldl (int, const long *);
14412 vector unsigned int vec_ldl (int, const vector unsigned int *);
14413 vector unsigned int vec_ldl (int, const unsigned int *);
14414 vector unsigned int vec_ldl (int, const unsigned long *);
14415 vector bool short vec_ldl (int, const vector bool short *);
14416 vector pixel vec_ldl (int, const vector pixel *);
14417 vector signed short vec_ldl (int, const vector signed short *);
14418 vector signed short vec_ldl (int, const short *);
14419 vector unsigned short vec_ldl (int, const vector unsigned short *);
14420 vector unsigned short vec_ldl (int, const unsigned short *);
14421 vector bool char vec_ldl (int, const vector bool char *);
14422 vector signed char vec_ldl (int, const vector signed char *);
14423 vector signed char vec_ldl (int, const signed char *);
14424 vector unsigned char vec_ldl (int, const vector unsigned char *);
14425 vector unsigned char vec_ldl (int, const unsigned char *);
14427 vector float vec_loge (vector float);
14429 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14430 vector unsigned char vec_lvsl (int, const volatile signed char *);
14431 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14432 vector unsigned char vec_lvsl (int, const volatile short *);
14433 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14434 vector unsigned char vec_lvsl (int, const volatile int *);
14435 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14436 vector unsigned char vec_lvsl (int, const volatile long *);
14437 vector unsigned char vec_lvsl (int, const volatile float *);
14439 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14440 vector unsigned char vec_lvsr (int, const volatile signed char *);
14441 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14442 vector unsigned char vec_lvsr (int, const volatile short *);
14443 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14444 vector unsigned char vec_lvsr (int, const volatile int *);
14445 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14446 vector unsigned char vec_lvsr (int, const volatile long *);
14447 vector unsigned char vec_lvsr (int, const volatile float *);
14449 vector float vec_madd (vector float, vector float, vector float);
14451 vector signed short vec_madds (vector signed short,
14452                                vector signed short,
14453                                vector signed short);
14455 vector unsigned char vec_max (vector bool char, vector unsigned char);
14456 vector unsigned char vec_max (vector unsigned char, vector bool char);
14457 vector unsigned char vec_max (vector unsigned char,
14458                               vector unsigned char);
14459 vector signed char vec_max (vector bool char, vector signed char);
14460 vector signed char vec_max (vector signed char, vector bool char);
14461 vector signed char vec_max (vector signed char, vector signed char);
14462 vector unsigned short vec_max (vector bool short,
14463                                vector unsigned short);
14464 vector unsigned short vec_max (vector unsigned short,
14465                                vector bool short);
14466 vector unsigned short vec_max (vector unsigned short,
14467                                vector unsigned short);
14468 vector signed short vec_max (vector bool short, vector signed short);
14469 vector signed short vec_max (vector signed short, vector bool short);
14470 vector signed short vec_max (vector signed short, vector signed short);
14471 vector unsigned int vec_max (vector bool int, vector unsigned int);
14472 vector unsigned int vec_max (vector unsigned int, vector bool int);
14473 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14474 vector signed int vec_max (vector bool int, vector signed int);
14475 vector signed int vec_max (vector signed int, vector bool int);
14476 vector signed int vec_max (vector signed int, vector signed int);
14477 vector float vec_max (vector float, vector float);
14479 vector float vec_vmaxfp (vector float, vector float);
14481 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14482 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14483 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14485 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14486 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14487 vector unsigned int vec_vmaxuw (vector unsigned int,
14488                                 vector unsigned int);
14490 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14491 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14492 vector signed short vec_vmaxsh (vector signed short,
14493                                 vector signed short);
14495 vector unsigned short vec_vmaxuh (vector bool short,
14496                                   vector unsigned short);
14497 vector unsigned short vec_vmaxuh (vector unsigned short,
14498                                   vector bool short);
14499 vector unsigned short vec_vmaxuh (vector unsigned short,
14500                                   vector unsigned short);
14502 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14503 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14504 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14506 vector unsigned char vec_vmaxub (vector bool char,
14507                                  vector unsigned char);
14508 vector unsigned char vec_vmaxub (vector unsigned char,
14509                                  vector bool char);
14510 vector unsigned char vec_vmaxub (vector unsigned char,
14511                                  vector unsigned char);
14513 vector bool char vec_mergeh (vector bool char, vector bool char);
14514 vector signed char vec_mergeh (vector signed char, vector signed char);
14515 vector unsigned char vec_mergeh (vector unsigned char,
14516                                  vector unsigned char);
14517 vector bool short vec_mergeh (vector bool short, vector bool short);
14518 vector pixel vec_mergeh (vector pixel, vector pixel);
14519 vector signed short vec_mergeh (vector signed short,
14520                                 vector signed short);
14521 vector unsigned short vec_mergeh (vector unsigned short,
14522                                   vector unsigned short);
14523 vector float vec_mergeh (vector float, vector float);
14524 vector bool int vec_mergeh (vector bool int, vector bool int);
14525 vector signed int vec_mergeh (vector signed int, vector signed int);
14526 vector unsigned int vec_mergeh (vector unsigned int,
14527                                 vector unsigned int);
14529 vector float vec_vmrghw (vector float, vector float);
14530 vector bool int vec_vmrghw (vector bool int, vector bool int);
14531 vector signed int vec_vmrghw (vector signed int, vector signed int);
14532 vector unsigned int vec_vmrghw (vector unsigned int,
14533                                 vector unsigned int);
14535 vector bool short vec_vmrghh (vector bool short, vector bool short);
14536 vector signed short vec_vmrghh (vector signed short,
14537                                 vector signed short);
14538 vector unsigned short vec_vmrghh (vector unsigned short,
14539                                   vector unsigned short);
14540 vector pixel vec_vmrghh (vector pixel, vector pixel);
14542 vector bool char vec_vmrghb (vector bool char, vector bool char);
14543 vector signed char vec_vmrghb (vector signed char, vector signed char);
14544 vector unsigned char vec_vmrghb (vector unsigned char,
14545                                  vector unsigned char);
14547 vector bool char vec_mergel (vector bool char, vector bool char);
14548 vector signed char vec_mergel (vector signed char, vector signed char);
14549 vector unsigned char vec_mergel (vector unsigned char,
14550                                  vector unsigned char);
14551 vector bool short vec_mergel (vector bool short, vector bool short);
14552 vector pixel vec_mergel (vector pixel, vector pixel);
14553 vector signed short vec_mergel (vector signed short,
14554                                 vector signed short);
14555 vector unsigned short vec_mergel (vector unsigned short,
14556                                   vector unsigned short);
14557 vector float vec_mergel (vector float, vector float);
14558 vector bool int vec_mergel (vector bool int, vector bool int);
14559 vector signed int vec_mergel (vector signed int, vector signed int);
14560 vector unsigned int vec_mergel (vector unsigned int,
14561                                 vector unsigned int);
14563 vector float vec_vmrglw (vector float, vector float);
14564 vector signed int vec_vmrglw (vector signed int, vector signed int);
14565 vector unsigned int vec_vmrglw (vector unsigned int,
14566                                 vector unsigned int);
14567 vector bool int vec_vmrglw (vector bool int, vector bool int);
14569 vector bool short vec_vmrglh (vector bool short, vector bool short);
14570 vector signed short vec_vmrglh (vector signed short,
14571                                 vector signed short);
14572 vector unsigned short vec_vmrglh (vector unsigned short,
14573                                   vector unsigned short);
14574 vector pixel vec_vmrglh (vector pixel, vector pixel);
14576 vector bool char vec_vmrglb (vector bool char, vector bool char);
14577 vector signed char vec_vmrglb (vector signed char, vector signed char);
14578 vector unsigned char vec_vmrglb (vector unsigned char,
14579                                  vector unsigned char);
14581 vector unsigned short vec_mfvscr (void);
14583 vector unsigned char vec_min (vector bool char, vector unsigned char);
14584 vector unsigned char vec_min (vector unsigned char, vector bool char);
14585 vector unsigned char vec_min (vector unsigned char,
14586                               vector unsigned char);
14587 vector signed char vec_min (vector bool char, vector signed char);
14588 vector signed char vec_min (vector signed char, vector bool char);
14589 vector signed char vec_min (vector signed char, vector signed char);
14590 vector unsigned short vec_min (vector bool short,
14591                                vector unsigned short);
14592 vector unsigned short vec_min (vector unsigned short,
14593                                vector bool short);
14594 vector unsigned short vec_min (vector unsigned short,
14595                                vector unsigned short);
14596 vector signed short vec_min (vector bool short, vector signed short);
14597 vector signed short vec_min (vector signed short, vector bool short);
14598 vector signed short vec_min (vector signed short, vector signed short);
14599 vector unsigned int vec_min (vector bool int, vector unsigned int);
14600 vector unsigned int vec_min (vector unsigned int, vector bool int);
14601 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14602 vector signed int vec_min (vector bool int, vector signed int);
14603 vector signed int vec_min (vector signed int, vector bool int);
14604 vector signed int vec_min (vector signed int, vector signed int);
14605 vector float vec_min (vector float, vector float);
14607 vector float vec_vminfp (vector float, vector float);
14609 vector signed int vec_vminsw (vector bool int, vector signed int);
14610 vector signed int vec_vminsw (vector signed int, vector bool int);
14611 vector signed int vec_vminsw (vector signed int, vector signed int);
14613 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14614 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14615 vector unsigned int vec_vminuw (vector unsigned int,
14616                                 vector unsigned int);
14618 vector signed short vec_vminsh (vector bool short, vector signed short);
14619 vector signed short vec_vminsh (vector signed short, vector bool short);
14620 vector signed short vec_vminsh (vector signed short,
14621                                 vector signed short);
14623 vector unsigned short vec_vminuh (vector bool short,
14624                                   vector unsigned short);
14625 vector unsigned short vec_vminuh (vector unsigned short,
14626                                   vector bool short);
14627 vector unsigned short vec_vminuh (vector unsigned short,
14628                                   vector unsigned short);
14630 vector signed char vec_vminsb (vector bool char, vector signed char);
14631 vector signed char vec_vminsb (vector signed char, vector bool char);
14632 vector signed char vec_vminsb (vector signed char, vector signed char);
14634 vector unsigned char vec_vminub (vector bool char,
14635                                  vector unsigned char);
14636 vector unsigned char vec_vminub (vector unsigned char,
14637                                  vector bool char);
14638 vector unsigned char vec_vminub (vector unsigned char,
14639                                  vector unsigned char);
14641 vector signed short vec_mladd (vector signed short,
14642                                vector signed short,
14643                                vector signed short);
14644 vector signed short vec_mladd (vector signed short,
14645                                vector unsigned short,
14646                                vector unsigned short);
14647 vector signed short vec_mladd (vector unsigned short,
14648                                vector signed short,
14649                                vector signed short);
14650 vector unsigned short vec_mladd (vector unsigned short,
14651                                  vector unsigned short,
14652                                  vector unsigned short);
14654 vector signed short vec_mradds (vector signed short,
14655                                 vector signed short,
14656                                 vector signed short);
14658 vector unsigned int vec_msum (vector unsigned char,
14659                               vector unsigned char,
14660                               vector unsigned int);
14661 vector signed int vec_msum (vector signed char,
14662                             vector unsigned char,
14663                             vector signed int);
14664 vector unsigned int vec_msum (vector unsigned short,
14665                               vector unsigned short,
14666                               vector unsigned int);
14667 vector signed int vec_msum (vector signed short,
14668                             vector signed short,
14669                             vector signed int);
14671 vector signed int vec_vmsumshm (vector signed short,
14672                                 vector signed short,
14673                                 vector signed int);
14675 vector unsigned int vec_vmsumuhm (vector unsigned short,
14676                                   vector unsigned short,
14677                                   vector unsigned int);
14679 vector signed int vec_vmsummbm (vector signed char,
14680                                 vector unsigned char,
14681                                 vector signed int);
14683 vector unsigned int vec_vmsumubm (vector unsigned char,
14684                                   vector unsigned char,
14685                                   vector unsigned int);
14687 vector unsigned int vec_msums (vector unsigned short,
14688                                vector unsigned short,
14689                                vector unsigned int);
14690 vector signed int vec_msums (vector signed short,
14691                              vector signed short,
14692                              vector signed int);
14694 vector signed int vec_vmsumshs (vector signed short,
14695                                 vector signed short,
14696                                 vector signed int);
14698 vector unsigned int vec_vmsumuhs (vector unsigned short,
14699                                   vector unsigned short,
14700                                   vector unsigned int);
14702 void vec_mtvscr (vector signed int);
14703 void vec_mtvscr (vector unsigned int);
14704 void vec_mtvscr (vector bool int);
14705 void vec_mtvscr (vector signed short);
14706 void vec_mtvscr (vector unsigned short);
14707 void vec_mtvscr (vector bool short);
14708 void vec_mtvscr (vector pixel);
14709 void vec_mtvscr (vector signed char);
14710 void vec_mtvscr (vector unsigned char);
14711 void vec_mtvscr (vector bool char);
14713 vector unsigned short vec_mule (vector unsigned char,
14714                                 vector unsigned char);
14715 vector signed short vec_mule (vector signed char,
14716                               vector signed char);
14717 vector unsigned int vec_mule (vector unsigned short,
14718                               vector unsigned short);
14719 vector signed int vec_mule (vector signed short, vector signed short);
14721 vector signed int vec_vmulesh (vector signed short,
14722                                vector signed short);
14724 vector unsigned int vec_vmuleuh (vector unsigned short,
14725                                  vector unsigned short);
14727 vector signed short vec_vmulesb (vector signed char,
14728                                  vector signed char);
14730 vector unsigned short vec_vmuleub (vector unsigned char,
14731                                   vector unsigned char);
14733 vector unsigned short vec_mulo (vector unsigned char,
14734                                 vector unsigned char);
14735 vector signed short vec_mulo (vector signed char, vector signed char);
14736 vector unsigned int vec_mulo (vector unsigned short,
14737                               vector unsigned short);
14738 vector signed int vec_mulo (vector signed short, vector signed short);
14740 vector signed int vec_vmulosh (vector signed short,
14741                                vector signed short);
14743 vector unsigned int vec_vmulouh (vector unsigned short,
14744                                  vector unsigned short);
14746 vector signed short vec_vmulosb (vector signed char,
14747                                  vector signed char);
14749 vector unsigned short vec_vmuloub (vector unsigned char,
14750                                    vector unsigned char);
14752 vector float vec_nmsub (vector float, vector float, vector float);
14754 vector float vec_nor (vector float, vector float);
14755 vector signed int vec_nor (vector signed int, vector signed int);
14756 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14757 vector bool int vec_nor (vector bool int, vector bool int);
14758 vector signed short vec_nor (vector signed short, vector signed short);
14759 vector unsigned short vec_nor (vector unsigned short,
14760                                vector unsigned short);
14761 vector bool short vec_nor (vector bool short, vector bool short);
14762 vector signed char vec_nor (vector signed char, vector signed char);
14763 vector unsigned char vec_nor (vector unsigned char,
14764                               vector unsigned char);
14765 vector bool char vec_nor (vector bool char, vector bool char);
14767 vector float vec_or (vector float, vector float);
14768 vector float vec_or (vector float, vector bool int);
14769 vector float vec_or (vector bool int, vector float);
14770 vector bool int vec_or (vector bool int, vector bool int);
14771 vector signed int vec_or (vector bool int, vector signed int);
14772 vector signed int vec_or (vector signed int, vector bool int);
14773 vector signed int vec_or (vector signed int, vector signed int);
14774 vector unsigned int vec_or (vector bool int, vector unsigned int);
14775 vector unsigned int vec_or (vector unsigned int, vector bool int);
14776 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14777 vector bool short vec_or (vector bool short, vector bool short);
14778 vector signed short vec_or (vector bool short, vector signed short);
14779 vector signed short vec_or (vector signed short, vector bool short);
14780 vector signed short vec_or (vector signed short, vector signed short);
14781 vector unsigned short vec_or (vector bool short, vector unsigned short);
14782 vector unsigned short vec_or (vector unsigned short, vector bool short);
14783 vector unsigned short vec_or (vector unsigned short,
14784                               vector unsigned short);
14785 vector signed char vec_or (vector bool char, vector signed char);
14786 vector bool char vec_or (vector bool char, vector bool char);
14787 vector signed char vec_or (vector signed char, vector bool char);
14788 vector signed char vec_or (vector signed char, vector signed char);
14789 vector unsigned char vec_or (vector bool char, vector unsigned char);
14790 vector unsigned char vec_or (vector unsigned char, vector bool char);
14791 vector unsigned char vec_or (vector unsigned char,
14792                              vector unsigned char);
14794 vector signed char vec_pack (vector signed short, vector signed short);
14795 vector unsigned char vec_pack (vector unsigned short,
14796                                vector unsigned short);
14797 vector bool char vec_pack (vector bool short, vector bool short);
14798 vector signed short vec_pack (vector signed int, vector signed int);
14799 vector unsigned short vec_pack (vector unsigned int,
14800                                 vector unsigned int);
14801 vector bool short vec_pack (vector bool int, vector bool int);
14803 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14804 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14805 vector unsigned short vec_vpkuwum (vector unsigned int,
14806                                    vector unsigned int);
14808 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14809 vector signed char vec_vpkuhum (vector signed short,
14810                                 vector signed short);
14811 vector unsigned char vec_vpkuhum (vector unsigned short,
14812                                   vector unsigned short);
14814 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14816 vector unsigned char vec_packs (vector unsigned short,
14817                                 vector unsigned short);
14818 vector signed char vec_packs (vector signed short, vector signed short);
14819 vector unsigned short vec_packs (vector unsigned int,
14820                                  vector unsigned int);
14821 vector signed short vec_packs (vector signed int, vector signed int);
14823 vector signed short vec_vpkswss (vector signed int, vector signed int);
14825 vector unsigned short vec_vpkuwus (vector unsigned int,
14826                                    vector unsigned int);
14828 vector signed char vec_vpkshss (vector signed short,
14829                                 vector signed short);
14831 vector unsigned char vec_vpkuhus (vector unsigned short,
14832                                   vector unsigned short);
14834 vector unsigned char vec_packsu (vector unsigned short,
14835                                  vector unsigned short);
14836 vector unsigned char vec_packsu (vector signed short,
14837                                  vector signed short);
14838 vector unsigned short vec_packsu (vector unsigned int,
14839                                   vector unsigned int);
14840 vector unsigned short vec_packsu (vector signed int, vector signed int);
14842 vector unsigned short vec_vpkswus (vector signed int,
14843                                    vector signed int);
14845 vector unsigned char vec_vpkshus (vector signed short,
14846                                   vector signed short);
14848 vector float vec_perm (vector float,
14849                        vector float,
14850                        vector unsigned char);
14851 vector signed int vec_perm (vector signed int,
14852                             vector signed int,
14853                             vector unsigned char);
14854 vector unsigned int vec_perm (vector unsigned int,
14855                               vector unsigned int,
14856                               vector unsigned char);
14857 vector bool int vec_perm (vector bool int,
14858                           vector bool int,
14859                           vector unsigned char);
14860 vector signed short vec_perm (vector signed short,
14861                               vector signed short,
14862                               vector unsigned char);
14863 vector unsigned short vec_perm (vector unsigned short,
14864                                 vector unsigned short,
14865                                 vector unsigned char);
14866 vector bool short vec_perm (vector bool short,
14867                             vector bool short,
14868                             vector unsigned char);
14869 vector pixel vec_perm (vector pixel,
14870                        vector pixel,
14871                        vector unsigned char);
14872 vector signed char vec_perm (vector signed char,
14873                              vector signed char,
14874                              vector unsigned char);
14875 vector unsigned char vec_perm (vector unsigned char,
14876                                vector unsigned char,
14877                                vector unsigned char);
14878 vector bool char vec_perm (vector bool char,
14879                            vector bool char,
14880                            vector unsigned char);
14882 vector float vec_re (vector float);
14884 vector signed char vec_rl (vector signed char,
14885                            vector unsigned char);
14886 vector unsigned char vec_rl (vector unsigned char,
14887                              vector unsigned char);
14888 vector signed short vec_rl (vector signed short, vector unsigned short);
14889 vector unsigned short vec_rl (vector unsigned short,
14890                               vector unsigned short);
14891 vector signed int vec_rl (vector signed int, vector unsigned int);
14892 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14894 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14895 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14897 vector signed short vec_vrlh (vector signed short,
14898                               vector unsigned short);
14899 vector unsigned short vec_vrlh (vector unsigned short,
14900                                 vector unsigned short);
14902 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14903 vector unsigned char vec_vrlb (vector unsigned char,
14904                                vector unsigned char);
14906 vector float vec_round (vector float);
14908 vector float vec_recip (vector float, vector float);
14910 vector float vec_rsqrt (vector float);
14912 vector float vec_rsqrte (vector float);
14914 vector float vec_sel (vector float, vector float, vector bool int);
14915 vector float vec_sel (vector float, vector float, vector unsigned int);
14916 vector signed int vec_sel (vector signed int,
14917                            vector signed int,
14918                            vector bool int);
14919 vector signed int vec_sel (vector signed int,
14920                            vector signed int,
14921                            vector unsigned int);
14922 vector unsigned int vec_sel (vector unsigned int,
14923                              vector unsigned int,
14924                              vector bool int);
14925 vector unsigned int vec_sel (vector unsigned int,
14926                              vector unsigned int,
14927                              vector unsigned int);
14928 vector bool int vec_sel (vector bool int,
14929                          vector bool int,
14930                          vector bool int);
14931 vector bool int vec_sel (vector bool int,
14932                          vector bool int,
14933                          vector unsigned int);
14934 vector signed short vec_sel (vector signed short,
14935                              vector signed short,
14936                              vector bool short);
14937 vector signed short vec_sel (vector signed short,
14938                              vector signed short,
14939                              vector unsigned short);
14940 vector unsigned short vec_sel (vector unsigned short,
14941                                vector unsigned short,
14942                                vector bool short);
14943 vector unsigned short vec_sel (vector unsigned short,
14944                                vector unsigned short,
14945                                vector unsigned short);
14946 vector bool short vec_sel (vector bool short,
14947                            vector bool short,
14948                            vector bool short);
14949 vector bool short vec_sel (vector bool short,
14950                            vector bool short,
14951                            vector unsigned short);
14952 vector signed char vec_sel (vector signed char,
14953                             vector signed char,
14954                             vector bool char);
14955 vector signed char vec_sel (vector signed char,
14956                             vector signed char,
14957                             vector unsigned char);
14958 vector unsigned char vec_sel (vector unsigned char,
14959                               vector unsigned char,
14960                               vector bool char);
14961 vector unsigned char vec_sel (vector unsigned char,
14962                               vector unsigned char,
14963                               vector unsigned char);
14964 vector bool char vec_sel (vector bool char,
14965                           vector bool char,
14966                           vector bool char);
14967 vector bool char vec_sel (vector bool char,
14968                           vector bool char,
14969                           vector unsigned char);
14971 vector signed char vec_sl (vector signed char,
14972                            vector unsigned char);
14973 vector unsigned char vec_sl (vector unsigned char,
14974                              vector unsigned char);
14975 vector signed short vec_sl (vector signed short, vector unsigned short);
14976 vector unsigned short vec_sl (vector unsigned short,
14977                               vector unsigned short);
14978 vector signed int vec_sl (vector signed int, vector unsigned int);
14979 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14981 vector signed int vec_vslw (vector signed int, vector unsigned int);
14982 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14984 vector signed short vec_vslh (vector signed short,
14985                               vector unsigned short);
14986 vector unsigned short vec_vslh (vector unsigned short,
14987                                 vector unsigned short);
14989 vector signed char vec_vslb (vector signed char, vector unsigned char);
14990 vector unsigned char vec_vslb (vector unsigned char,
14991                                vector unsigned char);
14993 vector float vec_sld (vector float, vector float, const int);
14994 vector signed int vec_sld (vector signed int,
14995                            vector signed int,
14996                            const int);
14997 vector unsigned int vec_sld (vector unsigned int,
14998                              vector unsigned int,
14999                              const int);
15000 vector bool int vec_sld (vector bool int,
15001                          vector bool int,
15002                          const int);
15003 vector signed short vec_sld (vector signed short,
15004                              vector signed short,
15005                              const int);
15006 vector unsigned short vec_sld (vector unsigned short,
15007                                vector unsigned short,
15008                                const int);
15009 vector bool short vec_sld (vector bool short,
15010                            vector bool short,
15011                            const int);
15012 vector pixel vec_sld (vector pixel,
15013                       vector pixel,
15014                       const int);
15015 vector signed char vec_sld (vector signed char,
15016                             vector signed char,
15017                             const int);
15018 vector unsigned char vec_sld (vector unsigned char,
15019                               vector unsigned char,
15020                               const int);
15021 vector bool char vec_sld (vector bool char,
15022                           vector bool char,
15023                           const int);
15025 vector signed int vec_sll (vector signed int,
15026                            vector unsigned int);
15027 vector signed int vec_sll (vector signed int,
15028                            vector unsigned short);
15029 vector signed int vec_sll (vector signed int,
15030                            vector unsigned char);
15031 vector unsigned int vec_sll (vector unsigned int,
15032                              vector unsigned int);
15033 vector unsigned int vec_sll (vector unsigned int,
15034                              vector unsigned short);
15035 vector unsigned int vec_sll (vector unsigned int,
15036                              vector unsigned char);
15037 vector bool int vec_sll (vector bool int,
15038                          vector unsigned int);
15039 vector bool int vec_sll (vector bool int,
15040                          vector unsigned short);
15041 vector bool int vec_sll (vector bool int,
15042                          vector unsigned char);
15043 vector signed short vec_sll (vector signed short,
15044                              vector unsigned int);
15045 vector signed short vec_sll (vector signed short,
15046                              vector unsigned short);
15047 vector signed short vec_sll (vector signed short,
15048                              vector unsigned char);
15049 vector unsigned short vec_sll (vector unsigned short,
15050                                vector unsigned int);
15051 vector unsigned short vec_sll (vector unsigned short,
15052                                vector unsigned short);
15053 vector unsigned short vec_sll (vector unsigned short,
15054                                vector unsigned char);
15055 vector bool short vec_sll (vector bool short, vector unsigned int);
15056 vector bool short vec_sll (vector bool short, vector unsigned short);
15057 vector bool short vec_sll (vector bool short, vector unsigned char);
15058 vector pixel vec_sll (vector pixel, vector unsigned int);
15059 vector pixel vec_sll (vector pixel, vector unsigned short);
15060 vector pixel vec_sll (vector pixel, vector unsigned char);
15061 vector signed char vec_sll (vector signed char, vector unsigned int);
15062 vector signed char vec_sll (vector signed char, vector unsigned short);
15063 vector signed char vec_sll (vector signed char, vector unsigned char);
15064 vector unsigned char vec_sll (vector unsigned char,
15065                               vector unsigned int);
15066 vector unsigned char vec_sll (vector unsigned char,
15067                               vector unsigned short);
15068 vector unsigned char vec_sll (vector unsigned char,
15069                               vector unsigned char);
15070 vector bool char vec_sll (vector bool char, vector unsigned int);
15071 vector bool char vec_sll (vector bool char, vector unsigned short);
15072 vector bool char vec_sll (vector bool char, vector unsigned char);
15074 vector float vec_slo (vector float, vector signed char);
15075 vector float vec_slo (vector float, vector unsigned char);
15076 vector signed int vec_slo (vector signed int, vector signed char);
15077 vector signed int vec_slo (vector signed int, vector unsigned char);
15078 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15079 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15080 vector signed short vec_slo (vector signed short, vector signed char);
15081 vector signed short vec_slo (vector signed short, vector unsigned char);
15082 vector unsigned short vec_slo (vector unsigned short,
15083                                vector signed char);
15084 vector unsigned short vec_slo (vector unsigned short,
15085                                vector unsigned char);
15086 vector pixel vec_slo (vector pixel, vector signed char);
15087 vector pixel vec_slo (vector pixel, vector unsigned char);
15088 vector signed char vec_slo (vector signed char, vector signed char);
15089 vector signed char vec_slo (vector signed char, vector unsigned char);
15090 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15091 vector unsigned char vec_slo (vector unsigned char,
15092                               vector unsigned char);
15094 vector signed char vec_splat (vector signed char, const int);
15095 vector unsigned char vec_splat (vector unsigned char, const int);
15096 vector bool char vec_splat (vector bool char, const int);
15097 vector signed short vec_splat (vector signed short, const int);
15098 vector unsigned short vec_splat (vector unsigned short, const int);
15099 vector bool short vec_splat (vector bool short, const int);
15100 vector pixel vec_splat (vector pixel, const int);
15101 vector float vec_splat (vector float, const int);
15102 vector signed int vec_splat (vector signed int, const int);
15103 vector unsigned int vec_splat (vector unsigned int, const int);
15104 vector bool int vec_splat (vector bool int, const int);
15105 vector signed long vec_splat (vector signed long, const int);
15106 vector unsigned long vec_splat (vector unsigned long, const int);
15108 vector signed char vec_splats (signed char);
15109 vector unsigned char vec_splats (unsigned char);
15110 vector signed short vec_splats (signed short);
15111 vector unsigned short vec_splats (unsigned short);
15112 vector signed int vec_splats (signed int);
15113 vector unsigned int vec_splats (unsigned int);
15114 vector float vec_splats (float);
15116 vector float vec_vspltw (vector float, const int);
15117 vector signed int vec_vspltw (vector signed int, const int);
15118 vector unsigned int vec_vspltw (vector unsigned int, const int);
15119 vector bool int vec_vspltw (vector bool int, const int);
15121 vector bool short vec_vsplth (vector bool short, const int);
15122 vector signed short vec_vsplth (vector signed short, const int);
15123 vector unsigned short vec_vsplth (vector unsigned short, const int);
15124 vector pixel vec_vsplth (vector pixel, const int);
15126 vector signed char vec_vspltb (vector signed char, const int);
15127 vector unsigned char vec_vspltb (vector unsigned char, const int);
15128 vector bool char vec_vspltb (vector bool char, const int);
15130 vector signed char vec_splat_s8 (const int);
15132 vector signed short vec_splat_s16 (const int);
15134 vector signed int vec_splat_s32 (const int);
15136 vector unsigned char vec_splat_u8 (const int);
15138 vector unsigned short vec_splat_u16 (const int);
15140 vector unsigned int vec_splat_u32 (const int);
15142 vector signed char vec_sr (vector signed char, vector unsigned char);
15143 vector unsigned char vec_sr (vector unsigned char,
15144                              vector unsigned char);
15145 vector signed short vec_sr (vector signed short,
15146                             vector unsigned short);
15147 vector unsigned short vec_sr (vector unsigned short,
15148                               vector unsigned short);
15149 vector signed int vec_sr (vector signed int, vector unsigned int);
15150 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15152 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15153 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15155 vector signed short vec_vsrh (vector signed short,
15156                               vector unsigned short);
15157 vector unsigned short vec_vsrh (vector unsigned short,
15158                                 vector unsigned short);
15160 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15161 vector unsigned char vec_vsrb (vector unsigned char,
15162                                vector unsigned char);
15164 vector signed char vec_sra (vector signed char, vector unsigned char);
15165 vector unsigned char vec_sra (vector unsigned char,
15166                               vector unsigned char);
15167 vector signed short vec_sra (vector signed short,
15168                              vector unsigned short);
15169 vector unsigned short vec_sra (vector unsigned short,
15170                                vector unsigned short);
15171 vector signed int vec_sra (vector signed int, vector unsigned int);
15172 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15174 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15175 vector unsigned int vec_vsraw (vector unsigned int,
15176                                vector unsigned int);
15178 vector signed short vec_vsrah (vector signed short,
15179                                vector unsigned short);
15180 vector unsigned short vec_vsrah (vector unsigned short,
15181                                  vector unsigned short);
15183 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15184 vector unsigned char vec_vsrab (vector unsigned char,
15185                                 vector unsigned char);
15187 vector signed int vec_srl (vector signed int, vector unsigned int);
15188 vector signed int vec_srl (vector signed int, vector unsigned short);
15189 vector signed int vec_srl (vector signed int, vector unsigned char);
15190 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15191 vector unsigned int vec_srl (vector unsigned int,
15192                              vector unsigned short);
15193 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15194 vector bool int vec_srl (vector bool int, vector unsigned int);
15195 vector bool int vec_srl (vector bool int, vector unsigned short);
15196 vector bool int vec_srl (vector bool int, vector unsigned char);
15197 vector signed short vec_srl (vector signed short, vector unsigned int);
15198 vector signed short vec_srl (vector signed short,
15199                              vector unsigned short);
15200 vector signed short vec_srl (vector signed short, vector unsigned char);
15201 vector unsigned short vec_srl (vector unsigned short,
15202                                vector unsigned int);
15203 vector unsigned short vec_srl (vector unsigned short,
15204                                vector unsigned short);
15205 vector unsigned short vec_srl (vector unsigned short,
15206                                vector unsigned char);
15207 vector bool short vec_srl (vector bool short, vector unsigned int);
15208 vector bool short vec_srl (vector bool short, vector unsigned short);
15209 vector bool short vec_srl (vector bool short, vector unsigned char);
15210 vector pixel vec_srl (vector pixel, vector unsigned int);
15211 vector pixel vec_srl (vector pixel, vector unsigned short);
15212 vector pixel vec_srl (vector pixel, vector unsigned char);
15213 vector signed char vec_srl (vector signed char, vector unsigned int);
15214 vector signed char vec_srl (vector signed char, vector unsigned short);
15215 vector signed char vec_srl (vector signed char, vector unsigned char);
15216 vector unsigned char vec_srl (vector unsigned char,
15217                               vector unsigned int);
15218 vector unsigned char vec_srl (vector unsigned char,
15219                               vector unsigned short);
15220 vector unsigned char vec_srl (vector unsigned char,
15221                               vector unsigned char);
15222 vector bool char vec_srl (vector bool char, vector unsigned int);
15223 vector bool char vec_srl (vector bool char, vector unsigned short);
15224 vector bool char vec_srl (vector bool char, vector unsigned char);
15226 vector float vec_sro (vector float, vector signed char);
15227 vector float vec_sro (vector float, vector unsigned char);
15228 vector signed int vec_sro (vector signed int, vector signed char);
15229 vector signed int vec_sro (vector signed int, vector unsigned char);
15230 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15231 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15232 vector signed short vec_sro (vector signed short, vector signed char);
15233 vector signed short vec_sro (vector signed short, vector unsigned char);
15234 vector unsigned short vec_sro (vector unsigned short,
15235                                vector signed char);
15236 vector unsigned short vec_sro (vector unsigned short,
15237                                vector unsigned char);
15238 vector pixel vec_sro (vector pixel, vector signed char);
15239 vector pixel vec_sro (vector pixel, vector unsigned char);
15240 vector signed char vec_sro (vector signed char, vector signed char);
15241 vector signed char vec_sro (vector signed char, vector unsigned char);
15242 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15243 vector unsigned char vec_sro (vector unsigned char,
15244                               vector unsigned char);
15246 void vec_st (vector float, int, vector float *);
15247 void vec_st (vector float, int, float *);
15248 void vec_st (vector signed int, int, vector signed int *);
15249 void vec_st (vector signed int, int, int *);
15250 void vec_st (vector unsigned int, int, vector unsigned int *);
15251 void vec_st (vector unsigned int, int, unsigned int *);
15252 void vec_st (vector bool int, int, vector bool int *);
15253 void vec_st (vector bool int, int, unsigned int *);
15254 void vec_st (vector bool int, int, int *);
15255 void vec_st (vector signed short, int, vector signed short *);
15256 void vec_st (vector signed short, int, short *);
15257 void vec_st (vector unsigned short, int, vector unsigned short *);
15258 void vec_st (vector unsigned short, int, unsigned short *);
15259 void vec_st (vector bool short, int, vector bool short *);
15260 void vec_st (vector bool short, int, unsigned short *);
15261 void vec_st (vector pixel, int, vector pixel *);
15262 void vec_st (vector pixel, int, unsigned short *);
15263 void vec_st (vector pixel, int, short *);
15264 void vec_st (vector bool short, int, short *);
15265 void vec_st (vector signed char, int, vector signed char *);
15266 void vec_st (vector signed char, int, signed char *);
15267 void vec_st (vector unsigned char, int, vector unsigned char *);
15268 void vec_st (vector unsigned char, int, unsigned char *);
15269 void vec_st (vector bool char, int, vector bool char *);
15270 void vec_st (vector bool char, int, unsigned char *);
15271 void vec_st (vector bool char, int, signed char *);
15273 void vec_ste (vector signed char, int, signed char *);
15274 void vec_ste (vector unsigned char, int, unsigned char *);
15275 void vec_ste (vector bool char, int, signed char *);
15276 void vec_ste (vector bool char, int, unsigned char *);
15277 void vec_ste (vector signed short, int, short *);
15278 void vec_ste (vector unsigned short, int, unsigned short *);
15279 void vec_ste (vector bool short, int, short *);
15280 void vec_ste (vector bool short, int, unsigned short *);
15281 void vec_ste (vector pixel, int, short *);
15282 void vec_ste (vector pixel, int, unsigned short *);
15283 void vec_ste (vector float, int, float *);
15284 void vec_ste (vector signed int, int, int *);
15285 void vec_ste (vector unsigned int, int, unsigned int *);
15286 void vec_ste (vector bool int, int, int *);
15287 void vec_ste (vector bool int, int, unsigned int *);
15289 void vec_stvewx (vector float, int, float *);
15290 void vec_stvewx (vector signed int, int, int *);
15291 void vec_stvewx (vector unsigned int, int, unsigned int *);
15292 void vec_stvewx (vector bool int, int, int *);
15293 void vec_stvewx (vector bool int, int, unsigned int *);
15295 void vec_stvehx (vector signed short, int, short *);
15296 void vec_stvehx (vector unsigned short, int, unsigned short *);
15297 void vec_stvehx (vector bool short, int, short *);
15298 void vec_stvehx (vector bool short, int, unsigned short *);
15299 void vec_stvehx (vector pixel, int, short *);
15300 void vec_stvehx (vector pixel, int, unsigned short *);
15302 void vec_stvebx (vector signed char, int, signed char *);
15303 void vec_stvebx (vector unsigned char, int, unsigned char *);
15304 void vec_stvebx (vector bool char, int, signed char *);
15305 void vec_stvebx (vector bool char, int, unsigned char *);
15307 void vec_stl (vector float, int, vector float *);
15308 void vec_stl (vector float, int, float *);
15309 void vec_stl (vector signed int, int, vector signed int *);
15310 void vec_stl (vector signed int, int, int *);
15311 void vec_stl (vector unsigned int, int, vector unsigned int *);
15312 void vec_stl (vector unsigned int, int, unsigned int *);
15313 void vec_stl (vector bool int, int, vector bool int *);
15314 void vec_stl (vector bool int, int, unsigned int *);
15315 void vec_stl (vector bool int, int, int *);
15316 void vec_stl (vector signed short, int, vector signed short *);
15317 void vec_stl (vector signed short, int, short *);
15318 void vec_stl (vector unsigned short, int, vector unsigned short *);
15319 void vec_stl (vector unsigned short, int, unsigned short *);
15320 void vec_stl (vector bool short, int, vector bool short *);
15321 void vec_stl (vector bool short, int, unsigned short *);
15322 void vec_stl (vector bool short, int, short *);
15323 void vec_stl (vector pixel, int, vector pixel *);
15324 void vec_stl (vector pixel, int, unsigned short *);
15325 void vec_stl (vector pixel, int, short *);
15326 void vec_stl (vector signed char, int, vector signed char *);
15327 void vec_stl (vector signed char, int, signed char *);
15328 void vec_stl (vector unsigned char, int, vector unsigned char *);
15329 void vec_stl (vector unsigned char, int, unsigned char *);
15330 void vec_stl (vector bool char, int, vector bool char *);
15331 void vec_stl (vector bool char, int, unsigned char *);
15332 void vec_stl (vector bool char, int, signed char *);
15334 vector signed char vec_sub (vector bool char, vector signed char);
15335 vector signed char vec_sub (vector signed char, vector bool char);
15336 vector signed char vec_sub (vector signed char, vector signed char);
15337 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15338 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15339 vector unsigned char vec_sub (vector unsigned char,
15340                               vector unsigned char);
15341 vector signed short vec_sub (vector bool short, vector signed short);
15342 vector signed short vec_sub (vector signed short, vector bool short);
15343 vector signed short vec_sub (vector signed short, vector signed short);
15344 vector unsigned short vec_sub (vector bool short,
15345                                vector unsigned short);
15346 vector unsigned short vec_sub (vector unsigned short,
15347                                vector bool short);
15348 vector unsigned short vec_sub (vector unsigned short,
15349                                vector unsigned short);
15350 vector signed int vec_sub (vector bool int, vector signed int);
15351 vector signed int vec_sub (vector signed int, vector bool int);
15352 vector signed int vec_sub (vector signed int, vector signed int);
15353 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15354 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15355 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15356 vector float vec_sub (vector float, vector float);
15358 vector float vec_vsubfp (vector float, vector float);
15360 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15361 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15362 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15363 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15364 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15365 vector unsigned int vec_vsubuwm (vector unsigned int,
15366                                  vector unsigned int);
15368 vector signed short vec_vsubuhm (vector bool short,
15369                                  vector signed short);
15370 vector signed short vec_vsubuhm (vector signed short,
15371                                  vector bool short);
15372 vector signed short vec_vsubuhm (vector signed short,
15373                                  vector signed short);
15374 vector unsigned short vec_vsubuhm (vector bool short,
15375                                    vector unsigned short);
15376 vector unsigned short vec_vsubuhm (vector unsigned short,
15377                                    vector bool short);
15378 vector unsigned short vec_vsubuhm (vector unsigned short,
15379                                    vector unsigned short);
15381 vector signed char vec_vsububm (vector bool char, vector signed char);
15382 vector signed char vec_vsububm (vector signed char, vector bool char);
15383 vector signed char vec_vsububm (vector signed char, vector signed char);
15384 vector unsigned char vec_vsububm (vector bool char,
15385                                   vector unsigned char);
15386 vector unsigned char vec_vsububm (vector unsigned char,
15387                                   vector bool char);
15388 vector unsigned char vec_vsububm (vector unsigned char,
15389                                   vector unsigned char);
15391 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15393 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15394 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15395 vector unsigned char vec_subs (vector unsigned char,
15396                                vector unsigned char);
15397 vector signed char vec_subs (vector bool char, vector signed char);
15398 vector signed char vec_subs (vector signed char, vector bool char);
15399 vector signed char vec_subs (vector signed char, vector signed char);
15400 vector unsigned short vec_subs (vector bool short,
15401                                 vector unsigned short);
15402 vector unsigned short vec_subs (vector unsigned short,
15403                                 vector bool short);
15404 vector unsigned short vec_subs (vector unsigned short,
15405                                 vector unsigned short);
15406 vector signed short vec_subs (vector bool short, vector signed short);
15407 vector signed short vec_subs (vector signed short, vector bool short);
15408 vector signed short vec_subs (vector signed short, vector signed short);
15409 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15410 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15411 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15412 vector signed int vec_subs (vector bool int, vector signed int);
15413 vector signed int vec_subs (vector signed int, vector bool int);
15414 vector signed int vec_subs (vector signed int, vector signed int);
15416 vector signed int vec_vsubsws (vector bool int, vector signed int);
15417 vector signed int vec_vsubsws (vector signed int, vector bool int);
15418 vector signed int vec_vsubsws (vector signed int, vector signed int);
15420 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15421 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15422 vector unsigned int vec_vsubuws (vector unsigned int,
15423                                  vector unsigned int);
15425 vector signed short vec_vsubshs (vector bool short,
15426                                  vector signed short);
15427 vector signed short vec_vsubshs (vector signed short,
15428                                  vector bool short);
15429 vector signed short vec_vsubshs (vector signed short,
15430                                  vector signed short);
15432 vector unsigned short vec_vsubuhs (vector bool short,
15433                                    vector unsigned short);
15434 vector unsigned short vec_vsubuhs (vector unsigned short,
15435                                    vector bool short);
15436 vector unsigned short vec_vsubuhs (vector unsigned short,
15437                                    vector unsigned short);
15439 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15440 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15441 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15443 vector unsigned char vec_vsububs (vector bool char,
15444                                   vector unsigned char);
15445 vector unsigned char vec_vsububs (vector unsigned char,
15446                                   vector bool char);
15447 vector unsigned char vec_vsububs (vector unsigned char,
15448                                   vector unsigned char);
15450 vector unsigned int vec_sum4s (vector unsigned char,
15451                                vector unsigned int);
15452 vector signed int vec_sum4s (vector signed char, vector signed int);
15453 vector signed int vec_sum4s (vector signed short, vector signed int);
15455 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15457 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15459 vector unsigned int vec_vsum4ubs (vector unsigned char,
15460                                   vector unsigned int);
15462 vector signed int vec_sum2s (vector signed int, vector signed int);
15464 vector signed int vec_sums (vector signed int, vector signed int);
15466 vector float vec_trunc (vector float);
15468 vector signed short vec_unpackh (vector signed char);
15469 vector bool short vec_unpackh (vector bool char);
15470 vector signed int vec_unpackh (vector signed short);
15471 vector bool int vec_unpackh (vector bool short);
15472 vector unsigned int vec_unpackh (vector pixel);
15474 vector bool int vec_vupkhsh (vector bool short);
15475 vector signed int vec_vupkhsh (vector signed short);
15477 vector unsigned int vec_vupkhpx (vector pixel);
15479 vector bool short vec_vupkhsb (vector bool char);
15480 vector signed short vec_vupkhsb (vector signed char);
15482 vector signed short vec_unpackl (vector signed char);
15483 vector bool short vec_unpackl (vector bool char);
15484 vector unsigned int vec_unpackl (vector pixel);
15485 vector signed int vec_unpackl (vector signed short);
15486 vector bool int vec_unpackl (vector bool short);
15488 vector unsigned int vec_vupklpx (vector pixel);
15490 vector bool int vec_vupklsh (vector bool short);
15491 vector signed int vec_vupklsh (vector signed short);
15493 vector bool short vec_vupklsb (vector bool char);
15494 vector signed short vec_vupklsb (vector signed char);
15496 vector float vec_xor (vector float, vector float);
15497 vector float vec_xor (vector float, vector bool int);
15498 vector float vec_xor (vector bool int, vector float);
15499 vector bool int vec_xor (vector bool int, vector bool int);
15500 vector signed int vec_xor (vector bool int, vector signed int);
15501 vector signed int vec_xor (vector signed int, vector bool int);
15502 vector signed int vec_xor (vector signed int, vector signed int);
15503 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15504 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15505 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15506 vector bool short vec_xor (vector bool short, vector bool short);
15507 vector signed short vec_xor (vector bool short, vector signed short);
15508 vector signed short vec_xor (vector signed short, vector bool short);
15509 vector signed short vec_xor (vector signed short, vector signed short);
15510 vector unsigned short vec_xor (vector bool short,
15511                                vector unsigned short);
15512 vector unsigned short vec_xor (vector unsigned short,
15513                                vector bool short);
15514 vector unsigned short vec_xor (vector unsigned short,
15515                                vector unsigned short);
15516 vector signed char vec_xor (vector bool char, vector signed char);
15517 vector bool char vec_xor (vector bool char, vector bool char);
15518 vector signed char vec_xor (vector signed char, vector bool char);
15519 vector signed char vec_xor (vector signed char, vector signed char);
15520 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15521 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15522 vector unsigned char vec_xor (vector unsigned char,
15523                               vector unsigned char);
15525 int vec_all_eq (vector signed char, vector bool char);
15526 int vec_all_eq (vector signed char, vector signed char);
15527 int vec_all_eq (vector unsigned char, vector bool char);
15528 int vec_all_eq (vector unsigned char, vector unsigned char);
15529 int vec_all_eq (vector bool char, vector bool char);
15530 int vec_all_eq (vector bool char, vector unsigned char);
15531 int vec_all_eq (vector bool char, vector signed char);
15532 int vec_all_eq (vector signed short, vector bool short);
15533 int vec_all_eq (vector signed short, vector signed short);
15534 int vec_all_eq (vector unsigned short, vector bool short);
15535 int vec_all_eq (vector unsigned short, vector unsigned short);
15536 int vec_all_eq (vector bool short, vector bool short);
15537 int vec_all_eq (vector bool short, vector unsigned short);
15538 int vec_all_eq (vector bool short, vector signed short);
15539 int vec_all_eq (vector pixel, vector pixel);
15540 int vec_all_eq (vector signed int, vector bool int);
15541 int vec_all_eq (vector signed int, vector signed int);
15542 int vec_all_eq (vector unsigned int, vector bool int);
15543 int vec_all_eq (vector unsigned int, vector unsigned int);
15544 int vec_all_eq (vector bool int, vector bool int);
15545 int vec_all_eq (vector bool int, vector unsigned int);
15546 int vec_all_eq (vector bool int, vector signed int);
15547 int vec_all_eq (vector float, vector float);
15549 int vec_all_ge (vector bool char, vector unsigned char);
15550 int vec_all_ge (vector unsigned char, vector bool char);
15551 int vec_all_ge (vector unsigned char, vector unsigned char);
15552 int vec_all_ge (vector bool char, vector signed char);
15553 int vec_all_ge (vector signed char, vector bool char);
15554 int vec_all_ge (vector signed char, vector signed char);
15555 int vec_all_ge (vector bool short, vector unsigned short);
15556 int vec_all_ge (vector unsigned short, vector bool short);
15557 int vec_all_ge (vector unsigned short, vector unsigned short);
15558 int vec_all_ge (vector signed short, vector signed short);
15559 int vec_all_ge (vector bool short, vector signed short);
15560 int vec_all_ge (vector signed short, vector bool short);
15561 int vec_all_ge (vector bool int, vector unsigned int);
15562 int vec_all_ge (vector unsigned int, vector bool int);
15563 int vec_all_ge (vector unsigned int, vector unsigned int);
15564 int vec_all_ge (vector bool int, vector signed int);
15565 int vec_all_ge (vector signed int, vector bool int);
15566 int vec_all_ge (vector signed int, vector signed int);
15567 int vec_all_ge (vector float, vector float);
15569 int vec_all_gt (vector bool char, vector unsigned char);
15570 int vec_all_gt (vector unsigned char, vector bool char);
15571 int vec_all_gt (vector unsigned char, vector unsigned char);
15572 int vec_all_gt (vector bool char, vector signed char);
15573 int vec_all_gt (vector signed char, vector bool char);
15574 int vec_all_gt (vector signed char, vector signed char);
15575 int vec_all_gt (vector bool short, vector unsigned short);
15576 int vec_all_gt (vector unsigned short, vector bool short);
15577 int vec_all_gt (vector unsigned short, vector unsigned short);
15578 int vec_all_gt (vector bool short, vector signed short);
15579 int vec_all_gt (vector signed short, vector bool short);
15580 int vec_all_gt (vector signed short, vector signed short);
15581 int vec_all_gt (vector bool int, vector unsigned int);
15582 int vec_all_gt (vector unsigned int, vector bool int);
15583 int vec_all_gt (vector unsigned int, vector unsigned int);
15584 int vec_all_gt (vector bool int, vector signed int);
15585 int vec_all_gt (vector signed int, vector bool int);
15586 int vec_all_gt (vector signed int, vector signed int);
15587 int vec_all_gt (vector float, vector float);
15589 int vec_all_in (vector float, vector float);
15591 int vec_all_le (vector bool char, vector unsigned char);
15592 int vec_all_le (vector unsigned char, vector bool char);
15593 int vec_all_le (vector unsigned char, vector unsigned char);
15594 int vec_all_le (vector bool char, vector signed char);
15595 int vec_all_le (vector signed char, vector bool char);
15596 int vec_all_le (vector signed char, vector signed char);
15597 int vec_all_le (vector bool short, vector unsigned short);
15598 int vec_all_le (vector unsigned short, vector bool short);
15599 int vec_all_le (vector unsigned short, vector unsigned short);
15600 int vec_all_le (vector bool short, vector signed short);
15601 int vec_all_le (vector signed short, vector bool short);
15602 int vec_all_le (vector signed short, vector signed short);
15603 int vec_all_le (vector bool int, vector unsigned int);
15604 int vec_all_le (vector unsigned int, vector bool int);
15605 int vec_all_le (vector unsigned int, vector unsigned int);
15606 int vec_all_le (vector bool int, vector signed int);
15607 int vec_all_le (vector signed int, vector bool int);
15608 int vec_all_le (vector signed int, vector signed int);
15609 int vec_all_le (vector float, vector float);
15611 int vec_all_lt (vector bool char, vector unsigned char);
15612 int vec_all_lt (vector unsigned char, vector bool char);
15613 int vec_all_lt (vector unsigned char, vector unsigned char);
15614 int vec_all_lt (vector bool char, vector signed char);
15615 int vec_all_lt (vector signed char, vector bool char);
15616 int vec_all_lt (vector signed char, vector signed char);
15617 int vec_all_lt (vector bool short, vector unsigned short);
15618 int vec_all_lt (vector unsigned short, vector bool short);
15619 int vec_all_lt (vector unsigned short, vector unsigned short);
15620 int vec_all_lt (vector bool short, vector signed short);
15621 int vec_all_lt (vector signed short, vector bool short);
15622 int vec_all_lt (vector signed short, vector signed short);
15623 int vec_all_lt (vector bool int, vector unsigned int);
15624 int vec_all_lt (vector unsigned int, vector bool int);
15625 int vec_all_lt (vector unsigned int, vector unsigned int);
15626 int vec_all_lt (vector bool int, vector signed int);
15627 int vec_all_lt (vector signed int, vector bool int);
15628 int vec_all_lt (vector signed int, vector signed int);
15629 int vec_all_lt (vector float, vector float);
15631 int vec_all_nan (vector float);
15633 int vec_all_ne (vector signed char, vector bool char);
15634 int vec_all_ne (vector signed char, vector signed char);
15635 int vec_all_ne (vector unsigned char, vector bool char);
15636 int vec_all_ne (vector unsigned char, vector unsigned char);
15637 int vec_all_ne (vector bool char, vector bool char);
15638 int vec_all_ne (vector bool char, vector unsigned char);
15639 int vec_all_ne (vector bool char, vector signed char);
15640 int vec_all_ne (vector signed short, vector bool short);
15641 int vec_all_ne (vector signed short, vector signed short);
15642 int vec_all_ne (vector unsigned short, vector bool short);
15643 int vec_all_ne (vector unsigned short, vector unsigned short);
15644 int vec_all_ne (vector bool short, vector bool short);
15645 int vec_all_ne (vector bool short, vector unsigned short);
15646 int vec_all_ne (vector bool short, vector signed short);
15647 int vec_all_ne (vector pixel, vector pixel);
15648 int vec_all_ne (vector signed int, vector bool int);
15649 int vec_all_ne (vector signed int, vector signed int);
15650 int vec_all_ne (vector unsigned int, vector bool int);
15651 int vec_all_ne (vector unsigned int, vector unsigned int);
15652 int vec_all_ne (vector bool int, vector bool int);
15653 int vec_all_ne (vector bool int, vector unsigned int);
15654 int vec_all_ne (vector bool int, vector signed int);
15655 int vec_all_ne (vector float, vector float);
15657 int vec_all_nge (vector float, vector float);
15659 int vec_all_ngt (vector float, vector float);
15661 int vec_all_nle (vector float, vector float);
15663 int vec_all_nlt (vector float, vector float);
15665 int vec_all_numeric (vector float);
15667 int vec_any_eq (vector signed char, vector bool char);
15668 int vec_any_eq (vector signed char, vector signed char);
15669 int vec_any_eq (vector unsigned char, vector bool char);
15670 int vec_any_eq (vector unsigned char, vector unsigned char);
15671 int vec_any_eq (vector bool char, vector bool char);
15672 int vec_any_eq (vector bool char, vector unsigned char);
15673 int vec_any_eq (vector bool char, vector signed char);
15674 int vec_any_eq (vector signed short, vector bool short);
15675 int vec_any_eq (vector signed short, vector signed short);
15676 int vec_any_eq (vector unsigned short, vector bool short);
15677 int vec_any_eq (vector unsigned short, vector unsigned short);
15678 int vec_any_eq (vector bool short, vector bool short);
15679 int vec_any_eq (vector bool short, vector unsigned short);
15680 int vec_any_eq (vector bool short, vector signed short);
15681 int vec_any_eq (vector pixel, vector pixel);
15682 int vec_any_eq (vector signed int, vector bool int);
15683 int vec_any_eq (vector signed int, vector signed int);
15684 int vec_any_eq (vector unsigned int, vector bool int);
15685 int vec_any_eq (vector unsigned int, vector unsigned int);
15686 int vec_any_eq (vector bool int, vector bool int);
15687 int vec_any_eq (vector bool int, vector unsigned int);
15688 int vec_any_eq (vector bool int, vector signed int);
15689 int vec_any_eq (vector float, vector float);
15691 int vec_any_ge (vector signed char, vector bool char);
15692 int vec_any_ge (vector unsigned char, vector bool char);
15693 int vec_any_ge (vector unsigned char, vector unsigned char);
15694 int vec_any_ge (vector signed char, vector signed char);
15695 int vec_any_ge (vector bool char, vector unsigned char);
15696 int vec_any_ge (vector bool char, vector signed char);
15697 int vec_any_ge (vector unsigned short, vector bool short);
15698 int vec_any_ge (vector unsigned short, vector unsigned short);
15699 int vec_any_ge (vector signed short, vector signed short);
15700 int vec_any_ge (vector signed short, vector bool short);
15701 int vec_any_ge (vector bool short, vector unsigned short);
15702 int vec_any_ge (vector bool short, vector signed short);
15703 int vec_any_ge (vector signed int, vector bool int);
15704 int vec_any_ge (vector unsigned int, vector bool int);
15705 int vec_any_ge (vector unsigned int, vector unsigned int);
15706 int vec_any_ge (vector signed int, vector signed int);
15707 int vec_any_ge (vector bool int, vector unsigned int);
15708 int vec_any_ge (vector bool int, vector signed int);
15709 int vec_any_ge (vector float, vector float);
15711 int vec_any_gt (vector bool char, vector unsigned char);
15712 int vec_any_gt (vector unsigned char, vector bool char);
15713 int vec_any_gt (vector unsigned char, vector unsigned char);
15714 int vec_any_gt (vector bool char, vector signed char);
15715 int vec_any_gt (vector signed char, vector bool char);
15716 int vec_any_gt (vector signed char, vector signed char);
15717 int vec_any_gt (vector bool short, vector unsigned short);
15718 int vec_any_gt (vector unsigned short, vector bool short);
15719 int vec_any_gt (vector unsigned short, vector unsigned short);
15720 int vec_any_gt (vector bool short, vector signed short);
15721 int vec_any_gt (vector signed short, vector bool short);
15722 int vec_any_gt (vector signed short, vector signed short);
15723 int vec_any_gt (vector bool int, vector unsigned int);
15724 int vec_any_gt (vector unsigned int, vector bool int);
15725 int vec_any_gt (vector unsigned int, vector unsigned int);
15726 int vec_any_gt (vector bool int, vector signed int);
15727 int vec_any_gt (vector signed int, vector bool int);
15728 int vec_any_gt (vector signed int, vector signed int);
15729 int vec_any_gt (vector float, vector float);
15731 int vec_any_le (vector bool char, vector unsigned char);
15732 int vec_any_le (vector unsigned char, vector bool char);
15733 int vec_any_le (vector unsigned char, vector unsigned char);
15734 int vec_any_le (vector bool char, vector signed char);
15735 int vec_any_le (vector signed char, vector bool char);
15736 int vec_any_le (vector signed char, vector signed char);
15737 int vec_any_le (vector bool short, vector unsigned short);
15738 int vec_any_le (vector unsigned short, vector bool short);
15739 int vec_any_le (vector unsigned short, vector unsigned short);
15740 int vec_any_le (vector bool short, vector signed short);
15741 int vec_any_le (vector signed short, vector bool short);
15742 int vec_any_le (vector signed short, vector signed short);
15743 int vec_any_le (vector bool int, vector unsigned int);
15744 int vec_any_le (vector unsigned int, vector bool int);
15745 int vec_any_le (vector unsigned int, vector unsigned int);
15746 int vec_any_le (vector bool int, vector signed int);
15747 int vec_any_le (vector signed int, vector bool int);
15748 int vec_any_le (vector signed int, vector signed int);
15749 int vec_any_le (vector float, vector float);
15751 int vec_any_lt (vector bool char, vector unsigned char);
15752 int vec_any_lt (vector unsigned char, vector bool char);
15753 int vec_any_lt (vector unsigned char, vector unsigned char);
15754 int vec_any_lt (vector bool char, vector signed char);
15755 int vec_any_lt (vector signed char, vector bool char);
15756 int vec_any_lt (vector signed char, vector signed char);
15757 int vec_any_lt (vector bool short, vector unsigned short);
15758 int vec_any_lt (vector unsigned short, vector bool short);
15759 int vec_any_lt (vector unsigned short, vector unsigned short);
15760 int vec_any_lt (vector bool short, vector signed short);
15761 int vec_any_lt (vector signed short, vector bool short);
15762 int vec_any_lt (vector signed short, vector signed short);
15763 int vec_any_lt (vector bool int, vector unsigned int);
15764 int vec_any_lt (vector unsigned int, vector bool int);
15765 int vec_any_lt (vector unsigned int, vector unsigned int);
15766 int vec_any_lt (vector bool int, vector signed int);
15767 int vec_any_lt (vector signed int, vector bool int);
15768 int vec_any_lt (vector signed int, vector signed int);
15769 int vec_any_lt (vector float, vector float);
15771 int vec_any_nan (vector float);
15773 int vec_any_ne (vector signed char, vector bool char);
15774 int vec_any_ne (vector signed char, vector signed char);
15775 int vec_any_ne (vector unsigned char, vector bool char);
15776 int vec_any_ne (vector unsigned char, vector unsigned char);
15777 int vec_any_ne (vector bool char, vector bool char);
15778 int vec_any_ne (vector bool char, vector unsigned char);
15779 int vec_any_ne (vector bool char, vector signed char);
15780 int vec_any_ne (vector signed short, vector bool short);
15781 int vec_any_ne (vector signed short, vector signed short);
15782 int vec_any_ne (vector unsigned short, vector bool short);
15783 int vec_any_ne (vector unsigned short, vector unsigned short);
15784 int vec_any_ne (vector bool short, vector bool short);
15785 int vec_any_ne (vector bool short, vector unsigned short);
15786 int vec_any_ne (vector bool short, vector signed short);
15787 int vec_any_ne (vector pixel, vector pixel);
15788 int vec_any_ne (vector signed int, vector bool int);
15789 int vec_any_ne (vector signed int, vector signed int);
15790 int vec_any_ne (vector unsigned int, vector bool int);
15791 int vec_any_ne (vector unsigned int, vector unsigned int);
15792 int vec_any_ne (vector bool int, vector bool int);
15793 int vec_any_ne (vector bool int, vector unsigned int);
15794 int vec_any_ne (vector bool int, vector signed int);
15795 int vec_any_ne (vector float, vector float);
15797 int vec_any_nge (vector float, vector float);
15799 int vec_any_ngt (vector float, vector float);
15801 int vec_any_nle (vector float, vector float);
15803 int vec_any_nlt (vector float, vector float);
15805 int vec_any_numeric (vector float);
15807 int vec_any_out (vector float, vector float);
15808 @end smallexample
15810 If the vector/scalar (VSX) instruction set is available, the following
15811 additional functions are available:
15813 @smallexample
15814 vector double vec_abs (vector double);
15815 vector double vec_add (vector double, vector double);
15816 vector double vec_and (vector double, vector double);
15817 vector double vec_and (vector double, vector bool long);
15818 vector double vec_and (vector bool long, vector double);
15819 vector long vec_and (vector long, vector long);
15820 vector long vec_and (vector long, vector bool long);
15821 vector long vec_and (vector bool long, vector long);
15822 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15823 vector unsigned long vec_and (vector unsigned long, vector bool long);
15824 vector unsigned long vec_and (vector bool long, vector unsigned long);
15825 vector double vec_andc (vector double, vector double);
15826 vector double vec_andc (vector double, vector bool long);
15827 vector double vec_andc (vector bool long, vector double);
15828 vector long vec_andc (vector long, vector long);
15829 vector long vec_andc (vector long, vector bool long);
15830 vector long vec_andc (vector bool long, vector long);
15831 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15832 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15833 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15834 vector double vec_ceil (vector double);
15835 vector bool long vec_cmpeq (vector double, vector double);
15836 vector bool long vec_cmpge (vector double, vector double);
15837 vector bool long vec_cmpgt (vector double, vector double);
15838 vector bool long vec_cmple (vector double, vector double);
15839 vector bool long vec_cmplt (vector double, vector double);
15840 vector double vec_cpsgn (vector double, vector double);
15841 vector float vec_div (vector float, vector float);
15842 vector double vec_div (vector double, vector double);
15843 vector long vec_div (vector long, vector long);
15844 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15845 vector double vec_floor (vector double);
15846 vector double vec_ld (int, const vector double *);
15847 vector double vec_ld (int, const double *);
15848 vector double vec_ldl (int, const vector double *);
15849 vector double vec_ldl (int, const double *);
15850 vector unsigned char vec_lvsl (int, const volatile double *);
15851 vector unsigned char vec_lvsr (int, const volatile double *);
15852 vector double vec_madd (vector double, vector double, vector double);
15853 vector double vec_max (vector double, vector double);
15854 vector signed long vec_mergeh (vector signed long, vector signed long);
15855 vector signed long vec_mergeh (vector signed long, vector bool long);
15856 vector signed long vec_mergeh (vector bool long, vector signed long);
15857 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15858 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15859 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15860 vector signed long vec_mergel (vector signed long, vector signed long);
15861 vector signed long vec_mergel (vector signed long, vector bool long);
15862 vector signed long vec_mergel (vector bool long, vector signed long);
15863 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15864 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15865 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15866 vector double vec_min (vector double, vector double);
15867 vector float vec_msub (vector float, vector float, vector float);
15868 vector double vec_msub (vector double, vector double, vector double);
15869 vector float vec_mul (vector float, vector float);
15870 vector double vec_mul (vector double, vector double);
15871 vector long vec_mul (vector long, vector long);
15872 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15873 vector float vec_nearbyint (vector float);
15874 vector double vec_nearbyint (vector double);
15875 vector float vec_nmadd (vector float, vector float, vector float);
15876 vector double vec_nmadd (vector double, vector double, vector double);
15877 vector double vec_nmsub (vector double, vector double, vector double);
15878 vector double vec_nor (vector double, vector double);
15879 vector long vec_nor (vector long, vector long);
15880 vector long vec_nor (vector long, vector bool long);
15881 vector long vec_nor (vector bool long, vector long);
15882 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15883 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15884 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15885 vector double vec_or (vector double, vector double);
15886 vector double vec_or (vector double, vector bool long);
15887 vector double vec_or (vector bool long, vector double);
15888 vector long vec_or (vector long, vector long);
15889 vector long vec_or (vector long, vector bool long);
15890 vector long vec_or (vector bool long, vector long);
15891 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15892 vector unsigned long vec_or (vector unsigned long, vector bool long);
15893 vector unsigned long vec_or (vector bool long, vector unsigned long);
15894 vector double vec_perm (vector double, vector double, vector unsigned char);
15895 vector long vec_perm (vector long, vector long, vector unsigned char);
15896 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15897                                vector unsigned char);
15898 vector double vec_rint (vector double);
15899 vector double vec_recip (vector double, vector double);
15900 vector double vec_rsqrt (vector double);
15901 vector double vec_rsqrte (vector double);
15902 vector double vec_sel (vector double, vector double, vector bool long);
15903 vector double vec_sel (vector double, vector double, vector unsigned long);
15904 vector long vec_sel (vector long, vector long, vector long);
15905 vector long vec_sel (vector long, vector long, vector unsigned long);
15906 vector long vec_sel (vector long, vector long, vector bool long);
15907 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15908                               vector long);
15909 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15910                               vector unsigned long);
15911 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15912                               vector bool long);
15913 vector double vec_splats (double);
15914 vector signed long vec_splats (signed long);
15915 vector unsigned long vec_splats (unsigned long);
15916 vector float vec_sqrt (vector float);
15917 vector double vec_sqrt (vector double);
15918 void vec_st (vector double, int, vector double *);
15919 void vec_st (vector double, int, double *);
15920 vector double vec_sub (vector double, vector double);
15921 vector double vec_trunc (vector double);
15922 vector double vec_xor (vector double, vector double);
15923 vector double vec_xor (vector double, vector bool long);
15924 vector double vec_xor (vector bool long, vector double);
15925 vector long vec_xor (vector long, vector long);
15926 vector long vec_xor (vector long, vector bool long);
15927 vector long vec_xor (vector bool long, vector long);
15928 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15929 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15930 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15931 int vec_all_eq (vector double, vector double);
15932 int vec_all_ge (vector double, vector double);
15933 int vec_all_gt (vector double, vector double);
15934 int vec_all_le (vector double, vector double);
15935 int vec_all_lt (vector double, vector double);
15936 int vec_all_nan (vector double);
15937 int vec_all_ne (vector double, vector double);
15938 int vec_all_nge (vector double, vector double);
15939 int vec_all_ngt (vector double, vector double);
15940 int vec_all_nle (vector double, vector double);
15941 int vec_all_nlt (vector double, vector double);
15942 int vec_all_numeric (vector double);
15943 int vec_any_eq (vector double, vector double);
15944 int vec_any_ge (vector double, vector double);
15945 int vec_any_gt (vector double, vector double);
15946 int vec_any_le (vector double, vector double);
15947 int vec_any_lt (vector double, vector double);
15948 int vec_any_nan (vector double);
15949 int vec_any_ne (vector double, vector double);
15950 int vec_any_nge (vector double, vector double);
15951 int vec_any_ngt (vector double, vector double);
15952 int vec_any_nle (vector double, vector double);
15953 int vec_any_nlt (vector double, vector double);
15954 int vec_any_numeric (vector double);
15956 vector double vec_vsx_ld (int, const vector double *);
15957 vector double vec_vsx_ld (int, const double *);
15958 vector float vec_vsx_ld (int, const vector float *);
15959 vector float vec_vsx_ld (int, const float *);
15960 vector bool int vec_vsx_ld (int, const vector bool int *);
15961 vector signed int vec_vsx_ld (int, const vector signed int *);
15962 vector signed int vec_vsx_ld (int, const int *);
15963 vector signed int vec_vsx_ld (int, const long *);
15964 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15965 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15966 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15967 vector bool short vec_vsx_ld (int, const vector bool short *);
15968 vector pixel vec_vsx_ld (int, const vector pixel *);
15969 vector signed short vec_vsx_ld (int, const vector signed short *);
15970 vector signed short vec_vsx_ld (int, const short *);
15971 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15972 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15973 vector bool char vec_vsx_ld (int, const vector bool char *);
15974 vector signed char vec_vsx_ld (int, const vector signed char *);
15975 vector signed char vec_vsx_ld (int, const signed char *);
15976 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15977 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15979 void vec_vsx_st (vector double, int, vector double *);
15980 void vec_vsx_st (vector double, int, double *);
15981 void vec_vsx_st (vector float, int, vector float *);
15982 void vec_vsx_st (vector float, int, float *);
15983 void vec_vsx_st (vector signed int, int, vector signed int *);
15984 void vec_vsx_st (vector signed int, int, int *);
15985 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15986 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15987 void vec_vsx_st (vector bool int, int, vector bool int *);
15988 void vec_vsx_st (vector bool int, int, unsigned int *);
15989 void vec_vsx_st (vector bool int, int, int *);
15990 void vec_vsx_st (vector signed short, int, vector signed short *);
15991 void vec_vsx_st (vector signed short, int, short *);
15992 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15993 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15994 void vec_vsx_st (vector bool short, int, vector bool short *);
15995 void vec_vsx_st (vector bool short, int, unsigned short *);
15996 void vec_vsx_st (vector pixel, int, vector pixel *);
15997 void vec_vsx_st (vector pixel, int, unsigned short *);
15998 void vec_vsx_st (vector pixel, int, short *);
15999 void vec_vsx_st (vector bool short, int, short *);
16000 void vec_vsx_st (vector signed char, int, vector signed char *);
16001 void vec_vsx_st (vector signed char, int, signed char *);
16002 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
16003 void vec_vsx_st (vector unsigned char, int, unsigned char *);
16004 void vec_vsx_st (vector bool char, int, vector bool char *);
16005 void vec_vsx_st (vector bool char, int, unsigned char *);
16006 void vec_vsx_st (vector bool char, int, signed char *);
16008 vector double vec_xxpermdi (vector double, vector double, int);
16009 vector float vec_xxpermdi (vector float, vector float, int);
16010 vector long long vec_xxpermdi (vector long long, vector long long, int);
16011 vector unsigned long long vec_xxpermdi (vector unsigned long long,
16012                                         vector unsigned long long, int);
16013 vector int vec_xxpermdi (vector int, vector int, int);
16014 vector unsigned int vec_xxpermdi (vector unsigned int,
16015                                   vector unsigned int, int);
16016 vector short vec_xxpermdi (vector short, vector short, int);
16017 vector unsigned short vec_xxpermdi (vector unsigned short,
16018                                     vector unsigned short, int);
16019 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
16020 vector unsigned char vec_xxpermdi (vector unsigned char,
16021                                    vector unsigned char, int);
16023 vector double vec_xxsldi (vector double, vector double, int);
16024 vector float vec_xxsldi (vector float, vector float, int);
16025 vector long long vec_xxsldi (vector long long, vector long long, int);
16026 vector unsigned long long vec_xxsldi (vector unsigned long long,
16027                                       vector unsigned long long, int);
16028 vector int vec_xxsldi (vector int, vector int, int);
16029 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
16030 vector short vec_xxsldi (vector short, vector short, int);
16031 vector unsigned short vec_xxsldi (vector unsigned short,
16032                                   vector unsigned short, int);
16033 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
16034 vector unsigned char vec_xxsldi (vector unsigned char,
16035                                  vector unsigned char, int);
16036 @end smallexample
16038 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16039 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16040 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
16041 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16042 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16044 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16045 instruction set is available, the following additional functions are
16046 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
16047 can use @var{vector long} instead of @var{vector long long},
16048 @var{vector bool long} instead of @var{vector bool long long}, and
16049 @var{vector unsigned long} instead of @var{vector unsigned long long}.
16051 @smallexample
16052 vector long long vec_abs (vector long long);
16054 vector long long vec_add (vector long long, vector long long);
16055 vector unsigned long long vec_add (vector unsigned long long,
16056                                    vector unsigned long long);
16058 int vec_all_eq (vector long long, vector long long);
16059 int vec_all_eq (vector unsigned long long, vector unsigned long long);
16060 int vec_all_ge (vector long long, vector long long);
16061 int vec_all_ge (vector unsigned long long, vector unsigned long long);
16062 int vec_all_gt (vector long long, vector long long);
16063 int vec_all_gt (vector unsigned long long, vector unsigned long long);
16064 int vec_all_le (vector long long, vector long long);
16065 int vec_all_le (vector unsigned long long, vector unsigned long long);
16066 int vec_all_lt (vector long long, vector long long);
16067 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16068 int vec_all_ne (vector long long, vector long long);
16069 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16071 int vec_any_eq (vector long long, vector long long);
16072 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16073 int vec_any_ge (vector long long, vector long long);
16074 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16075 int vec_any_gt (vector long long, vector long long);
16076 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16077 int vec_any_le (vector long long, vector long long);
16078 int vec_any_le (vector unsigned long long, vector unsigned long long);
16079 int vec_any_lt (vector long long, vector long long);
16080 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16081 int vec_any_ne (vector long long, vector long long);
16082 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16084 vector long long vec_eqv (vector long long, vector long long);
16085 vector long long vec_eqv (vector bool long long, vector long long);
16086 vector long long vec_eqv (vector long long, vector bool long long);
16087 vector unsigned long long vec_eqv (vector unsigned long long,
16088                                    vector unsigned long long);
16089 vector unsigned long long vec_eqv (vector bool long long,
16090                                    vector unsigned long long);
16091 vector unsigned long long vec_eqv (vector unsigned long long,
16092                                    vector bool long long);
16093 vector int vec_eqv (vector int, vector int);
16094 vector int vec_eqv (vector bool int, vector int);
16095 vector int vec_eqv (vector int, vector bool int);
16096 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16097 vector unsigned int vec_eqv (vector bool unsigned int,
16098                              vector unsigned int);
16099 vector unsigned int vec_eqv (vector unsigned int,
16100                              vector bool unsigned int);
16101 vector short vec_eqv (vector short, vector short);
16102 vector short vec_eqv (vector bool short, vector short);
16103 vector short vec_eqv (vector short, vector bool short);
16104 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16105 vector unsigned short vec_eqv (vector bool unsigned short,
16106                                vector unsigned short);
16107 vector unsigned short vec_eqv (vector unsigned short,
16108                                vector bool unsigned short);
16109 vector signed char vec_eqv (vector signed char, vector signed char);
16110 vector signed char vec_eqv (vector bool signed char, vector signed char);
16111 vector signed char vec_eqv (vector signed char, vector bool signed char);
16112 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16113 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16114 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16116 vector long long vec_max (vector long long, vector long long);
16117 vector unsigned long long vec_max (vector unsigned long long,
16118                                    vector unsigned long long);
16120 vector signed int vec_mergee (vector signed int, vector signed int);
16121 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16122 vector bool int vec_mergee (vector bool int, vector bool int);
16124 vector signed int vec_mergeo (vector signed int, vector signed int);
16125 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16126 vector bool int vec_mergeo (vector bool int, vector bool int);
16128 vector long long vec_min (vector long long, vector long long);
16129 vector unsigned long long vec_min (vector unsigned long long,
16130                                    vector unsigned long long);
16132 vector long long vec_nand (vector long long, vector long long);
16133 vector long long vec_nand (vector bool long long, vector long long);
16134 vector long long vec_nand (vector long long, vector bool long long);
16135 vector unsigned long long vec_nand (vector unsigned long long,
16136                                     vector unsigned long long);
16137 vector unsigned long long vec_nand (vector bool long long,
16138                                    vector unsigned long long);
16139 vector unsigned long long vec_nand (vector unsigned long long,
16140                                     vector bool long long);
16141 vector int vec_nand (vector int, vector int);
16142 vector int vec_nand (vector bool int, vector int);
16143 vector int vec_nand (vector int, vector bool int);
16144 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16145 vector unsigned int vec_nand (vector bool unsigned int,
16146                               vector unsigned int);
16147 vector unsigned int vec_nand (vector unsigned int,
16148                               vector bool unsigned int);
16149 vector short vec_nand (vector short, vector short);
16150 vector short vec_nand (vector bool short, vector short);
16151 vector short vec_nand (vector short, vector bool short);
16152 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16153 vector unsigned short vec_nand (vector bool unsigned short,
16154                                 vector unsigned short);
16155 vector unsigned short vec_nand (vector unsigned short,
16156                                 vector bool unsigned short);
16157 vector signed char vec_nand (vector signed char, vector signed char);
16158 vector signed char vec_nand (vector bool signed char, vector signed char);
16159 vector signed char vec_nand (vector signed char, vector bool signed char);
16160 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16161 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16162 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16164 vector long long vec_orc (vector long long, vector long long);
16165 vector long long vec_orc (vector bool long long, vector long long);
16166 vector long long vec_orc (vector long long, vector bool long long);
16167 vector unsigned long long vec_orc (vector unsigned long long,
16168                                    vector unsigned long long);
16169 vector unsigned long long vec_orc (vector bool long long,
16170                                    vector unsigned long long);
16171 vector unsigned long long vec_orc (vector unsigned long long,
16172                                    vector bool long long);
16173 vector int vec_orc (vector int, vector int);
16174 vector int vec_orc (vector bool int, vector int);
16175 vector int vec_orc (vector int, vector bool int);
16176 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16177 vector unsigned int vec_orc (vector bool unsigned int,
16178                              vector unsigned int);
16179 vector unsigned int vec_orc (vector unsigned int,
16180                              vector bool unsigned int);
16181 vector short vec_orc (vector short, vector short);
16182 vector short vec_orc (vector bool short, vector short);
16183 vector short vec_orc (vector short, vector bool short);
16184 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16185 vector unsigned short vec_orc (vector bool unsigned short,
16186                                vector unsigned short);
16187 vector unsigned short vec_orc (vector unsigned short,
16188                                vector bool unsigned short);
16189 vector signed char vec_orc (vector signed char, vector signed char);
16190 vector signed char vec_orc (vector bool signed char, vector signed char);
16191 vector signed char vec_orc (vector signed char, vector bool signed char);
16192 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16193 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16194 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16196 vector int vec_pack (vector long long, vector long long);
16197 vector unsigned int vec_pack (vector unsigned long long,
16198                               vector unsigned long long);
16199 vector bool int vec_pack (vector bool long long, vector bool long long);
16201 vector int vec_packs (vector long long, vector long long);
16202 vector unsigned int vec_packs (vector unsigned long long,
16203                                vector unsigned long long);
16205 vector unsigned int vec_packsu (vector long long, vector long long);
16206 vector unsigned int vec_packsu (vector unsigned long long,
16207                                 vector unsigned long long);
16209 vector long long vec_rl (vector long long,
16210                          vector unsigned long long);
16211 vector long long vec_rl (vector unsigned long long,
16212                          vector unsigned long long);
16214 vector long long vec_sl (vector long long, vector unsigned long long);
16215 vector long long vec_sl (vector unsigned long long,
16216                          vector unsigned long long);
16218 vector long long vec_sr (vector long long, vector unsigned long long);
16219 vector unsigned long long char vec_sr (vector unsigned long long,
16220                                        vector unsigned long long);
16222 vector long long vec_sra (vector long long, vector unsigned long long);
16223 vector unsigned long long vec_sra (vector unsigned long long,
16224                                    vector unsigned long long);
16226 vector long long vec_sub (vector long long, vector long long);
16227 vector unsigned long long vec_sub (vector unsigned long long,
16228                                    vector unsigned long long);
16230 vector long long vec_unpackh (vector int);
16231 vector unsigned long long vec_unpackh (vector unsigned int);
16233 vector long long vec_unpackl (vector int);
16234 vector unsigned long long vec_unpackl (vector unsigned int);
16236 vector long long vec_vaddudm (vector long long, vector long long);
16237 vector long long vec_vaddudm (vector bool long long, vector long long);
16238 vector long long vec_vaddudm (vector long long, vector bool long long);
16239 vector unsigned long long vec_vaddudm (vector unsigned long long,
16240                                        vector unsigned long long);
16241 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16242                                        vector unsigned long long);
16243 vector unsigned long long vec_vaddudm (vector unsigned long long,
16244                                        vector bool unsigned long long);
16246 vector long long vec_vbpermq (vector signed char, vector signed char);
16247 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16249 vector long long vec_cntlz (vector long long);
16250 vector unsigned long long vec_cntlz (vector unsigned long long);
16251 vector int vec_cntlz (vector int);
16252 vector unsigned int vec_cntlz (vector int);
16253 vector short vec_cntlz (vector short);
16254 vector unsigned short vec_cntlz (vector unsigned short);
16255 vector signed char vec_cntlz (vector signed char);
16256 vector unsigned char vec_cntlz (vector unsigned char);
16258 vector long long vec_vclz (vector long long);
16259 vector unsigned long long vec_vclz (vector unsigned long long);
16260 vector int vec_vclz (vector int);
16261 vector unsigned int vec_vclz (vector int);
16262 vector short vec_vclz (vector short);
16263 vector unsigned short vec_vclz (vector unsigned short);
16264 vector signed char vec_vclz (vector signed char);
16265 vector unsigned char vec_vclz (vector unsigned char);
16267 vector signed char vec_vclzb (vector signed char);
16268 vector unsigned char vec_vclzb (vector unsigned char);
16270 vector long long vec_vclzd (vector long long);
16271 vector unsigned long long vec_vclzd (vector unsigned long long);
16273 vector short vec_vclzh (vector short);
16274 vector unsigned short vec_vclzh (vector unsigned short);
16276 vector int vec_vclzw (vector int);
16277 vector unsigned int vec_vclzw (vector int);
16279 vector signed char vec_vgbbd (vector signed char);
16280 vector unsigned char vec_vgbbd (vector unsigned char);
16282 vector long long vec_vmaxsd (vector long long, vector long long);
16284 vector unsigned long long vec_vmaxud (vector unsigned long long,
16285                                       unsigned vector long long);
16287 vector long long vec_vminsd (vector long long, vector long long);
16289 vector unsigned long long vec_vminud (vector long long,
16290                                       vector long long);
16292 vector int vec_vpksdss (vector long long, vector long long);
16293 vector unsigned int vec_vpksdss (vector long long, vector long long);
16295 vector unsigned int vec_vpkudus (vector unsigned long long,
16296                                  vector unsigned long long);
16298 vector int vec_vpkudum (vector long long, vector long long);
16299 vector unsigned int vec_vpkudum (vector unsigned long long,
16300                                  vector unsigned long long);
16301 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16303 vector long long vec_vpopcnt (vector long long);
16304 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16305 vector int vec_vpopcnt (vector int);
16306 vector unsigned int vec_vpopcnt (vector int);
16307 vector short vec_vpopcnt (vector short);
16308 vector unsigned short vec_vpopcnt (vector unsigned short);
16309 vector signed char vec_vpopcnt (vector signed char);
16310 vector unsigned char vec_vpopcnt (vector unsigned char);
16312 vector signed char vec_vpopcntb (vector signed char);
16313 vector unsigned char vec_vpopcntb (vector unsigned char);
16315 vector long long vec_vpopcntd (vector long long);
16316 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16318 vector short vec_vpopcnth (vector short);
16319 vector unsigned short vec_vpopcnth (vector unsigned short);
16321 vector int vec_vpopcntw (vector int);
16322 vector unsigned int vec_vpopcntw (vector int);
16324 vector long long vec_vrld (vector long long, vector unsigned long long);
16325 vector unsigned long long vec_vrld (vector unsigned long long,
16326                                     vector unsigned long long);
16328 vector long long vec_vsld (vector long long, vector unsigned long long);
16329 vector long long vec_vsld (vector unsigned long long,
16330                            vector unsigned long long);
16332 vector long long vec_vsrad (vector long long, vector unsigned long long);
16333 vector unsigned long long vec_vsrad (vector unsigned long long,
16334                                      vector unsigned long long);
16336 vector long long vec_vsrd (vector long long, vector unsigned long long);
16337 vector unsigned long long char vec_vsrd (vector unsigned long long,
16338                                          vector unsigned long long);
16340 vector long long vec_vsubudm (vector long long, vector long long);
16341 vector long long vec_vsubudm (vector bool long long, vector long long);
16342 vector long long vec_vsubudm (vector long long, vector bool long long);
16343 vector unsigned long long vec_vsubudm (vector unsigned long long,
16344                                        vector unsigned long long);
16345 vector unsigned long long vec_vsubudm (vector bool long long,
16346                                        vector unsigned long long);
16347 vector unsigned long long vec_vsubudm (vector unsigned long long,
16348                                        vector bool long long);
16350 vector long long vec_vupkhsw (vector int);
16351 vector unsigned long long vec_vupkhsw (vector unsigned int);
16353 vector long long vec_vupklsw (vector int);
16354 vector unsigned long long vec_vupklsw (vector int);
16355 @end smallexample
16357 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16358 instruction set is available, the following additional functions are
16359 available for 64-bit targets.  New vector types
16360 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16361 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16362 builtins.
16364 The normal vector extract, and set operations work on
16365 @var{vector __int128_t} and @var{vector __uint128_t} types,
16366 but the index value must be 0.
16368 @smallexample
16369 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16370 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16372 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16373 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16375 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16376                                 vector __int128_t);
16377 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
16378                                  vector __uint128_t);
16380 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16381                                 vector __int128_t);
16382 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
16383                                  vector __uint128_t);
16385 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16386                                 vector __int128_t);
16387 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
16388                                  vector __uint128_t);
16390 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16391                                 vector __int128_t);
16392 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16393                                  vector __uint128_t);
16395 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16396 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16398 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16399 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16401 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16402 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16403 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16404 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16405 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16406 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16407 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16408 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16409 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16410 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16411 @end smallexample
16413 If the cryptographic instructions are enabled (@option{-mcrypto} or
16414 @option{-mcpu=power8}), the following builtins are enabled.
16416 @smallexample
16417 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16419 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16420                                                     vector unsigned long long);
16422 vector unsigned long long __builtin_crypto_vcipherlast
16423                                      (vector unsigned long long,
16424                                       vector unsigned long long);
16426 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16427                                                      vector unsigned long long);
16429 vector unsigned long long __builtin_crypto_vncipherlast
16430                                      (vector unsigned long long,
16431                                       vector unsigned long long);
16433 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16434                                                 vector unsigned char,
16435                                                 vector unsigned char);
16437 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16438                                                  vector unsigned short,
16439                                                  vector unsigned short);
16441 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16442                                                vector unsigned int,
16443                                                vector unsigned int);
16445 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16446                                                      vector unsigned long long,
16447                                                      vector unsigned long long);
16449 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16450                                                vector unsigned char);
16452 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16453                                                 vector unsigned short);
16455 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16456                                               vector unsigned int);
16458 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16459                                                     vector unsigned long long);
16461 vector unsigned long long __builtin_crypto_vshasigmad
16462                                (vector unsigned long long, int, int);
16464 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16465                                                  int, int);
16466 @end smallexample
16468 The second argument to the @var{__builtin_crypto_vshasigmad} and
16469 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16470 integer that is 0 or 1.  The third argument to these builtin functions
16471 must be a constant integer in the range of 0 to 15.
16473 @node PowerPC Hardware Transactional Memory Built-in Functions
16474 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16475 GCC provides two interfaces for accessing the Hardware Transactional
16476 Memory (HTM) instructions available on some of the PowerPC family
16477 of prcoessors (eg, POWER8).  The two interfaces come in a low level
16478 interface, consisting of built-in functions specific to PowerPC and a
16479 higher level interface consisting of inline functions that are common
16480 between PowerPC and S/390.
16482 @subsubsection PowerPC HTM Low Level Built-in Functions
16484 The following low level built-in functions are available with
16485 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16486 They all generate the machine instruction that is part of the name.
16488 The HTM built-ins return true or false depending on their success and
16489 their arguments match exactly the type and order of the associated
16490 hardware instruction's operands.  Refer to the ISA manual for a
16491 description of each instruction's operands.
16493 @smallexample
16494 unsigned int __builtin_tbegin (unsigned int)
16495 unsigned int __builtin_tend (unsigned int)
16497 unsigned int __builtin_tabort (unsigned int)
16498 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16499 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16500 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16501 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16503 unsigned int __builtin_tcheck (unsigned int)
16504 unsigned int __builtin_treclaim (unsigned int)
16505 unsigned int __builtin_trechkpt (void)
16506 unsigned int __builtin_tsr (unsigned int)
16507 @end smallexample
16509 In addition to the above HTM built-ins, we have added built-ins for
16510 some common extended mnemonics of the HTM instructions:
16512 @smallexample
16513 unsigned int __builtin_tendall (void)
16514 unsigned int __builtin_tresume (void)
16515 unsigned int __builtin_tsuspend (void)
16516 @end smallexample
16518 The following set of built-in functions are available to gain access
16519 to the HTM specific special purpose registers.
16521 @smallexample
16522 unsigned long __builtin_get_texasr (void)
16523 unsigned long __builtin_get_texasru (void)
16524 unsigned long __builtin_get_tfhar (void)
16525 unsigned long __builtin_get_tfiar (void)
16527 void __builtin_set_texasr (unsigned long);
16528 void __builtin_set_texasru (unsigned long);
16529 void __builtin_set_tfhar (unsigned long);
16530 void __builtin_set_tfiar (unsigned long);
16531 @end smallexample
16533 Example usage of these low level built-in functions may look like:
16535 @smallexample
16536 #include <htmintrin.h>
16538 int num_retries = 10;
16540 while (1)
16541   @{
16542     if (__builtin_tbegin (0))
16543       @{
16544         /* Transaction State Initiated.  */
16545         if (is_locked (lock))
16546           __builtin_tabort (0);
16547         ... transaction code...
16548         __builtin_tend (0);
16549         break;
16550       @}
16551     else
16552       @{
16553         /* Transaction State Failed.  Use locks if the transaction
16554            failure is "persistent" or we've tried too many times.  */
16555         if (num_retries-- <= 0
16556             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16557           @{
16558             acquire_lock (lock);
16559             ... non transactional fallback path...
16560             release_lock (lock);
16561             break;
16562           @}
16563       @}
16564   @}
16565 @end smallexample
16567 One final built-in function has been added that returns the value of
16568 the 2-bit Transaction State field of the Machine Status Register (MSR)
16569 as stored in @code{CR0}.
16571 @smallexample
16572 unsigned long __builtin_ttest (void)
16573 @end smallexample
16575 This built-in can be used to determine the current transaction state
16576 using the following code example:
16578 @smallexample
16579 #include <htmintrin.h>
16581 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16583 if (tx_state == _HTM_TRANSACTIONAL)
16584   @{
16585     /* Code to use in transactional state.  */
16586   @}
16587 else if (tx_state == _HTM_NONTRANSACTIONAL)
16588   @{
16589     /* Code to use in non-transactional state.  */
16590   @}
16591 else if (tx_state == _HTM_SUSPENDED)
16592   @{
16593     /* Code to use in transaction suspended state.  */
16594   @}
16595 @end smallexample
16597 @subsubsection PowerPC HTM High Level Inline Functions
16599 The following high level HTM interface is made available by including
16600 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16601 where CPU is `power8' or later.  This interface is common between PowerPC
16602 and S/390, allowing users to write one HTM source implementation that
16603 can be compiled and executed on either system.
16605 @smallexample
16606 long __TM_simple_begin (void)
16607 long __TM_begin (void* const TM_buff)
16608 long __TM_end (void)
16609 void __TM_abort (void)
16610 void __TM_named_abort (unsigned char const code)
16611 void __TM_resume (void)
16612 void __TM_suspend (void)
16614 long __TM_is_user_abort (void* const TM_buff)
16615 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16616 long __TM_is_illegal (void* const TM_buff)
16617 long __TM_is_footprint_exceeded (void* const TM_buff)
16618 long __TM_nesting_depth (void* const TM_buff)
16619 long __TM_is_nested_too_deep(void* const TM_buff)
16620 long __TM_is_conflict(void* const TM_buff)
16621 long __TM_is_failure_persistent(void* const TM_buff)
16622 long __TM_failure_address(void* const TM_buff)
16623 long long __TM_failure_code(void* const TM_buff)
16624 @end smallexample
16626 Using these common set of HTM inline functions, we can create
16627 a more portable version of the HTM example in the previous
16628 section that will work on either PowerPC or S/390:
16630 @smallexample
16631 #include <htmxlintrin.h>
16633 int num_retries = 10;
16634 TM_buff_type TM_buff;
16636 while (1)
16637   @{
16638     if (__TM_begin (TM_buff))
16639       @{
16640         /* Transaction State Initiated.  */
16641         if (is_locked (lock))
16642           __TM_abort ();
16643         ... transaction code...
16644         __TM_end ();
16645         break;
16646       @}
16647     else
16648       @{
16649         /* Transaction State Failed.  Use locks if the transaction
16650            failure is "persistent" or we've tried too many times.  */
16651         if (num_retries-- <= 0
16652             || __TM_is_failure_persistent (TM_buff))
16653           @{
16654             acquire_lock (lock);
16655             ... non transactional fallback path...
16656             release_lock (lock);
16657             break;
16658           @}
16659       @}
16660   @}
16661 @end smallexample
16663 @node RX Built-in Functions
16664 @subsection RX Built-in Functions
16665 GCC supports some of the RX instructions which cannot be expressed in
16666 the C programming language via the use of built-in functions.  The
16667 following functions are supported:
16669 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
16670 Generates the @code{brk} machine instruction.
16671 @end deftypefn
16673 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
16674 Generates the @code{clrpsw} machine instruction to clear the specified
16675 bit in the processor status word.
16676 @end deftypefn
16678 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
16679 Generates the @code{int} machine instruction to generate an interrupt
16680 with the specified value.
16681 @end deftypefn
16683 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
16684 Generates the @code{machi} machine instruction to add the result of
16685 multiplying the top 16 bits of the two arguments into the
16686 accumulator.
16687 @end deftypefn
16689 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
16690 Generates the @code{maclo} machine instruction to add the result of
16691 multiplying the bottom 16 bits of the two arguments into the
16692 accumulator.
16693 @end deftypefn
16695 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
16696 Generates the @code{mulhi} machine instruction to place the result of
16697 multiplying the top 16 bits of the two arguments into the
16698 accumulator.
16699 @end deftypefn
16701 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
16702 Generates the @code{mullo} machine instruction to place the result of
16703 multiplying the bottom 16 bits of the two arguments into the
16704 accumulator.
16705 @end deftypefn
16707 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
16708 Generates the @code{mvfachi} machine instruction to read the top
16709 32 bits of the accumulator.
16710 @end deftypefn
16712 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
16713 Generates the @code{mvfacmi} machine instruction to read the middle
16714 32 bits of the accumulator.
16715 @end deftypefn
16717 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
16718 Generates the @code{mvfc} machine instruction which reads the control
16719 register specified in its argument and returns its value.
16720 @end deftypefn
16722 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
16723 Generates the @code{mvtachi} machine instruction to set the top
16724 32 bits of the accumulator.
16725 @end deftypefn
16727 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
16728 Generates the @code{mvtaclo} machine instruction to set the bottom
16729 32 bits of the accumulator.
16730 @end deftypefn
16732 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
16733 Generates the @code{mvtc} machine instruction which sets control
16734 register number @code{reg} to @code{val}.
16735 @end deftypefn
16737 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
16738 Generates the @code{mvtipl} machine instruction set the interrupt
16739 priority level.
16740 @end deftypefn
16742 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
16743 Generates the @code{racw} machine instruction to round the accumulator
16744 according to the specified mode.
16745 @end deftypefn
16747 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
16748 Generates the @code{revw} machine instruction which swaps the bytes in
16749 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16750 and also bits 16--23 occupy bits 24--31 and vice versa.
16751 @end deftypefn
16753 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
16754 Generates the @code{rmpa} machine instruction which initiates a
16755 repeated multiply and accumulate sequence.
16756 @end deftypefn
16758 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
16759 Generates the @code{round} machine instruction which returns the
16760 floating-point argument rounded according to the current rounding mode
16761 set in the floating-point status word register.
16762 @end deftypefn
16764 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
16765 Generates the @code{sat} machine instruction which returns the
16766 saturated value of the argument.
16767 @end deftypefn
16769 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
16770 Generates the @code{setpsw} machine instruction to set the specified
16771 bit in the processor status word.
16772 @end deftypefn
16774 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
16775 Generates the @code{wait} machine instruction.
16776 @end deftypefn
16778 @node S/390 System z Built-in Functions
16779 @subsection S/390 System z Built-in Functions
16780 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16781 Generates the @code{tbegin} machine instruction starting a
16782 non-constraint hardware transaction.  If the parameter is non-NULL the
16783 memory area is used to store the transaction diagnostic buffer and
16784 will be passed as first operand to @code{tbegin}.  This buffer can be
16785 defined using the @code{struct __htm_tdb} C struct defined in
16786 @code{htmintrin.h} and must reside on a double-word boundary.  The
16787 second tbegin operand is set to @code{0xff0c}. This enables
16788 save/restore of all GPRs and disables aborts for FPR and AR
16789 manipulations inside the transaction body.  The condition code set by
16790 the tbegin instruction is returned as integer value.  The tbegin
16791 instruction by definition overwrites the content of all FPRs.  The
16792 compiler will generate code which saves and restores the FPRs.  For
16793 soft-float code it is recommended to used the @code{*_nofloat}
16794 variant.  In order to prevent a TDB from being written it is required
16795 to pass an constant zero value as parameter.  Passing the zero value
16796 through a variable is not sufficient.  Although modifications of
16797 access registers inside the transaction will not trigger an
16798 transaction abort it is not supported to actually modify them.  Access
16799 registers do not get saved when entering a transaction. They will have
16800 undefined state when reaching the abort code.
16801 @end deftypefn
16803 Macros for the possible return codes of tbegin are defined in the
16804 @code{htmintrin.h} header file:
16806 @table @code
16807 @item _HTM_TBEGIN_STARTED
16808 @code{tbegin} has been executed as part of normal processing.  The
16809 transaction body is supposed to be executed.
16810 @item _HTM_TBEGIN_INDETERMINATE
16811 The transaction was aborted due to an indeterminate condition which
16812 might be persistent.
16813 @item _HTM_TBEGIN_TRANSIENT
16814 The transaction aborted due to a transient failure.  The transaction
16815 should be re-executed in that case.
16816 @item _HTM_TBEGIN_PERSISTENT
16817 The transaction aborted due to a persistent failure.  Re-execution
16818 under same circumstances will not be productive.
16819 @end table
16821 @defmac _HTM_FIRST_USER_ABORT_CODE
16822 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16823 specifies the first abort code which can be used for
16824 @code{__builtin_tabort}.  Values below this threshold are reserved for
16825 machine use.
16826 @end defmac
16828 @deftp {Data type} {struct __htm_tdb}
16829 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16830 the structure of the transaction diagnostic block as specified in the
16831 Principles of Operation manual chapter 5-91.
16832 @end deftp
16834 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16835 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16836 Using this variant in code making use of FPRs will leave the FPRs in
16837 undefined state when entering the transaction abort handler code.
16838 @end deftypefn
16840 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16841 In addition to @code{__builtin_tbegin} a loop for transient failures
16842 is generated.  If tbegin returns a condition code of 2 the transaction
16843 will be retried as often as specified in the second argument.  The
16844 perform processor assist instruction is used to tell the CPU about the
16845 number of fails so far.
16846 @end deftypefn
16848 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16849 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16850 restores.  Using this variant in code making use of FPRs will leave
16851 the FPRs in undefined state when entering the transaction abort
16852 handler code.
16853 @end deftypefn
16855 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16856 Generates the @code{tbeginc} machine instruction starting a constraint
16857 hardware transaction.  The second operand is set to @code{0xff08}.
16858 @end deftypefn
16860 @deftypefn {Built-in Function} int __builtin_tend (void)
16861 Generates the @code{tend} machine instruction finishing a transaction
16862 and making the changes visible to other threads.  The condition code
16863 generated by tend is returned as integer value.
16864 @end deftypefn
16866 @deftypefn {Built-in Function} void __builtin_tabort (int)
16867 Generates the @code{tabort} machine instruction with the specified
16868 abort code.  Abort codes from 0 through 255 are reserved and will
16869 result in an error message.
16870 @end deftypefn
16872 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16873 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16874 integer parameter is loaded into rX and a value of zero is loaded into
16875 rY.  The integer parameter specifies the number of times the
16876 transaction repeatedly aborted.
16877 @end deftypefn
16879 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16880 Generates the @code{etnd} machine instruction.  The current nesting
16881 depth is returned as integer value.  For a nesting depth of 0 the code
16882 is not executed as part of an transaction.
16883 @end deftypefn
16885 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16887 Generates the @code{ntstg} machine instruction.  The second argument
16888 is written to the first arguments location.  The store operation will
16889 not be rolled-back in case of an transaction abort.
16890 @end deftypefn
16892 @node SH Built-in Functions
16893 @subsection SH Built-in Functions
16894 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16895 families of processors:
16897 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16898 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16899 used by system code that manages threads and execution contexts.  The compiler
16900 normally does not generate code that modifies the contents of @samp{GBR} and
16901 thus the value is preserved across function calls.  Changing the @samp{GBR}
16902 value in user code must be done with caution, since the compiler might use
16903 @samp{GBR} in order to access thread local variables.
16905 @end deftypefn
16907 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16908 Returns the value that is currently set in the @samp{GBR} register.
16909 Memory loads and stores that use the thread pointer as a base address are
16910 turned into @samp{GBR} based displacement loads and stores, if possible.
16911 For example:
16912 @smallexample
16913 struct my_tcb
16915    int a, b, c, d, e;
16918 int get_tcb_value (void)
16920   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16921   return ((my_tcb*)__builtin_thread_pointer ())->c;
16924 @end smallexample
16925 @end deftypefn
16927 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16928 Returns the value that is currently set in the @samp{FPSCR} register.
16929 @end deftypefn
16931 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16932 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16933 preserving the current values of the FR, SZ and PR bits.
16934 @end deftypefn
16936 @node SPARC VIS Built-in Functions
16937 @subsection SPARC VIS Built-in Functions
16939 GCC supports SIMD operations on the SPARC using both the generic vector
16940 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16941 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16942 switch, the VIS extension is exposed as the following built-in functions:
16944 @smallexample
16945 typedef int v1si __attribute__ ((vector_size (4)));
16946 typedef int v2si __attribute__ ((vector_size (8)));
16947 typedef short v4hi __attribute__ ((vector_size (8)));
16948 typedef short v2hi __attribute__ ((vector_size (4)));
16949 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16950 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16952 void __builtin_vis_write_gsr (int64_t);
16953 int64_t __builtin_vis_read_gsr (void);
16955 void * __builtin_vis_alignaddr (void *, long);
16956 void * __builtin_vis_alignaddrl (void *, long);
16957 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16958 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16959 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16960 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16962 v4hi __builtin_vis_fexpand (v4qi);
16964 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16965 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16966 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16967 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16968 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16969 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16970 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16972 v4qi __builtin_vis_fpack16 (v4hi);
16973 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16974 v2hi __builtin_vis_fpackfix (v2si);
16975 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16977 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16979 long __builtin_vis_edge8 (void *, void *);
16980 long __builtin_vis_edge8l (void *, void *);
16981 long __builtin_vis_edge16 (void *, void *);
16982 long __builtin_vis_edge16l (void *, void *);
16983 long __builtin_vis_edge32 (void *, void *);
16984 long __builtin_vis_edge32l (void *, void *);
16986 long __builtin_vis_fcmple16 (v4hi, v4hi);
16987 long __builtin_vis_fcmple32 (v2si, v2si);
16988 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16989 long __builtin_vis_fcmpne32 (v2si, v2si);
16990 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16991 long __builtin_vis_fcmpgt32 (v2si, v2si);
16992 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16993 long __builtin_vis_fcmpeq32 (v2si, v2si);
16995 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16996 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16997 v2si __builtin_vis_fpadd32 (v2si, v2si);
16998 v1si __builtin_vis_fpadd32s (v1si, v1si);
16999 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
17000 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
17001 v2si __builtin_vis_fpsub32 (v2si, v2si);
17002 v1si __builtin_vis_fpsub32s (v1si, v1si);
17004 long __builtin_vis_array8 (long, long);
17005 long __builtin_vis_array16 (long, long);
17006 long __builtin_vis_array32 (long, long);
17007 @end smallexample
17009 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
17010 functions also become available:
17012 @smallexample
17013 long __builtin_vis_bmask (long, long);
17014 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
17015 v2si __builtin_vis_bshufflev2si (v2si, v2si);
17016 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
17017 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
17019 long __builtin_vis_edge8n (void *, void *);
17020 long __builtin_vis_edge8ln (void *, void *);
17021 long __builtin_vis_edge16n (void *, void *);
17022 long __builtin_vis_edge16ln (void *, void *);
17023 long __builtin_vis_edge32n (void *, void *);
17024 long __builtin_vis_edge32ln (void *, void *);
17025 @end smallexample
17027 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
17028 functions also become available:
17030 @smallexample
17031 void __builtin_vis_cmask8 (long);
17032 void __builtin_vis_cmask16 (long);
17033 void __builtin_vis_cmask32 (long);
17035 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
17037 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
17038 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
17039 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
17040 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
17041 v2si __builtin_vis_fsll16 (v2si, v2si);
17042 v2si __builtin_vis_fslas16 (v2si, v2si);
17043 v2si __builtin_vis_fsrl16 (v2si, v2si);
17044 v2si __builtin_vis_fsra16 (v2si, v2si);
17046 long __builtin_vis_pdistn (v8qi, v8qi);
17048 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
17050 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
17051 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
17053 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
17054 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
17055 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
17056 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
17057 v2si __builtin_vis_fpadds32 (v2si, v2si);
17058 v1si __builtin_vis_fpadds32s (v1si, v1si);
17059 v2si __builtin_vis_fpsubs32 (v2si, v2si);
17060 v1si __builtin_vis_fpsubs32s (v1si, v1si);
17062 long __builtin_vis_fucmple8 (v8qi, v8qi);
17063 long __builtin_vis_fucmpne8 (v8qi, v8qi);
17064 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
17065 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
17067 float __builtin_vis_fhadds (float, float);
17068 double __builtin_vis_fhaddd (double, double);
17069 float __builtin_vis_fhsubs (float, float);
17070 double __builtin_vis_fhsubd (double, double);
17071 float __builtin_vis_fnhadds (float, float);
17072 double __builtin_vis_fnhaddd (double, double);
17074 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17075 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17076 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17077 @end smallexample
17079 @node SPU Built-in Functions
17080 @subsection SPU Built-in Functions
17082 GCC provides extensions for the SPU processor as described in the
17083 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17084 found at @uref{http://cell.scei.co.jp/} or
17085 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
17086 implementation differs in several ways.
17088 @itemize @bullet
17090 @item
17091 The optional extension of specifying vector constants in parentheses is
17092 not supported.
17094 @item
17095 A vector initializer requires no cast if the vector constant is of the
17096 same type as the variable it is initializing.
17098 @item
17099 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17100 vector type is the default signedness of the base type.  The default
17101 varies depending on the operating system, so a portable program should
17102 always specify the signedness.
17104 @item
17105 By default, the keyword @code{__vector} is added. The macro
17106 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17107 undefined.
17109 @item
17110 GCC allows using a @code{typedef} name as the type specifier for a
17111 vector type.
17113 @item
17114 For C, overloaded functions are implemented with macros so the following
17115 does not work:
17117 @smallexample
17118   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17119 @end smallexample
17121 @noindent
17122 Since @code{spu_add} is a macro, the vector constant in the example
17123 is treated as four separate arguments.  Wrap the entire argument in
17124 parentheses for this to work.
17126 @item
17127 The extended version of @code{__builtin_expect} is not supported.
17129 @end itemize
17131 @emph{Note:} Only the interface described in the aforementioned
17132 specification is supported. Internally, GCC uses built-in functions to
17133 implement the required functionality, but these are not supported and
17134 are subject to change without notice.
17136 @node TI C6X Built-in Functions
17137 @subsection TI C6X Built-in Functions
17139 GCC provides intrinsics to access certain instructions of the TI C6X
17140 processors.  These intrinsics, listed below, are available after
17141 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
17142 to C6X instructions.
17144 @smallexample
17146 int _sadd (int, int)
17147 int _ssub (int, int)
17148 int _sadd2 (int, int)
17149 int _ssub2 (int, int)
17150 long long _mpy2 (int, int)
17151 long long _smpy2 (int, int)
17152 int _add4 (int, int)
17153 int _sub4 (int, int)
17154 int _saddu4 (int, int)
17156 int _smpy (int, int)
17157 int _smpyh (int, int)
17158 int _smpyhl (int, int)
17159 int _smpylh (int, int)
17161 int _sshl (int, int)
17162 int _subc (int, int)
17164 int _avg2 (int, int)
17165 int _avgu4 (int, int)
17167 int _clrr (int, int)
17168 int _extr (int, int)
17169 int _extru (int, int)
17170 int _abs (int)
17171 int _abs2 (int)
17173 @end smallexample
17175 @node TILE-Gx Built-in Functions
17176 @subsection TILE-Gx Built-in Functions
17178 GCC provides intrinsics to access every instruction of the TILE-Gx
17179 processor.  The intrinsics are of the form:
17181 @smallexample
17183 unsigned long long __insn_@var{op} (...)
17185 @end smallexample
17187 Where @var{op} is the name of the instruction.  Refer to the ISA manual
17188 for the complete list of instructions.
17190 GCC also provides intrinsics to directly access the network registers.
17191 The intrinsics are:
17193 @smallexample
17195 unsigned long long __tile_idn0_receive (void)
17196 unsigned long long __tile_idn1_receive (void)
17197 unsigned long long __tile_udn0_receive (void)
17198 unsigned long long __tile_udn1_receive (void)
17199 unsigned long long __tile_udn2_receive (void)
17200 unsigned long long __tile_udn3_receive (void)
17201 void __tile_idn_send (unsigned long long)
17202 void __tile_udn_send (unsigned long long)
17204 @end smallexample
17206 The intrinsic @code{void __tile_network_barrier (void)} is used to
17207 guarantee that no network operations before it are reordered with
17208 those after it.
17210 @node TILEPro Built-in Functions
17211 @subsection TILEPro Built-in Functions
17213 GCC provides intrinsics to access every instruction of the TILEPro
17214 processor.  The intrinsics are of the form:
17216 @smallexample
17218 unsigned __insn_@var{op} (...)
17220 @end smallexample
17222 @noindent
17223 where @var{op} is the name of the instruction.  Refer to the ISA manual
17224 for the complete list of instructions.
17226 GCC also provides intrinsics to directly access the network registers.
17227 The intrinsics are:
17229 @smallexample
17231 unsigned __tile_idn0_receive (void)
17232 unsigned __tile_idn1_receive (void)
17233 unsigned __tile_sn_receive (void)
17234 unsigned __tile_udn0_receive (void)
17235 unsigned __tile_udn1_receive (void)
17236 unsigned __tile_udn2_receive (void)
17237 unsigned __tile_udn3_receive (void)
17238 void __tile_idn_send (unsigned)
17239 void __tile_sn_send (unsigned)
17240 void __tile_udn_send (unsigned)
17242 @end smallexample
17244 The intrinsic @code{void __tile_network_barrier (void)} is used to
17245 guarantee that no network operations before it are reordered with
17246 those after it.
17248 @node Target Format Checks
17249 @section Format Checks Specific to Particular Target Machines
17251 For some target machines, GCC supports additional options to the
17252 format attribute
17253 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17255 @menu
17256 * Solaris Format Checks::
17257 * Darwin Format Checks::
17258 @end menu
17260 @node Solaris Format Checks
17261 @subsection Solaris Format Checks
17263 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17264 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
17265 conversions, and the two-argument @code{%b} conversion for displaying
17266 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
17268 @node Darwin Format Checks
17269 @subsection Darwin Format Checks
17271 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17272 attribute context.  Declarations made with such attribution are parsed for correct syntax
17273 and format argument types.  However, parsing of the format string itself is currently undefined
17274 and is not carried out by this version of the compiler.
17276 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17277 also be used as format arguments.  Note that the relevant headers are only likely to be
17278 available on Darwin (OSX) installations.  On such installations, the XCode and system
17279 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17280 associated functions.
17282 @node Pragmas
17283 @section Pragmas Accepted by GCC
17284 @cindex pragmas
17285 @cindex @code{#pragma}
17287 GCC supports several types of pragmas, primarily in order to compile
17288 code originally written for other compilers.  Note that in general
17289 we do not recommend the use of pragmas; @xref{Function Attributes},
17290 for further explanation.
17292 @menu
17293 * ARM Pragmas::
17294 * M32C Pragmas::
17295 * MeP Pragmas::
17296 * RS/6000 and PowerPC Pragmas::
17297 * Darwin Pragmas::
17298 * Solaris Pragmas::
17299 * Symbol-Renaming Pragmas::
17300 * Structure-Packing Pragmas::
17301 * Weak Pragmas::
17302 * Diagnostic Pragmas::
17303 * Visibility Pragmas::
17304 * Push/Pop Macro Pragmas::
17305 * Function Specific Option Pragmas::
17306 * Loop-Specific Pragmas::
17307 @end menu
17309 @node ARM Pragmas
17310 @subsection ARM Pragmas
17312 The ARM target defines pragmas for controlling the default addition of
17313 @code{long_call} and @code{short_call} attributes to functions.
17314 @xref{Function Attributes}, for information about the effects of these
17315 attributes.
17317 @table @code
17318 @item long_calls
17319 @cindex pragma, long_calls
17320 Set all subsequent functions to have the @code{long_call} attribute.
17322 @item no_long_calls
17323 @cindex pragma, no_long_calls
17324 Set all subsequent functions to have the @code{short_call} attribute.
17326 @item long_calls_off
17327 @cindex pragma, long_calls_off
17328 Do not affect the @code{long_call} or @code{short_call} attributes of
17329 subsequent functions.
17330 @end table
17332 @node M32C Pragmas
17333 @subsection M32C Pragmas
17335 @table @code
17336 @item GCC memregs @var{number}
17337 @cindex pragma, memregs
17338 Overrides the command-line option @code{-memregs=} for the current
17339 file.  Use with care!  This pragma must be before any function in the
17340 file, and mixing different memregs values in different objects may
17341 make them incompatible.  This pragma is useful when a
17342 performance-critical function uses a memreg for temporary values,
17343 as it may allow you to reduce the number of memregs used.
17345 @item ADDRESS @var{name} @var{address}
17346 @cindex pragma, address
17347 For any declared symbols matching @var{name}, this does three things
17348 to that symbol: it forces the symbol to be located at the given
17349 address (a number), it forces the symbol to be volatile, and it
17350 changes the symbol's scope to be static.  This pragma exists for
17351 compatibility with other compilers, but note that the common
17352 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17353 instead).  Example:
17355 @smallexample
17356 #pragma ADDRESS port3 0x103
17357 char port3;
17358 @end smallexample
17360 @end table
17362 @node MeP Pragmas
17363 @subsection MeP Pragmas
17365 @table @code
17367 @item custom io_volatile (on|off)
17368 @cindex pragma, custom io_volatile
17369 Overrides the command-line option @code{-mio-volatile} for the current
17370 file.  Note that for compatibility with future GCC releases, this
17371 option should only be used once before any @code{io} variables in each
17372 file.
17374 @item GCC coprocessor available @var{registers}
17375 @cindex pragma, coprocessor available
17376 Specifies which coprocessor registers are available to the register
17377 allocator.  @var{registers} may be a single register, register range
17378 separated by ellipses, or comma-separated list of those.  Example:
17380 @smallexample
17381 #pragma GCC coprocessor available $c0...$c10, $c28
17382 @end smallexample
17384 @item GCC coprocessor call_saved @var{registers}
17385 @cindex pragma, coprocessor call_saved
17386 Specifies which coprocessor registers are to be saved and restored by
17387 any function using them.  @var{registers} may be a single register,
17388 register range separated by ellipses, or comma-separated list of
17389 those.  Example:
17391 @smallexample
17392 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17393 @end smallexample
17395 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17396 @cindex pragma, coprocessor subclass
17397 Creates and defines a register class.  These register classes can be
17398 used by inline @code{asm} constructs.  @var{registers} may be a single
17399 register, register range separated by ellipses, or comma-separated
17400 list of those.  Example:
17402 @smallexample
17403 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17405 asm ("cpfoo %0" : "=B" (x));
17406 @end smallexample
17408 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17409 @cindex pragma, disinterrupt
17410 For the named functions, the compiler adds code to disable interrupts
17411 for the duration of those functions.  If any functions so named 
17412 are not encountered in the source, a warning is emitted that the pragma is
17413 not used.  Examples:
17415 @smallexample
17416 #pragma disinterrupt foo
17417 #pragma disinterrupt bar, grill
17418 int foo () @{ @dots{} @}
17419 @end smallexample
17421 @item GCC call @var{name} , @var{name} @dots{}
17422 @cindex pragma, call
17423 For the named functions, the compiler always uses a register-indirect
17424 call model when calling the named functions.  Examples:
17426 @smallexample
17427 extern int foo ();
17428 #pragma call foo
17429 @end smallexample
17431 @end table
17433 @node RS/6000 and PowerPC Pragmas
17434 @subsection RS/6000 and PowerPC Pragmas
17436 The RS/6000 and PowerPC targets define one pragma for controlling
17437 whether or not the @code{longcall} attribute is added to function
17438 declarations by default.  This pragma overrides the @option{-mlongcall}
17439 option, but not the @code{longcall} and @code{shortcall} attributes.
17440 @xref{RS/6000 and PowerPC Options}, for more information about when long
17441 calls are and are not necessary.
17443 @table @code
17444 @item longcall (1)
17445 @cindex pragma, longcall
17446 Apply the @code{longcall} attribute to all subsequent function
17447 declarations.
17449 @item longcall (0)
17450 Do not apply the @code{longcall} attribute to subsequent function
17451 declarations.
17452 @end table
17454 @c Describe h8300 pragmas here.
17455 @c Describe sh pragmas here.
17456 @c Describe v850 pragmas here.
17458 @node Darwin Pragmas
17459 @subsection Darwin Pragmas
17461 The following pragmas are available for all architectures running the
17462 Darwin operating system.  These are useful for compatibility with other
17463 Mac OS compilers.
17465 @table @code
17466 @item mark @var{tokens}@dots{}
17467 @cindex pragma, mark
17468 This pragma is accepted, but has no effect.
17470 @item options align=@var{alignment}
17471 @cindex pragma, options align
17472 This pragma sets the alignment of fields in structures.  The values of
17473 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17474 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
17475 properly; to restore the previous setting, use @code{reset} for the
17476 @var{alignment}.
17478 @item segment @var{tokens}@dots{}
17479 @cindex pragma, segment
17480 This pragma is accepted, but has no effect.
17482 @item unused (@var{var} [, @var{var}]@dots{})
17483 @cindex pragma, unused
17484 This pragma declares variables to be possibly unused.  GCC does not
17485 produce warnings for the listed variables.  The effect is similar to
17486 that of the @code{unused} attribute, except that this pragma may appear
17487 anywhere within the variables' scopes.
17488 @end table
17490 @node Solaris Pragmas
17491 @subsection Solaris Pragmas
17493 The Solaris target supports @code{#pragma redefine_extname}
17494 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
17495 @code{#pragma} directives for compatibility with the system compiler.
17497 @table @code
17498 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17499 @cindex pragma, align
17501 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17502 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17503 Attributes}).  Macro expansion occurs on the arguments to this pragma
17504 when compiling C and Objective-C@.  It does not currently occur when
17505 compiling C++, but this is a bug which may be fixed in a future
17506 release.
17508 @item fini (@var{function} [, @var{function}]...)
17509 @cindex pragma, fini
17511 This pragma causes each listed @var{function} to be called after
17512 main, or during shared module unloading, by adding a call to the
17513 @code{.fini} section.
17515 @item init (@var{function} [, @var{function}]...)
17516 @cindex pragma, init
17518 This pragma causes each listed @var{function} to be called during
17519 initialization (before @code{main}) or during shared module loading, by
17520 adding a call to the @code{.init} section.
17522 @end table
17524 @node Symbol-Renaming Pragmas
17525 @subsection Symbol-Renaming Pragmas
17527 GCC supports a @code{#pragma} directive that changes the name used in
17528 assembly for a given declaration. This effect can also be achieved
17529 using the asm labels extension (@pxref{Asm Labels}).
17531 @table @code
17532 @item redefine_extname @var{oldname} @var{newname}
17533 @cindex pragma, redefine_extname
17535 This pragma gives the C function @var{oldname} the assembly symbol
17536 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17537 is defined if this pragma is available (currently on all platforms).
17538 @end table
17540 This pragma and the asm labels extension interact in a complicated
17541 manner.  Here are some corner cases you may want to be aware of:
17543 @enumerate
17544 @item This pragma silently applies only to declarations with external
17545 linkage.  Asm labels do not have this restriction.
17547 @item In C++, this pragma silently applies only to declarations with
17548 ``C'' linkage.  Again, asm labels do not have this restriction.
17550 @item If either of the ways of changing the assembly name of a
17551 declaration are applied to a declaration whose assembly name has
17552 already been determined (either by a previous use of one of these
17553 features, or because the compiler needed the assembly name in order to
17554 generate code), and the new name is different, a warning issues and
17555 the name does not change.
17557 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17558 always the C-language name.
17559 @end enumerate
17561 @node Structure-Packing Pragmas
17562 @subsection Structure-Packing Pragmas
17564 For compatibility with Microsoft Windows compilers, GCC supports a
17565 set of @code{#pragma} directives that change the maximum alignment of
17566 members of structures (other than zero-width bit-fields), unions, and
17567 classes subsequently defined. The @var{n} value below always is required
17568 to be a small power of two and specifies the new alignment in bytes.
17570 @enumerate
17571 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17572 @item @code{#pragma pack()} sets the alignment to the one that was in
17573 effect when compilation started (see also command-line option
17574 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17575 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17576 setting on an internal stack and then optionally sets the new alignment.
17577 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17578 saved at the top of the internal stack (and removes that stack entry).
17579 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17580 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17581 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17582 @code{#pragma pack(pop)}.
17583 @end enumerate
17585 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
17586 @code{#pragma} which lays out a structure as the documented
17587 @code{__attribute__ ((ms_struct))}.
17588 @enumerate
17589 @item @code{#pragma ms_struct on} turns on the layout for structures
17590 declared.
17591 @item @code{#pragma ms_struct off} turns off the layout for structures
17592 declared.
17593 @item @code{#pragma ms_struct reset} goes back to the default layout.
17594 @end enumerate
17596 @node Weak Pragmas
17597 @subsection Weak Pragmas
17599 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17600 directives for declaring symbols to be weak, and defining weak
17601 aliases.
17603 @table @code
17604 @item #pragma weak @var{symbol}
17605 @cindex pragma, weak
17606 This pragma declares @var{symbol} to be weak, as if the declaration
17607 had the attribute of the same name.  The pragma may appear before
17608 or after the declaration of @var{symbol}.  It is not an error for
17609 @var{symbol} to never be defined at all.
17611 @item #pragma weak @var{symbol1} = @var{symbol2}
17612 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17613 It is an error if @var{symbol2} is not defined in the current
17614 translation unit.
17615 @end table
17617 @node Diagnostic Pragmas
17618 @subsection Diagnostic Pragmas
17620 GCC allows the user to selectively enable or disable certain types of
17621 diagnostics, and change the kind of the diagnostic.  For example, a
17622 project's policy might require that all sources compile with
17623 @option{-Werror} but certain files might have exceptions allowing
17624 specific types of warnings.  Or, a project might selectively enable
17625 diagnostics and treat them as errors depending on which preprocessor
17626 macros are defined.
17628 @table @code
17629 @item #pragma GCC diagnostic @var{kind} @var{option}
17630 @cindex pragma, diagnostic
17632 Modifies the disposition of a diagnostic.  Note that not all
17633 diagnostics are modifiable; at the moment only warnings (normally
17634 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17635 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17636 are controllable and which option controls them.
17638 @var{kind} is @samp{error} to treat this diagnostic as an error,
17639 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17640 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17641 @var{option} is a double quoted string that matches the command-line
17642 option.
17644 @smallexample
17645 #pragma GCC diagnostic warning "-Wformat"
17646 #pragma GCC diagnostic error "-Wformat"
17647 #pragma GCC diagnostic ignored "-Wformat"
17648 @end smallexample
17650 Note that these pragmas override any command-line options.  GCC keeps
17651 track of the location of each pragma, and issues diagnostics according
17652 to the state as of that point in the source file.  Thus, pragmas occurring
17653 after a line do not affect diagnostics caused by that line.
17655 @item #pragma GCC diagnostic push
17656 @itemx #pragma GCC diagnostic pop
17658 Causes GCC to remember the state of the diagnostics as of each
17659 @code{push}, and restore to that point at each @code{pop}.  If a
17660 @code{pop} has no matching @code{push}, the command-line options are
17661 restored.
17663 @smallexample
17664 #pragma GCC diagnostic error "-Wuninitialized"
17665   foo(a);                       /* error is given for this one */
17666 #pragma GCC diagnostic push
17667 #pragma GCC diagnostic ignored "-Wuninitialized"
17668   foo(b);                       /* no diagnostic for this one */
17669 #pragma GCC diagnostic pop
17670   foo(c);                       /* error is given for this one */
17671 #pragma GCC diagnostic pop
17672   foo(d);                       /* depends on command-line options */
17673 @end smallexample
17675 @end table
17677 GCC also offers a simple mechanism for printing messages during
17678 compilation.
17680 @table @code
17681 @item #pragma message @var{string}
17682 @cindex pragma, diagnostic
17684 Prints @var{string} as a compiler message on compilation.  The message
17685 is informational only, and is neither a compilation warning nor an error.
17687 @smallexample
17688 #pragma message "Compiling " __FILE__ "..."
17689 @end smallexample
17691 @var{string} may be parenthesized, and is printed with location
17692 information.  For example,
17694 @smallexample
17695 #define DO_PRAGMA(x) _Pragma (#x)
17696 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17698 TODO(Remember to fix this)
17699 @end smallexample
17701 @noindent
17702 prints @samp{/tmp/file.c:4: note: #pragma message:
17703 TODO - Remember to fix this}.
17705 @end table
17707 @node Visibility Pragmas
17708 @subsection Visibility Pragmas
17710 @table @code
17711 @item #pragma GCC visibility push(@var{visibility})
17712 @itemx #pragma GCC visibility pop
17713 @cindex pragma, visibility
17715 This pragma allows the user to set the visibility for multiple
17716 declarations without having to give each a visibility attribute
17717 (@pxref{Function Attributes}).
17719 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17720 declarations.  Class members and template specializations are not
17721 affected; if you want to override the visibility for a particular
17722 member or instantiation, you must use an attribute.
17724 @end table
17727 @node Push/Pop Macro Pragmas
17728 @subsection Push/Pop Macro Pragmas
17730 For compatibility with Microsoft Windows compilers, GCC supports
17731 @samp{#pragma push_macro(@var{"macro_name"})}
17732 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17734 @table @code
17735 @item #pragma push_macro(@var{"macro_name"})
17736 @cindex pragma, push_macro
17737 This pragma saves the value of the macro named as @var{macro_name} to
17738 the top of the stack for this macro.
17740 @item #pragma pop_macro(@var{"macro_name"})
17741 @cindex pragma, pop_macro
17742 This pragma sets the value of the macro named as @var{macro_name} to
17743 the value on top of the stack for this macro. If the stack for
17744 @var{macro_name} is empty, the value of the macro remains unchanged.
17745 @end table
17747 For example:
17749 @smallexample
17750 #define X  1
17751 #pragma push_macro("X")
17752 #undef X
17753 #define X -1
17754 #pragma pop_macro("X")
17755 int x [X];
17756 @end smallexample
17758 @noindent
17759 In this example, the definition of X as 1 is saved by @code{#pragma
17760 push_macro} and restored by @code{#pragma pop_macro}.
17762 @node Function Specific Option Pragmas
17763 @subsection Function Specific Option Pragmas
17765 @table @code
17766 @item #pragma GCC target (@var{"string"}...)
17767 @cindex pragma GCC target
17769 This pragma allows you to set target specific options for functions
17770 defined later in the source file.  One or more strings can be
17771 specified.  Each function that is defined after this point is as
17772 if @code{attribute((target("STRING")))} was specified for that
17773 function.  The parenthesis around the options is optional.
17774 @xref{Function Attributes}, for more information about the
17775 @code{target} attribute and the attribute syntax.
17777 The @code{#pragma GCC target} pragma is presently implemented for
17778 i386/x86_64, PowerPC, and Nios II targets only.
17779 @end table
17781 @table @code
17782 @item #pragma GCC optimize (@var{"string"}...)
17783 @cindex pragma GCC optimize
17785 This pragma allows you to set global optimization options for functions
17786 defined later in the source file.  One or more strings can be
17787 specified.  Each function that is defined after this point is as
17788 if @code{attribute((optimize("STRING")))} was specified for that
17789 function.  The parenthesis around the options is optional.
17790 @xref{Function Attributes}, for more information about the
17791 @code{optimize} attribute and the attribute syntax.
17793 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17794 versions earlier than 4.4.
17795 @end table
17797 @table @code
17798 @item #pragma GCC push_options
17799 @itemx #pragma GCC pop_options
17800 @cindex pragma GCC push_options
17801 @cindex pragma GCC pop_options
17803 These pragmas maintain a stack of the current target and optimization
17804 options.  It is intended for include files where you temporarily want
17805 to switch to using a different @samp{#pragma GCC target} or
17806 @samp{#pragma GCC optimize} and then to pop back to the previous
17807 options.
17809 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17810 pragmas are not implemented in GCC versions earlier than 4.4.
17811 @end table
17813 @table @code
17814 @item #pragma GCC reset_options
17815 @cindex pragma GCC reset_options
17817 This pragma clears the current @code{#pragma GCC target} and
17818 @code{#pragma GCC optimize} to use the default switches as specified
17819 on the command line.
17821 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17822 versions earlier than 4.4.
17823 @end table
17825 @node Loop-Specific Pragmas
17826 @subsection Loop-Specific Pragmas
17828 @table @code
17829 @item #pragma GCC ivdep
17830 @cindex pragma GCC ivdep
17831 @end table
17833 With this pragma, the programmer asserts that there are no loop-carried
17834 dependencies which would prevent that consecutive iterations of
17835 the following loop can be executed concurrently with SIMD
17836 (single instruction multiple data) instructions.
17838 For example, the compiler can only unconditionally vectorize the following
17839 loop with the pragma:
17841 @smallexample
17842 void foo (int n, int *a, int *b, int *c)
17844   int i, j;
17845 #pragma GCC ivdep
17846   for (i = 0; i < n; ++i)
17847     a[i] = b[i] + c[i];
17849 @end smallexample
17851 @noindent
17852 In this example, using the @code{restrict} qualifier had the same
17853 effect. In the following example, that would not be possible. Assume
17854 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17855 that it can unconditionally vectorize the following loop:
17857 @smallexample
17858 void ignore_vec_dep (int *a, int k, int c, int m)
17860 #pragma GCC ivdep
17861   for (int i = 0; i < m; i++)
17862     a[i] = a[i + k] * c;
17864 @end smallexample
17867 @node Unnamed Fields
17868 @section Unnamed struct/union fields within structs/unions
17869 @cindex @code{struct}
17870 @cindex @code{union}
17872 As permitted by ISO C11 and for compatibility with other compilers,
17873 GCC allows you to define
17874 a structure or union that contains, as fields, structures and unions
17875 without names.  For example:
17877 @smallexample
17878 struct @{
17879   int a;
17880   union @{
17881     int b;
17882     float c;
17883   @};
17884   int d;
17885 @} foo;
17886 @end smallexample
17888 @noindent
17889 In this example, you are able to access members of the unnamed
17890 union with code like @samp{foo.b}.  Note that only unnamed structs and
17891 unions are allowed, you may not have, for example, an unnamed
17892 @code{int}.
17894 You must never create such structures that cause ambiguous field definitions.
17895 For example, in this structure:
17897 @smallexample
17898 struct @{
17899   int a;
17900   struct @{
17901     int a;
17902   @};
17903 @} foo;
17904 @end smallexample
17906 @noindent
17907 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17908 The compiler gives errors for such constructs.
17910 @opindex fms-extensions
17911 Unless @option{-fms-extensions} is used, the unnamed field must be a
17912 structure or union definition without a tag (for example, @samp{struct
17913 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
17914 also be a definition with a tag such as @samp{struct foo @{ int a;
17915 @};}, a reference to a previously defined structure or union such as
17916 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17917 previously defined structure or union type.
17919 @opindex fplan9-extensions
17920 The option @option{-fplan9-extensions} enables
17921 @option{-fms-extensions} as well as two other extensions.  First, a
17922 pointer to a structure is automatically converted to a pointer to an
17923 anonymous field for assignments and function calls.  For example:
17925 @smallexample
17926 struct s1 @{ int a; @};
17927 struct s2 @{ struct s1; @};
17928 extern void f1 (struct s1 *);
17929 void f2 (struct s2 *p) @{ f1 (p); @}
17930 @end smallexample
17932 @noindent
17933 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17934 converted into a pointer to the anonymous field.
17936 Second, when the type of an anonymous field is a @code{typedef} for a
17937 @code{struct} or @code{union}, code may refer to the field using the
17938 name of the @code{typedef}.
17940 @smallexample
17941 typedef struct @{ int a; @} s1;
17942 struct s2 @{ s1; @};
17943 s1 f1 (struct s2 *p) @{ return p->s1; @}
17944 @end smallexample
17946 These usages are only permitted when they are not ambiguous.
17948 @node Thread-Local
17949 @section Thread-Local Storage
17950 @cindex Thread-Local Storage
17951 @cindex @acronym{TLS}
17952 @cindex @code{__thread}
17954 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17955 are allocated such that there is one instance of the variable per extant
17956 thread.  The runtime model GCC uses to implement this originates
17957 in the IA-64 processor-specific ABI, but has since been migrated
17958 to other processors as well.  It requires significant support from
17959 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17960 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17961 is not available everywhere.
17963 At the user level, the extension is visible with a new storage
17964 class keyword: @code{__thread}.  For example:
17966 @smallexample
17967 __thread int i;
17968 extern __thread struct state s;
17969 static __thread char *p;
17970 @end smallexample
17972 The @code{__thread} specifier may be used alone, with the @code{extern}
17973 or @code{static} specifiers, but with no other storage class specifier.
17974 When used with @code{extern} or @code{static}, @code{__thread} must appear
17975 immediately after the other storage class specifier.
17977 The @code{__thread} specifier may be applied to any global, file-scoped
17978 static, function-scoped static, or static data member of a class.  It may
17979 not be applied to block-scoped automatic or non-static data member.
17981 When the address-of operator is applied to a thread-local variable, it is
17982 evaluated at run time and returns the address of the current thread's
17983 instance of that variable.  An address so obtained may be used by any
17984 thread.  When a thread terminates, any pointers to thread-local variables
17985 in that thread become invalid.
17987 No static initialization may refer to the address of a thread-local variable.
17989 In C++, if an initializer is present for a thread-local variable, it must
17990 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
17991 standard.
17993 See @uref{http://www.akkadia.org/drepper/tls.pdf,
17994 ELF Handling For Thread-Local Storage} for a detailed explanation of
17995 the four thread-local storage addressing models, and how the runtime
17996 is expected to function.
17998 @menu
17999 * C99 Thread-Local Edits::
18000 * C++98 Thread-Local Edits::
18001 @end menu
18003 @node C99 Thread-Local Edits
18004 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
18006 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
18007 that document the exact semantics of the language extension.
18009 @itemize @bullet
18010 @item
18011 @cite{5.1.2  Execution environments}
18013 Add new text after paragraph 1
18015 @quotation
18016 Within either execution environment, a @dfn{thread} is a flow of
18017 control within a program.  It is implementation defined whether
18018 or not there may be more than one thread associated with a program.
18019 It is implementation defined how threads beyond the first are
18020 created, the name and type of the function called at thread
18021 startup, and how threads may be terminated.  However, objects
18022 with thread storage duration shall be initialized before thread
18023 startup.
18024 @end quotation
18026 @item
18027 @cite{6.2.4  Storage durations of objects}
18029 Add new text before paragraph 3
18031 @quotation
18032 An object whose identifier is declared with the storage-class
18033 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
18034 Its lifetime is the entire execution of the thread, and its
18035 stored value is initialized only once, prior to thread startup.
18036 @end quotation
18038 @item
18039 @cite{6.4.1  Keywords}
18041 Add @code{__thread}.
18043 @item
18044 @cite{6.7.1  Storage-class specifiers}
18046 Add @code{__thread} to the list of storage class specifiers in
18047 paragraph 1.
18049 Change paragraph 2 to
18051 @quotation
18052 With the exception of @code{__thread}, at most one storage-class
18053 specifier may be given [@dots{}].  The @code{__thread} specifier may
18054 be used alone, or immediately following @code{extern} or
18055 @code{static}.
18056 @end quotation
18058 Add new text after paragraph 6
18060 @quotation
18061 The declaration of an identifier for a variable that has
18062 block scope that specifies @code{__thread} shall also
18063 specify either @code{extern} or @code{static}.
18065 The @code{__thread} specifier shall be used only with
18066 variables.
18067 @end quotation
18068 @end itemize
18070 @node C++98 Thread-Local Edits
18071 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18073 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18074 that document the exact semantics of the language extension.
18076 @itemize @bullet
18077 @item
18078 @b{[intro.execution]}
18080 New text after paragraph 4
18082 @quotation
18083 A @dfn{thread} is a flow of control within the abstract machine.
18084 It is implementation defined whether or not there may be more than
18085 one thread.
18086 @end quotation
18088 New text after paragraph 7
18090 @quotation
18091 It is unspecified whether additional action must be taken to
18092 ensure when and whether side effects are visible to other threads.
18093 @end quotation
18095 @item
18096 @b{[lex.key]}
18098 Add @code{__thread}.
18100 @item
18101 @b{[basic.start.main]}
18103 Add after paragraph 5
18105 @quotation
18106 The thread that begins execution at the @code{main} function is called
18107 the @dfn{main thread}.  It is implementation defined how functions
18108 beginning threads other than the main thread are designated or typed.
18109 A function so designated, as well as the @code{main} function, is called
18110 a @dfn{thread startup function}.  It is implementation defined what
18111 happens if a thread startup function returns.  It is implementation
18112 defined what happens to other threads when any thread calls @code{exit}.
18113 @end quotation
18115 @item
18116 @b{[basic.start.init]}
18118 Add after paragraph 4
18120 @quotation
18121 The storage for an object of thread storage duration shall be
18122 statically initialized before the first statement of the thread startup
18123 function.  An object of thread storage duration shall not require
18124 dynamic initialization.
18125 @end quotation
18127 @item
18128 @b{[basic.start.term]}
18130 Add after paragraph 3
18132 @quotation
18133 The type of an object with thread storage duration shall not have a
18134 non-trivial destructor, nor shall it be an array type whose elements
18135 (directly or indirectly) have non-trivial destructors.
18136 @end quotation
18138 @item
18139 @b{[basic.stc]}
18141 Add ``thread storage duration'' to the list in paragraph 1.
18143 Change paragraph 2
18145 @quotation
18146 Thread, static, and automatic storage durations are associated with
18147 objects introduced by declarations [@dots{}].
18148 @end quotation
18150 Add @code{__thread} to the list of specifiers in paragraph 3.
18152 @item
18153 @b{[basic.stc.thread]}
18155 New section before @b{[basic.stc.static]}
18157 @quotation
18158 The keyword @code{__thread} applied to a non-local object gives the
18159 object thread storage duration.
18161 A local variable or class data member declared both @code{static}
18162 and @code{__thread} gives the variable or member thread storage
18163 duration.
18164 @end quotation
18166 @item
18167 @b{[basic.stc.static]}
18169 Change paragraph 1
18171 @quotation
18172 All objects that have neither thread storage duration, dynamic
18173 storage duration nor are local [@dots{}].
18174 @end quotation
18176 @item
18177 @b{[dcl.stc]}
18179 Add @code{__thread} to the list in paragraph 1.
18181 Change paragraph 1
18183 @quotation
18184 With the exception of @code{__thread}, at most one
18185 @var{storage-class-specifier} shall appear in a given
18186 @var{decl-specifier-seq}.  The @code{__thread} specifier may
18187 be used alone, or immediately following the @code{extern} or
18188 @code{static} specifiers.  [@dots{}]
18189 @end quotation
18191 Add after paragraph 5
18193 @quotation
18194 The @code{__thread} specifier can be applied only to the names of objects
18195 and to anonymous unions.
18196 @end quotation
18198 @item
18199 @b{[class.mem]}
18201 Add after paragraph 6
18203 @quotation
18204 Non-@code{static} members shall not be @code{__thread}.
18205 @end quotation
18206 @end itemize
18208 @node Binary constants
18209 @section Binary constants using the @samp{0b} prefix
18210 @cindex Binary constants using the @samp{0b} prefix
18212 Integer constants can be written as binary constants, consisting of a
18213 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18214 @samp{0B}.  This is particularly useful in environments that operate a
18215 lot on the bit level (like microcontrollers).
18217 The following statements are identical:
18219 @smallexample
18220 i =       42;
18221 i =     0x2a;
18222 i =      052;
18223 i = 0b101010;
18224 @end smallexample
18226 The type of these constants follows the same rules as for octal or
18227 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18228 can be applied.
18230 @node C++ Extensions
18231 @chapter Extensions to the C++ Language
18232 @cindex extensions, C++ language
18233 @cindex C++ language extensions
18235 The GNU compiler provides these extensions to the C++ language (and you
18236 can also use most of the C language extensions in your C++ programs).  If you
18237 want to write code that checks whether these features are available, you can
18238 test for the GNU compiler the same way as for C programs: check for a
18239 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
18240 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18241 Predefined Macros,cpp,The GNU C Preprocessor}).
18243 @menu
18244 * C++ Volatiles::       What constitutes an access to a volatile object.
18245 * Restricted Pointers:: C99 restricted pointers and references.
18246 * Vague Linkage::       Where G++ puts inlines, vtables and such.
18247 * C++ Interface::       You can use a single C++ header file for both
18248                         declarations and definitions.
18249 * Template Instantiation:: Methods for ensuring that exactly one copy of
18250                         each needed template instantiation is emitted.
18251 * Bound member functions:: You can extract a function pointer to the
18252                         method denoted by a @samp{->*} or @samp{.*} expression.
18253 * C++ Attributes::      Variable, function, and type attributes for C++ only.
18254 * Function Multiversioning::   Declaring multiple function versions.
18255 * Namespace Association:: Strong using-directives for namespace association.
18256 * Type Traits::         Compiler support for type traits
18257 * Java Exceptions::     Tweaking exception handling to work with Java.
18258 * Deprecated Features:: Things will disappear from G++.
18259 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18260 @end menu
18262 @node C++ Volatiles
18263 @section When is a Volatile C++ Object Accessed?
18264 @cindex accessing volatiles
18265 @cindex volatile read
18266 @cindex volatile write
18267 @cindex volatile access
18269 The C++ standard differs from the C standard in its treatment of
18270 volatile objects.  It fails to specify what constitutes a volatile
18271 access, except to say that C++ should behave in a similar manner to C
18272 with respect to volatiles, where possible.  However, the different
18273 lvalueness of expressions between C and C++ complicate the behavior.
18274 G++ behaves the same as GCC for volatile access, @xref{C
18275 Extensions,,Volatiles}, for a description of GCC's behavior.
18277 The C and C++ language specifications differ when an object is
18278 accessed in a void context:
18280 @smallexample
18281 volatile int *src = @var{somevalue};
18282 *src;
18283 @end smallexample
18285 The C++ standard specifies that such expressions do not undergo lvalue
18286 to rvalue conversion, and that the type of the dereferenced object may
18287 be incomplete.  The C++ standard does not specify explicitly that it
18288 is lvalue to rvalue conversion that is responsible for causing an
18289 access.  There is reason to believe that it is, because otherwise
18290 certain simple expressions become undefined.  However, because it
18291 would surprise most programmers, G++ treats dereferencing a pointer to
18292 volatile object of complete type as GCC would do for an equivalent
18293 type in C@.  When the object has incomplete type, G++ issues a
18294 warning; if you wish to force an error, you must force a conversion to
18295 rvalue with, for instance, a static cast.
18297 When using a reference to volatile, G++ does not treat equivalent
18298 expressions as accesses to volatiles, but instead issues a warning that
18299 no volatile is accessed.  The rationale for this is that otherwise it
18300 becomes difficult to determine where volatile access occur, and not
18301 possible to ignore the return value from functions returning volatile
18302 references.  Again, if you wish to force a read, cast the reference to
18303 an rvalue.
18305 G++ implements the same behavior as GCC does when assigning to a
18306 volatile object---there is no reread of the assigned-to object, the
18307 assigned rvalue is reused.  Note that in C++ assignment expressions
18308 are lvalues, and if used as an lvalue, the volatile object is
18309 referred to.  For instance, @var{vref} refers to @var{vobj}, as
18310 expected, in the following example:
18312 @smallexample
18313 volatile int vobj;
18314 volatile int &vref = vobj = @var{something};
18315 @end smallexample
18317 @node Restricted Pointers
18318 @section Restricting Pointer Aliasing
18319 @cindex restricted pointers
18320 @cindex restricted references
18321 @cindex restricted this pointer
18323 As with the C front end, G++ understands the C99 feature of restricted pointers,
18324 specified with the @code{__restrict__}, or @code{__restrict} type
18325 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
18326 language flag, @code{restrict} is not a keyword in C++.
18328 In addition to allowing restricted pointers, you can specify restricted
18329 references, which indicate that the reference is not aliased in the local
18330 context.
18332 @smallexample
18333 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18335   /* @r{@dots{}} */
18337 @end smallexample
18339 @noindent
18340 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18341 @var{rref} refers to a (different) unaliased integer.
18343 You may also specify whether a member function's @var{this} pointer is
18344 unaliased by using @code{__restrict__} as a member function qualifier.
18346 @smallexample
18347 void T::fn () __restrict__
18349   /* @r{@dots{}} */
18351 @end smallexample
18353 @noindent
18354 Within the body of @code{T::fn}, @var{this} has the effective
18355 definition @code{T *__restrict__ const this}.  Notice that the
18356 interpretation of a @code{__restrict__} member function qualifier is
18357 different to that of @code{const} or @code{volatile} qualifier, in that it
18358 is applied to the pointer rather than the object.  This is consistent with
18359 other compilers that implement restricted pointers.
18361 As with all outermost parameter qualifiers, @code{__restrict__} is
18362 ignored in function definition matching.  This means you only need to
18363 specify @code{__restrict__} in a function definition, rather than
18364 in a function prototype as well.
18366 @node Vague Linkage
18367 @section Vague Linkage
18368 @cindex vague linkage
18370 There are several constructs in C++ that require space in the object
18371 file but are not clearly tied to a single translation unit.  We say that
18372 these constructs have ``vague linkage''.  Typically such constructs are
18373 emitted wherever they are needed, though sometimes we can be more
18374 clever.
18376 @table @asis
18377 @item Inline Functions
18378 Inline functions are typically defined in a header file which can be
18379 included in many different compilations.  Hopefully they can usually be
18380 inlined, but sometimes an out-of-line copy is necessary, if the address
18381 of the function is taken or if inlining fails.  In general, we emit an
18382 out-of-line copy in all translation units where one is needed.  As an
18383 exception, we only emit inline virtual functions with the vtable, since
18384 it always requires a copy.
18386 Local static variables and string constants used in an inline function
18387 are also considered to have vague linkage, since they must be shared
18388 between all inlined and out-of-line instances of the function.
18390 @item VTables
18391 @cindex vtable
18392 C++ virtual functions are implemented in most compilers using a lookup
18393 table, known as a vtable.  The vtable contains pointers to the virtual
18394 functions provided by a class, and each object of the class contains a
18395 pointer to its vtable (or vtables, in some multiple-inheritance
18396 situations).  If the class declares any non-inline, non-pure virtual
18397 functions, the first one is chosen as the ``key method'' for the class,
18398 and the vtable is only emitted in the translation unit where the key
18399 method is defined.
18401 @emph{Note:} If the chosen key method is later defined as inline, the
18402 vtable is still emitted in every translation unit that defines it.
18403 Make sure that any inline virtuals are declared inline in the class
18404 body, even if they are not defined there.
18406 @item @code{type_info} objects
18407 @cindex @code{type_info}
18408 @cindex RTTI
18409 C++ requires information about types to be written out in order to
18410 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18411 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18412 object is written out along with the vtable so that @samp{dynamic_cast}
18413 can determine the dynamic type of a class object at run time.  For all
18414 other types, we write out the @samp{type_info} object when it is used: when
18415 applying @samp{typeid} to an expression, throwing an object, or
18416 referring to a type in a catch clause or exception specification.
18418 @item Template Instantiations
18419 Most everything in this section also applies to template instantiations,
18420 but there are other options as well.
18421 @xref{Template Instantiation,,Where's the Template?}.
18423 @end table
18425 When used with GNU ld version 2.8 or later on an ELF system such as
18426 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18427 these constructs will be discarded at link time.  This is known as
18428 COMDAT support.
18430 On targets that don't support COMDAT, but do support weak symbols, GCC
18431 uses them.  This way one copy overrides all the others, but
18432 the unused copies still take up space in the executable.
18434 For targets that do not support either COMDAT or weak symbols,
18435 most entities with vague linkage are emitted as local symbols to
18436 avoid duplicate definition errors from the linker.  This does not happen
18437 for local statics in inlines, however, as having multiple copies
18438 almost certainly breaks things.
18440 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18441 another way to control placement of these constructs.
18443 @node C++ Interface
18444 @section #pragma interface and implementation
18446 @cindex interface and implementation headers, C++
18447 @cindex C++ interface and implementation headers
18448 @cindex pragmas, interface and implementation
18450 @code{#pragma interface} and @code{#pragma implementation} provide the
18451 user with a way of explicitly directing the compiler to emit entities
18452 with vague linkage (and debugging information) in a particular
18453 translation unit.
18455 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
18456 most cases, because of COMDAT support and the ``key method'' heuristic
18457 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
18458 program to grow due to unnecessary out-of-line copies of inline
18459 functions.  Currently (3.4) the only benefit of these
18460 @code{#pragma}s is reduced duplication of debugging information, and
18461 that should be addressed soon on DWARF 2 targets with the use of
18462 COMDAT groups.
18464 @table @code
18465 @item #pragma interface
18466 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18467 @kindex #pragma interface
18468 Use this directive in @emph{header files} that define object classes, to save
18469 space in most of the object files that use those classes.  Normally,
18470 local copies of certain information (backup copies of inline member
18471 functions, debugging information, and the internal tables that implement
18472 virtual functions) must be kept in each object file that includes class
18473 definitions.  You can use this pragma to avoid such duplication.  When a
18474 header file containing @samp{#pragma interface} is included in a
18475 compilation, this auxiliary information is not generated (unless
18476 the main input source file itself uses @samp{#pragma implementation}).
18477 Instead, the object files contain references to be resolved at link
18478 time.
18480 The second form of this directive is useful for the case where you have
18481 multiple headers with the same name in different directories.  If you
18482 use this form, you must specify the same string to @samp{#pragma
18483 implementation}.
18485 @item #pragma implementation
18486 @itemx #pragma implementation "@var{objects}.h"
18487 @kindex #pragma implementation
18488 Use this pragma in a @emph{main input file}, when you want full output from
18489 included header files to be generated (and made globally visible).  The
18490 included header file, in turn, should use @samp{#pragma interface}.
18491 Backup copies of inline member functions, debugging information, and the
18492 internal tables used to implement virtual functions are all generated in
18493 implementation files.
18495 @cindex implied @code{#pragma implementation}
18496 @cindex @code{#pragma implementation}, implied
18497 @cindex naming convention, implementation headers
18498 If you use @samp{#pragma implementation} with no argument, it applies to
18499 an include file with the same basename@footnote{A file's @dfn{basename}
18500 is the name stripped of all leading path information and of trailing
18501 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18502 file.  For example, in @file{allclass.cc}, giving just
18503 @samp{#pragma implementation}
18504 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18506 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
18507 an implementation file whenever you would include it from
18508 @file{allclass.cc} even if you never specified @samp{#pragma
18509 implementation}.  This was deemed to be more trouble than it was worth,
18510 however, and disabled.
18512 Use the string argument if you want a single implementation file to
18513 include code from multiple header files.  (You must also use
18514 @samp{#include} to include the header file; @samp{#pragma
18515 implementation} only specifies how to use the file---it doesn't actually
18516 include it.)
18518 There is no way to split up the contents of a single header file into
18519 multiple implementation files.
18520 @end table
18522 @cindex inlining and C++ pragmas
18523 @cindex C++ pragmas, effect on inlining
18524 @cindex pragmas in C++, effect on inlining
18525 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18526 effect on function inlining.
18528 If you define a class in a header file marked with @samp{#pragma
18529 interface}, the effect on an inline function defined in that class is
18530 similar to an explicit @code{extern} declaration---the compiler emits
18531 no code at all to define an independent version of the function.  Its
18532 definition is used only for inlining with its callers.
18534 @opindex fno-implement-inlines
18535 Conversely, when you include the same header file in a main source file
18536 that declares it as @samp{#pragma implementation}, the compiler emits
18537 code for the function itself; this defines a version of the function
18538 that can be found via pointers (or by callers compiled without
18539 inlining).  If all calls to the function can be inlined, you can avoid
18540 emitting the function by compiling with @option{-fno-implement-inlines}.
18541 If any calls are not inlined, you will get linker errors.
18543 @node Template Instantiation
18544 @section Where's the Template?
18545 @cindex template instantiation
18547 C++ templates are the first language feature to require more
18548 intelligence from the environment than one usually finds on a UNIX
18549 system.  Somehow the compiler and linker have to make sure that each
18550 template instance occurs exactly once in the executable if it is needed,
18551 and not at all otherwise.  There are two basic approaches to this
18552 problem, which are referred to as the Borland model and the Cfront model.
18554 @table @asis
18555 @item Borland model
18556 Borland C++ solved the template instantiation problem by adding the code
18557 equivalent of common blocks to their linker; the compiler emits template
18558 instances in each translation unit that uses them, and the linker
18559 collapses them together.  The advantage of this model is that the linker
18560 only has to consider the object files themselves; there is no external
18561 complexity to worry about.  This disadvantage is that compilation time
18562 is increased because the template code is being compiled repeatedly.
18563 Code written for this model tends to include definitions of all
18564 templates in the header file, since they must be seen to be
18565 instantiated.
18567 @item Cfront model
18568 The AT&T C++ translator, Cfront, solved the template instantiation
18569 problem by creating the notion of a template repository, an
18570 automatically maintained place where template instances are stored.  A
18571 more modern version of the repository works as follows: As individual
18572 object files are built, the compiler places any template definitions and
18573 instantiations encountered in the repository.  At link time, the link
18574 wrapper adds in the objects in the repository and compiles any needed
18575 instances that were not previously emitted.  The advantages of this
18576 model are more optimal compilation speed and the ability to use the
18577 system linker; to implement the Borland model a compiler vendor also
18578 needs to replace the linker.  The disadvantages are vastly increased
18579 complexity, and thus potential for error; for some code this can be
18580 just as transparent, but in practice it can been very difficult to build
18581 multiple programs in one directory and one program in multiple
18582 directories.  Code written for this model tends to separate definitions
18583 of non-inline member templates into a separate file, which should be
18584 compiled separately.
18585 @end table
18587 When used with GNU ld version 2.8 or later on an ELF system such as
18588 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18589 Borland model.  On other systems, G++ implements neither automatic
18590 model.
18592 You have the following options for dealing with template instantiations:
18594 @enumerate
18595 @item
18596 @opindex frepo
18597 Compile your template-using code with @option{-frepo}.  The compiler
18598 generates files with the extension @samp{.rpo} listing all of the
18599 template instantiations used in the corresponding object files that
18600 could be instantiated there; the link wrapper, @samp{collect2},
18601 then updates the @samp{.rpo} files to tell the compiler where to place
18602 those instantiations and rebuild any affected object files.  The
18603 link-time overhead is negligible after the first pass, as the compiler
18604 continues to place the instantiations in the same files.
18606 This is your best option for application code written for the Borland
18607 model, as it just works.  Code written for the Cfront model 
18608 needs to be modified so that the template definitions are available at
18609 one or more points of instantiation; usually this is as simple as adding
18610 @code{#include <tmethods.cc>} to the end of each template header.
18612 For library code, if you want the library to provide all of the template
18613 instantiations it needs, just try to link all of its object files
18614 together; the link will fail, but cause the instantiations to be
18615 generated as a side effect.  Be warned, however, that this may cause
18616 conflicts if multiple libraries try to provide the same instantiations.
18617 For greater control, use explicit instantiation as described in the next
18618 option.
18620 @item
18621 @opindex fno-implicit-templates
18622 Compile your code with @option{-fno-implicit-templates} to disable the
18623 implicit generation of template instances, and explicitly instantiate
18624 all the ones you use.  This approach requires more knowledge of exactly
18625 which instances you need than do the others, but it's less
18626 mysterious and allows greater control.  You can scatter the explicit
18627 instantiations throughout your program, perhaps putting them in the
18628 translation units where the instances are used or the translation units
18629 that define the templates themselves; you can put all of the explicit
18630 instantiations you need into one big file; or you can create small files
18631 like
18633 @smallexample
18634 #include "Foo.h"
18635 #include "Foo.cc"
18637 template class Foo<int>;
18638 template ostream& operator <<
18639                 (ostream&, const Foo<int>&);
18640 @end smallexample
18642 @noindent
18643 for each of the instances you need, and create a template instantiation
18644 library from those.
18646 If you are using Cfront-model code, you can probably get away with not
18647 using @option{-fno-implicit-templates} when compiling files that don't
18648 @samp{#include} the member template definitions.
18650 If you use one big file to do the instantiations, you may want to
18651 compile it without @option{-fno-implicit-templates} so you get all of the
18652 instances required by your explicit instantiations (but not by any
18653 other files) without having to specify them as well.
18655 The ISO C++ 2011 standard allows forward declaration of explicit
18656 instantiations (with @code{extern}). G++ supports explicit instantiation
18657 declarations in C++98 mode and has extended the template instantiation
18658 syntax to support instantiation of the compiler support data for a
18659 template class (i.e.@: the vtable) without instantiating any of its
18660 members (with @code{inline}), and instantiation of only the static data
18661 members of a template class, without the support data or member
18662 functions (with @code{static}):
18664 @smallexample
18665 extern template int max (int, int);
18666 inline template class Foo<int>;
18667 static template class Foo<int>;
18668 @end smallexample
18670 @item
18671 Do nothing.  Pretend G++ does implement automatic instantiation
18672 management.  Code written for the Borland model works fine, but
18673 each translation unit contains instances of each of the templates it
18674 uses.  In a large program, this can lead to an unacceptable amount of code
18675 duplication.
18676 @end enumerate
18678 @node Bound member functions
18679 @section Extracting the function pointer from a bound pointer to member function
18680 @cindex pmf
18681 @cindex pointer to member function
18682 @cindex bound pointer to member function
18684 In C++, pointer to member functions (PMFs) are implemented using a wide
18685 pointer of sorts to handle all the possible call mechanisms; the PMF
18686 needs to store information about how to adjust the @samp{this} pointer,
18687 and if the function pointed to is virtual, where to find the vtable, and
18688 where in the vtable to look for the member function.  If you are using
18689 PMFs in an inner loop, you should really reconsider that decision.  If
18690 that is not an option, you can extract the pointer to the function that
18691 would be called for a given object/PMF pair and call it directly inside
18692 the inner loop, to save a bit of time.
18694 Note that you still pay the penalty for the call through a
18695 function pointer; on most modern architectures, such a call defeats the
18696 branch prediction features of the CPU@.  This is also true of normal
18697 virtual function calls.
18699 The syntax for this extension is
18701 @smallexample
18702 extern A a;
18703 extern int (A::*fp)();
18704 typedef int (*fptr)(A *);
18706 fptr p = (fptr)(a.*fp);
18707 @end smallexample
18709 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18710 no object is needed to obtain the address of the function.  They can be
18711 converted to function pointers directly:
18713 @smallexample
18714 fptr p1 = (fptr)(&A::foo);
18715 @end smallexample
18717 @opindex Wno-pmf-conversions
18718 You must specify @option{-Wno-pmf-conversions} to use this extension.
18720 @node C++ Attributes
18721 @section C++-Specific Variable, Function, and Type Attributes
18723 Some attributes only make sense for C++ programs.
18725 @table @code
18726 @item abi_tag ("@var{tag}", ...)
18727 @cindex @code{abi_tag} attribute
18728 The @code{abi_tag} attribute can be applied to a function or class
18729 declaration.  It modifies the mangled name of the function or class to
18730 incorporate the tag name, in order to distinguish the function or
18731 class from an earlier version with a different ABI; perhaps the class
18732 has changed size, or the function has a different return type that is
18733 not encoded in the mangled name.
18735 The argument can be a list of strings of arbitrary length.  The
18736 strings are sorted on output, so the order of the list is
18737 unimportant.
18739 A redeclaration of a function or class must not add new ABI tags,
18740 since doing so would change the mangled name.
18742 The ABI tags apply to a name, so all instantiations and
18743 specializations of a template have the same tags.  The attribute will
18744 be ignored if applied to an explicit specialization or instantiation.
18746 The @option{-Wabi-tag} flag enables a warning about a class which does
18747 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18748 that needs to coexist with an earlier ABI, using this option can help
18749 to find all affected types that need to be tagged.
18751 @item init_priority (@var{priority})
18752 @cindex @code{init_priority} attribute
18755 In Standard C++, objects defined at namespace scope are guaranteed to be
18756 initialized in an order in strict accordance with that of their definitions
18757 @emph{in a given translation unit}.  No guarantee is made for initializations
18758 across translation units.  However, GNU C++ allows users to control the
18759 order of initialization of objects defined at namespace scope with the
18760 @code{init_priority} attribute by specifying a relative @var{priority},
18761 a constant integral expression currently bounded between 101 and 65535
18762 inclusive.  Lower numbers indicate a higher priority.
18764 In the following example, @code{A} would normally be created before
18765 @code{B}, but the @code{init_priority} attribute reverses that order:
18767 @smallexample
18768 Some_Class  A  __attribute__ ((init_priority (2000)));
18769 Some_Class  B  __attribute__ ((init_priority (543)));
18770 @end smallexample
18772 @noindent
18773 Note that the particular values of @var{priority} do not matter; only their
18774 relative ordering.
18776 @item java_interface
18777 @cindex @code{java_interface} attribute
18779 This type attribute informs C++ that the class is a Java interface.  It may
18780 only be applied to classes declared within an @code{extern "Java"} block.
18781 Calls to methods declared in this interface are dispatched using GCJ's
18782 interface table mechanism, instead of regular virtual table dispatch.
18784 @item warn_unused
18785 @cindex @code{warn_unused} attribute
18787 For C++ types with non-trivial constructors and/or destructors it is
18788 impossible for the compiler to determine whether a variable of this
18789 type is truly unused if it is not referenced. This type attribute
18790 informs the compiler that variables of this type should be warned
18791 about if they appear to be unused, just like variables of fundamental
18792 types.
18794 This attribute is appropriate for types which just represent a value,
18795 such as @code{std::string}; it is not appropriate for types which
18796 control a resource, such as @code{std::mutex}.
18798 This attribute is also accepted in C, but it is unnecessary because C
18799 does not have constructors or destructors.
18801 @end table
18803 See also @ref{Namespace Association}.
18805 @node Function Multiversioning
18806 @section Function Multiversioning
18807 @cindex function versions
18809 With the GNU C++ front end, for target i386, you may specify multiple
18810 versions of a function, where each function is specialized for a
18811 specific target feature.  At runtime, the appropriate version of the
18812 function is automatically executed depending on the characteristics of
18813 the execution platform.  Here is an example.
18815 @smallexample
18816 __attribute__ ((target ("default")))
18817 int foo ()
18819   // The default version of foo.
18820   return 0;
18823 __attribute__ ((target ("sse4.2")))
18824 int foo ()
18826   // foo version for SSE4.2
18827   return 1;
18830 __attribute__ ((target ("arch=atom")))
18831 int foo ()
18833   // foo version for the Intel ATOM processor
18834   return 2;
18837 __attribute__ ((target ("arch=amdfam10")))
18838 int foo ()
18840   // foo version for the AMD Family 0x10 processors.
18841   return 3;
18844 int main ()
18846   int (*p)() = &foo;
18847   assert ((*p) () == foo ());
18848   return 0;
18850 @end smallexample
18852 In the above example, four versions of function foo are created. The
18853 first version of foo with the target attribute "default" is the default
18854 version.  This version gets executed when no other target specific
18855 version qualifies for execution on a particular platform. A new version
18856 of foo is created by using the same function signature but with a
18857 different target string.  Function foo is called or a pointer to it is
18858 taken just like a regular function.  GCC takes care of doing the
18859 dispatching to call the right version at runtime.  Refer to the
18860 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18861 Function Multiversioning} for more details.
18863 @node Namespace Association
18864 @section Namespace Association
18866 @strong{Caution:} The semantics of this extension are equivalent
18867 to C++ 2011 inline namespaces.  Users should use inline namespaces
18868 instead as this extension will be removed in future versions of G++.
18870 A using-directive with @code{__attribute ((strong))} is stronger
18871 than a normal using-directive in two ways:
18873 @itemize @bullet
18874 @item
18875 Templates from the used namespace can be specialized and explicitly
18876 instantiated as though they were members of the using namespace.
18878 @item
18879 The using namespace is considered an associated namespace of all
18880 templates in the used namespace for purposes of argument-dependent
18881 name lookup.
18882 @end itemize
18884 The used namespace must be nested within the using namespace so that
18885 normal unqualified lookup works properly.
18887 This is useful for composing a namespace transparently from
18888 implementation namespaces.  For example:
18890 @smallexample
18891 namespace std @{
18892   namespace debug @{
18893     template <class T> struct A @{ @};
18894   @}
18895   using namespace debug __attribute ((__strong__));
18896   template <> struct A<int> @{ @};   // @r{OK to specialize}
18898   template <class T> void f (A<T>);
18901 int main()
18903   f (std::A<float>());             // @r{lookup finds} std::f
18904   f (std::A<int>());
18906 @end smallexample
18908 @node Type Traits
18909 @section Type Traits
18911 The C++ front end implements syntactic extensions that allow
18912 compile-time determination of 
18913 various characteristics of a type (or of a
18914 pair of types).
18916 @table @code
18917 @item __has_nothrow_assign (type)
18918 If @code{type} is const qualified or is a reference type then the trait is
18919 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18920 is true, else if @code{type} is a cv class or union type with copy assignment
18921 operators that are known not to throw an exception then the trait is true,
18922 else it is false.  Requires: @code{type} shall be a complete type,
18923 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18925 @item __has_nothrow_copy (type)
18926 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18927 @code{type} is a cv class or union type with copy constructors that
18928 are known not to throw an exception then the trait is true, else it is false.
18929 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18930 @code{void}, or an array of unknown bound.
18932 @item __has_nothrow_constructor (type)
18933 If @code{__has_trivial_constructor (type)} is true then the trait is
18934 true, else if @code{type} is a cv class or union type (or array
18935 thereof) with a default constructor that is known not to throw an
18936 exception then the trait is true, else it is false.  Requires:
18937 @code{type} shall be a complete type, (possibly cv-qualified)
18938 @code{void}, or an array of unknown bound.
18940 @item __has_trivial_assign (type)
18941 If @code{type} is const qualified or is a reference type then the trait is
18942 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
18943 true, else if @code{type} is a cv class or union type with a trivial
18944 copy assignment ([class.copy]) then the trait is true, else it is
18945 false.  Requires: @code{type} shall be a complete type, (possibly
18946 cv-qualified) @code{void}, or an array of unknown bound.
18948 @item __has_trivial_copy (type)
18949 If @code{__is_pod (type)} is true or @code{type} is a reference type
18950 then the trait is true, else if @code{type} is a cv class or union type
18951 with a trivial copy constructor ([class.copy]) then the trait
18952 is true, else it is false.  Requires: @code{type} shall be a complete
18953 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18955 @item __has_trivial_constructor (type)
18956 If @code{__is_pod (type)} is true then the trait is true, else if
18957 @code{type} is a cv class or union type (or array thereof) with a
18958 trivial default constructor ([class.ctor]) then the trait is true,
18959 else it is false.  Requires: @code{type} shall be a complete
18960 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18962 @item __has_trivial_destructor (type)
18963 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18964 the trait is true, else if @code{type} is a cv class or union type (or
18965 array thereof) with a trivial destructor ([class.dtor]) then the trait
18966 is true, else it is false.  Requires: @code{type} shall be a complete
18967 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18969 @item __has_virtual_destructor (type)
18970 If @code{type} is a class type with a virtual destructor
18971 ([class.dtor]) then the trait is true, else it is false.  Requires:
18972 @code{type} shall be a complete type, (possibly cv-qualified)
18973 @code{void}, or an array of unknown bound.
18975 @item __is_abstract (type)
18976 If @code{type} is an abstract class ([class.abstract]) then the trait
18977 is true, 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 __is_base_of (base_type, derived_type)
18981 If @code{base_type} is a base class of @code{derived_type}
18982 ([class.derived]) then the trait is true, otherwise it is false.
18983 Top-level cv qualifications of @code{base_type} and
18984 @code{derived_type} are ignored.  For the purposes of this trait, a
18985 class type is considered is own base.  Requires: if @code{__is_class
18986 (base_type)} and @code{__is_class (derived_type)} are true and
18987 @code{base_type} and @code{derived_type} are not the same type
18988 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
18989 type.  Diagnostic is produced if this requirement is not met.
18991 @item __is_class (type)
18992 If @code{type} is a cv class type, and not a union type
18993 ([basic.compound]) the trait is true, else it is false.
18995 @item __is_empty (type)
18996 If @code{__is_class (type)} is false then the trait is false.
18997 Otherwise @code{type} is considered empty if and only if: @code{type}
18998 has no non-static data members, or all non-static data members, if
18999 any, are bit-fields of length 0, and @code{type} has no virtual
19000 members, and @code{type} has no virtual base classes, and @code{type}
19001 has no base classes @code{base_type} for which
19002 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
19003 be a complete type, (possibly cv-qualified) @code{void}, or an array
19004 of unknown bound.
19006 @item __is_enum (type)
19007 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
19008 true, else it is false.
19010 @item __is_literal_type (type)
19011 If @code{type} is a literal type ([basic.types]) the trait is
19012 true, else it is false.  Requires: @code{type} shall be a complete type,
19013 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19015 @item __is_pod (type)
19016 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
19017 else it is false.  Requires: @code{type} shall be a complete type,
19018 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19020 @item __is_polymorphic (type)
19021 If @code{type} is a polymorphic class ([class.virtual]) then the trait
19022 is true, else it is false.  Requires: @code{type} shall be a complete
19023 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19025 @item __is_standard_layout (type)
19026 If @code{type} is a standard-layout type ([basic.types]) the trait is
19027 true, else it is false.  Requires: @code{type} shall be a complete
19028 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19030 @item __is_trivial (type)
19031 If @code{type} is a trivial type ([basic.types]) the trait is
19032 true, else it is false.  Requires: @code{type} shall be a complete
19033 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19035 @item __is_union (type)
19036 If @code{type} is a cv union type ([basic.compound]) the trait is
19037 true, else it is false.
19039 @item __underlying_type (type)
19040 The underlying type of @code{type}.  Requires: @code{type} shall be
19041 an enumeration type ([dcl.enum]).
19043 @end table
19045 @node Java Exceptions
19046 @section Java Exceptions
19048 The Java language uses a slightly different exception handling model
19049 from C++.  Normally, GNU C++ automatically detects when you are
19050 writing C++ code that uses Java exceptions, and handle them
19051 appropriately.  However, if C++ code only needs to execute destructors
19052 when Java exceptions are thrown through it, GCC guesses incorrectly.
19053 Sample problematic code is:
19055 @smallexample
19056   struct S @{ ~S(); @};
19057   extern void bar();    // @r{is written in Java, and may throw exceptions}
19058   void foo()
19059   @{
19060     S s;
19061     bar();
19062   @}
19063 @end smallexample
19065 @noindent
19066 The usual effect of an incorrect guess is a link failure, complaining of
19067 a missing routine called @samp{__gxx_personality_v0}.
19069 You can inform the compiler that Java exceptions are to be used in a
19070 translation unit, irrespective of what it might think, by writing
19071 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
19072 @samp{#pragma} must appear before any functions that throw or catch
19073 exceptions, or run destructors when exceptions are thrown through them.
19075 You cannot mix Java and C++ exceptions in the same translation unit.  It
19076 is believed to be safe to throw a C++ exception from one file through
19077 another file compiled for the Java exception model, or vice versa, but
19078 there may be bugs in this area.
19080 @node Deprecated Features
19081 @section Deprecated Features
19083 In the past, the GNU C++ compiler was extended to experiment with new
19084 features, at a time when the C++ language was still evolving.  Now that
19085 the C++ standard is complete, some of those features are superseded by
19086 superior alternatives.  Using the old features might cause a warning in
19087 some cases that the feature will be dropped in the future.  In other
19088 cases, the feature might be gone already.
19090 While the list below is not exhaustive, it documents some of the options
19091 that are now deprecated:
19093 @table @code
19094 @item -fexternal-templates
19095 @itemx -falt-external-templates
19096 These are two of the many ways for G++ to implement template
19097 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
19098 defines how template definitions have to be organized across
19099 implementation units.  G++ has an implicit instantiation mechanism that
19100 should work just fine for standard-conforming code.
19102 @item -fstrict-prototype
19103 @itemx -fno-strict-prototype
19104 Previously it was possible to use an empty prototype parameter list to
19105 indicate an unspecified number of parameters (like C), rather than no
19106 parameters, as C++ demands.  This feature has been removed, except where
19107 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
19108 @end table
19110 G++ allows a virtual function returning @samp{void *} to be overridden
19111 by one returning a different pointer type.  This extension to the
19112 covariant return type rules is now deprecated and will be removed from a
19113 future version.
19115 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19116 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19117 and are now removed from G++.  Code using these operators should be
19118 modified to use @code{std::min} and @code{std::max} instead.
19120 The named return value extension has been deprecated, and is now
19121 removed from G++.
19123 The use of initializer lists with new expressions has been deprecated,
19124 and is now removed from G++.
19126 Floating and complex non-type template parameters have been deprecated,
19127 and are now removed from G++.
19129 The implicit typename extension has been deprecated and is now
19130 removed from G++.
19132 The use of default arguments in function pointers, function typedefs
19133 and other places where they are not permitted by the standard is
19134 deprecated and will be removed from a future version of G++.
19136 G++ allows floating-point literals to appear in integral constant expressions,
19137 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19138 This extension is deprecated and will be removed from a future version.
19140 G++ allows static data members of const floating-point type to be declared
19141 with an initializer in a class definition. The standard only allows
19142 initializers for static members of const integral types and const
19143 enumeration types so this extension has been deprecated and will be removed
19144 from a future version.
19146 @node Backwards Compatibility
19147 @section Backwards Compatibility
19148 @cindex Backwards Compatibility
19149 @cindex ARM [Annotated C++ Reference Manual]
19151 Now that there is a definitive ISO standard C++, G++ has a specification
19152 to adhere to.  The C++ language evolved over time, and features that
19153 used to be acceptable in previous drafts of the standard, such as the ARM
19154 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
19155 compilation of C++ written to such drafts, G++ contains some backwards
19156 compatibilities.  @emph{All such backwards compatibility features are
19157 liable to disappear in future versions of G++.} They should be considered
19158 deprecated.   @xref{Deprecated Features}.
19160 @table @code
19161 @item For scope
19162 If a variable is declared at for scope, it used to remain in scope until
19163 the end of the scope that contained the for statement (rather than just
19164 within the for scope).  G++ retains this, but issues a warning, if such a
19165 variable is accessed outside the for scope.
19167 @item Implicit C language
19168 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19169 scope to set the language.  On such systems, all header files are
19170 implicitly scoped inside a C language scope.  Also, an empty prototype
19171 @code{()} is treated as an unspecified number of arguments, rather
19172 than no arguments, as C++ demands.
19173 @end table
19175 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
19176 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign