PR preprocessor/63831
[official-gcc.git] / gcc / doc / extend.texi
blobaaace5343870d22553e4d4da1931bb0caaa30843
1 @c Copyright (C) 1988-2014 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Initializers::        Non-constant initializers.
50 * Compound Literals::   Compound literals give structures, unions
51                         or arrays as values.
52 * Designated Inits::    Labeling elements of initializers.
53 * Case Ranges::         `case 1 ... 9' and such.
54 * Cast to Union::       Casting to union type from any member of the union.
55 * Mixed Declarations::  Mixing declarations and code.
56 * Function Attributes:: Declaring that functions have no side effects,
57                         or that they can never return.
58 * Label Attributes::    Specifying attributes on labels.
59 * Attribute Syntax::    Formal syntax for attributes.
60 * Function Prototypes:: Prototype declarations and old-style definitions.
61 * C++ Comments::        C++ comments are recognized.
62 * Dollar Signs::        Dollar sign is allowed in identifiers.
63 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
64 * Variable Attributes:: Specifying attributes of variables.
65 * Type Attributes::     Specifying attributes of types.
66 * Alignment::           Inquiring about the alignment of a type or variable.
67 * Inline::              Defining inline functions (as fast as macros).
68 * Volatiles::           What constitutes an access to a volatile object.
69 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
70 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
71 * Incomplete Enums::    @code{enum foo;}, with details to follow.
72 * Function Names::      Printable strings which are the name of the current
73                         function.
74 * Return Address::      Getting the return or frame address of a function.
75 * Vector Extensions::   Using vector instructions through built-in functions.
76 * Offsetof::            Special syntax for implementing @code{offsetof}.
77 * __sync Builtins::     Legacy built-in functions for atomic memory access.
78 * __atomic Builtins::   Atomic built-in functions with memory model.
79 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
80                         arithmetic overflow checking.
81 * x86 specific memory model extensions for transactional memory:: x86 memory models.
82 * Object Size Checking:: Built-in functions for limited buffer overflow
83                         checking.
84 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
85 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
86 * Other Builtins::      Other built-in functions.
87 * Target Builtins::     Built-in functions specific to particular targets.
88 * Target Format Checks:: Format checks specific to particular targets.
89 * Pragmas::             Pragmas accepted by GCC.
90 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
91 * Thread-Local::        Per-thread variables.
92 * Binary constants::    Binary constants using the @samp{0b} prefix.
93 @end menu
95 @node Statement Exprs
96 @section Statements and Declarations in Expressions
97 @cindex statements inside expressions
98 @cindex declarations inside expressions
99 @cindex expressions containing statements
100 @cindex macros, statements in expressions
102 @c the above section title wrapped and causes an underfull hbox.. i
103 @c changed it from "within" to "in". --mew 4feb93
104 A compound statement enclosed in parentheses may appear as an expression
105 in GNU C@.  This allows you to use loops, switches, and local variables
106 within an expression.
108 Recall that a compound statement is a sequence of statements surrounded
109 by braces; in this construct, parentheses go around the braces.  For
110 example:
112 @smallexample
113 (@{ int y = foo (); int z;
114    if (y > 0) z = y;
115    else z = - y;
116    z; @})
117 @end smallexample
119 @noindent
120 is a valid (though slightly more complex than necessary) expression
121 for the absolute value of @code{foo ()}.
123 The last thing in the compound statement should be an expression
124 followed by a semicolon; the value of this subexpression serves as the
125 value of the entire construct.  (If you use some other kind of statement
126 last within the braces, the construct has type @code{void}, and thus
127 effectively no value.)
129 This feature is especially useful in making macro definitions ``safe'' (so
130 that they evaluate each operand exactly once).  For example, the
131 ``maximum'' function is commonly defined as a macro in standard C as
132 follows:
134 @smallexample
135 #define max(a,b) ((a) > (b) ? (a) : (b))
136 @end smallexample
138 @noindent
139 @cindex side effects, macro argument
140 But this definition computes either @var{a} or @var{b} twice, with bad
141 results if the operand has side effects.  In GNU C, if you know the
142 type of the operands (here taken as @code{int}), you can define
143 the macro safely as follows:
145 @smallexample
146 #define maxint(a,b) \
147   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
148 @end smallexample
150 Embedded statements are not allowed in constant expressions, such as
151 the value of an enumeration constant, the width of a bit-field, or
152 the initial value of a static variable.
154 If you don't know the type of the operand, you can still do this, but you
155 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
157 In G++, the result value of a statement expression undergoes array and
158 function pointer decay, and is returned by value to the enclosing
159 expression.  For instance, if @code{A} is a class, then
161 @smallexample
162         A a;
164         (@{a;@}).Foo ()
165 @end smallexample
167 @noindent
168 constructs a temporary @code{A} object to hold the result of the
169 statement expression, and that is used to invoke @code{Foo}.
170 Therefore the @code{this} pointer observed by @code{Foo} is not the
171 address of @code{a}.
173 In a statement expression, any temporaries created within a statement
174 are destroyed at that statement's end.  This makes statement
175 expressions inside macros slightly different from function calls.  In
176 the latter case temporaries introduced during argument evaluation are
177 destroyed at the end of the statement that includes the function
178 call.  In the statement expression case they are destroyed during
179 the statement expression.  For instance,
181 @smallexample
182 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
183 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
185 void foo ()
187   macro (X ());
188   function (X ());
190 @end smallexample
192 @noindent
193 has different places where temporaries are destroyed.  For the
194 @code{macro} case, the temporary @code{X} is destroyed just after
195 the initialization of @code{b}.  In the @code{function} case that
196 temporary is destroyed when the function returns.
198 These considerations mean that it is probably a bad idea to use
199 statement expressions of this form in header files that are designed to
200 work with C++.  (Note that some versions of the GNU C Library contained
201 header files using statement expressions that lead to precisely this
202 bug.)
204 Jumping into a statement expression with @code{goto} or using a
205 @code{switch} statement outside the statement expression with a
206 @code{case} or @code{default} label inside the statement expression is
207 not permitted.  Jumping into a statement expression with a computed
208 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
209 Jumping out of a statement expression is permitted, but if the
210 statement expression is part of a larger expression then it is
211 unspecified which other subexpressions of that expression have been
212 evaluated except where the language definition requires certain
213 subexpressions to be evaluated before or after the statement
214 expression.  In any case, as with a function call, the evaluation of a
215 statement expression is not interleaved with the evaluation of other
216 parts of the containing expression.  For example,
218 @smallexample
219   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
220 @end smallexample
222 @noindent
223 calls @code{foo} and @code{bar1} and does not call @code{baz} but
224 may or may not call @code{bar2}.  If @code{bar2} is called, it is
225 called after @code{foo} and before @code{bar1}.
227 @node Local Labels
228 @section Locally Declared Labels
229 @cindex local labels
230 @cindex macros, local labels
232 GCC allows you to declare @dfn{local labels} in any nested block
233 scope.  A local label is just like an ordinary label, but you can
234 only reference it (with a @code{goto} statement, or by taking its
235 address) within the block in which it is declared.
237 A local label declaration looks like this:
239 @smallexample
240 __label__ @var{label};
241 @end smallexample
243 @noindent
246 @smallexample
247 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
248 @end smallexample
250 Local label declarations must come at the beginning of the block,
251 before any ordinary declarations or statements.
253 The label declaration defines the label @emph{name}, but does not define
254 the label itself.  You must do this in the usual way, with
255 @code{@var{label}:}, within the statements of the statement expression.
257 The local label feature is useful for complex macros.  If a macro
258 contains nested loops, a @code{goto} can be useful for breaking out of
259 them.  However, an ordinary label whose scope is the whole function
260 cannot be used: if the macro can be expanded several times in one
261 function, the label is multiply defined in that function.  A
262 local label avoids this problem.  For example:
264 @smallexample
265 #define SEARCH(value, array, target)              \
266 do @{                                              \
267   __label__ found;                                \
268   typeof (target) _SEARCH_target = (target);      \
269   typeof (*(array)) *_SEARCH_array = (array);     \
270   int i, j;                                       \
271   int value;                                      \
272   for (i = 0; i < max; i++)                       \
273     for (j = 0; j < max; j++)                     \
274       if (_SEARCH_array[i][j] == _SEARCH_target)  \
275         @{ (value) = i; goto found; @}              \
276   (value) = -1;                                   \
277  found:;                                          \
278 @} while (0)
279 @end smallexample
281 This could also be written using a statement expression:
283 @smallexample
284 #define SEARCH(array, target)                     \
285 (@{                                                \
286   __label__ found;                                \
287   typeof (target) _SEARCH_target = (target);      \
288   typeof (*(array)) *_SEARCH_array = (array);     \
289   int i, j;                                       \
290   int value;                                      \
291   for (i = 0; i < max; i++)                       \
292     for (j = 0; j < max; j++)                     \
293       if (_SEARCH_array[i][j] == _SEARCH_target)  \
294         @{ value = i; goto found; @}                \
295   value = -1;                                     \
296  found:                                           \
297   value;                                          \
299 @end smallexample
301 Local label declarations also make the labels they declare visible to
302 nested functions, if there are any.  @xref{Nested Functions}, for details.
304 @node Labels as Values
305 @section Labels as Values
306 @cindex labels as values
307 @cindex computed gotos
308 @cindex goto with computed label
309 @cindex address of a label
311 You can get the address of a label defined in the current function
312 (or a containing function) with the unary operator @samp{&&}.  The
313 value has type @code{void *}.  This value is a constant and can be used
314 wherever a constant of that type is valid.  For example:
316 @smallexample
317 void *ptr;
318 /* @r{@dots{}} */
319 ptr = &&foo;
320 @end smallexample
322 To use these values, you need to be able to jump to one.  This is done
323 with the computed goto statement@footnote{The analogous feature in
324 Fortran is called an assigned goto, but that name seems inappropriate in
325 C, where one can do more than simply store label addresses in label
326 variables.}, @code{goto *@var{exp};}.  For example,
328 @smallexample
329 goto *ptr;
330 @end smallexample
332 @noindent
333 Any expression of type @code{void *} is allowed.
335 One way of using these constants is in initializing a static array that
336 serves as a jump table:
338 @smallexample
339 static void *array[] = @{ &&foo, &&bar, &&hack @};
340 @end smallexample
342 @noindent
343 Then you can select a label with indexing, like this:
345 @smallexample
346 goto *array[i];
347 @end smallexample
349 @noindent
350 Note that this does not check whether the subscript is in bounds---array
351 indexing in C never does that.
353 Such an array of label values serves a purpose much like that of the
354 @code{switch} statement.  The @code{switch} statement is cleaner, so
355 use that rather than an array unless the problem does not fit a
356 @code{switch} statement very well.
358 Another use of label values is in an interpreter for threaded code.
359 The labels within the interpreter function can be stored in the
360 threaded code for super-fast dispatching.
362 You may not use this mechanism to jump to code in a different function.
363 If you do that, totally unpredictable things happen.  The best way to
364 avoid this is to store the label address only in automatic variables and
365 never pass it as an argument.
367 An alternate way to write the above example is
369 @smallexample
370 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
371                              &&hack - &&foo @};
372 goto *(&&foo + array[i]);
373 @end smallexample
375 @noindent
376 This is more friendly to code living in shared libraries, as it reduces
377 the number of dynamic relocations that are needed, and by consequence,
378 allows the data to be read-only.
379 This alternative with label differences is not supported for the AVR target,
380 please use the first approach for AVR programs.
382 The @code{&&foo} expressions for the same label might have different
383 values if the containing function is inlined or cloned.  If a program
384 relies on them being always the same,
385 @code{__attribute__((__noinline__,__noclone__))} should be used to
386 prevent inlining and cloning.  If @code{&&foo} is used in a static
387 variable initializer, inlining and cloning is forbidden.
389 @node Nested Functions
390 @section Nested Functions
391 @cindex nested functions
392 @cindex downward funargs
393 @cindex thunks
395 A @dfn{nested function} is a function defined inside another function.
396 Nested functions are supported as an extension in GNU C, but are not
397 supported by GNU C++.
399 The nested function's name is local to the block where it is defined.
400 For example, here we define a nested function named @code{square}, and
401 call it twice:
403 @smallexample
404 @group
405 foo (double a, double b)
407   double square (double z) @{ return z * z; @}
409   return square (a) + square (b);
411 @end group
412 @end smallexample
414 The nested function can access all the variables of the containing
415 function that are visible at the point of its definition.  This is
416 called @dfn{lexical scoping}.  For example, here we show a nested
417 function which uses an inherited variable named @code{offset}:
419 @smallexample
420 @group
421 bar (int *array, int offset, int size)
423   int access (int *array, int index)
424     @{ return array[index + offset]; @}
425   int i;
426   /* @r{@dots{}} */
427   for (i = 0; i < size; i++)
428     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
430 @end group
431 @end smallexample
433 Nested function definitions are permitted within functions in the places
434 where variable definitions are allowed; that is, in any block, mixed
435 with the other declarations and statements in the block.
437 It is possible to call the nested function from outside the scope of its
438 name by storing its address or passing the address to another function:
440 @smallexample
441 hack (int *array, int size)
443   void store (int index, int value)
444     @{ array[index] = value; @}
446   intermediate (store, size);
448 @end smallexample
450 Here, the function @code{intermediate} receives the address of
451 @code{store} as an argument.  If @code{intermediate} calls @code{store},
452 the arguments given to @code{store} are used to store into @code{array}.
453 But this technique works only so long as the containing function
454 (@code{hack}, in this example) does not exit.
456 If you try to call the nested function through its address after the
457 containing function exits, all hell breaks loose.  If you try
458 to call it after a containing scope level exits, and if it refers
459 to some of the variables that are no longer in scope, you may be lucky,
460 but it's not wise to take the risk.  If, however, the nested function
461 does not refer to anything that has gone out of scope, you should be
462 safe.
464 GCC implements taking the address of a nested function using a technique
465 called @dfn{trampolines}.  This technique was described in
466 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
467 C++ Conference Proceedings, October 17-21, 1988).
469 A nested function can jump to a label inherited from a containing
470 function, provided the label is explicitly declared in the containing
471 function (@pxref{Local Labels}).  Such a jump returns instantly to the
472 containing function, exiting the nested function that did the
473 @code{goto} and any intermediate functions as well.  Here is an example:
475 @smallexample
476 @group
477 bar (int *array, int offset, int size)
479   __label__ failure;
480   int access (int *array, int index)
481     @{
482       if (index > size)
483         goto failure;
484       return array[index + offset];
485     @}
486   int i;
487   /* @r{@dots{}} */
488   for (i = 0; i < size; i++)
489     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
490   /* @r{@dots{}} */
491   return 0;
493  /* @r{Control comes here from @code{access}
494     if it detects an error.}  */
495  failure:
496   return -1;
498 @end group
499 @end smallexample
501 A nested function always has no linkage.  Declaring one with
502 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
503 before its definition, use @code{auto} (which is otherwise meaningless
504 for function declarations).
506 @smallexample
507 bar (int *array, int offset, int size)
509   __label__ failure;
510   auto int access (int *, int);
511   /* @r{@dots{}} */
512   int access (int *array, int index)
513     @{
514       if (index > size)
515         goto failure;
516       return array[index + offset];
517     @}
518   /* @r{@dots{}} */
520 @end smallexample
522 @node Constructing Calls
523 @section Constructing Function Calls
524 @cindex constructing calls
525 @cindex forwarding calls
527 Using the built-in functions described below, you can record
528 the arguments a function received, and call another function
529 with the same arguments, without knowing the number or types
530 of the arguments.
532 You can also record the return value of that function call,
533 and later return that value, without knowing what data type
534 the function tried to return (as long as your caller expects
535 that data type).
537 However, these built-in functions may interact badly with some
538 sophisticated features or other extensions of the language.  It
539 is, therefore, not recommended to use them outside very simple
540 functions acting as mere forwarders for their arguments.
542 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
543 This built-in function returns a pointer to data
544 describing how to perform a call with the same arguments as are passed
545 to the current function.
547 The function saves the arg pointer register, structure value address,
548 and all registers that might be used to pass arguments to a function
549 into a block of memory allocated on the stack.  Then it returns the
550 address of that block.
551 @end deftypefn
553 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
554 This built-in function invokes @var{function}
555 with a copy of the parameters described by @var{arguments}
556 and @var{size}.
558 The value of @var{arguments} should be the value returned by
559 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
560 of the stack argument data, in bytes.
562 This function returns a pointer to data describing
563 how to return whatever value is returned by @var{function}.  The data
564 is saved in a block of memory allocated on the stack.
566 It is not always simple to compute the proper value for @var{size}.  The
567 value is used by @code{__builtin_apply} to compute the amount of data
568 that should be pushed on the stack and copied from the incoming argument
569 area.
570 @end deftypefn
572 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
573 This built-in function returns the value described by @var{result} from
574 the containing function.  You should specify, for @var{result}, a value
575 returned by @code{__builtin_apply}.
576 @end deftypefn
578 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
579 This built-in function represents all anonymous arguments of an inline
580 function.  It can be used only in inline functions that are always
581 inlined, never compiled as a separate function, such as those using
582 @code{__attribute__ ((__always_inline__))} or
583 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
584 It must be only passed as last argument to some other function
585 with variable arguments.  This is useful for writing small wrapper
586 inlines for variable argument functions, when using preprocessor
587 macros is undesirable.  For example:
588 @smallexample
589 extern int myprintf (FILE *f, const char *format, ...);
590 extern inline __attribute__ ((__gnu_inline__)) int
591 myprintf (FILE *f, const char *format, ...)
593   int r = fprintf (f, "myprintf: ");
594   if (r < 0)
595     return r;
596   int s = fprintf (f, format, __builtin_va_arg_pack ());
597   if (s < 0)
598     return s;
599   return r + s;
601 @end smallexample
602 @end deftypefn
604 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
605 This built-in function returns the number of anonymous arguments of
606 an inline function.  It can be used only in inline functions that
607 are always inlined, never compiled as a separate function, such
608 as those using @code{__attribute__ ((__always_inline__))} or
609 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
610 For example following does link- or run-time checking of open
611 arguments for optimized code:
612 @smallexample
613 #ifdef __OPTIMIZE__
614 extern inline __attribute__((__gnu_inline__)) int
615 myopen (const char *path, int oflag, ...)
617   if (__builtin_va_arg_pack_len () > 1)
618     warn_open_too_many_arguments ();
620   if (__builtin_constant_p (oflag))
621     @{
622       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
623         @{
624           warn_open_missing_mode ();
625           return __open_2 (path, oflag);
626         @}
627       return open (path, oflag, __builtin_va_arg_pack ());
628     @}
630   if (__builtin_va_arg_pack_len () < 1)
631     return __open_2 (path, oflag);
633   return open (path, oflag, __builtin_va_arg_pack ());
635 #endif
636 @end smallexample
637 @end deftypefn
639 @node Typeof
640 @section Referring to a Type with @code{typeof}
641 @findex typeof
642 @findex sizeof
643 @cindex macros, types of arguments
645 Another way to refer to the type of an expression is with @code{typeof}.
646 The syntax of using of this keyword looks like @code{sizeof}, but the
647 construct acts semantically like a type name defined with @code{typedef}.
649 There are two ways of writing the argument to @code{typeof}: with an
650 expression or with a type.  Here is an example with an expression:
652 @smallexample
653 typeof (x[0](1))
654 @end smallexample
656 @noindent
657 This assumes that @code{x} is an array of pointers to functions;
658 the type described is that of the values of the functions.
660 Here is an example with a typename as the argument:
662 @smallexample
663 typeof (int *)
664 @end smallexample
666 @noindent
667 Here the type described is that of pointers to @code{int}.
669 If you are writing a header file that must work when included in ISO C
670 programs, write @code{__typeof__} instead of @code{typeof}.
671 @xref{Alternate Keywords}.
673 A @code{typeof} construct can be used anywhere a typedef name can be
674 used.  For example, you can use it in a declaration, in a cast, or inside
675 of @code{sizeof} or @code{typeof}.
677 The operand of @code{typeof} is evaluated for its side effects if and
678 only if it is an expression of variably modified type or the name of
679 such a type.
681 @code{typeof} is often useful in conjunction with
682 statement expressions (@pxref{Statement Exprs}).
683 Here is how the two together can
684 be used to define a safe ``maximum'' macro which operates on any
685 arithmetic type and evaluates each of its arguments exactly once:
687 @smallexample
688 #define max(a,b) \
689   (@{ typeof (a) _a = (a); \
690       typeof (b) _b = (b); \
691     _a > _b ? _a : _b; @})
692 @end smallexample
694 @cindex underscores in variables in macros
695 @cindex @samp{_} in variables in macros
696 @cindex local variables in macros
697 @cindex variables, local, in macros
698 @cindex macros, local variables in
700 The reason for using names that start with underscores for the local
701 variables is to avoid conflicts with variable names that occur within the
702 expressions that are substituted for @code{a} and @code{b}.  Eventually we
703 hope to design a new form of declaration syntax that allows you to declare
704 variables whose scopes start only after their initializers; this will be a
705 more reliable way to prevent such conflicts.
707 @noindent
708 Some more examples of the use of @code{typeof}:
710 @itemize @bullet
711 @item
712 This declares @code{y} with the type of what @code{x} points to.
714 @smallexample
715 typeof (*x) y;
716 @end smallexample
718 @item
719 This declares @code{y} as an array of such values.
721 @smallexample
722 typeof (*x) y[4];
723 @end smallexample
725 @item
726 This declares @code{y} as an array of pointers to characters:
728 @smallexample
729 typeof (typeof (char *)[4]) y;
730 @end smallexample
732 @noindent
733 It is equivalent to the following traditional C declaration:
735 @smallexample
736 char *y[4];
737 @end smallexample
739 To see the meaning of the declaration using @code{typeof}, and why it
740 might be a useful way to write, rewrite it with these macros:
742 @smallexample
743 #define pointer(T)  typeof(T *)
744 #define array(T, N) typeof(T [N])
745 @end smallexample
747 @noindent
748 Now the declaration can be rewritten this way:
750 @smallexample
751 array (pointer (char), 4) y;
752 @end smallexample
754 @noindent
755 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
756 pointers to @code{char}.
757 @end itemize
759 In GNU C, but not GNU C++, you may also declare the type of a variable
760 as @code{__auto_type}.  In that case, the declaration must declare
761 only one variable, whose declarator must just be an identifier, the
762 declaration must be initialized, and the type of the variable is
763 determined by the initializer; the name of the variable is not in
764 scope until after the initializer.  (In C++, you should use C++11
765 @code{auto} for this purpose.)  Using @code{__auto_type}, the
766 ``maximum'' macro above could be written as:
768 @smallexample
769 #define max(a,b) \
770   (@{ __auto_type _a = (a); \
771       __auto_type _b = (b); \
772     _a > _b ? _a : _b; @})
773 @end smallexample
775 Using @code{__auto_type} instead of @code{typeof} has two advantages:
777 @itemize @bullet
778 @item Each argument to the macro appears only once in the expansion of
779 the macro.  This prevents the size of the macro expansion growing
780 exponentially when calls to such macros are nested inside arguments of
781 such macros.
783 @item If the argument to the macro has variably modified type, it is
784 evaluated only once when using @code{__auto_type}, but twice if
785 @code{typeof} is used.
786 @end itemize
788 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
789 a more limited extension that permitted one to write
791 @smallexample
792 typedef @var{T} = @var{expr};
793 @end smallexample
795 @noindent
796 with the effect of declaring @var{T} to have the type of the expression
797 @var{expr}.  This extension does not work with GCC 3 (versions between
798 3.0 and 3.2 crash; 3.2.1 and later give an error).  Code that
799 relies on it should be rewritten to use @code{typeof}:
801 @smallexample
802 typedef typeof(@var{expr}) @var{T};
803 @end smallexample
805 @noindent
806 This works with all versions of GCC@.
808 @node Conditionals
809 @section Conditionals with Omitted Operands
810 @cindex conditional expressions, extensions
811 @cindex omitted middle-operands
812 @cindex middle-operands, omitted
813 @cindex extensions, @code{?:}
814 @cindex @code{?:} extensions
816 The middle operand in a conditional expression may be omitted.  Then
817 if the first operand is nonzero, its value is the value of the conditional
818 expression.
820 Therefore, the expression
822 @smallexample
823 x ? : y
824 @end smallexample
826 @noindent
827 has the value of @code{x} if that is nonzero; otherwise, the value of
828 @code{y}.
830 This example is perfectly equivalent to
832 @smallexample
833 x ? x : y
834 @end smallexample
836 @cindex side effect in @code{?:}
837 @cindex @code{?:} side effect
838 @noindent
839 In this simple case, the ability to omit the middle operand is not
840 especially useful.  When it becomes useful is when the first operand does,
841 or may (if it is a macro argument), contain a side effect.  Then repeating
842 the operand in the middle would perform the side effect twice.  Omitting
843 the middle operand uses the value already computed without the undesirable
844 effects of recomputing it.
846 @node __int128
847 @section 128-bit integers
848 @cindex @code{__int128} data types
850 As an extension the integer scalar type @code{__int128} is supported for
851 targets which have an integer mode wide enough to hold 128 bits.
852 Simply write @code{__int128} for a signed 128-bit integer, or
853 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
854 support in GCC for expressing an integer constant of type @code{__int128}
855 for targets with @code{long long} integer less than 128 bits wide.
857 @node Long Long
858 @section Double-Word Integers
859 @cindex @code{long long} data types
860 @cindex double-word arithmetic
861 @cindex multiprecision arithmetic
862 @cindex @code{LL} integer suffix
863 @cindex @code{ULL} integer suffix
865 ISO C99 supports data types for integers that are at least 64 bits wide,
866 and as an extension GCC supports them in C90 mode and in C++.
867 Simply write @code{long long int} for a signed integer, or
868 @code{unsigned long long int} for an unsigned integer.  To make an
869 integer constant of type @code{long long int}, add the suffix @samp{LL}
870 to the integer.  To make an integer constant of type @code{unsigned long
871 long int}, add the suffix @samp{ULL} to the integer.
873 You can use these types in arithmetic like any other integer types.
874 Addition, subtraction, and bitwise boolean operations on these types
875 are open-coded on all types of machines.  Multiplication is open-coded
876 if the machine supports a fullword-to-doubleword widening multiply
877 instruction.  Division and shifts are open-coded only on machines that
878 provide special support.  The operations that are not open-coded use
879 special library routines that come with GCC@.
881 There may be pitfalls when you use @code{long long} types for function
882 arguments without function prototypes.  If a function
883 expects type @code{int} for its argument, and you pass a value of type
884 @code{long long int}, confusion results because the caller and the
885 subroutine disagree about the number of bytes for the argument.
886 Likewise, if the function expects @code{long long int} and you pass
887 @code{int}.  The best way to avoid such problems is to use prototypes.
889 @node Complex
890 @section Complex Numbers
891 @cindex complex numbers
892 @cindex @code{_Complex} keyword
893 @cindex @code{__complex__} keyword
895 ISO C99 supports complex floating data types, and as an extension GCC
896 supports them in C90 mode and in C++.  GCC also supports complex integer data
897 types which are not part of ISO C99.  You can declare complex types
898 using the keyword @code{_Complex}.  As an extension, the older GNU
899 keyword @code{__complex__} is also supported.
901 For example, @samp{_Complex double x;} declares @code{x} as a
902 variable whose real part and imaginary part are both of type
903 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
904 have real and imaginary parts of type @code{short int}; this is not
905 likely to be useful, but it shows that the set of complex types is
906 complete.
908 To write a constant with a complex data type, use the suffix @samp{i} or
909 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
910 has type @code{_Complex float} and @code{3i} has type
911 @code{_Complex int}.  Such a constant always has a pure imaginary
912 value, but you can form any complex value you like by adding one to a
913 real constant.  This is a GNU extension; if you have an ISO C99
914 conforming C library (such as the GNU C Library), and want to construct complex
915 constants of floating type, you should include @code{<complex.h>} and
916 use the macros @code{I} or @code{_Complex_I} instead.
918 @cindex @code{__real__} keyword
919 @cindex @code{__imag__} keyword
920 To extract the real part of a complex-valued expression @var{exp}, write
921 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
922 extract the imaginary part.  This is a GNU extension; for values of
923 floating type, you should use the ISO C99 functions @code{crealf},
924 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
925 @code{cimagl}, declared in @code{<complex.h>} and also provided as
926 built-in functions by GCC@.
928 @cindex complex conjugation
929 The operator @samp{~} performs complex conjugation when used on a value
930 with a complex type.  This is a GNU extension; for values of
931 floating type, you should use the ISO C99 functions @code{conjf},
932 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
933 provided as built-in functions by GCC@.
935 GCC can allocate complex automatic variables in a noncontiguous
936 fashion; it's even possible for the real part to be in a register while
937 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
938 debug info format can represent this, so use of DWARF 2 is recommended.
939 If you are using the stabs debug info format, GCC describes a noncontiguous
940 complex variable as if it were two separate variables of noncomplex type.
941 If the variable's actual name is @code{foo}, the two fictitious
942 variables are named @code{foo$real} and @code{foo$imag}.  You can
943 examine and set these two fictitious variables with your debugger.
945 @node Floating Types
946 @section Additional Floating Types
947 @cindex additional floating types
948 @cindex @code{__float80} data type
949 @cindex @code{__float128} data type
950 @cindex @code{w} floating point suffix
951 @cindex @code{q} floating point suffix
952 @cindex @code{W} floating point suffix
953 @cindex @code{Q} floating point suffix
955 As an extension, GNU C supports additional floating
956 types, @code{__float80} and @code{__float128} to support 80-bit
957 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
958 Support for additional types includes the arithmetic operators:
959 add, subtract, multiply, divide; unary arithmetic operators;
960 relational operators; equality operators; and conversions to and from
961 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
962 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
963 for @code{_float128}.  You can declare complex types using the
964 corresponding internal complex type, @code{XCmode} for @code{__float80}
965 type and @code{TCmode} for @code{__float128} type:
967 @smallexample
968 typedef _Complex float __attribute__((mode(TC))) _Complex128;
969 typedef _Complex float __attribute__((mode(XC))) _Complex80;
970 @end smallexample
972 Not all targets support additional floating-point types.  @code{__float80}
973 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
974 The @code{__float128} type is supported on hppa HP-UX targets.
976 @node Half-Precision
977 @section Half-Precision Floating Point
978 @cindex half-precision floating point
979 @cindex @code{__fp16} data type
981 On ARM targets, GCC supports half-precision (16-bit) floating point via
982 the @code{__fp16} type.  You must enable this type explicitly
983 with the @option{-mfp16-format} command-line option in order to use it.
985 ARM supports two incompatible representations for half-precision
986 floating-point values.  You must choose one of the representations and
987 use it consistently in your program.
989 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
990 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
991 There are 11 bits of significand precision, approximately 3
992 decimal digits.
994 Specifying @option{-mfp16-format=alternative} selects the ARM
995 alternative format.  This representation is similar to the IEEE
996 format, but does not support infinities or NaNs.  Instead, the range
997 of exponents is extended, so that this format can represent normalized
998 values in the range of @math{2^{-14}} to 131008.
1000 The @code{__fp16} type is a storage format only.  For purposes
1001 of arithmetic and other operations, @code{__fp16} values in C or C++
1002 expressions are automatically promoted to @code{float}.  In addition,
1003 you cannot declare a function with a return value or parameters
1004 of type @code{__fp16}.
1006 Note that conversions from @code{double} to @code{__fp16}
1007 involve an intermediate conversion to @code{float}.  Because
1008 of rounding, this can sometimes produce a different result than a
1009 direct conversion.
1011 ARM provides hardware support for conversions between
1012 @code{__fp16} and @code{float} values
1013 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
1014 code using these hardware instructions if you compile with
1015 options to select an FPU that provides them;
1016 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1017 in addition to the @option{-mfp16-format} option to select
1018 a half-precision format.
1020 Language-level support for the @code{__fp16} data type is
1021 independent of whether GCC generates code using hardware floating-point
1022 instructions.  In cases where hardware support is not specified, GCC
1023 implements conversions between @code{__fp16} and @code{float} values
1024 as library calls.
1026 @node Decimal Float
1027 @section Decimal Floating Types
1028 @cindex decimal floating types
1029 @cindex @code{_Decimal32} data type
1030 @cindex @code{_Decimal64} data type
1031 @cindex @code{_Decimal128} data type
1032 @cindex @code{df} integer suffix
1033 @cindex @code{dd} integer suffix
1034 @cindex @code{dl} integer suffix
1035 @cindex @code{DF} integer suffix
1036 @cindex @code{DD} integer suffix
1037 @cindex @code{DL} integer suffix
1039 As an extension, GNU C supports decimal floating types as
1040 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1041 floating types in GCC will evolve as the draft technical report changes.
1042 Calling conventions for any target might also change.  Not all targets
1043 support decimal floating types.
1045 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1046 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1047 @code{float}, @code{double}, and @code{long double} whose radix is not
1048 specified by the C standard but is usually two.
1050 Support for decimal floating types includes the arithmetic operators
1051 add, subtract, multiply, divide; unary arithmetic operators;
1052 relational operators; equality operators; and conversions to and from
1053 integer and other floating types.  Use a suffix @samp{df} or
1054 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1055 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1056 @code{_Decimal128}.
1058 GCC support of decimal float as specified by the draft technical report
1059 is incomplete:
1061 @itemize @bullet
1062 @item
1063 When the value of a decimal floating type cannot be represented in the
1064 integer type to which it is being converted, the result is undefined
1065 rather than the result value specified by the draft technical report.
1067 @item
1068 GCC does not provide the C library functionality associated with
1069 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1070 @file{wchar.h}, which must come from a separate C library implementation.
1071 Because of this the GNU C compiler does not define macro
1072 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1073 the technical report.
1074 @end itemize
1076 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1077 are supported by the DWARF 2 debug information format.
1079 @node Hex Floats
1080 @section Hex Floats
1081 @cindex hex floats
1083 ISO C99 supports floating-point numbers written not only in the usual
1084 decimal notation, such as @code{1.55e1}, but also numbers such as
1085 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1086 supports this in C90 mode (except in some cases when strictly
1087 conforming) and in C++.  In that format the
1088 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1089 mandatory.  The exponent is a decimal number that indicates the power of
1090 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1091 @tex
1092 $1 {15\over16}$,
1093 @end tex
1094 @ifnottex
1095 1 15/16,
1096 @end ifnottex
1097 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1098 is the same as @code{1.55e1}.
1100 Unlike for floating-point numbers in the decimal notation the exponent
1101 is always required in the hexadecimal notation.  Otherwise the compiler
1102 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1103 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1104 extension for floating-point constants of type @code{float}.
1106 @node Fixed-Point
1107 @section Fixed-Point Types
1108 @cindex fixed-point types
1109 @cindex @code{_Fract} data type
1110 @cindex @code{_Accum} data type
1111 @cindex @code{_Sat} data type
1112 @cindex @code{hr} fixed-suffix
1113 @cindex @code{r} fixed-suffix
1114 @cindex @code{lr} fixed-suffix
1115 @cindex @code{llr} fixed-suffix
1116 @cindex @code{uhr} fixed-suffix
1117 @cindex @code{ur} fixed-suffix
1118 @cindex @code{ulr} fixed-suffix
1119 @cindex @code{ullr} fixed-suffix
1120 @cindex @code{hk} fixed-suffix
1121 @cindex @code{k} fixed-suffix
1122 @cindex @code{lk} fixed-suffix
1123 @cindex @code{llk} fixed-suffix
1124 @cindex @code{uhk} fixed-suffix
1125 @cindex @code{uk} fixed-suffix
1126 @cindex @code{ulk} fixed-suffix
1127 @cindex @code{ullk} fixed-suffix
1128 @cindex @code{HR} fixed-suffix
1129 @cindex @code{R} fixed-suffix
1130 @cindex @code{LR} fixed-suffix
1131 @cindex @code{LLR} fixed-suffix
1132 @cindex @code{UHR} fixed-suffix
1133 @cindex @code{UR} fixed-suffix
1134 @cindex @code{ULR} fixed-suffix
1135 @cindex @code{ULLR} fixed-suffix
1136 @cindex @code{HK} fixed-suffix
1137 @cindex @code{K} fixed-suffix
1138 @cindex @code{LK} fixed-suffix
1139 @cindex @code{LLK} fixed-suffix
1140 @cindex @code{UHK} fixed-suffix
1141 @cindex @code{UK} fixed-suffix
1142 @cindex @code{ULK} fixed-suffix
1143 @cindex @code{ULLK} fixed-suffix
1145 As an extension, GNU C supports fixed-point types as
1146 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1147 types in GCC will evolve as the draft technical report changes.
1148 Calling conventions for any target might also change.  Not all targets
1149 support fixed-point types.
1151 The fixed-point types are
1152 @code{short _Fract},
1153 @code{_Fract},
1154 @code{long _Fract},
1155 @code{long long _Fract},
1156 @code{unsigned short _Fract},
1157 @code{unsigned _Fract},
1158 @code{unsigned long _Fract},
1159 @code{unsigned long long _Fract},
1160 @code{_Sat short _Fract},
1161 @code{_Sat _Fract},
1162 @code{_Sat long _Fract},
1163 @code{_Sat long long _Fract},
1164 @code{_Sat unsigned short _Fract},
1165 @code{_Sat unsigned _Fract},
1166 @code{_Sat unsigned long _Fract},
1167 @code{_Sat unsigned long long _Fract},
1168 @code{short _Accum},
1169 @code{_Accum},
1170 @code{long _Accum},
1171 @code{long long _Accum},
1172 @code{unsigned short _Accum},
1173 @code{unsigned _Accum},
1174 @code{unsigned long _Accum},
1175 @code{unsigned long long _Accum},
1176 @code{_Sat short _Accum},
1177 @code{_Sat _Accum},
1178 @code{_Sat long _Accum},
1179 @code{_Sat long long _Accum},
1180 @code{_Sat unsigned short _Accum},
1181 @code{_Sat unsigned _Accum},
1182 @code{_Sat unsigned long _Accum},
1183 @code{_Sat unsigned long long _Accum}.
1185 Fixed-point data values contain fractional and optional integral parts.
1186 The format of fixed-point data varies and depends on the target machine.
1188 Support for fixed-point types includes:
1189 @itemize @bullet
1190 @item
1191 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1192 @item
1193 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1194 @item
1195 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1196 @item
1197 binary shift operators (@code{<<}, @code{>>})
1198 @item
1199 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1200 @item
1201 equality operators (@code{==}, @code{!=})
1202 @item
1203 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1204 @code{<<=}, @code{>>=})
1205 @item
1206 conversions to and from integer, floating-point, or fixed-point types
1207 @end itemize
1209 Use a suffix in a fixed-point literal constant:
1210 @itemize
1211 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1212 @code{_Sat short _Fract}
1213 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1214 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1215 @code{_Sat long _Fract}
1216 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1217 @code{_Sat long long _Fract}
1218 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1219 @code{_Sat unsigned short _Fract}
1220 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1221 @code{_Sat unsigned _Fract}
1222 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1223 @code{_Sat unsigned long _Fract}
1224 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1225 and @code{_Sat unsigned long long _Fract}
1226 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1227 @code{_Sat short _Accum}
1228 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1229 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1230 @code{_Sat long _Accum}
1231 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1232 @code{_Sat long long _Accum}
1233 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1234 @code{_Sat unsigned short _Accum}
1235 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1236 @code{_Sat unsigned _Accum}
1237 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1238 @code{_Sat unsigned long _Accum}
1239 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1240 and @code{_Sat unsigned long long _Accum}
1241 @end itemize
1243 GCC support of fixed-point types as specified by the draft technical report
1244 is incomplete:
1246 @itemize @bullet
1247 @item
1248 Pragmas to control overflow and rounding behaviors are not implemented.
1249 @end itemize
1251 Fixed-point types are supported by the DWARF 2 debug information format.
1253 @node Named Address Spaces
1254 @section Named Address Spaces
1255 @cindex Named Address Spaces
1257 As an extension, GNU C supports named address spaces as
1258 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1259 address spaces in GCC will evolve as the draft technical report
1260 changes.  Calling conventions for any target might also change.  At
1261 present, only the AVR, SPU, M32C, and RL78 targets support address
1262 spaces other than the generic address space.
1264 Address space identifiers may be used exactly like any other C type
1265 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1266 document for more details.
1268 @anchor{AVR Named Address Spaces}
1269 @subsection AVR Named Address Spaces
1271 On the AVR target, there are several address spaces that can be used
1272 in order to put read-only data into the flash memory and access that
1273 data by means of the special instructions @code{LPM} or @code{ELPM}
1274 needed to read from flash.
1276 Per default, any data including read-only data is located in RAM
1277 (the generic address space) so that non-generic address spaces are
1278 needed to locate read-only data in flash memory
1279 @emph{and} to generate the right instructions to access this data
1280 without using (inline) assembler code.
1282 @table @code
1283 @item __flash
1284 @cindex @code{__flash} AVR Named Address Spaces
1285 The @code{__flash} qualifier locates data in the
1286 @code{.progmem.data} section. Data is read using the @code{LPM}
1287 instruction. Pointers to this address space are 16 bits wide.
1289 @item __flash1
1290 @itemx __flash2
1291 @itemx __flash3
1292 @itemx __flash4
1293 @itemx __flash5
1294 @cindex @code{__flash1} AVR Named Address Spaces
1295 @cindex @code{__flash2} AVR Named Address Spaces
1296 @cindex @code{__flash3} AVR Named Address Spaces
1297 @cindex @code{__flash4} AVR Named Address Spaces
1298 @cindex @code{__flash5} AVR Named Address Spaces
1299 These are 16-bit address spaces locating data in section
1300 @code{.progmem@var{N}.data} where @var{N} refers to
1301 address space @code{__flash@var{N}}.
1302 The compiler sets the @code{RAMPZ} segment register appropriately 
1303 before reading data by means of the @code{ELPM} instruction.
1305 @item __memx
1306 @cindex @code{__memx} AVR Named Address Spaces
1307 This is a 24-bit address space that linearizes flash and RAM:
1308 If the high bit of the address is set, data is read from
1309 RAM using the lower two bytes as RAM address.
1310 If the high bit of the address is clear, data is read from flash
1311 with @code{RAMPZ} set according to the high byte of the address.
1312 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1314 Objects in this address space are located in @code{.progmemx.data}.
1315 @end table
1317 @b{Example}
1319 @smallexample
1320 char my_read (const __flash char ** p)
1322     /* p is a pointer to RAM that points to a pointer to flash.
1323        The first indirection of p reads that flash pointer
1324        from RAM and the second indirection reads a char from this
1325        flash address.  */
1327     return **p;
1330 /* Locate array[] in flash memory */
1331 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1333 int i = 1;
1335 int main (void)
1337    /* Return 17 by reading from flash memory */
1338    return array[array[i]];
1340 @end smallexample
1342 @noindent
1343 For each named address space supported by avr-gcc there is an equally
1344 named but uppercase built-in macro defined. 
1345 The purpose is to facilitate testing if respective address space
1346 support is available or not:
1348 @smallexample
1349 #ifdef __FLASH
1350 const __flash int var = 1;
1352 int read_var (void)
1354     return var;
1356 #else
1357 #include <avr/pgmspace.h> /* From AVR-LibC */
1359 const int var PROGMEM = 1;
1361 int read_var (void)
1363     return (int) pgm_read_word (&var);
1365 #endif /* __FLASH */
1366 @end smallexample
1368 @noindent
1369 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1370 locates data in flash but
1371 accesses to these data read from generic address space, i.e.@:
1372 from RAM,
1373 so that you need special accessors like @code{pgm_read_byte}
1374 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1375 together with attribute @code{progmem}.
1377 @noindent
1378 @b{Limitations and caveats}
1380 @itemize
1381 @item
1382 Reading across the 64@tie{}KiB section boundary of
1383 the @code{__flash} or @code{__flash@var{N}} address spaces
1384 shows undefined behavior. The only address space that
1385 supports reading across the 64@tie{}KiB flash segment boundaries is
1386 @code{__memx}.
1388 @item
1389 If you use one of the @code{__flash@var{N}} address spaces
1390 you must arrange your linker script to locate the
1391 @code{.progmem@var{N}.data} sections according to your needs.
1393 @item
1394 Any data or pointers to the non-generic address spaces must
1395 be qualified as @code{const}, i.e.@: as read-only data.
1396 This still applies if the data in one of these address
1397 spaces like software version number or calibration lookup table are intended to
1398 be changed after load time by, say, a boot loader. In this case
1399 the right qualification is @code{const} @code{volatile} so that the compiler
1400 must not optimize away known values or insert them
1401 as immediates into operands of instructions.
1403 @item
1404 The following code initializes a variable @code{pfoo}
1405 located in static storage with a 24-bit address:
1406 @smallexample
1407 extern const __memx char foo;
1408 const __memx void *pfoo = &foo;
1409 @end smallexample
1411 @noindent
1412 Such code requires at least binutils 2.23, see
1413 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1415 @end itemize
1417 @subsection M32C Named Address Spaces
1418 @cindex @code{__far} M32C Named Address Spaces
1420 On the M32C target, with the R8C and M16C CPU variants, variables
1421 qualified with @code{__far} are accessed using 32-bit addresses in
1422 order to access memory beyond the first 64@tie{}Ki bytes.  If
1423 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1424 effect.
1426 @subsection RL78 Named Address Spaces
1427 @cindex @code{__far} RL78 Named Address Spaces
1429 On the RL78 target, variables qualified with @code{__far} are accessed
1430 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1431 addresses.  Non-far variables are assumed to appear in the topmost
1432 64@tie{}KiB of the address space.
1434 @subsection SPU Named Address Spaces
1435 @cindex @code{__ea} SPU Named Address Spaces
1437 On the SPU target variables may be declared as
1438 belonging to another address space by qualifying the type with the
1439 @code{__ea} address space identifier:
1441 @smallexample
1442 extern int __ea i;
1443 @end smallexample
1445 @noindent 
1446 The compiler generates special code to access the variable @code{i}.
1447 It may use runtime library
1448 support, or generate special machine instructions to access that address
1449 space.
1451 @node Zero Length
1452 @section Arrays of Length Zero
1453 @cindex arrays of length zero
1454 @cindex zero-length arrays
1455 @cindex length-zero arrays
1456 @cindex flexible array members
1458 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1459 last element of a structure that is really a header for a variable-length
1460 object:
1462 @smallexample
1463 struct line @{
1464   int length;
1465   char contents[0];
1468 struct line *thisline = (struct line *)
1469   malloc (sizeof (struct line) + this_length);
1470 thisline->length = this_length;
1471 @end smallexample
1473 In ISO C90, you would have to give @code{contents} a length of 1, which
1474 means either you waste space or complicate the argument to @code{malloc}.
1476 In ISO C99, you would use a @dfn{flexible array member}, which is
1477 slightly different in syntax and semantics:
1479 @itemize @bullet
1480 @item
1481 Flexible array members are written as @code{contents[]} without
1482 the @code{0}.
1484 @item
1485 Flexible array members have incomplete type, and so the @code{sizeof}
1486 operator may not be applied.  As a quirk of the original implementation
1487 of zero-length arrays, @code{sizeof} evaluates to zero.
1489 @item
1490 Flexible array members may only appear as the last member of a
1491 @code{struct} that is otherwise non-empty.
1493 @item
1494 A structure containing a flexible array member, or a union containing
1495 such a structure (possibly recursively), may not be a member of a
1496 structure or an element of an array.  (However, these uses are
1497 permitted by GCC as extensions.)
1498 @end itemize
1500 GCC versions before 3.0 allowed zero-length arrays to be statically
1501 initialized, as if they were flexible arrays.  In addition to those
1502 cases that were useful, it also allowed initializations in situations
1503 that would corrupt later data.  Non-empty initialization of zero-length
1504 arrays is now treated like any case where there are more initializer
1505 elements than the array holds, in that a suitable warning about ``excess
1506 elements in array'' is given, and the excess elements (all of them, in
1507 this case) are ignored.
1509 Instead GCC allows static initialization of flexible array members.
1510 This is equivalent to defining a new structure containing the original
1511 structure followed by an array of sufficient size to contain the data.
1512 E.g.@: in the following, @code{f1} is constructed as if it were declared
1513 like @code{f2}.
1515 @smallexample
1516 struct f1 @{
1517   int x; int y[];
1518 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1520 struct f2 @{
1521   struct f1 f1; int data[3];
1522 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1523 @end smallexample
1525 @noindent
1526 The convenience of this extension is that @code{f1} has the desired
1527 type, eliminating the need to consistently refer to @code{f2.f1}.
1529 This has symmetry with normal static arrays, in that an array of
1530 unknown size is also written with @code{[]}.
1532 Of course, this extension only makes sense if the extra data comes at
1533 the end of a top-level object, as otherwise we would be overwriting
1534 data at subsequent offsets.  To avoid undue complication and confusion
1535 with initialization of deeply nested arrays, we simply disallow any
1536 non-empty initialization except when the structure is the top-level
1537 object.  For example:
1539 @smallexample
1540 struct foo @{ int x; int y[]; @};
1541 struct bar @{ struct foo z; @};
1543 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1544 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1545 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1546 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1547 @end smallexample
1549 @node Empty Structures
1550 @section Structures With No Members
1551 @cindex empty structures
1552 @cindex zero-size structures
1554 GCC permits a C structure to have no members:
1556 @smallexample
1557 struct empty @{
1559 @end smallexample
1561 The structure has size zero.  In C++, empty structures are part
1562 of the language.  G++ treats empty structures as if they had a single
1563 member of type @code{char}.
1565 @node Variable Length
1566 @section Arrays of Variable Length
1567 @cindex variable-length arrays
1568 @cindex arrays of variable length
1569 @cindex VLAs
1571 Variable-length automatic arrays are allowed in ISO C99, and as an
1572 extension GCC accepts them in C90 mode and in C++.  These arrays are
1573 declared like any other automatic arrays, but with a length that is not
1574 a constant expression.  The storage is allocated at the point of
1575 declaration and deallocated when the block scope containing the declaration
1576 exits.  For
1577 example:
1579 @smallexample
1580 FILE *
1581 concat_fopen (char *s1, char *s2, char *mode)
1583   char str[strlen (s1) + strlen (s2) + 1];
1584   strcpy (str, s1);
1585   strcat (str, s2);
1586   return fopen (str, mode);
1588 @end smallexample
1590 @cindex scope of a variable length array
1591 @cindex variable-length array scope
1592 @cindex deallocating variable length arrays
1593 Jumping or breaking out of the scope of the array name deallocates the
1594 storage.  Jumping into the scope is not allowed; you get an error
1595 message for it.
1597 @cindex variable-length array in a structure
1598 As an extension, GCC accepts variable-length arrays as a member of
1599 a structure or a union.  For example:
1601 @smallexample
1602 void
1603 foo (int n)
1605   struct S @{ int x[n]; @};
1607 @end smallexample
1609 @cindex @code{alloca} vs variable-length arrays
1610 You can use the function @code{alloca} to get an effect much like
1611 variable-length arrays.  The function @code{alloca} is available in
1612 many other C implementations (but not in all).  On the other hand,
1613 variable-length arrays are more elegant.
1615 There are other differences between these two methods.  Space allocated
1616 with @code{alloca} exists until the containing @emph{function} returns.
1617 The space for a variable-length array is deallocated as soon as the array
1618 name's scope ends.  (If you use both variable-length arrays and
1619 @code{alloca} in the same function, deallocation of a variable-length array
1620 also deallocates anything more recently allocated with @code{alloca}.)
1622 You can also use variable-length arrays as arguments to functions:
1624 @smallexample
1625 struct entry
1626 tester (int len, char data[len][len])
1628   /* @r{@dots{}} */
1630 @end smallexample
1632 The length of an array is computed once when the storage is allocated
1633 and is remembered for the scope of the array in case you access it with
1634 @code{sizeof}.
1636 If you want to pass the array first and the length afterward, you can
1637 use a forward declaration in the parameter list---another GNU extension.
1639 @smallexample
1640 struct entry
1641 tester (int len; char data[len][len], int len)
1643   /* @r{@dots{}} */
1645 @end smallexample
1647 @cindex parameter forward declaration
1648 The @samp{int len} before the semicolon is a @dfn{parameter forward
1649 declaration}, and it serves the purpose of making the name @code{len}
1650 known when the declaration of @code{data} is parsed.
1652 You can write any number of such parameter forward declarations in the
1653 parameter list.  They can be separated by commas or semicolons, but the
1654 last one must end with a semicolon, which is followed by the ``real''
1655 parameter declarations.  Each forward declaration must match a ``real''
1656 declaration in parameter name and data type.  ISO C99 does not support
1657 parameter forward declarations.
1659 @node Variadic Macros
1660 @section Macros with a Variable Number of Arguments.
1661 @cindex variable number of arguments
1662 @cindex macro with variable arguments
1663 @cindex rest argument (in macro)
1664 @cindex variadic macros
1666 In the ISO C standard of 1999, a macro can be declared to accept a
1667 variable number of arguments much as a function can.  The syntax for
1668 defining the macro is similar to that of a function.  Here is an
1669 example:
1671 @smallexample
1672 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1673 @end smallexample
1675 @noindent
1676 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1677 such a macro, it represents the zero or more tokens until the closing
1678 parenthesis that ends the invocation, including any commas.  This set of
1679 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1680 wherever it appears.  See the CPP manual for more information.
1682 GCC has long supported variadic macros, and used a different syntax that
1683 allowed you to give a name to the variable arguments just like any other
1684 argument.  Here is an example:
1686 @smallexample
1687 #define debug(format, args...) fprintf (stderr, format, args)
1688 @end smallexample
1690 @noindent
1691 This is in all ways equivalent to the ISO C example above, but arguably
1692 more readable and descriptive.
1694 GNU CPP has two further variadic macro extensions, and permits them to
1695 be used with either of the above forms of macro definition.
1697 In standard C, you are not allowed to leave the variable argument out
1698 entirely; but you are allowed to pass an empty argument.  For example,
1699 this invocation is invalid in ISO C, because there is no comma after
1700 the string:
1702 @smallexample
1703 debug ("A message")
1704 @end smallexample
1706 GNU CPP permits you to completely omit the variable arguments in this
1707 way.  In the above examples, the compiler would complain, though since
1708 the expansion of the macro still has the extra comma after the format
1709 string.
1711 To help solve this problem, CPP behaves specially for variable arguments
1712 used with the token paste operator, @samp{##}.  If instead you write
1714 @smallexample
1715 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1716 @end smallexample
1718 @noindent
1719 and if the variable arguments are omitted or empty, the @samp{##}
1720 operator causes the preprocessor to remove the comma before it.  If you
1721 do provide some variable arguments in your macro invocation, GNU CPP
1722 does not complain about the paste operation and instead places the
1723 variable arguments after the comma.  Just like any other pasted macro
1724 argument, these arguments are not macro expanded.
1726 @node Escaped Newlines
1727 @section Slightly Looser Rules for Escaped Newlines
1728 @cindex escaped newlines
1729 @cindex newlines (escaped)
1731 Recently, the preprocessor has relaxed its treatment of escaped
1732 newlines.  Previously, the newline had to immediately follow a
1733 backslash.  The current implementation allows whitespace in the form
1734 of spaces, horizontal and vertical tabs, and form feeds between the
1735 backslash and the subsequent newline.  The preprocessor issues a
1736 warning, but treats it as a valid escaped newline and combines the two
1737 lines to form a single logical line.  This works within comments and
1738 tokens, as well as between tokens.  Comments are @emph{not} treated as
1739 whitespace for the purposes of this relaxation, since they have not
1740 yet been replaced with spaces.
1742 @node Subscripting
1743 @section Non-Lvalue Arrays May Have Subscripts
1744 @cindex subscripting
1745 @cindex arrays, non-lvalue
1747 @cindex subscripting and function values
1748 In ISO C99, arrays that are not lvalues still decay to pointers, and
1749 may be subscripted, although they may not be modified or used after
1750 the next sequence point and the unary @samp{&} operator may not be
1751 applied to them.  As an extension, GNU C allows such arrays to be
1752 subscripted in C90 mode, though otherwise they do not decay to
1753 pointers outside C99 mode.  For example,
1754 this is valid in GNU C though not valid in C90:
1756 @smallexample
1757 @group
1758 struct foo @{int a[4];@};
1760 struct foo f();
1762 bar (int index)
1764   return f().a[index];
1766 @end group
1767 @end smallexample
1769 @node Pointer Arith
1770 @section Arithmetic on @code{void}- and Function-Pointers
1771 @cindex void pointers, arithmetic
1772 @cindex void, size of pointer to
1773 @cindex function pointers, arithmetic
1774 @cindex function, size of pointer to
1776 In GNU C, addition and subtraction operations are supported on pointers to
1777 @code{void} and on pointers to functions.  This is done by treating the
1778 size of a @code{void} or of a function as 1.
1780 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1781 and on function types, and returns 1.
1783 @opindex Wpointer-arith
1784 The option @option{-Wpointer-arith} requests a warning if these extensions
1785 are used.
1787 @node Initializers
1788 @section Non-Constant Initializers
1789 @cindex initializers, non-constant
1790 @cindex non-constant initializers
1792 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1793 automatic variable are not required to be constant expressions in GNU C@.
1794 Here is an example of an initializer with run-time varying elements:
1796 @smallexample
1797 foo (float f, float g)
1799   float beat_freqs[2] = @{ f-g, f+g @};
1800   /* @r{@dots{}} */
1802 @end smallexample
1804 @node Compound Literals
1805 @section Compound Literals
1806 @cindex constructor expressions
1807 @cindex initializations in expressions
1808 @cindex structures, constructor expression
1809 @cindex expressions, constructor
1810 @cindex compound literals
1811 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1813 ISO C99 supports compound literals.  A compound literal looks like
1814 a cast containing an initializer.  Its value is an object of the
1815 type specified in the cast, containing the elements specified in
1816 the initializer; it is an lvalue.  As an extension, GCC supports
1817 compound literals in C90 mode and in C++, though the semantics are
1818 somewhat different in C++.
1820 Usually, the specified type is a structure.  Assume that
1821 @code{struct foo} and @code{structure} are declared as shown:
1823 @smallexample
1824 struct foo @{int a; char b[2];@} structure;
1825 @end smallexample
1827 @noindent
1828 Here is an example of constructing a @code{struct foo} with a compound literal:
1830 @smallexample
1831 structure = ((struct foo) @{x + y, 'a', 0@});
1832 @end smallexample
1834 @noindent
1835 This is equivalent to writing the following:
1837 @smallexample
1839   struct foo temp = @{x + y, 'a', 0@};
1840   structure = temp;
1842 @end smallexample
1844 You can also construct an array, though this is dangerous in C++, as
1845 explained below.  If all the elements of the compound literal are
1846 (made up of) simple constant expressions, suitable for use in
1847 initializers of objects of static storage duration, then the compound
1848 literal can be coerced to a pointer to its first element and used in
1849 such an initializer, as shown here:
1851 @smallexample
1852 char **foo = (char *[]) @{ "x", "y", "z" @};
1853 @end smallexample
1855 Compound literals for scalar types and union types are
1856 also allowed, but then the compound literal is equivalent
1857 to a cast.
1859 As a GNU extension, GCC allows initialization of objects with static storage
1860 duration by compound literals (which is not possible in ISO C99, because
1861 the initializer is not a constant).
1862 It is handled as if the object is initialized only with the bracket
1863 enclosed list if the types of the compound literal and the object match.
1864 The initializer list of the compound literal must be constant.
1865 If the object being initialized has array type of unknown size, the size is
1866 determined by compound literal size.
1868 @smallexample
1869 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1870 static int y[] = (int []) @{1, 2, 3@};
1871 static int z[] = (int [3]) @{1@};
1872 @end smallexample
1874 @noindent
1875 The above lines are equivalent to the following:
1876 @smallexample
1877 static struct foo x = @{1, 'a', 'b'@};
1878 static int y[] = @{1, 2, 3@};
1879 static int z[] = @{1, 0, 0@};
1880 @end smallexample
1882 In C, a compound literal designates an unnamed object with static or
1883 automatic storage duration.  In C++, a compound literal designates a
1884 temporary object, which only lives until the end of its
1885 full-expression.  As a result, well-defined C code that takes the
1886 address of a subobject of a compound literal can be undefined in C++.
1887 For instance, if the array compound literal example above appeared
1888 inside a function, any subsequent use of @samp{foo} in C++ has
1889 undefined behavior because the lifetime of the array ends after the
1890 declaration of @samp{foo}.  As a result, the C++ compiler now rejects
1891 the conversion of a temporary array to a pointer.
1893 As an optimization, the C++ compiler sometimes gives array compound
1894 literals longer lifetimes: when the array either appears outside a
1895 function or has const-qualified type.  If @samp{foo} and its
1896 initializer had elements of @samp{char *const} type rather than
1897 @samp{char *}, or if @samp{foo} were a global variable, the array
1898 would have static storage duration.  But it is probably safest just to
1899 avoid the use of array compound literals in code compiled as C++.
1901 @node Designated Inits
1902 @section Designated Initializers
1903 @cindex initializers with labeled elements
1904 @cindex labeled elements in initializers
1905 @cindex case labels in initializers
1906 @cindex designated initializers
1908 Standard C90 requires the elements of an initializer to appear in a fixed
1909 order, the same as the order of the elements in the array or structure
1910 being initialized.
1912 In ISO C99 you can give the elements in any order, specifying the array
1913 indices or structure field names they apply to, and GNU C allows this as
1914 an extension in C90 mode as well.  This extension is not
1915 implemented in GNU C++.
1917 To specify an array index, write
1918 @samp{[@var{index}] =} before the element value.  For example,
1920 @smallexample
1921 int a[6] = @{ [4] = 29, [2] = 15 @};
1922 @end smallexample
1924 @noindent
1925 is equivalent to
1927 @smallexample
1928 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1929 @end smallexample
1931 @noindent
1932 The index values must be constant expressions, even if the array being
1933 initialized is automatic.
1935 An alternative syntax for this that has been obsolete since GCC 2.5 but
1936 GCC still accepts is to write @samp{[@var{index}]} before the element
1937 value, with no @samp{=}.
1939 To initialize a range of elements to the same value, write
1940 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1941 extension.  For example,
1943 @smallexample
1944 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1945 @end smallexample
1947 @noindent
1948 If the value in it has side-effects, the side-effects happen only once,
1949 not for each initialized field by the range initializer.
1951 @noindent
1952 Note that the length of the array is the highest value specified
1953 plus one.
1955 In a structure initializer, specify the name of a field to initialize
1956 with @samp{.@var{fieldname} =} before the element value.  For example,
1957 given the following structure,
1959 @smallexample
1960 struct point @{ int x, y; @};
1961 @end smallexample
1963 @noindent
1964 the following initialization
1966 @smallexample
1967 struct point p = @{ .y = yvalue, .x = xvalue @};
1968 @end smallexample
1970 @noindent
1971 is equivalent to
1973 @smallexample
1974 struct point p = @{ xvalue, yvalue @};
1975 @end smallexample
1977 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1978 @samp{@var{fieldname}:}, as shown here:
1980 @smallexample
1981 struct point p = @{ y: yvalue, x: xvalue @};
1982 @end smallexample
1984 Omitted field members are implicitly initialized the same as objects
1985 that have static storage duration.
1987 @cindex designators
1988 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1989 @dfn{designator}.  You can also use a designator (or the obsolete colon
1990 syntax) when initializing a union, to specify which element of the union
1991 should be used.  For example,
1993 @smallexample
1994 union foo @{ int i; double d; @};
1996 union foo f = @{ .d = 4 @};
1997 @end smallexample
1999 @noindent
2000 converts 4 to a @code{double} to store it in the union using
2001 the second element.  By contrast, casting 4 to type @code{union foo}
2002 stores it into the union as the integer @code{i}, since it is
2003 an integer.  (@xref{Cast to Union}.)
2005 You can combine this technique of naming elements with ordinary C
2006 initialization of successive elements.  Each initializer element that
2007 does not have a designator applies to the next consecutive element of the
2008 array or structure.  For example,
2010 @smallexample
2011 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2012 @end smallexample
2014 @noindent
2015 is equivalent to
2017 @smallexample
2018 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2019 @end smallexample
2021 Labeling the elements of an array initializer is especially useful
2022 when the indices are characters or belong to an @code{enum} type.
2023 For example:
2025 @smallexample
2026 int whitespace[256]
2027   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2028       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2029 @end smallexample
2031 @cindex designator lists
2032 You can also write a series of @samp{.@var{fieldname}} and
2033 @samp{[@var{index}]} designators before an @samp{=} to specify a
2034 nested subobject to initialize; the list is taken relative to the
2035 subobject corresponding to the closest surrounding brace pair.  For
2036 example, with the @samp{struct point} declaration above:
2038 @smallexample
2039 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2040 @end smallexample
2042 @noindent
2043 If the same field is initialized multiple times, it has the value from
2044 the last initialization.  If any such overridden initialization has
2045 side-effect, it is unspecified whether the side-effect happens or not.
2046 Currently, GCC discards them and issues a warning.
2048 @node Case Ranges
2049 @section Case Ranges
2050 @cindex case ranges
2051 @cindex ranges in case statements
2053 You can specify a range of consecutive values in a single @code{case} label,
2054 like this:
2056 @smallexample
2057 case @var{low} ... @var{high}:
2058 @end smallexample
2060 @noindent
2061 This has the same effect as the proper number of individual @code{case}
2062 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2064 This feature is especially useful for ranges of ASCII character codes:
2066 @smallexample
2067 case 'A' ... 'Z':
2068 @end smallexample
2070 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2071 it may be parsed wrong when you use it with integer values.  For example,
2072 write this:
2074 @smallexample
2075 case 1 ... 5:
2076 @end smallexample
2078 @noindent
2079 rather than this:
2081 @smallexample
2082 case 1...5:
2083 @end smallexample
2085 @node Cast to Union
2086 @section Cast to a Union Type
2087 @cindex cast to a union
2088 @cindex union, casting to a
2090 A cast to union type is similar to other casts, except that the type
2091 specified is a union type.  You can specify the type either with
2092 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2093 a constructor, not a cast, and hence does not yield an lvalue like
2094 normal casts.  (@xref{Compound Literals}.)
2096 The types that may be cast to the union type are those of the members
2097 of the union.  Thus, given the following union and variables:
2099 @smallexample
2100 union foo @{ int i; double d; @};
2101 int x;
2102 double y;
2103 @end smallexample
2105 @noindent
2106 both @code{x} and @code{y} can be cast to type @code{union foo}.
2108 Using the cast as the right-hand side of an assignment to a variable of
2109 union type is equivalent to storing in a member of the union:
2111 @smallexample
2112 union foo u;
2113 /* @r{@dots{}} */
2114 u = (union foo) x  @equiv{}  u.i = x
2115 u = (union foo) y  @equiv{}  u.d = y
2116 @end smallexample
2118 You can also use the union cast as a function argument:
2120 @smallexample
2121 void hack (union foo);
2122 /* @r{@dots{}} */
2123 hack ((union foo) x);
2124 @end smallexample
2126 @node Mixed Declarations
2127 @section Mixed Declarations and Code
2128 @cindex mixed declarations and code
2129 @cindex declarations, mixed with code
2130 @cindex code, mixed with declarations
2132 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2133 within compound statements.  As an extension, GNU C also allows this in
2134 C90 mode.  For example, you could do:
2136 @smallexample
2137 int i;
2138 /* @r{@dots{}} */
2139 i++;
2140 int j = i + 2;
2141 @end smallexample
2143 Each identifier is visible from where it is declared until the end of
2144 the enclosing block.
2146 @node Function Attributes
2147 @section Declaring Attributes of Functions
2148 @cindex function attributes
2149 @cindex declaring attributes of functions
2150 @cindex functions that never return
2151 @cindex functions that return more than once
2152 @cindex functions that have no side effects
2153 @cindex functions in arbitrary sections
2154 @cindex functions that behave like malloc
2155 @cindex @code{volatile} applied to function
2156 @cindex @code{const} applied to function
2157 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2158 @cindex functions with non-null pointer arguments
2159 @cindex functions that are passed arguments in registers on the 386
2160 @cindex functions that pop the argument stack on the 386
2161 @cindex functions that do not pop the argument stack on the 386
2162 @cindex functions that have different compilation options on the 386
2163 @cindex functions that have different optimization options
2164 @cindex functions that are dynamically resolved
2166 In GNU C, you declare certain things about functions called in your program
2167 which help the compiler optimize function calls and check your code more
2168 carefully.
2170 The keyword @code{__attribute__} allows you to specify special
2171 attributes when making a declaration.  This keyword is followed by an
2172 attribute specification inside double parentheses.  The following
2173 attributes are currently defined for functions on all targets:
2174 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2175 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2176 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2177 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2178 @code{no_instrument_function}, @code{no_split_stack},
2179 @code{section}, @code{constructor},
2180 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2181 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2182 @code{warn_unused_result}, @code{nonnull},
2183 @code{returns_nonnull}, @code{gnu_inline},
2184 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2185 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2186 @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
2187 @code{bnd_instrument},
2188 @code{error} and @code{warning}.
2189 Several other attributes are defined for functions on particular
2190 target systems.  Other attributes, including @code{section} are
2191 supported for variables declarations (@pxref{Variable Attributes}),
2192 labels (@pxref{Label Attributes})
2193 and for types (@pxref{Type Attributes}).
2195 GCC plugins may provide their own attributes.
2197 You may also specify attributes with @samp{__} preceding and following
2198 each keyword.  This allows you to use them in header files without
2199 being concerned about a possible macro of the same name.  For example,
2200 you may use @code{__noreturn__} instead of @code{noreturn}.
2202 @xref{Attribute Syntax}, for details of the exact syntax for using
2203 attributes.
2205 @table @code
2206 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2208 @item alias ("@var{target}")
2209 @cindex @code{alias} attribute
2210 The @code{alias} attribute causes the declaration to be emitted as an
2211 alias for another symbol, which must be specified.  For instance,
2213 @smallexample
2214 void __f () @{ /* @r{Do something.} */; @}
2215 void f () __attribute__ ((weak, alias ("__f")));
2216 @end smallexample
2218 @noindent
2219 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2220 mangled name for the target must be used.  It is an error if @samp{__f}
2221 is not defined in the same translation unit.
2223 Not all target machines support this attribute.
2225 @item aligned (@var{alignment})
2226 @cindex @code{aligned} attribute
2227 This attribute specifies a minimum alignment for the function,
2228 measured in bytes.
2230 You cannot use this attribute to decrease the alignment of a function,
2231 only to increase it.  However, when you explicitly specify a function
2232 alignment this overrides the effect of the
2233 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2234 function.
2236 Note that the effectiveness of @code{aligned} attributes may be
2237 limited by inherent limitations in your linker.  On many systems, the
2238 linker is only able to arrange for functions to be aligned up to a
2239 certain maximum alignment.  (For some linkers, the maximum supported
2240 alignment may be very very small.)  See your linker documentation for
2241 further information.
2243 The @code{aligned} attribute can also be used for variables and fields
2244 (@pxref{Variable Attributes}.)
2246 @item alloc_size
2247 @cindex @code{alloc_size} attribute
2248 The @code{alloc_size} attribute is used to tell the compiler that the
2249 function return value points to memory, where the size is given by
2250 one or two of the functions parameters.  GCC uses this
2251 information to improve the correctness of @code{__builtin_object_size}.
2253 The function parameter(s) denoting the allocated size are specified by
2254 one or two integer arguments supplied to the attribute.  The allocated size
2255 is either the value of the single function argument specified or the product
2256 of the two function arguments specified.  Argument numbering starts at
2257 one.
2259 For instance,
2261 @smallexample
2262 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2263 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2264 @end smallexample
2266 @noindent
2267 declares that @code{my_calloc} returns memory of the size given by
2268 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2269 of the size given by parameter 2.
2271 @item alloc_align
2272 @cindex @code{alloc_align} attribute
2273 The @code{alloc_align} attribute is used to tell the compiler that the
2274 function return value points to memory, where the returned pointer minimum
2275 alignment is given by one of the functions parameters.  GCC uses this
2276 information to improve pointer alignment analysis.
2278 The function parameter denoting the allocated alignment is specified by
2279 one integer argument, whose number is the argument of the attribute.
2280 Argument numbering starts at one.
2282 For instance,
2284 @smallexample
2285 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2286 @end smallexample
2288 @noindent
2289 declares that @code{my_memalign} returns memory with minimum alignment
2290 given by parameter 1.
2292 @item assume_aligned
2293 @cindex @code{assume_aligned} attribute
2294 The @code{assume_aligned} attribute is used to tell the compiler that the
2295 function return value points to memory, where the returned pointer minimum
2296 alignment is given by the first argument.
2297 If the attribute has two arguments, the second argument is misalignment offset.
2299 For instance
2301 @smallexample
2302 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2303 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2304 @end smallexample
2306 @noindent
2307 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2308 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2309 to 8.
2311 @item always_inline
2312 @cindex @code{always_inline} function attribute
2313 Generally, functions are not inlined unless optimization is specified.
2314 For functions declared inline, this attribute inlines the function
2315 independent of any restrictions that otherwise apply to inlining.
2316 Failure to inline such a function is diagnosed as an error.
2317 Note that if such a function is called indirectly the compiler may
2318 or may not inline it depending on optimization level and a failure
2319 to inline an indirect call may or may not be diagnosed.
2321 @item gnu_inline
2322 @cindex @code{gnu_inline} function attribute
2323 This attribute should be used with a function that is also declared
2324 with the @code{inline} keyword.  It directs GCC to treat the function
2325 as if it were defined in gnu90 mode even when compiling in C99 or
2326 gnu99 mode.
2328 If the function is declared @code{extern}, then this definition of the
2329 function is used only for inlining.  In no case is the function
2330 compiled as a standalone function, not even if you take its address
2331 explicitly.  Such an address becomes an external reference, as if you
2332 had only declared the function, and had not defined it.  This has
2333 almost the effect of a macro.  The way to use this is to put a
2334 function definition in a header file with this attribute, and put
2335 another copy of the function, without @code{extern}, in a library
2336 file.  The definition in the header file causes most calls to the
2337 function to be inlined.  If any uses of the function remain, they
2338 refer to the single copy in the library.  Note that the two
2339 definitions of the functions need not be precisely the same, although
2340 if they do not have the same effect your program may behave oddly.
2342 In C, if the function is neither @code{extern} nor @code{static}, then
2343 the function is compiled as a standalone function, as well as being
2344 inlined where possible.
2346 This is how GCC traditionally handled functions declared
2347 @code{inline}.  Since ISO C99 specifies a different semantics for
2348 @code{inline}, this function attribute is provided as a transition
2349 measure and as a useful feature in its own right.  This attribute is
2350 available in GCC 4.1.3 and later.  It is available if either of the
2351 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2352 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2353 Function is As Fast As a Macro}.
2355 In C++, this attribute does not depend on @code{extern} in any way,
2356 but it still requires the @code{inline} keyword to enable its special
2357 behavior.
2359 @item artificial
2360 @cindex @code{artificial} function attribute
2361 This attribute is useful for small inline wrappers that if possible
2362 should appear during debugging as a unit.  Depending on the debug
2363 info format it either means marking the function as artificial
2364 or using the caller location for all instructions within the inlined
2365 body.
2367 @item bank_switch
2368 @cindex interrupt handler functions
2369 When added to an interrupt handler with the M32C port, causes the
2370 prologue and epilogue to use bank switching to preserve the registers
2371 rather than saving them on the stack.
2373 @item flatten
2374 @cindex @code{flatten} function attribute
2375 Generally, inlining into a function is limited.  For a function marked with
2376 this attribute, every call inside this function is inlined, if possible.
2377 Whether the function itself is considered for inlining depends on its size and
2378 the current inlining parameters.
2380 @item error ("@var{message}")
2381 @cindex @code{error} function attribute
2382 If this attribute is used on a function declaration and a call to such a function
2383 is not eliminated through dead code elimination or other optimizations, an error
2384 that includes @var{message} is diagnosed.  This is useful
2385 for compile-time checking, especially together with @code{__builtin_constant_p}
2386 and inline functions where checking the inline function arguments is not
2387 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2388 While it is possible to leave the function undefined and thus invoke
2389 a link failure, when using this attribute the problem is diagnosed
2390 earlier and with exact location of the call even in presence of inline
2391 functions or when not emitting debugging information.
2393 @item warning ("@var{message}")
2394 @cindex @code{warning} function attribute
2395 If this attribute is used on a function declaration and a call to such a function
2396 is not eliminated through dead code elimination or other optimizations, a warning
2397 that includes @var{message} is diagnosed.  This is useful
2398 for compile-time checking, especially together with @code{__builtin_constant_p}
2399 and inline functions.  While it is possible to define the function with
2400 a message in @code{.gnu.warning*} section, when using this attribute the problem
2401 is diagnosed earlier and with exact location of the call even in presence
2402 of inline functions or when not emitting debugging information.
2404 @item cdecl
2405 @cindex functions that do pop the argument stack on the 386
2406 @opindex mrtd
2407 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2408 assume that the calling function pops off the stack space used to
2409 pass arguments.  This is
2410 useful to override the effects of the @option{-mrtd} switch.
2412 @item const
2413 @cindex @code{const} function attribute
2414 Many functions do not examine any values except their arguments, and
2415 have no effects except the return value.  Basically this is just slightly
2416 more strict class than the @code{pure} attribute below, since function is not
2417 allowed to read global memory.
2419 @cindex pointer arguments
2420 Note that a function that has pointer arguments and examines the data
2421 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2422 function that calls a non-@code{const} function usually must not be
2423 @code{const}.  It does not make sense for a @code{const} function to
2424 return @code{void}.
2426 The attribute @code{const} is not implemented in GCC versions earlier
2427 than 2.5.  An alternative way to declare that a function has no side
2428 effects, which works in the current version and in some older versions,
2429 is as follows:
2431 @smallexample
2432 typedef int intfn ();
2434 extern const intfn square;
2435 @end smallexample
2437 @noindent
2438 This approach does not work in GNU C++ from 2.6.0 on, since the language
2439 specifies that the @samp{const} must be attached to the return value.
2441 @item constructor
2442 @itemx destructor
2443 @itemx constructor (@var{priority})
2444 @itemx destructor (@var{priority})
2445 @cindex @code{constructor} function attribute
2446 @cindex @code{destructor} function attribute
2447 The @code{constructor} attribute causes the function to be called
2448 automatically before execution enters @code{main ()}.  Similarly, the
2449 @code{destructor} attribute causes the function to be called
2450 automatically after @code{main ()} completes or @code{exit ()} is
2451 called.  Functions with these attributes are useful for
2452 initializing data that is used implicitly during the execution of
2453 the program.
2455 You may provide an optional integer priority to control the order in
2456 which constructor and destructor functions are run.  A constructor
2457 with a smaller priority number runs before a constructor with a larger
2458 priority number; the opposite relationship holds for destructors.  So,
2459 if you have a constructor that allocates a resource and a destructor
2460 that deallocates the same resource, both functions typically have the
2461 same priority.  The priorities for constructor and destructor
2462 functions are the same as those specified for namespace-scope C++
2463 objects (@pxref{C++ Attributes}).
2465 These attributes are not currently implemented for Objective-C@.
2467 @item deprecated
2468 @itemx deprecated (@var{msg})
2469 @cindex @code{deprecated} attribute.
2470 The @code{deprecated} attribute results in a warning if the function
2471 is used anywhere in the source file.  This is useful when identifying
2472 functions that are expected to be removed in a future version of a
2473 program.  The warning also includes the location of the declaration
2474 of the deprecated function, to enable users to easily find further
2475 information about why the function is deprecated, or what they should
2476 do instead.  Note that the warnings only occurs for uses:
2478 @smallexample
2479 int old_fn () __attribute__ ((deprecated));
2480 int old_fn ();
2481 int (*fn_ptr)() = old_fn;
2482 @end smallexample
2484 @noindent
2485 results in a warning on line 3 but not line 2.  The optional @var{msg}
2486 argument, which must be a string, is printed in the warning if
2487 present.
2489 The @code{deprecated} attribute can also be used for variables and
2490 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2492 @item disinterrupt
2493 @cindex @code{disinterrupt} attribute
2494 On Epiphany and MeP targets, this attribute causes the compiler to emit
2495 instructions to disable interrupts for the duration of the given
2496 function.
2498 @item dllexport
2499 @cindex @code{__declspec(dllexport)}
2500 On Microsoft Windows targets and Symbian OS targets the
2501 @code{dllexport} attribute causes the compiler to provide a global
2502 pointer to a pointer in a DLL, so that it can be referenced with the
2503 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2504 name is formed by combining @code{_imp__} and the function or variable
2505 name.
2507 You can use @code{__declspec(dllexport)} as a synonym for
2508 @code{__attribute__ ((dllexport))} for compatibility with other
2509 compilers.
2511 On systems that support the @code{visibility} attribute, this
2512 attribute also implies ``default'' visibility.  It is an error to
2513 explicitly specify any other visibility.
2515 In previous versions of GCC, the @code{dllexport} attribute was ignored
2516 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2517 had been used.  The default behavior now is to emit all dllexported
2518 inline functions; however, this can cause object file-size bloat, in
2519 which case the old behavior can be restored by using
2520 @option{-fno-keep-inline-dllexport}.
2522 The attribute is also ignored for undefined symbols.
2524 When applied to C++ classes, the attribute marks defined non-inlined
2525 member functions and static data members as exports.  Static consts
2526 initialized in-class are not marked unless they are also defined
2527 out-of-class.
2529 For Microsoft Windows targets there are alternative methods for
2530 including the symbol in the DLL's export table such as using a
2531 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2532 the @option{--export-all} linker flag.
2534 @item dllimport
2535 @cindex @code{__declspec(dllimport)}
2536 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2537 attribute causes the compiler to reference a function or variable via
2538 a global pointer to a pointer that is set up by the DLL exporting the
2539 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2540 targets, the pointer name is formed by combining @code{_imp__} and the
2541 function or variable name.
2543 You can use @code{__declspec(dllimport)} as a synonym for
2544 @code{__attribute__ ((dllimport))} for compatibility with other
2545 compilers.
2547 On systems that support the @code{visibility} attribute, this
2548 attribute also implies ``default'' visibility.  It is an error to
2549 explicitly specify any other visibility.
2551 Currently, the attribute is ignored for inlined functions.  If the
2552 attribute is applied to a symbol @emph{definition}, an error is reported.
2553 If a symbol previously declared @code{dllimport} is later defined, the
2554 attribute is ignored in subsequent references, and a warning is emitted.
2555 The attribute is also overridden by a subsequent declaration as
2556 @code{dllexport}.
2558 When applied to C++ classes, the attribute marks non-inlined
2559 member functions and static data members as imports.  However, the
2560 attribute is ignored for virtual methods to allow creation of vtables
2561 using thunks.
2563 On the SH Symbian OS target the @code{dllimport} attribute also has
2564 another affect---it can cause the vtable and run-time type information
2565 for a class to be exported.  This happens when the class has a
2566 dllimported constructor or a non-inline, non-pure virtual function
2567 and, for either of those two conditions, the class also has an inline
2568 constructor or destructor and has a key function that is defined in
2569 the current translation unit.
2571 For Microsoft Windows targets the use of the @code{dllimport}
2572 attribute on functions is not necessary, but provides a small
2573 performance benefit by eliminating a thunk in the DLL@.  The use of the
2574 @code{dllimport} attribute on imported variables was required on older
2575 versions of the GNU linker, but can now be avoided by passing the
2576 @option{--enable-auto-import} switch to the GNU linker.  As with
2577 functions, using the attribute for a variable eliminates a thunk in
2578 the DLL@.
2580 One drawback to using this attribute is that a pointer to a
2581 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2582 address. However, a pointer to a @emph{function} with the
2583 @code{dllimport} attribute can be used as a constant initializer; in
2584 this case, the address of a stub function in the import lib is
2585 referenced.  On Microsoft Windows targets, the attribute can be disabled
2586 for functions by setting the @option{-mnop-fun-dllimport} flag.
2588 @item eightbit_data
2589 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2590 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2591 variable should be placed into the eight-bit data section.
2592 The compiler generates more efficient code for certain operations
2593 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2594 256 bytes of data.
2596 You must use GAS and GLD from GNU binutils version 2.7 or later for
2597 this attribute to work correctly.
2599 @item exception
2600 @cindex exception handler functions
2601 Use this attribute on the NDS32 target to indicate that the specified function
2602 is an exception handler.  The compiler will generate corresponding sections
2603 for use in an exception handler.
2605 @item exception_handler
2606 @cindex exception handler functions on the Blackfin processor
2607 Use this attribute on the Blackfin to indicate that the specified function
2608 is an exception handler.  The compiler generates function entry and
2609 exit sequences suitable for use in an exception handler when this
2610 attribute is present.
2612 @item externally_visible
2613 @cindex @code{externally_visible} attribute.
2614 This attribute, attached to a global variable or function, nullifies
2615 the effect of the @option{-fwhole-program} command-line option, so the
2616 object remains visible outside the current compilation unit.
2618 If @option{-fwhole-program} is used together with @option{-flto} and 
2619 @command{gold} is used as the linker plugin, 
2620 @code{externally_visible} attributes are automatically added to functions 
2621 (not variable yet due to a current @command{gold} issue) 
2622 that are accessed outside of LTO objects according to resolution file
2623 produced by @command{gold}.
2624 For other linkers that cannot generate resolution file,
2625 explicit @code{externally_visible} attributes are still necessary.
2627 @item far
2628 @cindex functions that handle memory bank switching
2629 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2630 use a calling convention that takes care of switching memory banks when
2631 entering and leaving a function.  This calling convention is also the
2632 default when using the @option{-mlong-calls} option.
2634 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2635 to call and return from a function.
2637 On 68HC11 the compiler generates a sequence of instructions
2638 to invoke a board-specific routine to switch the memory bank and call the
2639 real function.  The board-specific routine simulates a @code{call}.
2640 At the end of a function, it jumps to a board-specific routine
2641 instead of using @code{rts}.  The board-specific return routine simulates
2642 the @code{rtc}.
2644 On MeP targets this causes the compiler to use a calling convention
2645 that assumes the called function is too far away for the built-in
2646 addressing modes.
2648 @item fast_interrupt
2649 @cindex interrupt handler functions
2650 Use this attribute on the M32C and RX ports to indicate that the specified
2651 function is a fast interrupt handler.  This is just like the
2652 @code{interrupt} attribute, except that @code{freit} is used to return
2653 instead of @code{reit}.
2655 @item fastcall
2656 @cindex functions that pop the argument stack on the 386
2657 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2658 pass the first argument (if of integral type) in the register ECX and
2659 the second argument (if of integral type) in the register EDX@.  Subsequent
2660 and other typed arguments are passed on the stack.  The called function
2661 pops the arguments off the stack.  If the number of arguments is variable all
2662 arguments are pushed on the stack.
2664 @item thiscall
2665 @cindex functions that pop the argument stack on the 386
2666 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2667 pass the first argument (if of integral type) in the register ECX.
2668 Subsequent and other typed arguments are passed on the stack. The called
2669 function pops the arguments off the stack.
2670 If the number of arguments is variable all arguments are pushed on the
2671 stack.
2672 The @code{thiscall} attribute is intended for C++ non-static member functions.
2673 As a GCC extension, this calling convention can be used for C functions
2674 and for static member methods.
2676 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2677 @cindex @code{format} function attribute
2678 @opindex Wformat
2679 The @code{format} attribute specifies that a function takes @code{printf},
2680 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2681 should be type-checked against a format string.  For example, the
2682 declaration:
2684 @smallexample
2685 extern int
2686 my_printf (void *my_object, const char *my_format, ...)
2687       __attribute__ ((format (printf, 2, 3)));
2688 @end smallexample
2690 @noindent
2691 causes the compiler to check the arguments in calls to @code{my_printf}
2692 for consistency with the @code{printf} style format string argument
2693 @code{my_format}.
2695 The parameter @var{archetype} determines how the format string is
2696 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2697 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2698 @code{strfmon}.  (You can also use @code{__printf__},
2699 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2700 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2701 @code{ms_strftime} are also present.
2702 @var{archetype} values such as @code{printf} refer to the formats accepted
2703 by the system's C runtime library,
2704 while values prefixed with @samp{gnu_} always refer
2705 to the formats accepted by the GNU C Library.  On Microsoft Windows
2706 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2707 @file{msvcrt.dll} library.
2708 The parameter @var{string-index}
2709 specifies which argument is the format string argument (starting
2710 from 1), while @var{first-to-check} is the number of the first
2711 argument to check against the format string.  For functions
2712 where the arguments are not available to be checked (such as
2713 @code{vprintf}), specify the third parameter as zero.  In this case the
2714 compiler only checks the format string for consistency.  For
2715 @code{strftime} formats, the third parameter is required to be zero.
2716 Since non-static C++ methods have an implicit @code{this} argument, the
2717 arguments of such methods should be counted from two, not one, when
2718 giving values for @var{string-index} and @var{first-to-check}.
2720 In the example above, the format string (@code{my_format}) is the second
2721 argument of the function @code{my_print}, and the arguments to check
2722 start with the third argument, so the correct parameters for the format
2723 attribute are 2 and 3.
2725 @opindex ffreestanding
2726 @opindex fno-builtin
2727 The @code{format} attribute allows you to identify your own functions
2728 that take format strings as arguments, so that GCC can check the
2729 calls to these functions for errors.  The compiler always (unless
2730 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2731 for the standard library functions @code{printf}, @code{fprintf},
2732 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2733 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2734 warnings are requested (using @option{-Wformat}), so there is no need to
2735 modify the header file @file{stdio.h}.  In C99 mode, the functions
2736 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2737 @code{vsscanf} are also checked.  Except in strictly conforming C
2738 standard modes, the X/Open function @code{strfmon} is also checked as
2739 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2740 @xref{C Dialect Options,,Options Controlling C Dialect}.
2742 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2743 recognized in the same context.  Declarations including these format attributes
2744 are parsed for correct syntax, however the result of checking of such format
2745 strings is not yet defined, and is not carried out by this version of the
2746 compiler.
2748 The target may also provide additional types of format checks.
2749 @xref{Target Format Checks,,Format Checks Specific to Particular
2750 Target Machines}.
2752 @item format_arg (@var{string-index})
2753 @cindex @code{format_arg} function attribute
2754 @opindex Wformat-nonliteral
2755 The @code{format_arg} attribute specifies that a function takes a format
2756 string for a @code{printf}, @code{scanf}, @code{strftime} or
2757 @code{strfmon} style function and modifies it (for example, to translate
2758 it into another language), so the result can be passed to a
2759 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2760 function (with the remaining arguments to the format function the same
2761 as they would have been for the unmodified string).  For example, the
2762 declaration:
2764 @smallexample
2765 extern char *
2766 my_dgettext (char *my_domain, const char *my_format)
2767       __attribute__ ((format_arg (2)));
2768 @end smallexample
2770 @noindent
2771 causes the compiler to check the arguments in calls to a @code{printf},
2772 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2773 format string argument is a call to the @code{my_dgettext} function, for
2774 consistency with the format string argument @code{my_format}.  If the
2775 @code{format_arg} attribute had not been specified, all the compiler
2776 could tell in such calls to format functions would be that the format
2777 string argument is not constant; this would generate a warning when
2778 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2779 without the attribute.
2781 The parameter @var{string-index} specifies which argument is the format
2782 string argument (starting from one).  Since non-static C++ methods have
2783 an implicit @code{this} argument, the arguments of such methods should
2784 be counted from two.
2786 The @code{format_arg} attribute allows you to identify your own
2787 functions that modify format strings, so that GCC can check the
2788 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2789 type function whose operands are a call to one of your own function.
2790 The compiler always treats @code{gettext}, @code{dgettext}, and
2791 @code{dcgettext} in this manner except when strict ISO C support is
2792 requested by @option{-ansi} or an appropriate @option{-std} option, or
2793 @option{-ffreestanding} or @option{-fno-builtin}
2794 is used.  @xref{C Dialect Options,,Options
2795 Controlling C Dialect}.
2797 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2798 @code{NSString} reference for compatibility with the @code{format} attribute
2799 above.
2801 The target may also allow additional types in @code{format-arg} attributes.
2802 @xref{Target Format Checks,,Format Checks Specific to Particular
2803 Target Machines}.
2805 @item function_vector
2806 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2807 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2808 function should be called through the function vector.  Calling a
2809 function through the function vector reduces code size, however;
2810 the function vector has a limited size (maximum 128 entries on the H8/300
2811 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2813 On SH2A targets, this attribute declares a function to be called using the
2814 TBR relative addressing mode.  The argument to this attribute is the entry
2815 number of the same function in a vector table containing all the TBR
2816 relative addressable functions.  For correct operation the TBR must be setup
2817 accordingly to point to the start of the vector table before any functions with
2818 this attribute are invoked.  Usually a good place to do the initialization is
2819 the startup routine.  The TBR relative vector table can have at max 256 function
2820 entries.  The jumps to these functions are generated using a SH2A specific,
2821 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2822 from GNU binutils version 2.7 or later for this attribute to work correctly.
2824 Please refer the example of M16C target, to see the use of this
2825 attribute while declaring a function,
2827 In an application, for a function being called once, this attribute
2828 saves at least 8 bytes of code; and if other successive calls are being
2829 made to the same function, it saves 2 bytes of code per each of these
2830 calls.
2832 On M16C/M32C targets, the @code{function_vector} attribute declares a
2833 special page subroutine call function. Use of this attribute reduces
2834 the code size by 2 bytes for each call generated to the
2835 subroutine. The argument to the attribute is the vector number entry
2836 from the special page vector table which contains the 16 low-order
2837 bits of the subroutine's entry address. Each vector table has special
2838 page number (18 to 255) that is used in @code{jsrs} instructions.
2839 Jump addresses of the routines are generated by adding 0x0F0000 (in
2840 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2841 2-byte addresses set in the vector table. Therefore you need to ensure
2842 that all the special page vector routines should get mapped within the
2843 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2844 (for M32C).
2846 In the following example 2 bytes are saved for each call to
2847 function @code{foo}.
2849 @smallexample
2850 void foo (void) __attribute__((function_vector(0x18)));
2851 void foo (void)
2855 void bar (void)
2857     foo();
2859 @end smallexample
2861 If functions are defined in one file and are called in another file,
2862 then be sure to write this declaration in both files.
2864 This attribute is ignored for R8C target.
2866 @item ifunc ("@var{resolver}")
2867 @cindex @code{ifunc} attribute
2868 The @code{ifunc} attribute is used to mark a function as an indirect
2869 function using the STT_GNU_IFUNC symbol type extension to the ELF
2870 standard.  This allows the resolution of the symbol value to be
2871 determined dynamically at load time, and an optimized version of the
2872 routine can be selected for the particular processor or other system
2873 characteristics determined then.  To use this attribute, first define
2874 the implementation functions available, and a resolver function that
2875 returns a pointer to the selected implementation function.  The
2876 implementation functions' declarations must match the API of the
2877 function being implemented, the resolver's declaration is be a
2878 function returning pointer to void function returning void:
2880 @smallexample
2881 void *my_memcpy (void *dst, const void *src, size_t len)
2883   @dots{}
2886 static void (*resolve_memcpy (void)) (void)
2888   return my_memcpy; // we'll just always select this routine
2890 @end smallexample
2892 @noindent
2893 The exported header file declaring the function the user calls would
2894 contain:
2896 @smallexample
2897 extern void *memcpy (void *, const void *, size_t);
2898 @end smallexample
2900 @noindent
2901 allowing the user to call this as a regular function, unaware of the
2902 implementation.  Finally, the indirect function needs to be defined in
2903 the same translation unit as the resolver function:
2905 @smallexample
2906 void *memcpy (void *, const void *, size_t)
2907      __attribute__ ((ifunc ("resolve_memcpy")));
2908 @end smallexample
2910 Indirect functions cannot be weak, and require a recent binutils (at
2911 least version 2.20.1), and GNU C library (at least version 2.11.1).
2913 @item interrupt
2914 @cindex interrupt handler functions
2915 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2916 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2917 the specified function is an
2918 interrupt handler.  The compiler generates function entry and exit
2919 sequences suitable for use in an interrupt handler when this attribute
2920 is present.  With Epiphany targets it may also generate a special section with
2921 code to initialize the interrupt vector table.
2923 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2924 and SH processors can be specified via the @code{interrupt_handler} attribute.
2926 Note, on the ARC, you must specify the kind of interrupt to be handled
2927 in a parameter to the interrupt attribute like this:
2929 @smallexample
2930 void f () __attribute__ ((interrupt ("ilink1")));
2931 @end smallexample
2933 Permissible values for this parameter are: @w{@code{ilink1}} and
2934 @w{@code{ilink2}}.
2936 Note, on the AVR, the hardware globally disables interrupts when an
2937 interrupt is executed.  The first instruction of an interrupt handler
2938 declared with this attribute is a @code{SEI} instruction to
2939 re-enable interrupts.  See also the @code{signal} function attribute
2940 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2941 @code{interrupt} are specified for the same function, @code{signal}
2942 is silently ignored.
2944 Note, for the ARM, you can specify the kind of interrupt to be handled by
2945 adding an optional parameter to the interrupt attribute like this:
2947 @smallexample
2948 void f () __attribute__ ((interrupt ("IRQ")));
2949 @end smallexample
2951 @noindent
2952 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2953 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2955 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2956 may be called with a word-aligned stack pointer.
2958 Note, for the MSP430 you can provide an argument to the interrupt
2959 attribute which specifies a name or number.  If the argument is a
2960 number it indicates the slot in the interrupt vector table (0 - 31) to
2961 which this handler should be assigned.  If the argument is a name it
2962 is treated as a symbolic name for the vector slot.  These names should
2963 match up with appropriate entries in the linker script.  By default
2964 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2965 @code{reset} for vector 31 are recognised.
2967 You can also use the following function attributes to modify how
2968 normal functions interact with interrupt functions:
2970 @table @code
2971 @item critical
2972 @cindex @code{critical} attribute
2973 Critical functions disable interrupts upon entry and restore the
2974 previous interrupt state upon exit.  Critical functions cannot also
2975 have the @code{naked} or @code{reentrant} attributes.  They can have
2976 the @code{interrupt} attribute.
2978 @item reentrant
2979 @cindex @code{reentrant} attribute
2980 Reentrant functions disable interrupts upon entry and enable them
2981 upon exit.  Reentrant functions cannot also have the @code{naked}
2982 or @code{critical} attributes.  They can have the @code{interrupt}
2983 attribute.
2985 @item wakeup
2986 @cindex @code{wakeup} attribute
2987 This attribute only applies to interrupt functions.  It is silently
2988 ignored if applied to a non-interrupt function.  A wakeup interrupt
2989 function will rouse the processor from any low-power state that it
2990 might be in when the function exits.
2992 @end table
2994 On Epiphany targets one or more optional parameters can be added like this:
2996 @smallexample
2997 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2998 @end smallexample
3000 Permissible values for these parameters are: @w{@code{reset}},
3001 @w{@code{software_exception}}, @w{@code{page_miss}},
3002 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3003 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3004 Multiple parameters indicate that multiple entries in the interrupt
3005 vector table should be initialized for this function, i.e.@: for each
3006 parameter @w{@var{name}}, a jump to the function is emitted in
3007 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3008 entirely, in which case no interrupt vector table entry is provided.
3010 Note, on Epiphany targets, interrupts are enabled inside the function
3011 unless the @code{disinterrupt} attribute is also specified.
3013 On Epiphany targets, you can also use the following attribute to
3014 modify the behavior of an interrupt handler:
3015 @table @code
3016 @item forwarder_section
3017 @cindex @code{forwarder_section} attribute
3018 The interrupt handler may be in external memory which cannot be
3019 reached by a branch instruction, so generate a local memory trampoline
3020 to transfer control.  The single parameter identifies the section where
3021 the trampoline is placed.
3022 @end table
3024 The following examples are all valid uses of these attributes on
3025 Epiphany targets:
3026 @smallexample
3027 void __attribute__ ((interrupt)) universal_handler ();
3028 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3029 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3030 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3031   fast_timer_handler ();
3032 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3033   external_dma_handler ();
3034 @end smallexample
3036 On MIPS targets, you can use the following attributes to modify the behavior
3037 of an interrupt handler:
3038 @table @code
3039 @item use_shadow_register_set
3040 @cindex @code{use_shadow_register_set} attribute
3041 Assume that the handler uses a shadow register set, instead of
3042 the main general-purpose registers.
3044 @item keep_interrupts_masked
3045 @cindex @code{keep_interrupts_masked} attribute
3046 Keep interrupts masked for the whole function.  Without this attribute,
3047 GCC tries to reenable interrupts for as much of the function as it can.
3049 @item use_debug_exception_return
3050 @cindex @code{use_debug_exception_return} attribute
3051 Return using the @code{deret} instruction.  Interrupt handlers that don't
3052 have this attribute return using @code{eret} instead.
3053 @end table
3055 You can use any combination of these attributes, as shown below:
3056 @smallexample
3057 void __attribute__ ((interrupt)) v0 ();
3058 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3059 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3060 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3061 void __attribute__ ((interrupt, use_shadow_register_set,
3062                      keep_interrupts_masked)) v4 ();
3063 void __attribute__ ((interrupt, use_shadow_register_set,
3064                      use_debug_exception_return)) v5 ();
3065 void __attribute__ ((interrupt, keep_interrupts_masked,
3066                      use_debug_exception_return)) v6 ();
3067 void __attribute__ ((interrupt, use_shadow_register_set,
3068                      keep_interrupts_masked,
3069                      use_debug_exception_return)) v7 ();
3070 @end smallexample
3072 On NDS32 target, this attribute is to indicate that the specified function
3073 is an interrupt handler.  The compiler will generate corresponding sections
3074 for use in an interrupt handler.  You can use the following attributes
3075 to modify the behavior:
3076 @table @code
3077 @item nested
3078 @cindex @code{nested} attribute
3079 This interrupt service routine is interruptible.
3080 @item not_nested
3081 @cindex @code{not_nested} attribute
3082 This interrupt service routine is not interruptible.
3083 @item nested_ready
3084 @cindex @code{nested_ready} attribute
3085 This interrupt service routine is interruptible after @code{PSW.GIE}
3086 (global interrupt enable) is set.  This allows interrupt service routine to
3087 finish some short critical code before enabling interrupts.
3088 @item save_all
3089 @cindex @code{save_all} attribute
3090 The system will help save all registers into stack before entering
3091 interrupt handler.
3092 @item partial_save
3093 @cindex @code{partial_save} attribute
3094 The system will help save caller registers into stack before entering
3095 interrupt handler.
3096 @end table
3098 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3099 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3100 that must end with @code{RETB} instead of @code{RETI}).
3102 On RX targets, you may specify one or more vector numbers as arguments
3103 to the attribute, as well as naming an alternate table name.
3104 Parameters are handled sequentially, so one handler can be assigned to
3105 multiple entries in multiple tables.  One may also pass the magic
3106 string @code{"$default"} which causes the function to be used for any
3107 unfilled slots in the current table.
3109 This example shows a simple assignment of a function to one vector in
3110 the default table (note that preprocessor macros may be used for
3111 chip-specific symbolic vector names):
3112 @smallexample
3113 void __attribute__ ((interrupt (5))) txd1_handler ();
3114 @end smallexample
3116 This example assigns a function to two slots in the default table
3117 (using preprocessor macros defined elsewhere) and makes it the default
3118 for the @code{dct} table:
3119 @smallexample
3120 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3121         txd1_handler ();
3122 @end smallexample
3124 @item interrupt_handler
3125 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3126 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3127 indicate that the specified function is an interrupt handler.  The compiler
3128 generates function entry and exit sequences suitable for use in an
3129 interrupt handler when this attribute is present.
3131 @item interrupt_thread
3132 @cindex interrupt thread functions on fido
3133 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3134 that the specified function is an interrupt handler that is designed
3135 to run as a thread.  The compiler omits generate prologue/epilogue
3136 sequences and replaces the return instruction with a @code{sleep}
3137 instruction.  This attribute is available only on fido.
3139 @item isr
3140 @cindex interrupt service routines on ARM
3141 Use this attribute on ARM to write Interrupt Service Routines. This is an
3142 alias to the @code{interrupt} attribute above.
3144 @item kspisusp
3145 @cindex User stack pointer in interrupts on the Blackfin
3146 When used together with @code{interrupt_handler}, @code{exception_handler}
3147 or @code{nmi_handler}, code is generated to load the stack pointer
3148 from the USP register in the function prologue.
3150 @item l1_text
3151 @cindex @code{l1_text} function attribute
3152 This attribute specifies a function to be placed into L1 Instruction
3153 SRAM@. The function is put into a specific section named @code{.l1.text}.
3154 With @option{-mfdpic}, function calls with a such function as the callee
3155 or caller uses inlined PLT.
3157 @item l2
3158 @cindex @code{l2} function attribute
3159 On the Blackfin, this attribute specifies a function to be placed into L2
3160 SRAM. The function is put into a specific section named
3161 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3162 an inlined PLT.
3164 @item leaf
3165 @cindex @code{leaf} function attribute
3166 Calls to external functions with this attribute must return to the current
3167 compilation unit only by return or by exception handling.  In particular, leaf
3168 functions are not allowed to call callback function passed to it from the current
3169 compilation unit or directly call functions exported by the unit or longjmp
3170 into the unit.  Leaf function might still call functions from other compilation
3171 units and thus they are not necessarily leaf in the sense that they contain no
3172 function calls at all.
3174 The attribute is intended for library functions to improve dataflow analysis.
3175 The compiler takes the hint that any data not escaping the current compilation unit can
3176 not be used or modified by the leaf function.  For example, the @code{sin} function
3177 is a leaf function, but @code{qsort} is not.
3179 Note that leaf functions might invoke signals and signal handlers might be
3180 defined in the current compilation unit and use static variables.  The only
3181 compliant way to write such a signal handler is to declare such variables
3182 @code{volatile}.
3184 The attribute has no effect on functions defined within the current compilation
3185 unit.  This is to allow easy merging of multiple compilation units into one,
3186 for example, by using the link-time optimization.  For this reason the
3187 attribute is not allowed on types to annotate indirect calls.
3189 @item long_call/medium_call/short_call
3190 @cindex indirect calls on ARC
3191 @cindex indirect calls on ARM
3192 @cindex indirect calls on Epiphany
3193 These attributes specify how a particular function is called on
3194 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3195 These attributes override the
3196 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3197 and @option{-mmedium-calls} (@pxref{ARC Options})
3198 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3199 @code{long_call} attribute indicates that the function might be far
3200 away from the call site and require a different (more expensive)
3201 calling sequence.   The @code{short_call} attribute always places
3202 the offset to the function from the call site into the @samp{BL}
3203 instruction directly.
3205 For ARC, a function marked with the @code{long_call} attribute is
3206 always called using register-indirect jump-and-link instructions,
3207 thereby enabling the called function to be placed anywhere within the
3208 32-bit address space.  A function marked with the @code{medium_call}
3209 attribute will always be close enough to be called with an unconditional
3210 branch-and-link instruction, which has a 25-bit offset from
3211 the call site.  A function marked with the @code{short_call}
3212 attribute will always be close enough to be called with a conditional
3213 branch-and-link instruction, which has a 21-bit offset from
3214 the call site.
3216 @item longcall/shortcall
3217 @cindex functions called via pointer on the RS/6000 and PowerPC
3218 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3219 indicates that the function might be far away from the call site and
3220 require a different (more expensive) calling sequence.  The
3221 @code{shortcall} attribute indicates that the function is always close
3222 enough for the shorter calling sequence to be used.  These attributes
3223 override both the @option{-mlongcall} switch and, on the RS/6000 and
3224 PowerPC, the @code{#pragma longcall} setting.
3226 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3227 calls are necessary.
3229 @item long_call/near/far
3230 @cindex indirect calls on MIPS
3231 These attributes specify how a particular function is called on MIPS@.
3232 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3233 command-line switch.  The @code{long_call} and @code{far} attributes are
3234 synonyms, and cause the compiler to always call
3235 the function by first loading its address into a register, and then using
3236 the contents of that register.  The @code{near} attribute has the opposite
3237 effect; it specifies that non-PIC calls should be made using the more
3238 efficient @code{jal} instruction.
3240 @item malloc
3241 @cindex @code{malloc} attribute
3242 This tells the compiler that a function is @code{malloc}-like, i.e.,
3243 that the pointer @var{P} returned by the function cannot alias any
3244 other pointer valid when the function returns, and moreover no
3245 pointers to valid objects occur in any storage addressed by @var{P}.
3247 Using this attribute can improve optimization.  Functions like
3248 @code{malloc} and @code{calloc} have this property because they return
3249 a pointer to uninitialized or zeroed-out storage.  However, functions
3250 like @code{realloc} do not have this property, as they can return a
3251 pointer to storage containing pointers.
3253 @item mips16/nomips16
3254 @cindex @code{mips16} attribute
3255 @cindex @code{nomips16} attribute
3257 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3258 function attributes to locally select or turn off MIPS16 code generation.
3259 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3260 while MIPS16 code generation is disabled for functions with the
3261 @code{nomips16} attribute.  These attributes override the
3262 @option{-mips16} and @option{-mno-mips16} options on the command line
3263 (@pxref{MIPS Options}).
3265 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3266 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3267 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3268 may interact badly with some GCC extensions such as @code{__builtin_apply}
3269 (@pxref{Constructing Calls}).
3271 @item micromips/nomicromips
3272 @cindex @code{micromips} attribute
3273 @cindex @code{nomicromips} attribute
3275 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3276 function attributes to locally select or turn off microMIPS code generation.
3277 A function with the @code{micromips} attribute is emitted as microMIPS code,
3278 while microMIPS code generation is disabled for functions with the
3279 @code{nomicromips} attribute.  These attributes override the
3280 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3281 (@pxref{MIPS Options}).
3283 When compiling files containing mixed microMIPS and non-microMIPS code, the
3284 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3285 command line,
3286 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3287 may interact badly with some GCC extensions such as @code{__builtin_apply}
3288 (@pxref{Constructing Calls}).
3290 @item model (@var{model-name})
3291 @cindex function addressability on the M32R/D
3292 @cindex variable addressability on the IA-64
3294 On the M32R/D, use this attribute to set the addressability of an
3295 object, and of the code generated for a function.  The identifier
3296 @var{model-name} is one of @code{small}, @code{medium}, or
3297 @code{large}, representing each of the code models.
3299 Small model objects live in the lower 16MB of memory (so that their
3300 addresses can be loaded with the @code{ld24} instruction), and are
3301 callable with the @code{bl} instruction.
3303 Medium model objects may live anywhere in the 32-bit address space (the
3304 compiler generates @code{seth/add3} instructions to load their addresses),
3305 and are callable with the @code{bl} instruction.
3307 Large model objects may live anywhere in the 32-bit address space (the
3308 compiler generates @code{seth/add3} instructions to load their addresses),
3309 and may not be reachable with the @code{bl} instruction (the compiler
3310 generates the much slower @code{seth/add3/jl} instruction sequence).
3312 On IA-64, use this attribute to set the addressability of an object.
3313 At present, the only supported identifier for @var{model-name} is
3314 @code{small}, indicating addressability via ``small'' (22-bit)
3315 addresses (so that their addresses can be loaded with the @code{addl}
3316 instruction).  Caveat: such addressing is by definition not position
3317 independent and hence this attribute must not be used for objects
3318 defined by shared libraries.
3320 @item ms_abi/sysv_abi
3321 @cindex @code{ms_abi} attribute
3322 @cindex @code{sysv_abi} attribute
3324 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3325 to indicate which calling convention should be used for a function.  The
3326 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3327 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3328 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3329 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3331 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3332 requires the @option{-maccumulate-outgoing-args} option.
3334 @item callee_pop_aggregate_return (@var{number})
3335 @cindex @code{callee_pop_aggregate_return} attribute
3337 On 32-bit i?86-*-* targets, you can use this attribute to control how
3338 aggregates are returned in memory.  If the caller is responsible for
3339 popping the hidden pointer together with the rest of the arguments, specify
3340 @var{number} equal to zero.  If callee is responsible for popping the
3341 hidden pointer, specify @var{number} equal to one.  
3343 The default i386 ABI assumes that the callee pops the
3344 stack for hidden pointer.  However, on 32-bit i386 Microsoft Windows targets,
3345 the compiler assumes that the
3346 caller pops the stack for hidden pointer.
3348 @item ms_hook_prologue
3349 @cindex @code{ms_hook_prologue} attribute
3351 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3352 this function attribute to make GCC generate the ``hot-patching'' function
3353 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3354 and newer.
3356 @item hotpatch [(@var{prologue-halfwords})]
3357 @cindex @code{hotpatch} attribute
3359 On S/390 System z targets, you can use this function attribute to
3360 make GCC generate a ``hot-patching'' function prologue.  The
3361 @code{hotpatch} has no effect on funtions that are explicitly
3362 inline.  If the @option{-mhotpatch} or @option{-mno-hotpatch}
3363 command-line option is used at the same time, the @code{hotpatch}
3364 attribute takes precedence.  If an argument is given, the maximum
3365 allowed value is 1000000.
3367 @item naked
3368 @cindex function without a prologue/epilogue code
3369 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3370 RL78, RX and SPU ports.  It allows the compiler to construct the
3371 requisite function declaration, while allowing the body of the
3372 function to be assembly code. The specified function will not have
3373 prologue/epilogue sequences generated by the compiler. Only Basic
3374 @code{asm} statements can safely be included in naked functions
3375 (@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
3376 Basic @code{asm} and ``C'' code may appear to work, they cannot be
3377 depended upon to work reliably and are not supported.
3379 @item near
3380 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3381 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3382 use the normal calling convention based on @code{jsr} and @code{rts}.
3383 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3384 option.
3386 On MeP targets this attribute causes the compiler to assume the called
3387 function is close enough to use the normal calling convention,
3388 overriding the @option{-mtf} command-line option.
3390 @item nesting
3391 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3392 Use this attribute together with @code{interrupt_handler},
3393 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3394 entry code should enable nested interrupts or exceptions.
3396 @item nmi_handler
3397 @cindex NMI handler functions on the Blackfin processor
3398 Use this attribute on the Blackfin to indicate that the specified function
3399 is an NMI handler.  The compiler generates function entry and
3400 exit sequences suitable for use in an NMI handler when this
3401 attribute is present.
3403 @item nocompression
3404 @cindex @code{nocompression} attribute
3405 On MIPS targets, you can use the @code{nocompression} function attribute
3406 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3407 overrides the @option{-mips16} and @option{-mmicromips} options on the
3408 command line (@pxref{MIPS Options}).
3410 @item no_instrument_function
3411 @cindex @code{no_instrument_function} function attribute
3412 @opindex finstrument-functions
3413 If @option{-finstrument-functions} is given, profiling function calls are
3414 generated at entry and exit of most user-compiled functions.
3415 Functions with this attribute are not so instrumented.
3417 @item no_split_stack
3418 @cindex @code{no_split_stack} function attribute
3419 @opindex fsplit-stack
3420 If @option{-fsplit-stack} is given, functions have a small
3421 prologue which decides whether to split the stack.  Functions with the
3422 @code{no_split_stack} attribute do not have that prologue, and thus
3423 may run with only a small amount of stack space available.
3425 @item noinline
3426 @cindex @code{noinline} function attribute
3427 This function attribute prevents a function from being considered for
3428 inlining.
3429 @c Don't enumerate the optimizations by name here; we try to be
3430 @c future-compatible with this mechanism.
3431 If the function does not have side-effects, there are optimizations
3432 other than inlining that cause function calls to be optimized away,
3433 although the function call is live.  To keep such calls from being
3434 optimized away, put
3435 @smallexample
3436 asm ("");
3437 @end smallexample
3439 @noindent
3440 (@pxref{Extended Asm}) in the called function, to serve as a special
3441 side-effect.
3443 @item noclone
3444 @cindex @code{noclone} function attribute
3445 This function attribute prevents a function from being considered for
3446 cloning---a mechanism that produces specialized copies of functions
3447 and which is (currently) performed by interprocedural constant
3448 propagation.
3450 @item nonnull (@var{arg-index}, @dots{})
3451 @cindex @code{nonnull} function attribute
3452 The @code{nonnull} attribute specifies that some function parameters should
3453 be non-null pointers.  For instance, the declaration:
3455 @smallexample
3456 extern void *
3457 my_memcpy (void *dest, const void *src, size_t len)
3458         __attribute__((nonnull (1, 2)));
3459 @end smallexample
3461 @noindent
3462 causes the compiler to check that, in calls to @code{my_memcpy},
3463 arguments @var{dest} and @var{src} are non-null.  If the compiler
3464 determines that a null pointer is passed in an argument slot marked
3465 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3466 is issued.  The compiler may also choose to make optimizations based
3467 on the knowledge that certain function arguments will never be null.
3469 If no argument index list is given to the @code{nonnull} attribute,
3470 all pointer arguments are marked as non-null.  To illustrate, the
3471 following declaration is equivalent to the previous example:
3473 @smallexample
3474 extern void *
3475 my_memcpy (void *dest, const void *src, size_t len)
3476         __attribute__((nonnull));
3477 @end smallexample
3479 @item no_reorder
3480 @cindex @code{no_reorder} function or variable attribute
3481 Do not reorder functions or variables marked @code{no_reorder}
3482 against each other or top level assembler statements the executable.
3483 The actual order in the program will depend on the linker command
3484 line. Static variables marked like this are also not removed.
3485 This has a similar effect
3486 as the @option{-fno-toplevel-reorder} option, but only applies to the
3487 marked symbols.
3489 @item returns_nonnull
3490 @cindex @code{returns_nonnull} function attribute
3491 The @code{returns_nonnull} attribute specifies that the function
3492 return value should be a non-null pointer.  For instance, the declaration:
3494 @smallexample
3495 extern void *
3496 mymalloc (size_t len) __attribute__((returns_nonnull));
3497 @end smallexample
3499 @noindent
3500 lets the compiler optimize callers based on the knowledge
3501 that the return value will never be null.
3503 @item noreturn
3504 @cindex @code{noreturn} function attribute
3505 A few standard library functions, such as @code{abort} and @code{exit},
3506 cannot return.  GCC knows this automatically.  Some programs define
3507 their own functions that never return.  You can declare them
3508 @code{noreturn} to tell the compiler this fact.  For example,
3510 @smallexample
3511 @group
3512 void fatal () __attribute__ ((noreturn));
3514 void
3515 fatal (/* @r{@dots{}} */)
3517   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3518   exit (1);
3520 @end group
3521 @end smallexample
3523 The @code{noreturn} keyword tells the compiler to assume that
3524 @code{fatal} cannot return.  It can then optimize without regard to what
3525 would happen if @code{fatal} ever did return.  This makes slightly
3526 better code.  More importantly, it helps avoid spurious warnings of
3527 uninitialized variables.
3529 The @code{noreturn} keyword does not affect the exceptional path when that
3530 applies: a @code{noreturn}-marked function may still return to the caller
3531 by throwing an exception or calling @code{longjmp}.
3533 Do not assume that registers saved by the calling function are
3534 restored before calling the @code{noreturn} function.
3536 It does not make sense for a @code{noreturn} function to have a return
3537 type other than @code{void}.
3539 The attribute @code{noreturn} is not implemented in GCC versions
3540 earlier than 2.5.  An alternative way to declare that a function does
3541 not return, which works in the current version and in some older
3542 versions, is as follows:
3544 @smallexample
3545 typedef void voidfn ();
3547 volatile voidfn fatal;
3548 @end smallexample
3550 @noindent
3551 This approach does not work in GNU C++.
3553 @item nothrow
3554 @cindex @code{nothrow} function attribute
3555 The @code{nothrow} attribute is used to inform the compiler that a
3556 function cannot throw an exception.  For example, most functions in
3557 the standard C library can be guaranteed not to throw an exception
3558 with the notable exceptions of @code{qsort} and @code{bsearch} that
3559 take function pointer arguments.  The @code{nothrow} attribute is not
3560 implemented in GCC versions earlier than 3.3.
3562 @item nosave_low_regs
3563 @cindex @code{nosave_low_regs} attribute
3564 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3565 function should not save and restore registers R0..R7.  This can be used on SH3*
3566 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3567 interrupt handlers.
3569 @item optimize
3570 @cindex @code{optimize} function attribute
3571 The @code{optimize} attribute is used to specify that a function is to
3572 be compiled with different optimization options than specified on the
3573 command line.  Arguments can either be numbers or strings.  Numbers
3574 are assumed to be an optimization level.  Strings that begin with
3575 @code{O} are assumed to be an optimization option, while other options
3576 are assumed to be used with a @code{-f} prefix.  You can also use the
3577 @samp{#pragma GCC optimize} pragma to set the optimization options
3578 that affect more than one function.
3579 @xref{Function Specific Option Pragmas}, for details about the
3580 @samp{#pragma GCC optimize} pragma.
3582 This can be used for instance to have frequently-executed functions
3583 compiled with more aggressive optimization options that produce faster
3584 and larger code, while other functions can be compiled with less
3585 aggressive options.
3587 @item OS_main/OS_task
3588 @cindex @code{OS_main} AVR function attribute
3589 @cindex @code{OS_task} AVR function attribute
3590 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3591 do not save/restore any call-saved register in their prologue/epilogue.
3593 The @code{OS_main} attribute can be used when there @emph{is
3594 guarantee} that interrupts are disabled at the time when the function
3595 is entered.  This saves resources when the stack pointer has to be
3596 changed to set up a frame for local variables.
3598 The @code{OS_task} attribute can be used when there is @emph{no
3599 guarantee} that interrupts are disabled at that time when the function
3600 is entered like for, e@.g@. task functions in a multi-threading operating
3601 system. In that case, changing the stack pointer register is
3602 guarded by save/clear/restore of the global interrupt enable flag.
3604 The differences to the @code{naked} function attribute are:
3605 @itemize @bullet
3606 @item @code{naked} functions do not have a return instruction whereas 
3607 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3608 @code{RETI} return instruction.
3609 @item @code{naked} functions do not set up a frame for local variables
3610 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3611 as needed.
3612 @end itemize
3614 @item pcs
3615 @cindex @code{pcs} function attribute
3617 The @code{pcs} attribute can be used to control the calling convention
3618 used for a function on ARM.  The attribute takes an argument that specifies
3619 the calling convention to use.
3621 When compiling using the AAPCS ABI (or a variant of it) then valid
3622 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3623 order to use a variant other than @code{"aapcs"} then the compiler must
3624 be permitted to use the appropriate co-processor registers (i.e., the
3625 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3626 For example,
3628 @smallexample
3629 /* Argument passed in r0, and result returned in r0+r1.  */
3630 double f2d (float) __attribute__((pcs("aapcs")));
3631 @end smallexample
3633 Variadic functions always use the @code{"aapcs"} calling convention and
3634 the compiler rejects attempts to specify an alternative.
3636 @item pure
3637 @cindex @code{pure} function attribute
3638 Many functions have no effects except the return value and their
3639 return value depends only on the parameters and/or global variables.
3640 Such a function can be subject
3641 to common subexpression elimination and loop optimization just as an
3642 arithmetic operator would be.  These functions should be declared
3643 with the attribute @code{pure}.  For example,
3645 @smallexample
3646 int square (int) __attribute__ ((pure));
3647 @end smallexample
3649 @noindent
3650 says that the hypothetical function @code{square} is safe to call
3651 fewer times than the program says.
3653 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3654 Interesting non-pure functions are functions with infinite loops or those
3655 depending on volatile memory or other system resource, that may change between
3656 two consecutive calls (such as @code{feof} in a multithreading environment).
3658 The attribute @code{pure} is not implemented in GCC versions earlier
3659 than 2.96.
3661 @item hot
3662 @cindex @code{hot} function attribute
3663 The @code{hot} attribute on a function is used to inform the compiler that
3664 the function is a hot spot of the compiled program.  The function is
3665 optimized more aggressively and on many targets it is placed into a special
3666 subsection of the text section so all hot functions appear close together,
3667 improving locality.
3669 When profile feedback is available, via @option{-fprofile-use}, hot functions
3670 are automatically detected and this attribute is ignored.
3672 The @code{hot} attribute on functions is not implemented in GCC versions
3673 earlier than 4.3.
3675 @item cold
3676 @cindex @code{cold} function attribute
3677 The @code{cold} attribute on functions is used to inform the compiler that
3678 the function is unlikely to be executed.  The function is optimized for
3679 size rather than speed and on many targets it is placed into a special
3680 subsection of the text section so all cold functions appear close together,
3681 improving code locality of non-cold parts of program.  The paths leading
3682 to calls of cold functions within code are marked as unlikely by the branch
3683 prediction mechanism.  It is thus useful to mark functions used to handle
3684 unlikely conditions, such as @code{perror}, as cold to improve optimization
3685 of hot functions that do call marked functions in rare occasions.
3687 When profile feedback is available, via @option{-fprofile-use}, cold functions
3688 are automatically detected and this attribute is ignored.
3690 The @code{cold} attribute on functions is not implemented in GCC versions
3691 earlier than 4.3.
3693 @item no_sanitize_address
3694 @itemx no_address_safety_analysis
3695 @cindex @code{no_sanitize_address} function attribute
3696 The @code{no_sanitize_address} attribute on functions is used
3697 to inform the compiler that it should not instrument memory accesses
3698 in the function when compiling with the @option{-fsanitize=address} option.
3699 The @code{no_address_safety_analysis} is a deprecated alias of the
3700 @code{no_sanitize_address} attribute, new code should use
3701 @code{no_sanitize_address}.
3703 @item no_sanitize_undefined
3704 @cindex @code{no_sanitize_undefined} function attribute
3705 The @code{no_sanitize_undefined} attribute on functions is used
3706 to inform the compiler that it should not check for undefined behavior
3707 in the function when compiling with the @option{-fsanitize=undefined} option.
3709 @item bnd_legacy
3710 @cindex @code{bnd_legacy} function attribute
3711 The @code{bnd_legacy} attribute on functions is used to inform
3712 compiler that function should not be instrumented when compiled
3713 with @option{-fcheck-pointer-bounds} option.
3715 @item bnd_instrument
3716 @cindex @code{bnd_instrument} function attribute
3717 The @code{bnd_instrument} attribute on functions is used to inform
3718 compiler that function should be instrumented when compiled
3719 with @option{-fchkp-instrument-marked-only} option.
3721 @item regparm (@var{number})
3722 @cindex @code{regparm} attribute
3723 @cindex functions that are passed arguments in registers on the 386
3724 On the Intel 386, the @code{regparm} attribute causes the compiler to
3725 pass arguments number one to @var{number} if they are of integral type
3726 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3727 take a variable number of arguments continue to be passed all of their
3728 arguments on the stack.
3730 Beware that on some ELF systems this attribute is unsuitable for
3731 global functions in shared libraries with lazy binding (which is the
3732 default).  Lazy binding sends the first call via resolving code in
3733 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3734 per the standard calling conventions.  Solaris 8 is affected by this.
3735 Systems with the GNU C Library version 2.1 or higher
3736 and FreeBSD are believed to be
3737 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3738 disabled with the linker or the loader if desired, to avoid the
3739 problem.)
3741 @item reset
3742 @cindex reset handler functions
3743 Use this attribute on the NDS32 target to indicate that the specified function
3744 is a reset handler.  The compiler will generate corresponding sections
3745 for use in a reset handler.  You can use the following attributes
3746 to provide extra exception handling:
3747 @table @code
3748 @item nmi
3749 @cindex @code{nmi} attribute
3750 Provide a user-defined function to handle NMI exception.
3751 @item warm
3752 @cindex @code{warm} attribute
3753 Provide a user-defined function to handle warm reset exception.
3754 @end table
3756 @item sseregparm
3757 @cindex @code{sseregparm} attribute
3758 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3759 causes the compiler to pass up to 3 floating-point arguments in
3760 SSE registers instead of on the stack.  Functions that take a
3761 variable number of arguments continue to pass all of their
3762 floating-point arguments on the stack.
3764 @item force_align_arg_pointer
3765 @cindex @code{force_align_arg_pointer} attribute
3766 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3767 applied to individual function definitions, generating an alternate
3768 prologue and epilogue that realigns the run-time stack if necessary.
3769 This supports mixing legacy codes that run with a 4-byte aligned stack
3770 with modern codes that keep a 16-byte stack for SSE compatibility.
3772 @item renesas
3773 @cindex @code{renesas} attribute
3774 On SH targets this attribute specifies that the function or struct follows the
3775 Renesas ABI.
3777 @item resbank
3778 @cindex @code{resbank} attribute
3779 On the SH2A target, this attribute enables the high-speed register
3780 saving and restoration using a register bank for @code{interrupt_handler}
3781 routines.  Saving to the bank is performed automatically after the CPU
3782 accepts an interrupt that uses a register bank.
3784 The nineteen 32-bit registers comprising general register R0 to R14,
3785 control register GBR, and system registers MACH, MACL, and PR and the
3786 vector table address offset are saved into a register bank.  Register
3787 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3788 from the bank is executed by issuing a RESBANK instruction.
3790 @item returns_twice
3791 @cindex @code{returns_twice} attribute
3792 The @code{returns_twice} attribute tells the compiler that a function may
3793 return more than one time.  The compiler ensures that all registers
3794 are dead before calling such a function and emits a warning about
3795 the variables that may be clobbered after the second return from the
3796 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3797 The @code{longjmp}-like counterpart of such function, if any, might need
3798 to be marked with the @code{noreturn} attribute.
3800 @item saveall
3801 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3802 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3803 all registers except the stack pointer should be saved in the prologue
3804 regardless of whether they are used or not.
3806 @item save_volatiles
3807 @cindex save volatile registers on the MicroBlaze
3808 Use this attribute on the MicroBlaze to indicate that the function is
3809 an interrupt handler.  All volatile registers (in addition to non-volatile
3810 registers) are saved in the function prologue.  If the function is a leaf
3811 function, only volatiles used by the function are saved.  A normal function
3812 return is generated instead of a return from interrupt.
3814 @item break_handler
3815 @cindex break handler functions
3816 Use this attribute on the MicroBlaze ports to indicate that
3817 the specified function is an break handler.  The compiler generates function
3818 entry and exit sequences suitable for use in an break handler when this
3819 attribute is present. The return from @code{break_handler} is done through
3820 the @code{rtbd} instead of @code{rtsd}.
3822 @smallexample
3823 void f () __attribute__ ((break_handler));
3824 @end smallexample
3826 @item section ("@var{section-name}")
3827 @cindex @code{section} function attribute
3828 Normally, the compiler places the code it generates in the @code{text} section.
3829 Sometimes, however, you need additional sections, or you need certain
3830 particular functions to appear in special sections.  The @code{section}
3831 attribute specifies that a function lives in a particular section.
3832 For example, the declaration:
3834 @smallexample
3835 extern void foobar (void) __attribute__ ((section ("bar")));
3836 @end smallexample
3838 @noindent
3839 puts the function @code{foobar} in the @code{bar} section.
3841 Some file formats do not support arbitrary sections so the @code{section}
3842 attribute is not available on all platforms.
3843 If you need to map the entire contents of a module to a particular
3844 section, consider using the facilities of the linker instead.
3846 @item sentinel
3847 @cindex @code{sentinel} function attribute
3848 This function attribute ensures that a parameter in a function call is
3849 an explicit @code{NULL}.  The attribute is only valid on variadic
3850 functions.  By default, the sentinel is located at position zero, the
3851 last parameter of the function call.  If an optional integer position
3852 argument P is supplied to the attribute, the sentinel must be located at
3853 position P counting backwards from the end of the argument list.
3855 @smallexample
3856 __attribute__ ((sentinel))
3857 is equivalent to
3858 __attribute__ ((sentinel(0)))
3859 @end smallexample
3861 The attribute is automatically set with a position of 0 for the built-in
3862 functions @code{execl} and @code{execlp}.  The built-in function
3863 @code{execle} has the attribute set with a position of 1.
3865 A valid @code{NULL} in this context is defined as zero with any pointer
3866 type.  If your system defines the @code{NULL} macro with an integer type
3867 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3868 with a copy that redefines NULL appropriately.
3870 The warnings for missing or incorrect sentinels are enabled with
3871 @option{-Wformat}.
3873 @item short_call
3874 See @code{long_call/short_call}.
3876 @item shortcall
3877 See @code{longcall/shortcall}.
3879 @item signal
3880 @cindex interrupt handler functions on the AVR processors
3881 Use this attribute on the AVR to indicate that the specified
3882 function is an interrupt handler.  The compiler generates function
3883 entry and exit sequences suitable for use in an interrupt handler when this
3884 attribute is present.
3886 See also the @code{interrupt} function attribute. 
3888 The AVR hardware globally disables interrupts when an interrupt is executed.
3889 Interrupt handler functions defined with the @code{signal} attribute
3890 do not re-enable interrupts.  It is save to enable interrupts in a
3891 @code{signal} handler.  This ``save'' only applies to the code
3892 generated by the compiler and not to the IRQ layout of the
3893 application which is responsibility of the application.
3895 If both @code{signal} and @code{interrupt} are specified for the same
3896 function, @code{signal} is silently ignored.
3898 @item sp_switch
3899 @cindex @code{sp_switch} attribute
3900 Use this attribute on the SH to indicate an @code{interrupt_handler}
3901 function should switch to an alternate stack.  It expects a string
3902 argument that names a global variable holding the address of the
3903 alternate stack.
3905 @smallexample
3906 void *alt_stack;
3907 void f () __attribute__ ((interrupt_handler,
3908                           sp_switch ("alt_stack")));
3909 @end smallexample
3911 @item stdcall
3912 @cindex functions that pop the argument stack on the 386
3913 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3914 assume that the called function pops off the stack space used to
3915 pass arguments, unless it takes a variable number of arguments.
3917 @item syscall_linkage
3918 @cindex @code{syscall_linkage} attribute
3919 This attribute is used to modify the IA-64 calling convention by marking
3920 all input registers as live at all function exits.  This makes it possible
3921 to restart a system call after an interrupt without having to save/restore
3922 the input registers.  This also prevents kernel data from leaking into
3923 application code.
3925 @item target
3926 @cindex @code{target} function attribute
3927 The @code{target} attribute is used to specify that a function is to
3928 be compiled with different target options than specified on the
3929 command line.  This can be used for instance to have functions
3930 compiled with a different ISA (instruction set architecture) than the
3931 default.  You can also use the @samp{#pragma GCC target} pragma to set
3932 more than one function to be compiled with specific target options.
3933 @xref{Function Specific Option Pragmas}, for details about the
3934 @samp{#pragma GCC target} pragma.
3936 For instance on a 386, you could compile one function with
3937 @code{target("sse4.1,arch=core2")} and another with
3938 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3939 compiling the first function with @option{-msse4.1} and
3940 @option{-march=core2} options, and the second function with
3941 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3942 user to make sure that a function is only invoked on a machine that
3943 supports the particular ISA it is compiled for (for example by using
3944 @code{cpuid} on 386 to determine what feature bits and architecture
3945 family are used).
3947 @smallexample
3948 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3949 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3950 @end smallexample
3952 You can either use multiple
3953 strings to specify multiple options, or separate the options
3954 with a comma (@samp{,}).
3956 The @code{target} attribute is presently implemented for
3957 i386/x86_64, PowerPC, and Nios II targets only.
3958 The options supported are specific to each target.
3960 On the 386, the following options are allowed:
3962 @table @samp
3963 @item abm
3964 @itemx no-abm
3965 @cindex @code{target("abm")} attribute
3966 Enable/disable the generation of the advanced bit instructions.
3968 @item aes
3969 @itemx no-aes
3970 @cindex @code{target("aes")} attribute
3971 Enable/disable the generation of the AES instructions.
3973 @item default
3974 @cindex @code{target("default")} attribute
3975 @xref{Function Multiversioning}, where it is used to specify the
3976 default function version.
3978 @item mmx
3979 @itemx no-mmx
3980 @cindex @code{target("mmx")} attribute
3981 Enable/disable the generation of the MMX instructions.
3983 @item pclmul
3984 @itemx no-pclmul
3985 @cindex @code{target("pclmul")} attribute
3986 Enable/disable the generation of the PCLMUL instructions.
3988 @item popcnt
3989 @itemx no-popcnt
3990 @cindex @code{target("popcnt")} attribute
3991 Enable/disable the generation of the POPCNT instruction.
3993 @item sse
3994 @itemx no-sse
3995 @cindex @code{target("sse")} attribute
3996 Enable/disable the generation of the SSE instructions.
3998 @item sse2
3999 @itemx no-sse2
4000 @cindex @code{target("sse2")} attribute
4001 Enable/disable the generation of the SSE2 instructions.
4003 @item sse3
4004 @itemx no-sse3
4005 @cindex @code{target("sse3")} attribute
4006 Enable/disable the generation of the SSE3 instructions.
4008 @item sse4
4009 @itemx no-sse4
4010 @cindex @code{target("sse4")} attribute
4011 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4012 and SSE4.2).
4014 @item sse4.1
4015 @itemx no-sse4.1
4016 @cindex @code{target("sse4.1")} attribute
4017 Enable/disable the generation of the sse4.1 instructions.
4019 @item sse4.2
4020 @itemx no-sse4.2
4021 @cindex @code{target("sse4.2")} attribute
4022 Enable/disable the generation of the sse4.2 instructions.
4024 @item sse4a
4025 @itemx no-sse4a
4026 @cindex @code{target("sse4a")} attribute
4027 Enable/disable the generation of the SSE4A instructions.
4029 @item fma4
4030 @itemx no-fma4
4031 @cindex @code{target("fma4")} attribute
4032 Enable/disable the generation of the FMA4 instructions.
4034 @item xop
4035 @itemx no-xop
4036 @cindex @code{target("xop")} attribute
4037 Enable/disable the generation of the XOP instructions.
4039 @item lwp
4040 @itemx no-lwp
4041 @cindex @code{target("lwp")} attribute
4042 Enable/disable the generation of the LWP instructions.
4044 @item ssse3
4045 @itemx no-ssse3
4046 @cindex @code{target("ssse3")} attribute
4047 Enable/disable the generation of the SSSE3 instructions.
4049 @item cld
4050 @itemx no-cld
4051 @cindex @code{target("cld")} attribute
4052 Enable/disable the generation of the CLD before string moves.
4054 @item fancy-math-387
4055 @itemx no-fancy-math-387
4056 @cindex @code{target("fancy-math-387")} attribute
4057 Enable/disable the generation of the @code{sin}, @code{cos}, and
4058 @code{sqrt} instructions on the 387 floating-point unit.
4060 @item fused-madd
4061 @itemx no-fused-madd
4062 @cindex @code{target("fused-madd")} attribute
4063 Enable/disable the generation of the fused multiply/add instructions.
4065 @item ieee-fp
4066 @itemx no-ieee-fp
4067 @cindex @code{target("ieee-fp")} attribute
4068 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4070 @item inline-all-stringops
4071 @itemx no-inline-all-stringops
4072 @cindex @code{target("inline-all-stringops")} attribute
4073 Enable/disable inlining of string operations.
4075 @item inline-stringops-dynamically
4076 @itemx no-inline-stringops-dynamically
4077 @cindex @code{target("inline-stringops-dynamically")} attribute
4078 Enable/disable the generation of the inline code to do small string
4079 operations and calling the library routines for large operations.
4081 @item align-stringops
4082 @itemx no-align-stringops
4083 @cindex @code{target("align-stringops")} attribute
4084 Do/do not align destination of inlined string operations.
4086 @item recip
4087 @itemx no-recip
4088 @cindex @code{target("recip")} attribute
4089 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4090 instructions followed an additional Newton-Raphson step instead of
4091 doing a floating-point division.
4093 @item arch=@var{ARCH}
4094 @cindex @code{target("arch=@var{ARCH}")} attribute
4095 Specify the architecture to generate code for in compiling the function.
4097 @item tune=@var{TUNE}
4098 @cindex @code{target("tune=@var{TUNE}")} attribute
4099 Specify the architecture to tune for in compiling the function.
4101 @item fpmath=@var{FPMATH}
4102 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4103 Specify which floating-point unit to use.  The
4104 @code{target("fpmath=sse,387")} option must be specified as
4105 @code{target("fpmath=sse+387")} because the comma would separate
4106 different options.
4107 @end table
4109 On the PowerPC, the following options are allowed:
4111 @table @samp
4112 @item altivec
4113 @itemx no-altivec
4114 @cindex @code{target("altivec")} attribute
4115 Generate code that uses (does not use) AltiVec instructions.  In
4116 32-bit code, you cannot enable AltiVec instructions unless
4117 @option{-mabi=altivec} is used on the command line.
4119 @item cmpb
4120 @itemx no-cmpb
4121 @cindex @code{target("cmpb")} attribute
4122 Generate code that uses (does not use) the compare bytes instruction
4123 implemented on the POWER6 processor and other processors that support
4124 the PowerPC V2.05 architecture.
4126 @item dlmzb
4127 @itemx no-dlmzb
4128 @cindex @code{target("dlmzb")} attribute
4129 Generate code that uses (does not use) the string-search @samp{dlmzb}
4130 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4131 generated by default when targeting those processors.
4133 @item fprnd
4134 @itemx no-fprnd
4135 @cindex @code{target("fprnd")} attribute
4136 Generate code that uses (does not use) the FP round to integer
4137 instructions implemented on the POWER5+ processor and other processors
4138 that support the PowerPC V2.03 architecture.
4140 @item hard-dfp
4141 @itemx no-hard-dfp
4142 @cindex @code{target("hard-dfp")} attribute
4143 Generate code that uses (does not use) the decimal floating-point
4144 instructions implemented on some POWER processors.
4146 @item isel
4147 @itemx no-isel
4148 @cindex @code{target("isel")} attribute
4149 Generate code that uses (does not use) ISEL instruction.
4151 @item mfcrf
4152 @itemx no-mfcrf
4153 @cindex @code{target("mfcrf")} attribute
4154 Generate code that uses (does not use) the move from condition
4155 register field instruction implemented on the POWER4 processor and
4156 other processors that support the PowerPC V2.01 architecture.
4158 @item mfpgpr
4159 @itemx no-mfpgpr
4160 @cindex @code{target("mfpgpr")} attribute
4161 Generate code that uses (does not use) the FP move to/from general
4162 purpose register instructions implemented on the POWER6X processor and
4163 other processors that support the extended PowerPC V2.05 architecture.
4165 @item mulhw
4166 @itemx no-mulhw
4167 @cindex @code{target("mulhw")} attribute
4168 Generate code that uses (does not use) the half-word multiply and
4169 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4170 These instructions are generated by default when targeting those
4171 processors.
4173 @item multiple
4174 @itemx no-multiple
4175 @cindex @code{target("multiple")} attribute
4176 Generate code that uses (does not use) the load multiple word
4177 instructions and the store multiple word instructions.
4179 @item update
4180 @itemx no-update
4181 @cindex @code{target("update")} attribute
4182 Generate code that uses (does not use) the load or store instructions
4183 that update the base register to the address of the calculated memory
4184 location.
4186 @item popcntb
4187 @itemx no-popcntb
4188 @cindex @code{target("popcntb")} attribute
4189 Generate code that uses (does not use) the popcount and double-precision
4190 FP reciprocal estimate instruction implemented on the POWER5
4191 processor and other processors that support the PowerPC V2.02
4192 architecture.
4194 @item popcntd
4195 @itemx no-popcntd
4196 @cindex @code{target("popcntd")} attribute
4197 Generate code that uses (does not use) the popcount instruction
4198 implemented on the POWER7 processor and other processors that support
4199 the PowerPC V2.06 architecture.
4201 @item powerpc-gfxopt
4202 @itemx no-powerpc-gfxopt
4203 @cindex @code{target("powerpc-gfxopt")} attribute
4204 Generate code that uses (does not use) the optional PowerPC
4205 architecture instructions in the Graphics group, including
4206 floating-point select.
4208 @item powerpc-gpopt
4209 @itemx no-powerpc-gpopt
4210 @cindex @code{target("powerpc-gpopt")} attribute
4211 Generate code that uses (does not use) the optional PowerPC
4212 architecture instructions in the General Purpose group, including
4213 floating-point square root.
4215 @item recip-precision
4216 @itemx no-recip-precision
4217 @cindex @code{target("recip-precision")} attribute
4218 Assume (do not assume) that the reciprocal estimate instructions
4219 provide higher-precision estimates than is mandated by the powerpc
4220 ABI.
4222 @item string
4223 @itemx no-string
4224 @cindex @code{target("string")} attribute
4225 Generate code that uses (does not use) the load string instructions
4226 and the store string word instructions to save multiple registers and
4227 do small block moves.
4229 @item vsx
4230 @itemx no-vsx
4231 @cindex @code{target("vsx")} attribute
4232 Generate code that uses (does not use) vector/scalar (VSX)
4233 instructions, and also enable the use of built-in functions that allow
4234 more direct access to the VSX instruction set.  In 32-bit code, you
4235 cannot enable VSX or AltiVec instructions unless
4236 @option{-mabi=altivec} is used on the command line.
4238 @item friz
4239 @itemx no-friz
4240 @cindex @code{target("friz")} attribute
4241 Generate (do not generate) the @code{friz} instruction when the
4242 @option{-funsafe-math-optimizations} option is used to optimize
4243 rounding a floating-point value to 64-bit integer and back to floating
4244 point.  The @code{friz} instruction does not return the same value if
4245 the floating-point number is too large to fit in an integer.
4247 @item avoid-indexed-addresses
4248 @itemx no-avoid-indexed-addresses
4249 @cindex @code{target("avoid-indexed-addresses")} attribute
4250 Generate code that tries to avoid (not avoid) the use of indexed load
4251 or store instructions.
4253 @item paired
4254 @itemx no-paired
4255 @cindex @code{target("paired")} attribute
4256 Generate code that uses (does not use) the generation of PAIRED simd
4257 instructions.
4259 @item longcall
4260 @itemx no-longcall
4261 @cindex @code{target("longcall")} attribute
4262 Generate code that assumes (does not assume) that all calls are far
4263 away so that a longer more expensive calling sequence is required.
4265 @item cpu=@var{CPU}
4266 @cindex @code{target("cpu=@var{CPU}")} attribute
4267 Specify the architecture to generate code for when compiling the
4268 function.  If you select the @code{target("cpu=power7")} attribute when
4269 generating 32-bit code, VSX and AltiVec instructions are not generated
4270 unless you use the @option{-mabi=altivec} option on the command line.
4272 @item tune=@var{TUNE}
4273 @cindex @code{target("tune=@var{TUNE}")} attribute
4274 Specify the architecture to tune for when compiling the function.  If
4275 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4276 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4277 compilation tunes for the @var{CPU} architecture, and not the
4278 default tuning specified on the command line.
4279 @end table
4281 When compiling for Nios II, the following options are allowed:
4283 @table @samp
4284 @item custom-@var{insn}=@var{N}
4285 @itemx no-custom-@var{insn}
4286 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4287 @cindex @code{target("no-custom-@var{insn}")} attribute
4288 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4289 custom instruction with encoding @var{N} when generating code that uses 
4290 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4291 the custom instruction @var{insn}.
4292 These target attributes correspond to the
4293 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4294 command-line options, and support the same set of @var{insn} keywords.
4295 @xref{Nios II Options}, for more information.
4297 @item custom-fpu-cfg=@var{name}
4298 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4299 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4300 command-line option, to select a predefined set of custom instructions
4301 named @var{name}.
4302 @xref{Nios II Options}, for more information.
4303 @end table
4305 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4306 function that has different target options than the caller, unless the
4307 callee has a subset of the target options of the caller.  For example
4308 a function declared with @code{target("sse3")} can inline a function
4309 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4311 @item tiny_data
4312 @cindex tiny data section on the H8/300H and H8S
4313 Use this attribute on the H8/300H and H8S to indicate that the specified
4314 variable should be placed into the tiny data section.
4315 The compiler generates more efficient code for loads and stores
4316 on data in the tiny data section.  Note the tiny data area is limited to
4317 slightly under 32KB of data.
4319 @item trap_exit
4320 @cindex @code{trap_exit} attribute
4321 Use this attribute on the SH for an @code{interrupt_handler} to return using
4322 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4323 argument specifying the trap number to be used.
4325 @item trapa_handler
4326 @cindex @code{trapa_handler} attribute
4327 On SH targets this function attribute is similar to @code{interrupt_handler}
4328 but it does not save and restore all registers.
4330 @item unused
4331 @cindex @code{unused} attribute.
4332 This attribute, attached to a function, means that the function is meant
4333 to be possibly unused.  GCC does not produce a warning for this
4334 function.
4336 @item used
4337 @cindex @code{used} attribute.
4338 This attribute, attached to a function, means that code must be emitted
4339 for the function even if it appears that the function is not referenced.
4340 This is useful, for example, when the function is referenced only in
4341 inline assembly.
4343 When applied to a member function of a C++ class template, the
4344 attribute also means that the function is instantiated if the
4345 class itself is instantiated.
4347 @item vector
4348 @cindex @code{vector} attribute
4349 This RX attribute is similar to the @code{interrupt} attribute, including its
4350 parameters, but does not make the function an interrupt-handler type
4351 function (i.e. it retains the normal C function calling ABI).  See the
4352 @code{interrupt} attribute for a description of its arguments.
4354 @item version_id
4355 @cindex @code{version_id} attribute
4356 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4357 symbol to contain a version string, thus allowing for function level
4358 versioning.  HP-UX system header files may use function level versioning
4359 for some system calls.
4361 @smallexample
4362 extern int foo () __attribute__((version_id ("20040821")));
4363 @end smallexample
4365 @noindent
4366 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4368 @item visibility ("@var{visibility_type}")
4369 @cindex @code{visibility} attribute
4370 This attribute affects the linkage of the declaration to which it is attached.
4371 There are four supported @var{visibility_type} values: default,
4372 hidden, protected or internal visibility.
4374 @smallexample
4375 void __attribute__ ((visibility ("protected")))
4376 f () @{ /* @r{Do something.} */; @}
4377 int i __attribute__ ((visibility ("hidden")));
4378 @end smallexample
4380 The possible values of @var{visibility_type} correspond to the
4381 visibility settings in the ELF gABI.
4383 @table @dfn
4384 @c keep this list of visibilities in alphabetical order.
4386 @item default
4387 Default visibility is the normal case for the object file format.
4388 This value is available for the visibility attribute to override other
4389 options that may change the assumed visibility of entities.
4391 On ELF, default visibility means that the declaration is visible to other
4392 modules and, in shared libraries, means that the declared entity may be
4393 overridden.
4395 On Darwin, default visibility means that the declaration is visible to
4396 other modules.
4398 Default visibility corresponds to ``external linkage'' in the language.
4400 @item hidden
4401 Hidden visibility indicates that the entity declared has a new
4402 form of linkage, which we call ``hidden linkage''.  Two
4403 declarations of an object with hidden linkage refer to the same object
4404 if they are in the same shared object.
4406 @item internal
4407 Internal visibility is like hidden visibility, but with additional
4408 processor specific semantics.  Unless otherwise specified by the
4409 psABI, GCC defines internal visibility to mean that a function is
4410 @emph{never} called from another module.  Compare this with hidden
4411 functions which, while they cannot be referenced directly by other
4412 modules, can be referenced indirectly via function pointers.  By
4413 indicating that a function cannot be called from outside the module,
4414 GCC may for instance omit the load of a PIC register since it is known
4415 that the calling function loaded the correct value.
4417 @item protected
4418 Protected visibility is like default visibility except that it
4419 indicates that references within the defining module bind to the
4420 definition in that module.  That is, the declared entity cannot be
4421 overridden by another module.
4423 @end table
4425 All visibilities are supported on many, but not all, ELF targets
4426 (supported when the assembler supports the @samp{.visibility}
4427 pseudo-op).  Default visibility is supported everywhere.  Hidden
4428 visibility is supported on Darwin targets.
4430 The visibility attribute should be applied only to declarations that
4431 would otherwise have external linkage.  The attribute should be applied
4432 consistently, so that the same entity should not be declared with
4433 different settings of the attribute.
4435 In C++, the visibility attribute applies to types as well as functions
4436 and objects, because in C++ types have linkage.  A class must not have
4437 greater visibility than its non-static data member types and bases,
4438 and class members default to the visibility of their class.  Also, a
4439 declaration without explicit visibility is limited to the visibility
4440 of its type.
4442 In C++, you can mark member functions and static member variables of a
4443 class with the visibility attribute.  This is useful if you know a
4444 particular method or static member variable should only be used from
4445 one shared object; then you can mark it hidden while the rest of the
4446 class has default visibility.  Care must be taken to avoid breaking
4447 the One Definition Rule; for example, it is usually not useful to mark
4448 an inline method as hidden without marking the whole class as hidden.
4450 A C++ namespace declaration can also have the visibility attribute.
4452 @smallexample
4453 namespace nspace1 __attribute__ ((visibility ("protected")))
4454 @{ /* @r{Do something.} */; @}
4455 @end smallexample
4457 This attribute applies only to the particular namespace body, not to
4458 other definitions of the same namespace; it is equivalent to using
4459 @samp{#pragma GCC visibility} before and after the namespace
4460 definition (@pxref{Visibility Pragmas}).
4462 In C++, if a template argument has limited visibility, this
4463 restriction is implicitly propagated to the template instantiation.
4464 Otherwise, template instantiations and specializations default to the
4465 visibility of their template.
4467 If both the template and enclosing class have explicit visibility, the
4468 visibility from the template is used.
4470 @item vliw
4471 @cindex @code{vliw} attribute
4472 On MeP, the @code{vliw} attribute tells the compiler to emit
4473 instructions in VLIW mode instead of core mode.  Note that this
4474 attribute is not allowed unless a VLIW coprocessor has been configured
4475 and enabled through command-line options.
4477 @item warn_unused_result
4478 @cindex @code{warn_unused_result} attribute
4479 The @code{warn_unused_result} attribute causes a warning to be emitted
4480 if a caller of the function with this attribute does not use its
4481 return value.  This is useful for functions where not checking
4482 the result is either a security problem or always a bug, such as
4483 @code{realloc}.
4485 @smallexample
4486 int fn () __attribute__ ((warn_unused_result));
4487 int foo ()
4489   if (fn () < 0) return -1;
4490   fn ();
4491   return 0;
4493 @end smallexample
4495 @noindent
4496 results in warning on line 5.
4498 @item weak
4499 @cindex @code{weak} attribute
4500 The @code{weak} attribute causes the declaration to be emitted as a weak
4501 symbol rather than a global.  This is primarily useful in defining
4502 library functions that can be overridden in user code, though it can
4503 also be used with non-function declarations.  Weak symbols are supported
4504 for ELF targets, and also for a.out targets when using the GNU assembler
4505 and linker.
4507 @item weakref
4508 @itemx weakref ("@var{target}")
4509 @cindex @code{weakref} attribute
4510 The @code{weakref} attribute marks a declaration as a weak reference.
4511 Without arguments, it should be accompanied by an @code{alias} attribute
4512 naming the target symbol.  Optionally, the @var{target} may be given as
4513 an argument to @code{weakref} itself.  In either case, @code{weakref}
4514 implicitly marks the declaration as @code{weak}.  Without a
4515 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4516 @code{weakref} is equivalent to @code{weak}.
4518 @smallexample
4519 static int x() __attribute__ ((weakref ("y")));
4520 /* is equivalent to... */
4521 static int x() __attribute__ ((weak, weakref, alias ("y")));
4522 /* and to... */
4523 static int x() __attribute__ ((weakref));
4524 static int x() __attribute__ ((alias ("y")));
4525 @end smallexample
4527 A weak reference is an alias that does not by itself require a
4528 definition to be given for the target symbol.  If the target symbol is
4529 only referenced through weak references, then it becomes a @code{weak}
4530 undefined symbol.  If it is directly referenced, however, then such
4531 strong references prevail, and a definition is required for the
4532 symbol, not necessarily in the same translation unit.
4534 The effect is equivalent to moving all references to the alias to a
4535 separate translation unit, renaming the alias to the aliased symbol,
4536 declaring it as weak, compiling the two separate translation units and
4537 performing a reloadable link on them.
4539 At present, a declaration to which @code{weakref} is attached can
4540 only be @code{static}.
4542 @end table
4544 You can specify multiple attributes in a declaration by separating them
4545 by commas within the double parentheses or by immediately following an
4546 attribute declaration with another attribute declaration.
4548 @cindex @code{#pragma}, reason for not using
4549 @cindex pragma, reason for not using
4550 Some people object to the @code{__attribute__} feature, suggesting that
4551 ISO C's @code{#pragma} should be used instead.  At the time
4552 @code{__attribute__} was designed, there were two reasons for not doing
4553 this.
4555 @enumerate
4556 @item
4557 It is impossible to generate @code{#pragma} commands from a macro.
4559 @item
4560 There is no telling what the same @code{#pragma} might mean in another
4561 compiler.
4562 @end enumerate
4564 These two reasons applied to almost any application that might have been
4565 proposed for @code{#pragma}.  It was basically a mistake to use
4566 @code{#pragma} for @emph{anything}.
4568 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4569 to be generated from macros.  In addition, a @code{#pragma GCC}
4570 namespace is now in use for GCC-specific pragmas.  However, it has been
4571 found convenient to use @code{__attribute__} to achieve a natural
4572 attachment of attributes to their corresponding declarations, whereas
4573 @code{#pragma GCC} is of use for constructs that do not naturally form
4574 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4576 @node Label Attributes
4577 @section Label Attributes
4578 @cindex Label Attributes
4580 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
4581 details of the exact syntax for using attributes.  Other attributes are 
4582 available for functions (@pxref{Function Attributes}), variables 
4583 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4585 This example uses the @code{cold} label attribute to indicate the 
4586 @code{ErrorHandling} branch is unlikely to be taken and that the
4587 @code{ErrorHandling} label is unused:
4589 @smallexample
4591    asm goto ("some asm" : : : : NoError);
4593 /* This branch (the fallthru from the asm) is less commonly used */
4594 ErrorHandling: 
4595    __attribute__((cold, unused)); /* Semi-colon is required here */
4596    printf("error\n");
4597    return 0;
4599 NoError:
4600    printf("no error\n");
4601    return 1;
4602 @end smallexample
4604 @table @code
4605 @item unused
4606 @cindex @code{unused} label attribute
4607 This feature is intended for program-generated code that may contain 
4608 unused labels, but which is compiled with @option{-Wall}.  It is
4609 not normally appropriate to use in it human-written code, though it
4610 could be useful in cases where the code that jumps to the label is
4611 contained within an @code{#ifdef} conditional.
4613 @item hot
4614 @cindex @code{hot} label attribute
4615 The @code{hot} attribute on a label is used to inform the compiler that
4616 the path following the label is more likely than paths that are not so
4617 annotated.  This attribute is used in cases where @code{__builtin_expect}
4618 cannot be used, for instance with computed goto or @code{asm goto}.
4620 The @code{hot} attribute on labels is not implemented in GCC versions
4621 earlier than 4.8.
4623 @item cold
4624 @cindex @code{cold} label attribute
4625 The @code{cold} attribute on labels is used to inform the compiler that
4626 the path following the label is unlikely to be executed.  This attribute
4627 is used in cases where @code{__builtin_expect} cannot be used, for instance
4628 with computed goto or @code{asm goto}.
4630 The @code{cold} attribute on labels is not implemented in GCC versions
4631 earlier than 4.8.
4633 @end table
4635 @node Attribute Syntax
4636 @section Attribute Syntax
4637 @cindex attribute syntax
4639 This section describes the syntax with which @code{__attribute__} may be
4640 used, and the constructs to which attribute specifiers bind, for the C
4641 language.  Some details may vary for C++ and Objective-C@.  Because of
4642 infelicities in the grammar for attributes, some forms described here
4643 may not be successfully parsed in all cases.
4645 There are some problems with the semantics of attributes in C++.  For
4646 example, there are no manglings for attributes, although they may affect
4647 code generation, so problems may arise when attributed types are used in
4648 conjunction with templates or overloading.  Similarly, @code{typeid}
4649 does not distinguish between types with different attributes.  Support
4650 for attributes in C++ may be restricted in future to attributes on
4651 declarations only, but not on nested declarators.
4653 @xref{Function Attributes}, for details of the semantics of attributes
4654 applying to functions.  @xref{Variable Attributes}, for details of the
4655 semantics of attributes applying to variables.  @xref{Type Attributes},
4656 for details of the semantics of attributes applying to structure, union
4657 and enumerated types.
4658 @xref{Label Attributes}, for details of the semantics of attributes 
4659 applying to labels.
4661 An @dfn{attribute specifier} is of the form
4662 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4663 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4664 each attribute is one of the following:
4666 @itemize @bullet
4667 @item
4668 Empty.  Empty attributes are ignored.
4670 @item
4671 A word (which may be an identifier such as @code{unused}, or a reserved
4672 word such as @code{const}).
4674 @item
4675 A word, followed by, in parentheses, parameters for the attribute.
4676 These parameters take one of the following forms:
4678 @itemize @bullet
4679 @item
4680 An identifier.  For example, @code{mode} attributes use this form.
4682 @item
4683 An identifier followed by a comma and a non-empty comma-separated list
4684 of expressions.  For example, @code{format} attributes use this form.
4686 @item
4687 A possibly empty comma-separated list of expressions.  For example,
4688 @code{format_arg} attributes use this form with the list being a single
4689 integer constant expression, and @code{alias} attributes use this form
4690 with the list being a single string constant.
4691 @end itemize
4692 @end itemize
4694 An @dfn{attribute specifier list} is a sequence of one or more attribute
4695 specifiers, not separated by any other tokens.
4697 @subsubheading Label Attributes
4699 In GNU C, an attribute specifier list may appear after the colon following a
4700 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
4701 attributes on labels if the attribute specifier is immediately
4702 followed by a semicolon (i.e., the label applies to an empty
4703 statement).  If the semicolon is missing, C++ label attributes are
4704 ambiguous, as it is permissible for a declaration, which could begin
4705 with an attribute list, to be labelled in C++.  Declarations cannot be
4706 labelled in C90 or C99, so the ambiguity does not arise there.
4708 @subsubheading Type Attributes
4710 An attribute specifier list may appear as part of a @code{struct},
4711 @code{union} or @code{enum} specifier.  It may go either immediately
4712 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4713 the closing brace.  The former syntax is preferred.
4714 Where attribute specifiers follow the closing brace, they are considered
4715 to relate to the structure, union or enumerated type defined, not to any
4716 enclosing declaration the type specifier appears in, and the type
4717 defined is not complete until after the attribute specifiers.
4718 @c Otherwise, there would be the following problems: a shift/reduce
4719 @c conflict between attributes binding the struct/union/enum and
4720 @c binding to the list of specifiers/qualifiers; and "aligned"
4721 @c attributes could use sizeof for the structure, but the size could be
4722 @c changed later by "packed" attributes.
4725 @subsubheading All other attributes
4727 Otherwise, an attribute specifier appears as part of a declaration,
4728 counting declarations of unnamed parameters and type names, and relates
4729 to that declaration (which may be nested in another declaration, for
4730 example in the case of a parameter declaration), or to a particular declarator
4731 within a declaration.  Where an
4732 attribute specifier is applied to a parameter declared as a function or
4733 an array, it should apply to the function or array rather than the
4734 pointer to which the parameter is implicitly converted, but this is not
4735 yet correctly implemented.
4737 Any list of specifiers and qualifiers at the start of a declaration may
4738 contain attribute specifiers, whether or not such a list may in that
4739 context contain storage class specifiers.  (Some attributes, however,
4740 are essentially in the nature of storage class specifiers, and only make
4741 sense where storage class specifiers may be used; for example,
4742 @code{section}.)  There is one necessary limitation to this syntax: the
4743 first old-style parameter declaration in a function definition cannot
4744 begin with an attribute specifier, because such an attribute applies to
4745 the function instead by syntax described below (which, however, is not
4746 yet implemented in this case).  In some other cases, attribute
4747 specifiers are permitted by this grammar but not yet supported by the
4748 compiler.  All attribute specifiers in this place relate to the
4749 declaration as a whole.  In the obsolescent usage where a type of
4750 @code{int} is implied by the absence of type specifiers, such a list of
4751 specifiers and qualifiers may be an attribute specifier list with no
4752 other specifiers or qualifiers.
4754 At present, the first parameter in a function prototype must have some
4755 type specifier that is not an attribute specifier; this resolves an
4756 ambiguity in the interpretation of @code{void f(int
4757 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4758 the parentheses of a function declarator contain only attributes then
4759 those attributes are ignored, rather than yielding an error or warning
4760 or implying a single parameter of type int, but this is subject to
4761 change.
4763 An attribute specifier list may appear immediately before a declarator
4764 (other than the first) in a comma-separated list of declarators in a
4765 declaration of more than one identifier using a single list of
4766 specifiers and qualifiers.  Such attribute specifiers apply
4767 only to the identifier before whose declarator they appear.  For
4768 example, in
4770 @smallexample
4771 __attribute__((noreturn)) void d0 (void),
4772     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4773      d2 (void)
4774 @end smallexample
4776 @noindent
4777 the @code{noreturn} attribute applies to all the functions
4778 declared; the @code{format} attribute only applies to @code{d1}.
4780 An attribute specifier list may appear immediately before the comma,
4781 @code{=} or semicolon terminating the declaration of an identifier other
4782 than a function definition.  Such attribute specifiers apply
4783 to the declared object or function.  Where an
4784 assembler name for an object or function is specified (@pxref{Asm
4785 Labels}), the attribute must follow the @code{asm}
4786 specification.
4788 An attribute specifier list may, in future, be permitted to appear after
4789 the declarator in a function definition (before any old-style parameter
4790 declarations or the function body).
4792 Attribute specifiers may be mixed with type qualifiers appearing inside
4793 the @code{[]} of a parameter array declarator, in the C99 construct by
4794 which such qualifiers are applied to the pointer to which the array is
4795 implicitly converted.  Such attribute specifiers apply to the pointer,
4796 not to the array, but at present this is not implemented and they are
4797 ignored.
4799 An attribute specifier list may appear at the start of a nested
4800 declarator.  At present, there are some limitations in this usage: the
4801 attributes correctly apply to the declarator, but for most individual
4802 attributes the semantics this implies are not implemented.
4803 When attribute specifiers follow the @code{*} of a pointer
4804 declarator, they may be mixed with any type qualifiers present.
4805 The following describes the formal semantics of this syntax.  It makes the
4806 most sense if you are familiar with the formal specification of
4807 declarators in the ISO C standard.
4809 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4810 D1}, where @code{T} contains declaration specifiers that specify a type
4811 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4812 contains an identifier @var{ident}.  The type specified for @var{ident}
4813 for derived declarators whose type does not include an attribute
4814 specifier is as in the ISO C standard.
4816 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4817 and the declaration @code{T D} specifies the type
4818 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4819 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4820 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4822 If @code{D1} has the form @code{*
4823 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4824 declaration @code{T D} specifies the type
4825 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4826 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4827 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4828 @var{ident}.
4830 For example,
4832 @smallexample
4833 void (__attribute__((noreturn)) ****f) (void);
4834 @end smallexample
4836 @noindent
4837 specifies the type ``pointer to pointer to pointer to pointer to
4838 non-returning function returning @code{void}''.  As another example,
4840 @smallexample
4841 char *__attribute__((aligned(8))) *f;
4842 @end smallexample
4844 @noindent
4845 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4846 Note again that this does not work with most attributes; for example,
4847 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4848 is not yet supported.
4850 For compatibility with existing code written for compiler versions that
4851 did not implement attributes on nested declarators, some laxity is
4852 allowed in the placing of attributes.  If an attribute that only applies
4853 to types is applied to a declaration, it is treated as applying to
4854 the type of that declaration.  If an attribute that only applies to
4855 declarations is applied to the type of a declaration, it is treated
4856 as applying to that declaration; and, for compatibility with code
4857 placing the attributes immediately before the identifier declared, such
4858 an attribute applied to a function return type is treated as
4859 applying to the function type, and such an attribute applied to an array
4860 element type is treated as applying to the array type.  If an
4861 attribute that only applies to function types is applied to a
4862 pointer-to-function type, it is treated as applying to the pointer
4863 target type; if such an attribute is applied to a function return type
4864 that is not a pointer-to-function type, it is treated as applying
4865 to the function type.
4867 @node Function Prototypes
4868 @section Prototypes and Old-Style Function Definitions
4869 @cindex function prototype declarations
4870 @cindex old-style function definitions
4871 @cindex promotion of formal parameters
4873 GNU C extends ISO C to allow a function prototype to override a later
4874 old-style non-prototype definition.  Consider the following example:
4876 @smallexample
4877 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4878 #ifdef __STDC__
4879 #define P(x) x
4880 #else
4881 #define P(x) ()
4882 #endif
4884 /* @r{Prototype function declaration.}  */
4885 int isroot P((uid_t));
4887 /* @r{Old-style function definition.}  */
4889 isroot (x)   /* @r{??? lossage here ???} */
4890      uid_t x;
4892   return x == 0;
4894 @end smallexample
4896 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4897 not allow this example, because subword arguments in old-style
4898 non-prototype definitions are promoted.  Therefore in this example the
4899 function definition's argument is really an @code{int}, which does not
4900 match the prototype argument type of @code{short}.
4902 This restriction of ISO C makes it hard to write code that is portable
4903 to traditional C compilers, because the programmer does not know
4904 whether the @code{uid_t} type is @code{short}, @code{int}, or
4905 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4906 to override a later old-style definition.  More precisely, in GNU C, a
4907 function prototype argument type overrides the argument type specified
4908 by a later old-style definition if the former type is the same as the
4909 latter type before promotion.  Thus in GNU C the above example is
4910 equivalent to the following:
4912 @smallexample
4913 int isroot (uid_t);
4916 isroot (uid_t x)
4918   return x == 0;
4920 @end smallexample
4922 @noindent
4923 GNU C++ does not support old-style function definitions, so this
4924 extension is irrelevant.
4926 @node C++ Comments
4927 @section C++ Style Comments
4928 @cindex @code{//}
4929 @cindex C++ comments
4930 @cindex comments, C++ style
4932 In GNU C, you may use C++ style comments, which start with @samp{//} and
4933 continue until the end of the line.  Many other C implementations allow
4934 such comments, and they are included in the 1999 C standard.  However,
4935 C++ style comments are not recognized if you specify an @option{-std}
4936 option specifying a version of ISO C before C99, or @option{-ansi}
4937 (equivalent to @option{-std=c90}).
4939 @node Dollar Signs
4940 @section Dollar Signs in Identifier Names
4941 @cindex $
4942 @cindex dollar signs in identifier names
4943 @cindex identifier names, dollar signs in
4945 In GNU C, you may normally use dollar signs in identifier names.
4946 This is because many traditional C implementations allow such identifiers.
4947 However, dollar signs in identifiers are not supported on a few target
4948 machines, typically because the target assembler does not allow them.
4950 @node Character Escapes
4951 @section The Character @key{ESC} in Constants
4953 You can use the sequence @samp{\e} in a string or character constant to
4954 stand for the ASCII character @key{ESC}.
4956 @node Variable Attributes
4957 @section Specifying Attributes of Variables
4958 @cindex attribute of variables
4959 @cindex variable attributes
4961 The keyword @code{__attribute__} allows you to specify special
4962 attributes of variables or structure fields.  This keyword is followed
4963 by an attribute specification inside double parentheses.  Some
4964 attributes are currently defined generically for variables.
4965 Other attributes are defined for variables on particular target
4966 systems.  Other attributes are available for functions
4967 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
4968 types (@pxref{Type Attributes}).
4969 Other front ends might define more attributes
4970 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4972 You may also specify attributes with @samp{__} preceding and following
4973 each keyword.  This allows you to use them in header files without
4974 being concerned about a possible macro of the same name.  For example,
4975 you may use @code{__aligned__} instead of @code{aligned}.
4977 @xref{Attribute Syntax}, for details of the exact syntax for using
4978 attributes.
4980 @table @code
4981 @cindex @code{aligned} attribute
4982 @item aligned (@var{alignment})
4983 This attribute specifies a minimum alignment for the variable or
4984 structure field, measured in bytes.  For example, the declaration:
4986 @smallexample
4987 int x __attribute__ ((aligned (16))) = 0;
4988 @end smallexample
4990 @noindent
4991 causes the compiler to allocate the global variable @code{x} on a
4992 16-byte boundary.  On a 68040, this could be used in conjunction with
4993 an @code{asm} expression to access the @code{move16} instruction which
4994 requires 16-byte aligned operands.
4996 You can also specify the alignment of structure fields.  For example, to
4997 create a double-word aligned @code{int} pair, you could write:
4999 @smallexample
5000 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5001 @end smallexample
5003 @noindent
5004 This is an alternative to creating a union with a @code{double} member,
5005 which forces the union to be double-word aligned.
5007 As in the preceding examples, you can explicitly specify the alignment
5008 (in bytes) that you wish the compiler to use for a given variable or
5009 structure field.  Alternatively, you can leave out the alignment factor
5010 and just ask the compiler to align a variable or field to the
5011 default alignment for the target architecture you are compiling for.
5012 The default alignment is sufficient for all scalar types, but may not be
5013 enough for all vector types on a target that supports vector operations.
5014 The default alignment is fixed for a particular target ABI.
5016 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5017 which is the largest alignment ever used for any data type on the
5018 target machine you are compiling for.  For example, you could write:
5020 @smallexample
5021 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5022 @end smallexample
5024 The compiler automatically sets the alignment for the declared
5025 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5026 often make copy operations more efficient, because the compiler can
5027 use whatever instructions copy the biggest chunks of memory when
5028 performing copies to or from the variables or fields that you have
5029 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5030 may change depending on command-line options.
5032 When used on a struct, or struct member, the @code{aligned} attribute can
5033 only increase the alignment; in order to decrease it, the @code{packed}
5034 attribute must be specified as well.  When used as part of a typedef, the
5035 @code{aligned} attribute can both increase and decrease alignment, and
5036 specifying the @code{packed} attribute generates a warning.
5038 Note that the effectiveness of @code{aligned} attributes may be limited
5039 by inherent limitations in your linker.  On many systems, the linker is
5040 only able to arrange for variables to be aligned up to a certain maximum
5041 alignment.  (For some linkers, the maximum supported alignment may
5042 be very very small.)  If your linker is only able to align variables
5043 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5044 in an @code{__attribute__} still only provides you with 8-byte
5045 alignment.  See your linker documentation for further information.
5047 The @code{aligned} attribute can also be used for functions
5048 (@pxref{Function Attributes}.)
5050 @item cleanup (@var{cleanup_function})
5051 @cindex @code{cleanup} attribute
5052 The @code{cleanup} attribute runs a function when the variable goes
5053 out of scope.  This attribute can only be applied to auto function
5054 scope variables; it may not be applied to parameters or variables
5055 with static storage duration.  The function must take one parameter,
5056 a pointer to a type compatible with the variable.  The return value
5057 of the function (if any) is ignored.
5059 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5060 is run during the stack unwinding that happens during the
5061 processing of the exception.  Note that the @code{cleanup} attribute
5062 does not allow the exception to be caught, only to perform an action.
5063 It is undefined what happens if @var{cleanup_function} does not
5064 return normally.
5066 @item common
5067 @itemx nocommon
5068 @cindex @code{common} attribute
5069 @cindex @code{nocommon} attribute
5070 @opindex fcommon
5071 @opindex fno-common
5072 The @code{common} attribute requests GCC to place a variable in
5073 ``common'' storage.  The @code{nocommon} attribute requests the
5074 opposite---to allocate space for it directly.
5076 These attributes override the default chosen by the
5077 @option{-fno-common} and @option{-fcommon} flags respectively.
5079 @item deprecated
5080 @itemx deprecated (@var{msg})
5081 @cindex @code{deprecated} attribute
5082 The @code{deprecated} attribute results in a warning if the variable
5083 is used anywhere in the source file.  This is useful when identifying
5084 variables that are expected to be removed in a future version of a
5085 program.  The warning also includes the location of the declaration
5086 of the deprecated variable, to enable users to easily find further
5087 information about why the variable is deprecated, or what they should
5088 do instead.  Note that the warning only occurs for uses:
5090 @smallexample
5091 extern int old_var __attribute__ ((deprecated));
5092 extern int old_var;
5093 int new_fn () @{ return old_var; @}
5094 @end smallexample
5096 @noindent
5097 results in a warning on line 3 but not line 2.  The optional @var{msg}
5098 argument, which must be a string, is printed in the warning if
5099 present.
5101 The @code{deprecated} attribute can also be used for functions and
5102 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5104 @item mode (@var{mode})
5105 @cindex @code{mode} attribute
5106 This attribute specifies the data type for the declaration---whichever
5107 type corresponds to the mode @var{mode}.  This in effect lets you
5108 request an integer or floating-point type according to its width.
5110 You may also specify a mode of @code{byte} or @code{__byte__} to
5111 indicate the mode corresponding to a one-byte integer, @code{word} or
5112 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5113 or @code{__pointer__} for the mode used to represent pointers.
5115 @item packed
5116 @cindex @code{packed} attribute
5117 The @code{packed} attribute specifies that a variable or structure field
5118 should have the smallest possible alignment---one byte for a variable,
5119 and one bit for a field, unless you specify a larger value with the
5120 @code{aligned} attribute.
5122 Here is a structure in which the field @code{x} is packed, so that it
5123 immediately follows @code{a}:
5125 @smallexample
5126 struct foo
5128   char a;
5129   int x[2] __attribute__ ((packed));
5131 @end smallexample
5133 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5134 @code{packed} attribute on bit-fields of type @code{char}.  This has
5135 been fixed in GCC 4.4 but the change can lead to differences in the
5136 structure layout.  See the documentation of
5137 @option{-Wpacked-bitfield-compat} for more information.
5139 @item section ("@var{section-name}")
5140 @cindex @code{section} variable attribute
5141 Normally, the compiler places the objects it generates in sections like
5142 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5143 or you need certain particular variables to appear in special sections,
5144 for example to map to special hardware.  The @code{section}
5145 attribute specifies that a variable (or function) lives in a particular
5146 section.  For example, this small program uses several specific section names:
5148 @smallexample
5149 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5150 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5151 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5152 int init_data __attribute__ ((section ("INITDATA")));
5154 main()
5156   /* @r{Initialize stack pointer} */
5157   init_sp (stack + sizeof (stack));
5159   /* @r{Initialize initialized data} */
5160   memcpy (&init_data, &data, &edata - &data);
5162   /* @r{Turn on the serial ports} */
5163   init_duart (&a);
5164   init_duart (&b);
5166 @end smallexample
5168 @noindent
5169 Use the @code{section} attribute with
5170 @emph{global} variables and not @emph{local} variables,
5171 as shown in the example.
5173 You may use the @code{section} attribute with initialized or
5174 uninitialized global variables but the linker requires
5175 each object be defined once, with the exception that uninitialized
5176 variables tentatively go in the @code{common} (or @code{bss}) section
5177 and can be multiply ``defined''.  Using the @code{section} attribute
5178 changes what section the variable goes into and may cause the
5179 linker to issue an error if an uninitialized variable has multiple
5180 definitions.  You can force a variable to be initialized with the
5181 @option{-fno-common} flag or the @code{nocommon} attribute.
5183 Some file formats do not support arbitrary sections so the @code{section}
5184 attribute is not available on all platforms.
5185 If you need to map the entire contents of a module to a particular
5186 section, consider using the facilities of the linker instead.
5188 @item shared
5189 @cindex @code{shared} variable attribute
5190 On Microsoft Windows, in addition to putting variable definitions in a named
5191 section, the section can also be shared among all running copies of an
5192 executable or DLL@.  For example, this small program defines shared data
5193 by putting it in a named section @code{shared} and marking the section
5194 shareable:
5196 @smallexample
5197 int foo __attribute__((section ("shared"), shared)) = 0;
5200 main()
5202   /* @r{Read and write foo.  All running
5203      copies see the same value.}  */
5204   return 0;
5206 @end smallexample
5208 @noindent
5209 You may only use the @code{shared} attribute along with @code{section}
5210 attribute with a fully-initialized global definition because of the way
5211 linkers work.  See @code{section} attribute for more information.
5213 The @code{shared} attribute is only available on Microsoft Windows@.
5215 @item tls_model ("@var{tls_model}")
5216 @cindex @code{tls_model} attribute
5217 The @code{tls_model} attribute sets thread-local storage model
5218 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5219 overriding @option{-ftls-model=} command-line switch on a per-variable
5220 basis.
5221 The @var{tls_model} argument should be one of @code{global-dynamic},
5222 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5224 Not all targets support this attribute.
5226 @item unused
5227 This attribute, attached to a variable, means that the variable is meant
5228 to be possibly unused.  GCC does not produce a warning for this
5229 variable.
5231 @item used
5232 This attribute, attached to a variable with the static storage, means that
5233 the variable must be emitted even if it appears that the variable is not
5234 referenced.
5236 When applied to a static data member of a C++ class template, the
5237 attribute also means that the member is instantiated if the
5238 class itself is instantiated.
5240 @item vector_size (@var{bytes})
5241 This attribute specifies the vector size for the variable, measured in
5242 bytes.  For example, the declaration:
5244 @smallexample
5245 int foo __attribute__ ((vector_size (16)));
5246 @end smallexample
5248 @noindent
5249 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5250 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5251 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5253 This attribute is only applicable to integral and float scalars,
5254 although arrays, pointers, and function return values are allowed in
5255 conjunction with this construct.
5257 Aggregates with this attribute are invalid, even if they are of the same
5258 size as a corresponding scalar.  For example, the declaration:
5260 @smallexample
5261 struct S @{ int a; @};
5262 struct S  __attribute__ ((vector_size (16))) foo;
5263 @end smallexample
5265 @noindent
5266 is invalid even if the size of the structure is the same as the size of
5267 the @code{int}.
5269 @item selectany
5270 The @code{selectany} attribute causes an initialized global variable to
5271 have link-once semantics.  When multiple definitions of the variable are
5272 encountered by the linker, the first is selected and the remainder are
5273 discarded.  Following usage by the Microsoft compiler, the linker is told
5274 @emph{not} to warn about size or content differences of the multiple
5275 definitions.
5277 Although the primary usage of this attribute is for POD types, the
5278 attribute can also be applied to global C++ objects that are initialized
5279 by a constructor.  In this case, the static initialization and destruction
5280 code for the object is emitted in each translation defining the object,
5281 but the calls to the constructor and destructor are protected by a
5282 link-once guard variable.
5284 The @code{selectany} attribute is only available on Microsoft Windows
5285 targets.  You can use @code{__declspec (selectany)} as a synonym for
5286 @code{__attribute__ ((selectany))} for compatibility with other
5287 compilers.
5289 @item weak
5290 The @code{weak} attribute is described in @ref{Function Attributes}.
5292 @item dllimport
5293 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5295 @item dllexport
5296 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5298 @end table
5300 @anchor{AVR Variable Attributes}
5301 @subsection AVR Variable Attributes
5303 @table @code
5304 @item progmem
5305 @cindex @code{progmem} AVR variable attribute
5306 The @code{progmem} attribute is used on the AVR to place read-only
5307 data in the non-volatile program memory (flash). The @code{progmem}
5308 attribute accomplishes this by putting respective variables into a
5309 section whose name starts with @code{.progmem}.
5311 This attribute works similar to the @code{section} attribute
5312 but adds additional checking. Notice that just like the
5313 @code{section} attribute, @code{progmem} affects the location
5314 of the data but not how this data is accessed.
5316 In order to read data located with the @code{progmem} attribute
5317 (inline) assembler must be used.
5318 @smallexample
5319 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5320 #include <avr/pgmspace.h> 
5322 /* Locate var in flash memory */
5323 const int var[2] PROGMEM = @{ 1, 2 @};
5325 int read_var (int i)
5327     /* Access var[] by accessor macro from avr/pgmspace.h */
5328     return (int) pgm_read_word (& var[i]);
5330 @end smallexample
5332 AVR is a Harvard architecture processor and data and read-only data
5333 normally resides in the data memory (RAM).
5335 See also the @ref{AVR Named Address Spaces} section for
5336 an alternate way to locate and access data in flash memory.
5338 @item io
5339 @itemx io (@var{addr})
5340 Variables with the @code{io} attribute are used to address
5341 memory-mapped peripherals in the io address range.
5342 If an address is specified, the variable
5343 is assigned that address, and the value is interpreted as an
5344 address in the data address space.
5345 Example:
5347 @smallexample
5348 volatile int porta __attribute__((io (0x22)));
5349 @end smallexample
5351 The address specified in the address in the data address range.
5353 Otherwise, the variable it is not assigned an address, but the
5354 compiler will still use in/out instructions where applicable,
5355 assuming some other module assigns an address in the io address range.
5356 Example:
5358 @smallexample
5359 extern volatile int porta __attribute__((io));
5360 @end smallexample
5362 @item io_low
5363 @itemx io_low (@var{addr})
5364 This is like the @code{io} attribute, but additionally it informs the
5365 compiler that the object lies in the lower half of the I/O area,
5366 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5367 instructions.
5369 @item address
5370 @itemx address (@var{addr})
5371 Variables with the @code{address} attribute are used to address
5372 memory-mapped peripherals that may lie outside the io address range.
5374 @smallexample
5375 volatile int porta __attribute__((address (0x600)));
5376 @end smallexample
5378 @end table
5380 @subsection Blackfin Variable Attributes
5382 Three attributes are currently defined for the Blackfin.
5384 @table @code
5385 @item l1_data
5386 @itemx l1_data_A
5387 @itemx l1_data_B
5388 @cindex @code{l1_data} variable attribute
5389 @cindex @code{l1_data_A} variable attribute
5390 @cindex @code{l1_data_B} variable attribute
5391 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5392 Variables with @code{l1_data} attribute are put into the specific section
5393 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5394 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5395 attribute are put into the specific section named @code{.l1.data.B}.
5397 @item l2
5398 @cindex @code{l2} variable attribute
5399 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5400 Variables with @code{l2} attribute are put into the specific section
5401 named @code{.l2.data}.
5402 @end table
5404 @subsection M32R/D Variable Attributes
5406 One attribute is currently defined for the M32R/D@.
5408 @table @code
5409 @item model (@var{model-name})
5410 @cindex variable addressability on the M32R/D
5411 Use this attribute on the M32R/D to set the addressability of an object.
5412 The identifier @var{model-name} is one of @code{small}, @code{medium},
5413 or @code{large}, representing each of the code models.
5415 Small model objects live in the lower 16MB of memory (so that their
5416 addresses can be loaded with the @code{ld24} instruction).
5418 Medium and large model objects may live anywhere in the 32-bit address space
5419 (the compiler generates @code{seth/add3} instructions to load their
5420 addresses).
5421 @end table
5423 @anchor{MeP Variable Attributes}
5424 @subsection MeP Variable Attributes
5426 The MeP target has a number of addressing modes and busses.  The
5427 @code{near} space spans the standard memory space's first 16 megabytes
5428 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5429 The @code{based} space is a 128-byte region in the memory space that
5430 is addressed relative to the @code{$tp} register.  The @code{tiny}
5431 space is a 65536-byte region relative to the @code{$gp} register.  In
5432 addition to these memory regions, the MeP target has a separate 16-bit
5433 control bus which is specified with @code{cb} attributes.
5435 @table @code
5437 @item based
5438 Any variable with the @code{based} attribute is assigned to the
5439 @code{.based} section, and is accessed with relative to the
5440 @code{$tp} register.
5442 @item tiny
5443 Likewise, the @code{tiny} attribute assigned variables to the
5444 @code{.tiny} section, relative to the @code{$gp} register.
5446 @item near
5447 Variables with the @code{near} attribute are assumed to have addresses
5448 that fit in a 24-bit addressing mode.  This is the default for large
5449 variables (@code{-mtiny=4} is the default) but this attribute can
5450 override @code{-mtiny=} for small variables, or override @code{-ml}.
5452 @item far
5453 Variables with the @code{far} attribute are addressed using a full
5454 32-bit address.  Since this covers the entire memory space, this
5455 allows modules to make no assumptions about where variables might be
5456 stored.
5458 @item io
5459 @itemx io (@var{addr})
5460 Variables with the @code{io} attribute are used to address
5461 memory-mapped peripherals.  If an address is specified, the variable
5462 is assigned that address, else it is not assigned an address (it is
5463 assumed some other module assigns an address).  Example:
5465 @smallexample
5466 int timer_count __attribute__((io(0x123)));
5467 @end smallexample
5469 @item cb
5470 @itemx cb (@var{addr})
5471 Variables with the @code{cb} attribute are used to access the control
5472 bus, using special instructions.  @code{addr} indicates the control bus
5473 address.  Example:
5475 @smallexample
5476 int cpu_clock __attribute__((cb(0x123)));
5477 @end smallexample
5479 @end table
5481 @anchor{i386 Variable Attributes}
5482 @subsection i386 Variable Attributes
5484 Two attributes are currently defined for i386 configurations:
5485 @code{ms_struct} and @code{gcc_struct}
5487 @table @code
5488 @item ms_struct
5489 @itemx gcc_struct
5490 @cindex @code{ms_struct} attribute
5491 @cindex @code{gcc_struct} attribute
5493 If @code{packed} is used on a structure, or if bit-fields are used,
5494 it may be that the Microsoft ABI lays out the structure differently
5495 than the way GCC normally does.  Particularly when moving packed
5496 data between functions compiled with GCC and the native Microsoft compiler
5497 (either via function call or as data in a file), it may be necessary to access
5498 either format.
5500 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5501 compilers to match the native Microsoft compiler.
5503 The Microsoft structure layout algorithm is fairly simple with the exception
5504 of the bit-field packing.  
5505 The padding and alignment of members of structures and whether a bit-field 
5506 can straddle a storage-unit boundary are determine by these rules:
5508 @enumerate
5509 @item Structure members are stored sequentially in the order in which they are
5510 declared: the first member has the lowest memory address and the last member
5511 the highest.
5513 @item Every data object has an alignment requirement.  The alignment requirement
5514 for all data except structures, unions, and arrays is either the size of the
5515 object or the current packing size (specified with either the
5516 @code{aligned} attribute or the @code{pack} pragma),
5517 whichever is less.  For structures, unions, and arrays,
5518 the alignment requirement is the largest alignment requirement of its members.
5519 Every object is allocated an offset so that:
5521 @smallexample
5522 offset % alignment_requirement == 0
5523 @end smallexample
5525 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5526 unit if the integral types are the same size and if the next bit-field fits
5527 into the current allocation unit without crossing the boundary imposed by the
5528 common alignment requirements of the bit-fields.
5529 @end enumerate
5531 MSVC interprets zero-length bit-fields in the following ways:
5533 @enumerate
5534 @item If a zero-length bit-field is inserted between two bit-fields that
5535 are normally coalesced, the bit-fields are not coalesced.
5537 For example:
5539 @smallexample
5540 struct
5541  @{
5542    unsigned long bf_1 : 12;
5543    unsigned long : 0;
5544    unsigned long bf_2 : 12;
5545  @} t1;
5546 @end smallexample
5548 @noindent
5549 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5550 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5552 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5553 alignment of the zero-length bit-field is greater than the member that follows it,
5554 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5556 For example:
5558 @smallexample
5559 struct
5560  @{
5561    char foo : 4;
5562    short : 0;
5563    char bar;
5564  @} t2;
5566 struct
5567  @{
5568    char foo : 4;
5569    short : 0;
5570    double bar;
5571  @} t3;
5572 @end smallexample
5574 @noindent
5575 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5576 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5577 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5578 of the structure.
5580 Taking this into account, it is important to note the following:
5582 @enumerate
5583 @item If a zero-length bit-field follows a normal bit-field, the type of the
5584 zero-length bit-field may affect the alignment of the structure as whole. For
5585 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5586 normal bit-field, and is of type short.
5588 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5589 still affect the alignment of the structure:
5591 @smallexample
5592 struct
5593  @{
5594    char foo : 6;
5595    long : 0;
5596  @} t4;
5597 @end smallexample
5599 @noindent
5600 Here, @code{t4} takes up 4 bytes.
5601 @end enumerate
5603 @item Zero-length bit-fields following non-bit-field members are ignored:
5605 @smallexample
5606 struct
5607  @{
5608    char foo;
5609    long : 0;
5610    char bar;
5611  @} t5;
5612 @end smallexample
5614 @noindent
5615 Here, @code{t5} takes up 2 bytes.
5616 @end enumerate
5617 @end table
5619 @subsection PowerPC Variable Attributes
5621 Three attributes currently are defined for PowerPC configurations:
5622 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5624 For full documentation of the struct attributes please see the
5625 documentation in @ref{i386 Variable Attributes}.
5627 For documentation of @code{altivec} attribute please see the
5628 documentation in @ref{PowerPC Type Attributes}.
5630 @subsection SPU Variable Attributes
5632 The SPU supports the @code{spu_vector} attribute for variables.  For
5633 documentation of this attribute please see the documentation in
5634 @ref{SPU Type Attributes}.
5636 @subsection Xstormy16 Variable Attributes
5638 One attribute is currently defined for xstormy16 configurations:
5639 @code{below100}.
5641 @table @code
5642 @item below100
5643 @cindex @code{below100} attribute
5645 If a variable has the @code{below100} attribute (@code{BELOW100} is
5646 allowed also), GCC places the variable in the first 0x100 bytes of
5647 memory and use special opcodes to access it.  Such variables are
5648 placed in either the @code{.bss_below100} section or the
5649 @code{.data_below100} section.
5651 @end table
5653 @node Type Attributes
5654 @section Specifying Attributes of Types
5655 @cindex attribute of types
5656 @cindex type attributes
5658 The keyword @code{__attribute__} allows you to specify special
5659 attributes of @code{struct} and @code{union} types when you define
5660 such types.  This keyword is followed by an attribute specification
5661 inside double parentheses.  Eight attributes are currently defined for
5662 types: @code{aligned}, @code{packed}, @code{transparent_union},
5663 @code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias}
5664 and @code{bnd_variable_size}.  Other attributes are defined for
5665 functions (@pxref{Function Attributes}), labels (@pxref{Label 
5666 Attributes}) and for variables (@pxref{Variable Attributes}).
5668 You may also specify any one of these attributes with @samp{__}
5669 preceding and following its keyword.  This allows you to use these
5670 attributes in header files without being concerned about a possible
5671 macro of the same name.  For example, you may use @code{__aligned__}
5672 instead of @code{aligned}.
5674 You may specify type attributes in an enum, struct or union type
5675 declaration or definition, or for other types in a @code{typedef}
5676 declaration.
5678 For an enum, struct or union type, you may specify attributes either
5679 between the enum, struct or union tag and the name of the type, or
5680 just past the closing curly brace of the @emph{definition}.  The
5681 former syntax is preferred.
5683 @xref{Attribute Syntax}, for details of the exact syntax for using
5684 attributes.
5686 @table @code
5687 @cindex @code{aligned} attribute
5688 @item aligned (@var{alignment})
5689 This attribute specifies a minimum alignment (in bytes) for variables
5690 of the specified type.  For example, the declarations:
5692 @smallexample
5693 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5694 typedef int more_aligned_int __attribute__ ((aligned (8)));
5695 @end smallexample
5697 @noindent
5698 force the compiler to ensure (as far as it can) that each variable whose
5699 type is @code{struct S} or @code{more_aligned_int} is allocated and
5700 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5701 variables of type @code{struct S} aligned to 8-byte boundaries allows
5702 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5703 store) instructions when copying one variable of type @code{struct S} to
5704 another, thus improving run-time efficiency.
5706 Note that the alignment of any given @code{struct} or @code{union} type
5707 is required by the ISO C standard to be at least a perfect multiple of
5708 the lowest common multiple of the alignments of all of the members of
5709 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5710 effectively adjust the alignment of a @code{struct} or @code{union}
5711 type by attaching an @code{aligned} attribute to any one of the members
5712 of such a type, but the notation illustrated in the example above is a
5713 more obvious, intuitive, and readable way to request the compiler to
5714 adjust the alignment of an entire @code{struct} or @code{union} type.
5716 As in the preceding example, you can explicitly specify the alignment
5717 (in bytes) that you wish the compiler to use for a given @code{struct}
5718 or @code{union} type.  Alternatively, you can leave out the alignment factor
5719 and just ask the compiler to align a type to the maximum
5720 useful alignment for the target machine you are compiling for.  For
5721 example, you could write:
5723 @smallexample
5724 struct S @{ short f[3]; @} __attribute__ ((aligned));
5725 @end smallexample
5727 Whenever you leave out the alignment factor in an @code{aligned}
5728 attribute specification, the compiler automatically sets the alignment
5729 for the type to the largest alignment that is ever used for any data
5730 type on the target machine you are compiling for.  Doing this can often
5731 make copy operations more efficient, because the compiler can use
5732 whatever instructions copy the biggest chunks of memory when performing
5733 copies to or from the variables that have types that you have aligned
5734 this way.
5736 In the example above, if the size of each @code{short} is 2 bytes, then
5737 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5738 power of two that is greater than or equal to that is 8, so the
5739 compiler sets the alignment for the entire @code{struct S} type to 8
5740 bytes.
5742 Note that although you can ask the compiler to select a time-efficient
5743 alignment for a given type and then declare only individual stand-alone
5744 objects of that type, the compiler's ability to select a time-efficient
5745 alignment is primarily useful only when you plan to create arrays of
5746 variables having the relevant (efficiently aligned) type.  If you
5747 declare or use arrays of variables of an efficiently-aligned type, then
5748 it is likely that your program also does pointer arithmetic (or
5749 subscripting, which amounts to the same thing) on pointers to the
5750 relevant type, and the code that the compiler generates for these
5751 pointer arithmetic operations is often more efficient for
5752 efficiently-aligned types than for other types.
5754 The @code{aligned} attribute can only increase the alignment; but you
5755 can decrease it by specifying @code{packed} as well.  See below.
5757 Note that the effectiveness of @code{aligned} attributes may be limited
5758 by inherent limitations in your linker.  On many systems, the linker is
5759 only able to arrange for variables to be aligned up to a certain maximum
5760 alignment.  (For some linkers, the maximum supported alignment may
5761 be very very small.)  If your linker is only able to align variables
5762 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5763 in an @code{__attribute__} still only provides you with 8-byte
5764 alignment.  See your linker documentation for further information.
5766 @item packed
5767 This attribute, attached to @code{struct} or @code{union} type
5768 definition, specifies that each member (other than zero-width bit-fields)
5769 of the structure or union is placed to minimize the memory required.  When
5770 attached to an @code{enum} definition, it indicates that the smallest
5771 integral type should be used.
5773 @opindex fshort-enums
5774 Specifying this attribute for @code{struct} and @code{union} types is
5775 equivalent to specifying the @code{packed} attribute on each of the
5776 structure or union members.  Specifying the @option{-fshort-enums}
5777 flag on the line is equivalent to specifying the @code{packed}
5778 attribute on all @code{enum} definitions.
5780 In the following example @code{struct my_packed_struct}'s members are
5781 packed closely together, but the internal layout of its @code{s} member
5782 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5783 be packed too.
5785 @smallexample
5786 struct my_unpacked_struct
5787  @{
5788     char c;
5789     int i;
5790  @};
5792 struct __attribute__ ((__packed__)) my_packed_struct
5793   @{
5794      char c;
5795      int  i;
5796      struct my_unpacked_struct s;
5797   @};
5798 @end smallexample
5800 You may only specify this attribute on the definition of an @code{enum},
5801 @code{struct} or @code{union}, not on a @code{typedef} that does not
5802 also define the enumerated type, structure or union.
5804 @item transparent_union
5805 @cindex @code{transparent_union} attribute
5807 This attribute, attached to a @code{union} type definition, indicates
5808 that any function parameter having that union type causes calls to that
5809 function to be treated in a special way.
5811 First, the argument corresponding to a transparent union type can be of
5812 any type in the union; no cast is required.  Also, if the union contains
5813 a pointer type, the corresponding argument can be a null pointer
5814 constant or a void pointer expression; and if the union contains a void
5815 pointer type, the corresponding argument can be any pointer expression.
5816 If the union member type is a pointer, qualifiers like @code{const} on
5817 the referenced type must be respected, just as with normal pointer
5818 conversions.
5820 Second, the argument is passed to the function using the calling
5821 conventions of the first member of the transparent union, not the calling
5822 conventions of the union itself.  All members of the union must have the
5823 same machine representation; this is necessary for this argument passing
5824 to work properly.
5826 Transparent unions are designed for library functions that have multiple
5827 interfaces for compatibility reasons.  For example, suppose the
5828 @code{wait} function must accept either a value of type @code{int *} to
5829 comply with POSIX, or a value of type @code{union wait *} to comply with
5830 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5831 @code{wait} would accept both kinds of arguments, but it would also
5832 accept any other pointer type and this would make argument type checking
5833 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5834 as follows:
5836 @smallexample
5837 typedef union __attribute__ ((__transparent_union__))
5838   @{
5839     int *__ip;
5840     union wait *__up;
5841   @} wait_status_ptr_t;
5843 pid_t wait (wait_status_ptr_t);
5844 @end smallexample
5846 @noindent
5847 This interface allows either @code{int *} or @code{union wait *}
5848 arguments to be passed, using the @code{int *} calling convention.
5849 The program can call @code{wait} with arguments of either type:
5851 @smallexample
5852 int w1 () @{ int w; return wait (&w); @}
5853 int w2 () @{ union wait w; return wait (&w); @}
5854 @end smallexample
5856 @noindent
5857 With this interface, @code{wait}'s implementation might look like this:
5859 @smallexample
5860 pid_t wait (wait_status_ptr_t p)
5862   return waitpid (-1, p.__ip, 0);
5864 @end smallexample
5866 @item unused
5867 When attached to a type (including a @code{union} or a @code{struct}),
5868 this attribute means that variables of that type are meant to appear
5869 possibly unused.  GCC does not produce a warning for any variables of
5870 that type, even if the variable appears to do nothing.  This is often
5871 the case with lock or thread classes, which are usually defined and then
5872 not referenced, but contain constructors and destructors that have
5873 nontrivial bookkeeping functions.
5875 @item deprecated
5876 @itemx deprecated (@var{msg})
5877 The @code{deprecated} attribute results in a warning if the type
5878 is used anywhere in the source file.  This is useful when identifying
5879 types that are expected to be removed in a future version of a program.
5880 If possible, the warning also includes the location of the declaration
5881 of the deprecated type, to enable users to easily find further
5882 information about why the type is deprecated, or what they should do
5883 instead.  Note that the warnings only occur for uses and then only
5884 if the type is being applied to an identifier that itself is not being
5885 declared as deprecated.
5887 @smallexample
5888 typedef int T1 __attribute__ ((deprecated));
5889 T1 x;
5890 typedef T1 T2;
5891 T2 y;
5892 typedef T1 T3 __attribute__ ((deprecated));
5893 T3 z __attribute__ ((deprecated));
5894 @end smallexample
5896 @noindent
5897 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5898 warning is issued for line 4 because T2 is not explicitly
5899 deprecated.  Line 5 has no warning because T3 is explicitly
5900 deprecated.  Similarly for line 6.  The optional @var{msg}
5901 argument, which must be a string, is printed in the warning if
5902 present.
5904 The @code{deprecated} attribute can also be used for functions and
5905 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5907 @item may_alias
5908 Accesses through pointers to types with this attribute are not subject
5909 to type-based alias analysis, but are instead assumed to be able to alias
5910 any other type of objects.
5911 In the context of section 6.5 paragraph 7 of the C99 standard,
5912 an lvalue expression
5913 dereferencing such a pointer is treated like having a character type.
5914 See @option{-fstrict-aliasing} for more information on aliasing issues.
5915 This extension exists to support some vector APIs, in which pointers to
5916 one vector type are permitted to alias pointers to a different vector type.
5918 Note that an object of a type with this attribute does not have any
5919 special semantics.
5921 Example of use:
5923 @smallexample
5924 typedef short __attribute__((__may_alias__)) short_a;
5927 main (void)
5929   int a = 0x12345678;
5930   short_a *b = (short_a *) &a;
5932   b[1] = 0;
5934   if (a == 0x12345678)
5935     abort();
5937   exit(0);
5939 @end smallexample
5941 @noindent
5942 If you replaced @code{short_a} with @code{short} in the variable
5943 declaration, the above program would abort when compiled with
5944 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5945 above in recent GCC versions.
5947 @item visibility
5948 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5949 applied to class, struct, union and enum types.  Unlike other type
5950 attributes, the attribute must appear between the initial keyword and
5951 the name of the type; it cannot appear after the body of the type.
5953 Note that the type visibility is applied to vague linkage entities
5954 associated with the class (vtable, typeinfo node, etc.).  In
5955 particular, if a class is thrown as an exception in one shared object
5956 and caught in another, the class must have default visibility.
5957 Otherwise the two shared objects are unable to use the same
5958 typeinfo node and exception handling will break.
5960 @item designated_init
5961 This attribute may only be applied to structure types.  It indicates
5962 that any initialization of an object of this type must use designated
5963 initializers rather than positional initializers.  The intent of this
5964 attribute is to allow the programmer to indicate that a structure's
5965 layout may change, and that therefore relying on positional
5966 initialization will result in future breakage.
5968 GCC emits warnings based on this attribute by default; use
5969 @option{-Wno-designated-init} to suppress them.
5971 @item bnd_variable_size
5972 When applied to a structure field, this attribute tells Pointer
5973 Bounds Checker that the size of this field should not be computed
5974 using static type information.  It may be used to mark variable
5975 sized static array fields placed at the end of a structure.
5977 @smallexample
5978 struct S
5980   int size;
5981   char data[1];
5983 S *p = (S *)malloc (sizeof(S) + 100);
5984 p->data[10] = 0; //Bounds violation
5985 @end smallexample
5987 By using an attribute for a field we may avoid bound violation
5988 we most probably do not want to see:
5990 @smallexample
5991 struct S
5993   int size;
5994   char data[1] __attribute__((bnd_variable_size));
5996 S *p = (S *)malloc (sizeof(S) + 100);
5997 p->data[10] = 0; //OK
5998 @end smallexample
6000 @end table
6002 To specify multiple attributes, separate them by commas within the
6003 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6004 packed))}.
6006 @subsection ARM Type Attributes
6008 On those ARM targets that support @code{dllimport} (such as Symbian
6009 OS), you can use the @code{notshared} attribute to indicate that the
6010 virtual table and other similar data for a class should not be
6011 exported from a DLL@.  For example:
6013 @smallexample
6014 class __declspec(notshared) C @{
6015 public:
6016   __declspec(dllimport) C();
6017   virtual void f();
6020 __declspec(dllexport)
6021 C::C() @{@}
6022 @end smallexample
6024 @noindent
6025 In this code, @code{C::C} is exported from the current DLL, but the
6026 virtual table for @code{C} is not exported.  (You can use
6027 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6028 most Symbian OS code uses @code{__declspec}.)
6030 @anchor{MeP Type Attributes}
6031 @subsection MeP Type Attributes
6033 Many of the MeP variable attributes may be applied to types as well.
6034 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6035 @code{far} attributes may be applied to either.  The @code{io} and
6036 @code{cb} attributes may not be applied to types.
6038 @anchor{i386 Type Attributes}
6039 @subsection i386 Type Attributes
6041 Two attributes are currently defined for i386 configurations:
6042 @code{ms_struct} and @code{gcc_struct}.
6044 @table @code
6046 @item ms_struct
6047 @itemx gcc_struct
6048 @cindex @code{ms_struct}
6049 @cindex @code{gcc_struct}
6051 If @code{packed} is used on a structure, or if bit-fields are used
6052 it may be that the Microsoft ABI packs them differently
6053 than GCC normally packs them.  Particularly when moving packed
6054 data between functions compiled with GCC and the native Microsoft compiler
6055 (either via function call or as data in a file), it may be necessary to access
6056 either format.
6058 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
6059 compilers to match the native Microsoft compiler.
6060 @end table
6062 @anchor{PowerPC Type Attributes}
6063 @subsection PowerPC Type Attributes
6065 Three attributes currently are defined for PowerPC configurations:
6066 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6068 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6069 attributes please see the documentation in @ref{i386 Type Attributes}.
6071 The @code{altivec} attribute allows one to declare AltiVec vector data
6072 types supported by the AltiVec Programming Interface Manual.  The
6073 attribute requires an argument to specify one of three vector types:
6074 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6075 and @code{bool__} (always followed by unsigned).
6077 @smallexample
6078 __attribute__((altivec(vector__)))
6079 __attribute__((altivec(pixel__))) unsigned short
6080 __attribute__((altivec(bool__))) unsigned
6081 @end smallexample
6083 These attributes mainly are intended to support the @code{__vector},
6084 @code{__pixel}, and @code{__bool} AltiVec keywords.
6086 @anchor{SPU Type Attributes}
6087 @subsection SPU Type Attributes
6089 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6090 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6091 Language Extensions Specification.  It is intended to support the
6092 @code{__vector} keyword.
6094 @node Alignment
6095 @section Inquiring on Alignment of Types or Variables
6096 @cindex alignment
6097 @cindex type alignment
6098 @cindex variable alignment
6100 The keyword @code{__alignof__} allows you to inquire about how an object
6101 is aligned, or the minimum alignment usually required by a type.  Its
6102 syntax is just like @code{sizeof}.
6104 For example, if the target machine requires a @code{double} value to be
6105 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6106 This is true on many RISC machines.  On more traditional machine
6107 designs, @code{__alignof__ (double)} is 4 or even 2.
6109 Some machines never actually require alignment; they allow reference to any
6110 data type even at an odd address.  For these machines, @code{__alignof__}
6111 reports the smallest alignment that GCC gives the data type, usually as
6112 mandated by the target ABI.
6114 If the operand of @code{__alignof__} is an lvalue rather than a type,
6115 its value is the required alignment for its type, taking into account
6116 any minimum alignment specified with GCC's @code{__attribute__}
6117 extension (@pxref{Variable Attributes}).  For example, after this
6118 declaration:
6120 @smallexample
6121 struct foo @{ int x; char y; @} foo1;
6122 @end smallexample
6124 @noindent
6125 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6126 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6128 It is an error to ask for the alignment of an incomplete type.
6131 @node Inline
6132 @section An Inline Function is As Fast As a Macro
6133 @cindex inline functions
6134 @cindex integrating function code
6135 @cindex open coding
6136 @cindex macros, inline alternative
6138 By declaring a function inline, you can direct GCC to make
6139 calls to that function faster.  One way GCC can achieve this is to
6140 integrate that function's code into the code for its callers.  This
6141 makes execution faster by eliminating the function-call overhead; in
6142 addition, if any of the actual argument values are constant, their
6143 known values may permit simplifications at compile time so that not
6144 all of the inline function's code needs to be included.  The effect on
6145 code size is less predictable; object code may be larger or smaller
6146 with function inlining, depending on the particular case.  You can
6147 also direct GCC to try to integrate all ``simple enough'' functions
6148 into their callers with the option @option{-finline-functions}.
6150 GCC implements three different semantics of declaring a function
6151 inline.  One is available with @option{-std=gnu89} or
6152 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6153 on all inline declarations, another when
6154 @option{-std=c99}, @option{-std=c11},
6155 @option{-std=gnu99} or @option{-std=gnu11}
6156 (without @option{-fgnu89-inline}), and the third
6157 is used when compiling C++.
6159 To declare a function inline, use the @code{inline} keyword in its
6160 declaration, like this:
6162 @smallexample
6163 static inline int
6164 inc (int *a)
6166   return (*a)++;
6168 @end smallexample
6170 If you are writing a header file to be included in ISO C90 programs, write
6171 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6173 The three types of inlining behave similarly in two important cases:
6174 when the @code{inline} keyword is used on a @code{static} function,
6175 like the example above, and when a function is first declared without
6176 using the @code{inline} keyword and then is defined with
6177 @code{inline}, like this:
6179 @smallexample
6180 extern int inc (int *a);
6181 inline int
6182 inc (int *a)
6184   return (*a)++;
6186 @end smallexample
6188 In both of these common cases, the program behaves the same as if you
6189 had not used the @code{inline} keyword, except for its speed.
6191 @cindex inline functions, omission of
6192 @opindex fkeep-inline-functions
6193 When a function is both inline and @code{static}, if all calls to the
6194 function are integrated into the caller, and the function's address is
6195 never used, then the function's own assembler code is never referenced.
6196 In this case, GCC does not actually output assembler code for the
6197 function, unless you specify the option @option{-fkeep-inline-functions}.
6198 Some calls cannot be integrated for various reasons (in particular,
6199 calls that precede the function's definition cannot be integrated, and
6200 neither can recursive calls within the definition).  If there is a
6201 nonintegrated call, then the function is compiled to assembler code as
6202 usual.  The function must also be compiled as usual if the program
6203 refers to its address, because that can't be inlined.
6205 @opindex Winline
6206 Note that certain usages in a function definition can make it unsuitable
6207 for inline substitution.  Among these usages are: variadic functions, use of
6208 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6209 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6210 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6211 warns when a function marked @code{inline} could not be substituted,
6212 and gives the reason for the failure.
6214 @cindex automatic @code{inline} for C++ member fns
6215 @cindex @code{inline} automatic for C++ member fns
6216 @cindex member fns, automatically @code{inline}
6217 @cindex C++ member fns, automatically @code{inline}
6218 @opindex fno-default-inline
6219 As required by ISO C++, GCC considers member functions defined within
6220 the body of a class to be marked inline even if they are
6221 not explicitly declared with the @code{inline} keyword.  You can
6222 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6223 Options,,Options Controlling C++ Dialect}.
6225 GCC does not inline any functions when not optimizing unless you specify
6226 the @samp{always_inline} attribute for the function, like this:
6228 @smallexample
6229 /* @r{Prototype.}  */
6230 inline void foo (const char) __attribute__((always_inline));
6231 @end smallexample
6233 The remainder of this section is specific to GNU C90 inlining.
6235 @cindex non-static inline function
6236 When an inline function is not @code{static}, then the compiler must assume
6237 that there may be calls from other source files; since a global symbol can
6238 be defined only once in any program, the function must not be defined in
6239 the other source files, so the calls therein cannot be integrated.
6240 Therefore, a non-@code{static} inline function is always compiled on its
6241 own in the usual fashion.
6243 If you specify both @code{inline} and @code{extern} in the function
6244 definition, then the definition is used only for inlining.  In no case
6245 is the function compiled on its own, not even if you refer to its
6246 address explicitly.  Such an address becomes an external reference, as
6247 if you had only declared the function, and had not defined it.
6249 This combination of @code{inline} and @code{extern} has almost the
6250 effect of a macro.  The way to use it is to put a function definition in
6251 a header file with these keywords, and put another copy of the
6252 definition (lacking @code{inline} and @code{extern}) in a library file.
6253 The definition in the header file causes most calls to the function
6254 to be inlined.  If any uses of the function remain, they refer to
6255 the single copy in the library.
6257 @node Volatiles
6258 @section When is a Volatile Object Accessed?
6259 @cindex accessing volatiles
6260 @cindex volatile read
6261 @cindex volatile write
6262 @cindex volatile access
6264 C has the concept of volatile objects.  These are normally accessed by
6265 pointers and used for accessing hardware or inter-thread
6266 communication.  The standard encourages compilers to refrain from
6267 optimizations concerning accesses to volatile objects, but leaves it
6268 implementation defined as to what constitutes a volatile access.  The
6269 minimum requirement is that at a sequence point all previous accesses
6270 to volatile objects have stabilized and no subsequent accesses have
6271 occurred.  Thus an implementation is free to reorder and combine
6272 volatile accesses that occur between sequence points, but cannot do
6273 so for accesses across a sequence point.  The use of volatile does
6274 not allow you to violate the restriction on updating objects multiple
6275 times between two sequence points.
6277 Accesses to non-volatile objects are not ordered with respect to
6278 volatile accesses.  You cannot use a volatile object as a memory
6279 barrier to order a sequence of writes to non-volatile memory.  For
6280 instance:
6282 @smallexample
6283 int *ptr = @var{something};
6284 volatile int vobj;
6285 *ptr = @var{something};
6286 vobj = 1;
6287 @end smallexample
6289 @noindent
6290 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6291 that the write to @var{*ptr} occurs by the time the update
6292 of @var{vobj} happens.  If you need this guarantee, you must use
6293 a stronger memory barrier such as:
6295 @smallexample
6296 int *ptr = @var{something};
6297 volatile int vobj;
6298 *ptr = @var{something};
6299 asm volatile ("" : : : "memory");
6300 vobj = 1;
6301 @end smallexample
6303 A scalar volatile object is read when it is accessed in a void context:
6305 @smallexample
6306 volatile int *src = @var{somevalue};
6307 *src;
6308 @end smallexample
6310 Such expressions are rvalues, and GCC implements this as a
6311 read of the volatile object being pointed to.
6313 Assignments are also expressions and have an rvalue.  However when
6314 assigning to a scalar volatile, the volatile object is not reread,
6315 regardless of whether the assignment expression's rvalue is used or
6316 not.  If the assignment's rvalue is used, the value is that assigned
6317 to the volatile object.  For instance, there is no read of @var{vobj}
6318 in all the following cases:
6320 @smallexample
6321 int obj;
6322 volatile int vobj;
6323 vobj = @var{something};
6324 obj = vobj = @var{something};
6325 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6326 obj = (@var{something}, vobj = @var{anotherthing});
6327 @end smallexample
6329 If you need to read the volatile object after an assignment has
6330 occurred, you must use a separate expression with an intervening
6331 sequence point.
6333 As bit-fields are not individually addressable, volatile bit-fields may
6334 be implicitly read when written to, or when adjacent bit-fields are
6335 accessed.  Bit-field operations may be optimized such that adjacent
6336 bit-fields are only partially accessed, if they straddle a storage unit
6337 boundary.  For these reasons it is unwise to use volatile bit-fields to
6338 access hardware.
6340 @node Using Assembly Language with C
6341 @section How to Use Inline Assembly Language in C Code
6343 GCC provides various extensions that allow you to embed assembler within 
6344 C code.
6346 @menu
6347 * Basic Asm::          Inline assembler with no operands.
6348 * Extended Asm::       Inline assembler with operands.
6349 * Constraints::        Constraints for @code{asm} operands
6350 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6351 * Explicit Reg Vars::  Defining variables residing in specified registers.
6352 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6353 @end menu
6355 @node Basic Asm
6356 @subsection Basic Asm --- Assembler Instructions with No Operands
6357 @cindex basic @code{asm}
6359 The @code{asm} keyword allows you to embed assembler instructions within 
6360 C code.
6362 @example
6363 asm [ volatile ] ( AssemblerInstructions )
6364 @end example
6366 To create headers compatible with ISO C, write @code{__asm__} instead of 
6367 @code{asm} (@pxref{Alternate Keywords}).
6369 By definition, a Basic @code{asm} statement is one with no operands. 
6370 @code{asm} statements that contain one or more colons (used to delineate 
6371 operands) are considered to be Extended (for example, @code{asm("int $3")} 
6372 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6374 @subsubheading Qualifiers
6375 @emph{volatile}
6377 This optional qualifier has no effect. All Basic @code{asm} blocks are 
6378 implicitly volatile.
6380 @subsubheading Parameters
6381 @emph{AssemblerInstructions}
6383 This is a literal string that specifies the assembler code. The string can 
6384 contain any instructions recognized by the assembler, including directives. 
6385 GCC does not parse the assembler instructions themselves and 
6386 does not know what they mean or even whether they are valid assembler input. 
6387 The compiler copies it verbatim to the assembly language output file, without 
6388 processing dialects or any of the "%" operators that are available with
6389 Extended @code{asm}. This results in minor differences between Basic 
6390 @code{asm} strings and Extended @code{asm} templates. For example, to refer to 
6391 registers you might use %%eax in Extended @code{asm} and %eax in Basic 
6392 @code{asm}.
6394 You may place multiple assembler instructions together in a single @code{asm} 
6395 string, separated by the characters normally used in assembly code for the 
6396 system. A combination that works in most places is a newline to break the 
6397 line, plus a tab character (written as "\n\t").
6398 Some assemblers allow semicolons as a line separator. However, 
6399 note that some assembler dialects use semicolons to start a comment. 
6401 Do not expect a sequence of @code{asm} statements to remain perfectly 
6402 consecutive after compilation. If certain instructions need to remain 
6403 consecutive in the output, put them in a single multi-instruction asm 
6404 statement. Note that GCC's optimizers can move @code{asm} statements 
6405 relative to other code, including across jumps.
6407 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6408 GCC does not know about these jumps, and therefore cannot take 
6409 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6410 labels are only supported in Extended @code{asm}.
6412 @subsubheading Remarks
6413 Using Extended @code{asm} will typically produce smaller, safer, and more 
6414 efficient code, and in most cases it is a better solution. When writing 
6415 inline assembly language outside of C functions, however, you must use Basic 
6416 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6417 Functions declared with the @code{naked} attribute also require Basic 
6418 @code{asm} (@pxref{Function Attributes}).
6420 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6421 assembly code when optimizing. This can lead to unexpected duplicate 
6422 symbol errors during compilation if your assembly code defines symbols or 
6423 labels.
6425 Safely accessing C data and calling functions from Basic @code{asm} is more 
6426 complex than it may appear. To access C data, it is better to use Extended 
6427 @code{asm}.
6429 Since GCC does not parse the AssemblerInstructions, it has no 
6430 visibility of any symbols it references. This may result in GCC discarding 
6431 those symbols as unreferenced.
6433 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly 
6434 volatile. @xref{Volatile}.  Similarly, Basic @code{asm} blocks are not treated 
6435 as though they used a "memory" clobber (@pxref{Clobbers}).
6437 All Basic @code{asm} blocks use the assembler dialect specified by the 
6438 @option{-masm} command-line option. Basic @code{asm} provides no
6439 mechanism to provide different assembler strings for different dialects.
6441 Here is an example of Basic @code{asm} for i386:
6443 @example
6444 /* Note that this code will not compile with -masm=intel */
6445 #define DebugBreak() asm("int $3")
6446 @end example
6448 @node Extended Asm
6449 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6450 @cindex @code{asm} keyword
6451 @cindex extended @code{asm}
6452 @cindex assembler instructions
6454 The @code{asm} keyword allows you to embed assembler instructions within C 
6455 code. With Extended @code{asm} you can read and write C variables from 
6456 assembler and perform jumps from assembler code to C labels.
6458 @example
6459 @ifhtml
6460 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6462 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6463 @end ifhtml
6464 @ifnothtml
6465 asm [volatile] ( AssemblerTemplate 
6466                  : [OutputOperands] 
6467                  [ : [InputOperands] 
6468                  [ : [Clobbers] ] ])
6470 asm [volatile] goto ( AssemblerTemplate 
6471                       : 
6472                       : [InputOperands] 
6473                       : [Clobbers] 
6474                       : GotoLabels)
6475 @end ifnothtml
6476 @end example
6478 To create headers compatible with ISO C, write @code{__asm__} instead of 
6479 @code{asm} and @code{__volatile__} instead of @code{volatile} 
6480 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6482 By definition, Extended @code{asm} is an @code{asm} statement that contains 
6483 operands. To separate the classes of operands, you use colons. Basic 
6484 @code{asm} statements contain no colons. (So, for example, 
6485 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is 
6486 Extended @code{asm}. @pxref{Basic Asm}.)
6488 @subsubheading Qualifiers
6489 @emph{volatile}
6491 The typical use of Extended @code{asm} statements is to manipulate input 
6492 values to produce output values. However, your @code{asm} statements may 
6493 also produce side effects. If so, you may need to use the @code{volatile} 
6494 qualifier to disable certain optimizations. @xref{Volatile}.
6496 @emph{goto}
6498 This qualifier informs the compiler that the @code{asm} statement may 
6499 perform a jump to one of the labels listed in the GotoLabels section. 
6500 @xref{GotoLabels}.
6502 @subsubheading Parameters
6503 @emph{AssemblerTemplate}
6505 This is a literal string that contains the assembler code. It is a 
6506 combination of fixed text and tokens that refer to the input, output, 
6507 and goto parameters. @xref{AssemblerTemplate}.
6509 @emph{OutputOperands}
6511 A comma-separated list of the C variables modified by the instructions in the 
6512 AssemblerTemplate. @xref{OutputOperands}.
6514 @emph{InputOperands}
6516 A comma-separated list of C expressions read by the instructions in the 
6517 AssemblerTemplate. @xref{InputOperands}.
6519 @emph{Clobbers}
6521 A comma-separated list of registers or other values changed by the 
6522 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6524 @emph{GotoLabels}
6526 When you are using the @code{goto} form of @code{asm}, this section contains 
6527 the list of all C labels to which the AssemblerTemplate may jump. 
6528 @xref{GotoLabels}.
6530 @subsubheading Remarks
6531 The @code{asm} statement allows you to include assembly instructions directly 
6532 within C code. This may help you to maximize performance in time-sensitive 
6533 code or to access assembly instructions that are not readily available to C 
6534 programs.
6536 Note that Extended @code{asm} statements must be inside a function. Only 
6537 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6538 Functions declared with the @code{naked} attribute also require Basic 
6539 @code{asm} (@pxref{Function Attributes}).
6541 While the uses of @code{asm} are many and varied, it may help to think of an 
6542 @code{asm} statement as a series of low-level instructions that convert input 
6543 parameters to output parameters. So a simple (if not particularly useful) 
6544 example for i386 using @code{asm} might look like this:
6546 @example
6547 int src = 1;
6548 int dst;   
6550 asm ("mov %1, %0\n\t"
6551     "add $1, %0"
6552     : "=r" (dst) 
6553     : "r" (src));
6555 printf("%d\n", dst);
6556 @end example
6558 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6560 @anchor{Volatile}
6561 @subsubsection Volatile
6562 @cindex volatile @code{asm}
6563 @cindex @code{asm} volatile
6565 GCC's optimizers sometimes discard @code{asm} statements if they determine 
6566 there is no need for the output variables. Also, the optimizers may move 
6567 code out of loops if they believe that the code will always return the same 
6568 result (i.e. none of its input values change between calls). Using the 
6569 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
6570 that have no output operands are implicitly volatile.
6572 Examples:
6574 This i386 code demonstrates a case that does not use (or require) the 
6575 @code{volatile} qualifier. If it is performing assertion checking, this code 
6576 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is 
6577 unreferenced by any code. As a result, the optimizers can discard the 
6578 @code{asm} statement, which in turn removes the need for the entire 
6579 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
6580 isn't needed you allow the optimizers to produce the most efficient code 
6581 possible.
6583 @example
6584 void DoCheck(uint32_t dwSomeValue)
6586    uint32_t dwRes;
6588    // Assumes dwSomeValue is not zero.
6589    asm ("bsfl %1,%0"
6590      : "=r" (dwRes)
6591      : "r" (dwSomeValue)
6592      : "cc");
6594    assert(dwRes > 3);
6596 @end example
6598 The next example shows a case where the optimizers can recognize that the input 
6599 (@var{dwSomeValue}) never changes during the execution of the function and can 
6600 therefore move the @code{asm} outside the loop to produce more efficient code. 
6601 Again, using @code{volatile} disables this type of optimization.
6603 @example
6604 void do_print(uint32_t dwSomeValue)
6606    uint32_t dwRes;
6608    for (uint32_t x=0; x < 5; x++)
6609    @{
6610       // Assumes dwSomeValue is not zero.
6611       asm ("bsfl %1,%0"
6612         : "=r" (dwRes)
6613         : "r" (dwSomeValue)
6614         : "cc");
6616       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6617    @}
6619 @end example
6621 The following example demonstrates a case where you need to use the 
6622 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads 
6623 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
6624 the optimizers might assume that the @code{asm} block will always return the 
6625 same value and therefore optimize away the second call.
6627 @example
6628 uint64_t msr;
6630 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6631         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6632         "or %%rdx, %0"        // 'Or' in the lower bits.
6633         : "=a" (msr)
6634         : 
6635         : "rdx");
6637 printf("msr: %llx\n", msr);
6639 // Do other work...
6641 // Reprint the timestamp
6642 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6643         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6644         "or %%rdx, %0"        // 'Or' in the lower bits.
6645         : "=a" (msr)
6646         : 
6647         : "rdx");
6649 printf("msr: %llx\n", msr);
6650 @end example
6652 GCC's optimizers will not treat this code like the non-volatile code in the 
6653 earlier examples. They do not move it out of loops or omit it on the 
6654 assumption that the result from a previous call is still valid.
6656 Note that the compiler can move even volatile @code{asm} instructions relative 
6657 to other code, including across jump instructions. For example, on many 
6658 targets there is a system register that controls the rounding mode of 
6659 floating-point operations. Setting it with a volatile @code{asm}, as in the 
6660 following PowerPC example, will not work reliably.
6662 @example
6663 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6664 sum = x + y;
6665 @end example
6667 The compiler may move the addition back before the volatile @code{asm}. To 
6668 make it work as expected, add an artificial dependency to the @code{asm} by 
6669 referencing a variable in the subsequent code, for example: 
6671 @example
6672 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6673 sum = x + y;
6674 @end example
6676 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6677 assembly code when optimizing. This can lead to unexpected duplicate symbol 
6678 errors during compilation if your asm code defines symbols or labels. Using %= 
6679 (@pxref{AssemblerTemplate}) may help resolve this problem.
6681 @anchor{AssemblerTemplate}
6682 @subsubsection Assembler Template
6683 @cindex @code{asm} assembler template
6685 An assembler template is a literal string containing assembler instructions. 
6686 The compiler will replace any references to inputs, outputs, and goto labels 
6687 in the template, and then output the resulting string to the assembler. The 
6688 string can contain any instructions recognized by the assembler, including 
6689 directives. GCC does not parse the assembler instructions 
6690 themselves and does not know what they mean or even whether they are valid 
6691 assembler input. However, it does count the statements 
6692 (@pxref{Size of an asm}).
6694 You may place multiple assembler instructions together in a single @code{asm} 
6695 string, separated by the characters normally used in assembly code for the 
6696 system. A combination that works in most places is a newline to break the 
6697 line, plus a tab character to move to the instruction field (written as 
6698 "\n\t"). Some assemblers allow semicolons as a line separator. However, note 
6699 that some assembler dialects use semicolons to start a comment. 
6701 Do not expect a sequence of @code{asm} statements to remain perfectly 
6702 consecutive after compilation, even when you are using the @code{volatile} 
6703 qualifier. If certain instructions need to remain consecutive in the output, 
6704 put them in a single multi-instruction asm statement.
6706 Accessing data from C programs without using input/output operands (such as 
6707 by using global symbols directly from the assembler template) may not work as 
6708 expected. Similarly, calling functions directly from an assembler template 
6709 requires a detailed understanding of the target assembler and ABI.
6711 Since GCC does not parse the AssemblerTemplate, it has no visibility of any 
6712 symbols it references. This may result in GCC discarding those symbols as 
6713 unreferenced unless they are also listed as input, output, or goto operands.
6715 GCC can support multiple assembler dialects (for example, GCC for i386 
6716 supports "att" and "intel" dialects) for inline assembler. In builds that 
6717 support this capability, the @option{-masm} option controls which dialect 
6718 GCC uses as its default. The hardware-specific documentation for the 
6719 @option{-masm} option contains the list of supported dialects, as well as the 
6720 default dialect if the option is not specified. This information may be 
6721 important to understand, since assembler code that works correctly when 
6722 compiled using one dialect will likely fail if compiled using another.
6724 @subsubheading Using braces in @code{asm} templates
6726 If your code needs to support multiple assembler dialects (for example, if 
6727 you are writing public headers that need to support a variety of compilation 
6728 options), use constructs of this form:
6730 @example
6731 @{ dialect0 | dialect1 | dialect2... @}
6732 @end example
6734 This construct outputs 'dialect0' when using dialect #0 to compile the code, 
6735 'dialect1' for dialect #1, etc. If there are fewer alternatives within the 
6736 braces than the number of dialects the compiler supports, the construct 
6737 outputs nothing.
6739 For example, if an i386 compiler supports two dialects (att, intel), an 
6740 assembler template such as this:
6742 @example
6743 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6744 @end example
6746 would produce the output:
6748 @example
6749 For att: "btl %[Offset],%[Base] ; jc %l2"
6750 For intel: "bt %[Base],%[Offset]; jc %l2"
6751 @end example
6753 Using that same compiler, this code:
6755 @example
6756 "xchg@{l@}\t@{%%@}ebx, %1"
6757 @end example
6759 would produce 
6761 @example
6762 For att: "xchgl\t%%ebx, %1"
6763 For intel: "xchg\tebx, %1"
6764 @end example
6766 There is no support for nesting dialect alternatives. Also, there is no 
6767 ``escape'' for an open brace (@{), so do not use open braces in an Extended 
6768 @code{asm} template other than as a dialect indicator.
6770 @subsubheading Other format strings
6772 In addition to the tokens described by the input, output, and goto operands, 
6773 there are a few special cases:
6775 @itemize
6776 @item
6777 "%%" outputs a single "%" into the assembler code.
6779 @item
6780 "%=" outputs a number that is unique to each instance of the @code{asm} 
6781 statement in the entire compilation. This option is useful when creating local 
6782 labels and referring to them multiple times in a single template that 
6783 generates multiple assembler instructions. 
6785 @end itemize
6787 @anchor{OutputOperands}
6788 @subsubsection Output Operands
6789 @cindex @code{asm} output operands
6791 An @code{asm} statement has zero or more output operands indicating the names
6792 of C variables modified by the assembler code.
6794 In this i386 example, @var{old} (referred to in the template string as 
6795 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset} 
6796 (@code{%2}) is an input:
6798 @example
6799 bool old;
6801 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6802          "sbb %0,%0"      // Use the CF to calculate old.
6803    : "=r" (old), "+rm" (*Base)
6804    : "Ir" (Offset)
6805    : "cc");
6807 return old;
6808 @end example
6810 Operands use this format:
6812 @example
6813 [ [asmSymbolicName] ] "constraint" (cvariablename)
6814 @end example
6816 @emph{asmSymbolicName}
6819 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6820 in the list of operands in the assembler template. For example if there are 
6821 three output operands, use @code{%0} in the template to refer to the first, 
6822 @code{%1} for the second, and @code{%2} for the third. When using an 
6823 asmSymbolicName, reference it by enclosing the name in square brackets 
6824 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement 
6825 that contains the definition. Any valid C variable name is acceptable, 
6826 including names already defined in the surrounding code. No two operands 
6827 within the same @code{asm} statement can use the same symbolic name.
6829 @emph{constraint}
6831 Output constraints must begin with either @code{"="} (a variable overwriting an 
6832 existing value) or @code{"+"} (when reading and writing). When using 
6833 @code{"="}, do not assume the location will contain the existing value (except 
6834 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6836 After the prefix, there must be one or more additional constraints 
6837 (@pxref{Constraints}) that describe where the value resides. Common 
6838 constraints include @code{"r"} for register and @code{"m"} for memory. 
6839 When you list more than one possible location (for example @code{"=rm"}), the 
6840 compiler chooses the most efficient one based on the current context. If you 
6841 list as many alternates as the @code{asm} statement allows, you will permit 
6842 the optimizers to produce the best possible code. If you must use a specific
6843 register, but your Machine Constraints do not provide sufficient 
6844 control to select the specific register you want, Local Reg Vars may provide 
6845 a solution (@pxref{Local Reg Vars}).
6847 @emph{cvariablename}
6849 Specifies the C variable name of the output (enclosed by parentheses). Accepts 
6850 any (non-constant) variable within scope.
6852 Remarks:
6854 The total number of input + output + goto operands has a limit of 30. Commas 
6855 separate the operands. When the compiler selects the registers to use to 
6856 represent the output operands, it will not use any of the clobbered registers 
6857 (@pxref{Clobbers}).
6859 Output operand expressions must be lvalues. The compiler cannot check whether 
6860 the operands have data types that are reasonable for the instruction being 
6861 executed. For output expressions that are not directly addressable (for 
6862 example a bit-field), the constraint must allow a register. In that case, GCC 
6863 uses the register as the output of the @code{asm}, and then stores that 
6864 register into the output. 
6866 Unless an output operand has the '@code{&}' constraint modifier 
6867 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated 
6868 input operand, on the assumption that the assembler code will consume its 
6869 inputs before producing outputs. This assumption may be false if the assembler 
6870 code actually consists of more than one instruction. In this case, use 
6871 '@code{&}' on each output operand that must not overlap an input.
6873 The same problem can occur if one output parameter (@var{a}) allows a register 
6874 constraint and another output parameter (@var{b}) allows a memory constraint.
6875 The code generated by GCC to access the memory address in @var{b} can contain
6876 registers which @emph{might} be shared by @var{a}, and GCC considers those 
6877 registers to be inputs to the asm. As above, GCC assumes that such input
6878 registers are consumed before any outputs are written. This assumption may 
6879 result in incorrect behavior if the asm writes to @var{a} before using 
6880 @var{b}. Combining the `@code{&}' constraint with the register constraint 
6881 ensures that modifying @var{a} will not affect what address is referenced by 
6882 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b} 
6883 will be undefined if @var{a} is modified before using @var{b}.
6885 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6886 instead of simply @code{%2}). Typically these qualifiers are hardware 
6887 dependent. The list of supported modifiers for i386 is found at 
6888 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6890 If the C code that follows the @code{asm} makes no use of any of the output 
6891 operands, use @code{volatile} for the @code{asm} statement to prevent the 
6892 optimizers from discarding the @code{asm} statement as unneeded 
6893 (see @ref{Volatile}).
6895 Examples:
6897 This code makes no use of the optional asmSymbolicName. Therefore it 
6898 references the first output operand as @code{%0} (were there a second, it 
6899 would be @code{%1}, etc). The number of the first input operand is one greater 
6900 than that of the last output operand. In this i386 example, that makes 
6901 @var{Mask} @code{%1}:
6903 @example
6904 uint32_t Mask = 1234;
6905 uint32_t Index;
6907   asm ("bsfl %1, %0"
6908      : "=r" (Index)
6909      : "r" (Mask)
6910      : "cc");
6911 @end example
6913 That code overwrites the variable Index ("="), placing the value in a register 
6914 ("r"). The generic "r" constraint instead of a constraint for a specific 
6915 register allows the compiler to pick the register to use, which can result 
6916 in more efficient code. This may not be possible if an assembler instruction 
6917 requires a specific register.
6919 The following i386 example uses the asmSymbolicName operand. It produces the 
6920 same result as the code above, but some may consider it more readable or more 
6921 maintainable since reordering index numbers is not necessary when adding or 
6922 removing operands. The names aIndex and aMask are only used to emphasize which 
6923 names get used where. It is acceptable to reuse the names Index and Mask.
6925 @example
6926 uint32_t Mask = 1234;
6927 uint32_t Index;
6929   asm ("bsfl %[aMask], %[aIndex]"
6930      : [aIndex] "=r" (Index)
6931      : [aMask] "r" (Mask)
6932      : "cc");
6933 @end example
6935 Here are some more examples of output operands.
6937 @example
6938 uint32_t c = 1;
6939 uint32_t d;
6940 uint32_t *e = &c;
6942 asm ("mov %[e], %[d]"
6943    : [d] "=rm" (d)
6944    : [e] "rm" (*e));
6945 @end example
6947 Here, @var{d} may either be in a register or in memory. Since the compiler 
6948 might already have the current value of the uint32_t pointed to by @var{e} 
6949 in a register, you can enable it to choose the best location
6950 for @var{d} by specifying both constraints.
6952 @anchor{InputOperands}
6953 @subsubsection Input Operands
6954 @cindex @code{asm} input operands
6955 @cindex @code{asm} expressions
6957 Input operands make inputs from C variables and expressions available to the 
6958 assembly code.
6960 Specify input operands by using the format:
6962 @example
6963 [ [asmSymbolicName] ] "constraint" (cexpression)
6964 @end example
6966 @emph{asmSymbolicName}
6968 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6969 in the list of operands, including outputs, in the assembler template. For 
6970 example, if there are two output parameters and three inputs, @code{%2} refers 
6971 to the first input, @code{%3} to the second, and @code{%4} to the third.
6972 When using an asmSymbolicName, reference it by enclosing the name in square 
6973 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm} 
6974 statement that contains the definition. Any valid C variable name is 
6975 acceptable, including names already defined in the surrounding code. No two 
6976 operands within the same @code{asm} statement can use the same symbolic name.
6978 @emph{constraint}
6980 Input constraints must be a string containing one or more constraints 
6981 (@pxref{Constraints}). When you give more than one possible constraint 
6982 (for example, @code{"irm"}), the compiler will choose the most efficient 
6983 method based on the current context. Input constraints may not begin with 
6984 either "=" or "+". If you must use a specific register, but your Machine
6985 Constraints do not provide sufficient control to select the specific 
6986 register you want, Local Reg Vars may provide a solution 
6987 (@pxref{Local Reg Vars}).
6989 Input constraints can also be digits (for example, @code{"0"}). This indicates 
6990 that the specified input will be in the same place as the output constraint 
6991 at the (zero-based) index in the output constraint list. When using 
6992 asmSymbolicNames for the output operands, you may use these names (enclosed 
6993 in brackets []) instead of digits.
6995 @emph{cexpression}
6997 This is the C variable or expression being passed to the @code{asm} statement 
6998 as input.
7000 When the compiler selects the registers to use to represent the input 
7001 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
7003 If there are no output operands but there are input operands, place two 
7004 consecutive colons where the output operands would go:
7006 @example
7007 __asm__ ("some instructions"
7008    : /* No outputs. */
7009    : "r" (Offset / 8);
7010 @end example
7012 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7013 (except for inputs tied to outputs). The compiler assumes that on exit from 
7014 the @code{asm} statement these operands will contain the same values as they 
7015 had before executing the assembler. It is @emph{not} possible to use Clobbers 
7016 to inform the compiler that the values in these inputs are changing. One 
7017 common work-around is to tie the changing input variable to an output variable 
7018 that never gets used. Note, however, that if the code that follows the 
7019 @code{asm} statement makes no use of any of the output operands, the GCC 
7020 optimizers may discard the @code{asm} statement as unneeded 
7021 (see @ref{Volatile}).
7023 Remarks:
7025 The total number of input + output + goto operands has a limit of 30.
7027 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
7028 instead of simply @code{%2}). Typically these qualifiers are hardware 
7029 dependent. The list of supported modifiers for i386 is found at 
7030 @ref{i386Operandmodifiers,i386 Operand modifiers}.
7032 Examples:
7034 In this example using the fictitious @code{combine} instruction, the 
7035 constraint @code{"0"} for input operand 1 says that it must occupy the same 
7036 location as output operand 0. Only input operands may use numbers in 
7037 constraints, and they must each refer to an output operand. Only a number (or 
7038 the symbolic assembler name) in the constraint can guarantee that one operand 
7039 is in the same place as another. The mere fact that @var{foo} is the value of 
7040 both operands is not enough to guarantee that they are in the same place in 
7041 the generated assembler code.
7043 @example
7044 asm ("combine %2, %0" 
7045    : "=r" (foo) 
7046    : "0" (foo), "g" (bar));
7047 @end example
7049 Here is an example using symbolic names.
7051 @example
7052 asm ("cmoveq %1, %2, %[result]" 
7053    : [result] "=r"(result) 
7054    : "r" (test), "r" (new), "[result]" (old));
7055 @end example
7057 @anchor{Clobbers}
7058 @subsubsection Clobbers
7059 @cindex @code{asm} clobbers
7061 While the compiler is aware of changes to entries listed in the output 
7062 operands, the assembler code may modify more than just the outputs. For 
7063 example, calculations may require additional registers, or the processor may 
7064 overwrite a register as a side effect of a particular assembler instruction. 
7065 In order to inform the compiler of these changes, list them in the clobber 
7066 list. Clobber list items are either register names or the special clobbers 
7067 (listed below). Each clobber list item is enclosed in double quotes and 
7068 separated by commas.
7070 Clobber descriptions may not in any way overlap with an input or output 
7071 operand. For example, you may not have an operand describing a register class 
7072 with one member when listing that register in the clobber list. Variables 
7073 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used 
7074 as @code{asm} input or output operands, must have no part mentioned in the 
7075 clobber description. In particular, there is no way to specify that input 
7076 operands get modified without also specifying them as output operands.
7078 When the compiler selects which registers to use to represent input and output 
7079 operands, it will not use any of the clobbered registers. As a result, 
7080 clobbered registers are available for any use in the assembler code.
7082 Here is a realistic example for the VAX showing the use of clobbered 
7083 registers: 
7085 @example
7086 asm volatile ("movc3 %0, %1, %2"
7087                    : /* No outputs. */
7088                    : "g" (from), "g" (to), "g" (count)
7089                    : "r0", "r1", "r2", "r3", "r4", "r5");
7090 @end example
7092 Also, there are two special clobber arguments:
7094 @enumerate
7095 @item
7096 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7097 register. On some machines, GCC represents the condition codes as a specific 
7098 hardware register; "cc" serves to name this register. On other machines, 
7099 condition code handling is different, and specifying "cc" has no effect. But 
7100 it is valid no matter what the machine.
7102 @item
7103 The "memory" clobber tells the compiler that the assembly code performs memory 
7104 reads or writes to items other than those listed in the input and output 
7105 operands (for example accessing the memory pointed to by one of the input 
7106 parameters). To ensure memory contains correct values, GCC may need to flush 
7107 specific register values to memory before executing the @code{asm}. Further, 
7108 the compiler will not assume that any values read from memory before an 
7109 @code{asm} will remain unchanged after that @code{asm}; it will reload them as 
7110 needed. This effectively forms a read/write memory barrier for the compiler.
7112 Note that this clobber does not prevent the @emph{processor} from doing 
7113 speculative reads past the @code{asm} statement. To prevent that, you need 
7114 processor-specific fence instructions.
7116 Flushing registers to memory has performance implications and may be an issue 
7117 for time-sensitive code. One trick to avoid this is available if the size of 
7118 the memory being accessed is known at compile time. For example, if accessing 
7119 ten bytes of a string, use a memory input like: 
7121 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7123 @end enumerate
7125 @anchor{GotoLabels}
7126 @subsubsection Goto Labels
7127 @cindex @code{asm} goto labels
7129 @code{asm goto} allows assembly code to jump to one or more C labels. The 
7130 GotoLabels section in an @code{asm goto} statement contains a comma-separated 
7131 list of all C labels to which the assembler code may jump. GCC assumes that 
7132 @code{asm} execution falls through to the next statement (if this is not the 
7133 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7134 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7135 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7136 Attributes}). The total number of input + output + goto operands has 
7137 a limit of 30.
7139 An @code{asm goto} statement can not have outputs (which means that the 
7140 statement is implicitly volatile). This is due to an internal restriction of 
7141 the compiler: control transfer instructions cannot have outputs. If the 
7142 assembler code does modify anything, use the "memory" clobber to force the 
7143 optimizers to flush all register values to memory, and reload them if 
7144 necessary, after the @code{asm} statement.
7146 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed 
7147 by its (zero-based) position in GotoLabels plus the number of input 
7148 arguments.  For example, if the @code{asm} has three inputs and references two 
7149 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7151 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7152 GCC's optimizers do not know about these jumps; therefore they cannot take 
7153 account of them when deciding how to optimize.
7155 Example code for i386 might look like:
7157 @example
7158 asm goto (
7159     "btl %1, %0\n\t"
7160     "jc %l2"
7161     : /* No outputs. */
7162     : "r" (p1), "r" (p2) 
7163     : "cc" 
7164     : carry);
7166 return 0;
7168 carry:
7169 return 1;
7170 @end example
7172 The following example shows an @code{asm goto} that uses the memory clobber.
7174 @example
7175 int frob(int x)
7177   int y;
7178   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7179             : /* No outputs. */
7180             : "r"(x), "r"(&y)
7181             : "r5", "memory" 
7182             : error);
7183   return y;
7184 error:
7185   return -1;
7187 @end example
7189 @anchor{i386Operandmodifiers}
7190 @subsubsection i386 Operand modifiers
7192 Input, output, and goto operands for extended @code{asm} statements can use 
7193 modifiers to affect the code output to the assembler. For example, the 
7194 following code uses the "h" and "b" modifiers for i386:
7196 @example
7197 uint16_t  num;
7198 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7199 @end example
7201 These modifiers generate this assembler code:
7203 @example
7204 xchg %ah, %al
7205 @end example
7207 The rest of this discussion uses the following code for illustrative purposes.
7209 @example
7210 int main()
7212    int iInt = 1;
7214 top:
7216    asm volatile goto ("some assembler instructions here"
7217    : /* No outputs. */
7218    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7219    : /* No clobbers. */
7220    : top);
7222 @end example
7224 With no modifiers, this is what the output from the operands would be for the 
7225 att and intel dialects of assembler:
7227 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7228 @headitem Operand @tab masm=att @tab masm=intel
7229 @item @code{%0}
7230 @tab @code{%eax}
7231 @tab @code{eax}
7232 @item @code{%1}
7233 @tab @code{$2}
7234 @tab @code{2}
7235 @item @code{%2}
7236 @tab @code{$.L2}
7237 @tab @code{OFFSET FLAT:.L2}
7238 @end multitable
7240 The table below shows the list of supported modifiers and their effects.
7242 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7243 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7244 @item @code{z}
7245 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7246 @tab @code{%z0}
7247 @tab @code{l}
7248 @tab 
7249 @item @code{b}
7250 @tab Print the QImode name of the register.
7251 @tab @code{%b0}
7252 @tab @code{%al}
7253 @tab @code{al}
7254 @item @code{h}
7255 @tab Print the QImode name for a ``high'' register.
7256 @tab @code{%h0}
7257 @tab @code{%ah}
7258 @tab @code{ah}
7259 @item @code{w}
7260 @tab Print the HImode name of the register.
7261 @tab @code{%w0}
7262 @tab @code{%ax}
7263 @tab @code{ax}
7264 @item @code{k}
7265 @tab Print the SImode name of the register.
7266 @tab @code{%k0}
7267 @tab @code{%eax}
7268 @tab @code{eax}
7269 @item @code{q}
7270 @tab Print the DImode name of the register.
7271 @tab @code{%q0}
7272 @tab @code{%rax}
7273 @tab @code{rax}
7274 @item @code{l}
7275 @tab Print the label name with no punctuation.
7276 @tab @code{%l2}
7277 @tab @code{.L2}
7278 @tab @code{.L2}
7279 @item @code{c}
7280 @tab Require a constant operand and print the constant expression with no punctuation.
7281 @tab @code{%c1}
7282 @tab @code{2}
7283 @tab @code{2}
7284 @end multitable
7286 @anchor{i386floatingpointasmoperands}
7287 @subsubsection i386 floating-point asm operands
7289 On i386 targets, there are several rules on the usage of stack-like registers
7290 in the operands of an @code{asm}.  These rules apply only to the operands
7291 that are stack-like registers:
7293 @enumerate
7294 @item
7295 Given a set of input registers that die in an @code{asm}, it is
7296 necessary to know which are implicitly popped by the @code{asm}, and
7297 which must be explicitly popped by GCC@.
7299 An input register that is implicitly popped by the @code{asm} must be
7300 explicitly clobbered, unless it is constrained to match an
7301 output operand.
7303 @item
7304 For any input register that is implicitly popped by an @code{asm}, it is
7305 necessary to know how to adjust the stack to compensate for the pop.
7306 If any non-popped input is closer to the top of the reg-stack than
7307 the implicitly popped register, it would not be possible to know what the
7308 stack looked like---it's not clear how the rest of the stack ``slides
7309 up''.
7311 All implicitly popped input registers must be closer to the top of
7312 the reg-stack than any input that is not implicitly popped.
7314 It is possible that if an input dies in an @code{asm}, the compiler might
7315 use the input register for an output reload.  Consider this example:
7317 @smallexample
7318 asm ("foo" : "=t" (a) : "f" (b));
7319 @end smallexample
7321 @noindent
7322 This code says that input @code{b} is not popped by the @code{asm}, and that
7323 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7324 deeper after the @code{asm} than it was before.  But, it is possible that
7325 reload may think that it can use the same register for both the input and
7326 the output.
7328 To prevent this from happening,
7329 if any input operand uses the @code{f} constraint, all output register
7330 constraints must use the @code{&} early-clobber modifier.
7332 The example above would be correctly written as:
7334 @smallexample
7335 asm ("foo" : "=&t" (a) : "f" (b));
7336 @end smallexample
7338 @item
7339 Some operands need to be in particular places on the stack.  All
7340 output operands fall in this category---GCC has no other way to
7341 know which registers the outputs appear in unless you indicate
7342 this in the constraints.
7344 Output operands must specifically indicate which register an output
7345 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
7346 constraints must select a class with a single register.
7348 @item
7349 Output operands may not be ``inserted'' between existing stack registers.
7350 Since no 387 opcode uses a read/write operand, all output operands
7351 are dead before the @code{asm}, and are pushed by the @code{asm}.
7352 It makes no sense to push anywhere but the top of the reg-stack.
7354 Output operands must start at the top of the reg-stack: output
7355 operands may not ``skip'' a register.
7357 @item
7358 Some @code{asm} statements may need extra stack space for internal
7359 calculations.  This can be guaranteed by clobbering stack registers
7360 unrelated to the inputs and outputs.
7362 @end enumerate
7364 Here are a couple of reasonable @code{asm}s to want to write.  This
7365 @code{asm}
7366 takes one input, which is internally popped, and produces two outputs.
7368 @smallexample
7369 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7370 @end smallexample
7372 @noindent
7373 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7374 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7375 for the compiler to know that @code{fyl2xp1} pops both inputs.
7377 @smallexample
7378 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7379 @end smallexample
7381 @lowersections
7382 @include md.texi
7383 @raisesections
7385 @node Asm Labels
7386 @subsection Controlling Names Used in Assembler Code
7387 @cindex assembler names for identifiers
7388 @cindex names used in assembler code
7389 @cindex identifiers, names in assembler code
7391 You can specify the name to be used in the assembler code for a C
7392 function or variable by writing the @code{asm} (or @code{__asm__})
7393 keyword after the declarator as follows:
7395 @smallexample
7396 int foo asm ("myfoo") = 2;
7397 @end smallexample
7399 @noindent
7400 This specifies that the name to be used for the variable @code{foo} in
7401 the assembler code should be @samp{myfoo} rather than the usual
7402 @samp{_foo}.
7404 On systems where an underscore is normally prepended to the name of a C
7405 function or variable, this feature allows you to define names for the
7406 linker that do not start with an underscore.
7408 It does not make sense to use this feature with a non-static local
7409 variable since such variables do not have assembler names.  If you are
7410 trying to put the variable in a particular register, see @ref{Explicit
7411 Reg Vars}.  GCC presently accepts such code with a warning, but will
7412 probably be changed to issue an error, rather than a warning, in the
7413 future.
7415 You cannot use @code{asm} in this way in a function @emph{definition}; but
7416 you can get the same effect by writing a declaration for the function
7417 before its definition and putting @code{asm} there, like this:
7419 @smallexample
7420 extern func () asm ("FUNC");
7422 func (x, y)
7423      int x, y;
7424 /* @r{@dots{}} */
7425 @end smallexample
7427 It is up to you to make sure that the assembler names you choose do not
7428 conflict with any other assembler symbols.  Also, you must not use a
7429 register name; that would produce completely invalid assembler code.  GCC
7430 does not as yet have the ability to store static variables in registers.
7431 Perhaps that will be added.
7433 @node Explicit Reg Vars
7434 @subsection Variables in Specified Registers
7435 @cindex explicit register variables
7436 @cindex variables in specified registers
7437 @cindex specified registers
7438 @cindex registers, global allocation
7440 GNU C allows you to put a few global variables into specified hardware
7441 registers.  You can also specify the register in which an ordinary
7442 register variable should be allocated.
7444 @itemize @bullet
7445 @item
7446 Global register variables reserve registers throughout the program.
7447 This may be useful in programs such as programming language
7448 interpreters that have a couple of global variables that are accessed
7449 very often.
7451 @item
7452 Local register variables in specific registers do not reserve the
7453 registers, except at the point where they are used as input or output
7454 operands in an @code{asm} statement and the @code{asm} statement itself is
7455 not deleted.  The compiler's data flow analysis is capable of determining
7456 where the specified registers contain live values, and where they are
7457 available for other uses.  Stores into local register variables may be deleted
7458 when they appear to be dead according to dataflow analysis.  References
7459 to local register variables may be deleted or moved or simplified.
7461 These local variables are sometimes convenient for use with the extended
7462 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7463 output of the assembler instruction directly into a particular register.
7464 (This works provided the register you specify fits the constraints
7465 specified for that operand in the @code{asm}.)
7466 @end itemize
7468 @menu
7469 * Global Reg Vars::
7470 * Local Reg Vars::
7471 @end menu
7473 @node Global Reg Vars
7474 @subsubsection Defining Global Register Variables
7475 @cindex global register variables
7476 @cindex registers, global variables in
7478 You can define a global register variable in GNU C like this:
7480 @smallexample
7481 register int *foo asm ("a5");
7482 @end smallexample
7484 @noindent
7485 Here @code{a5} is the name of the register that should be used.  Choose a
7486 register that is normally saved and restored by function calls on your
7487 machine, so that library routines will not clobber it.
7489 Naturally the register name is cpu-dependent, so you need to
7490 conditionalize your program according to cpu type.  The register
7491 @code{a5} is a good choice on a 68000 for a variable of pointer
7492 type.  On machines with register windows, be sure to choose a ``global''
7493 register that is not affected magically by the function call mechanism.
7495 In addition, different operating systems on the same CPU may differ in how they
7496 name the registers; then you need additional conditionals.  For
7497 example, some 68000 operating systems call this register @code{%a5}.
7499 Eventually there may be a way of asking the compiler to choose a register
7500 automatically, but first we need to figure out how it should choose and
7501 how to enable you to guide the choice.  No solution is evident.
7503 Defining a global register variable in a certain register reserves that
7504 register entirely for this use, at least within the current compilation.
7505 The register is not allocated for any other purpose in the functions
7506 in the current compilation, and is not saved and restored by
7507 these functions.  Stores into this register are never deleted even if they
7508 appear to be dead, but references may be deleted or moved or
7509 simplified.
7511 It is not safe to access the global register variables from signal
7512 handlers, or from more than one thread of control, because the system
7513 library routines may temporarily use the register for other things (unless
7514 you recompile them specially for the task at hand).
7516 @cindex @code{qsort}, and global register variables
7517 It is not safe for one function that uses a global register variable to
7518 call another such function @code{foo} by way of a third function
7519 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7520 different source file in which the variable isn't declared).  This is
7521 because @code{lose} might save the register and put some other value there.
7522 For example, you can't expect a global register variable to be available in
7523 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7524 might have put something else in that register.  (If you are prepared to
7525 recompile @code{qsort} with the same global register variable, you can
7526 solve this problem.)
7528 If you want to recompile @code{qsort} or other source files that do not
7529 actually use your global register variable, so that they do not use that
7530 register for any other purpose, then it suffices to specify the compiler
7531 option @option{-ffixed-@var{reg}}.  You need not actually add a global
7532 register declaration to their source code.
7534 A function that can alter the value of a global register variable cannot
7535 safely be called from a function compiled without this variable, because it
7536 could clobber the value the caller expects to find there on return.
7537 Therefore, the function that is the entry point into the part of the
7538 program that uses the global register variable must explicitly save and
7539 restore the value that belongs to its caller.
7541 @cindex register variable after @code{longjmp}
7542 @cindex global register after @code{longjmp}
7543 @cindex value after @code{longjmp}
7544 @findex longjmp
7545 @findex setjmp
7546 On most machines, @code{longjmp} restores to each global register
7547 variable the value it had at the time of the @code{setjmp}.  On some
7548 machines, however, @code{longjmp} does not change the value of global
7549 register variables.  To be portable, the function that called @code{setjmp}
7550 should make other arrangements to save the values of the global register
7551 variables, and to restore them in a @code{longjmp}.  This way, the same
7552 thing happens regardless of what @code{longjmp} does.
7554 All global register variable declarations must precede all function
7555 definitions.  If such a declaration could appear after function
7556 definitions, the declaration would be too late to prevent the register from
7557 being used for other purposes in the preceding functions.
7559 Global register variables may not have initial values, because an
7560 executable file has no means to supply initial contents for a register.
7562 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7563 registers, but certain library functions, such as @code{getwd}, as well
7564 as the subroutines for division and remainder, modify g3 and g4.  g1 and
7565 g2 are local temporaries.
7567 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7568 Of course, it does not do to use more than a few of those.
7570 @node Local Reg Vars
7571 @subsubsection Specifying Registers for Local Variables
7572 @cindex local variables, specifying registers
7573 @cindex specifying registers for local variables
7574 @cindex registers for local variables
7576 You can define a local register variable with a specified register
7577 like this:
7579 @smallexample
7580 register int *foo asm ("a5");
7581 @end smallexample
7583 @noindent
7584 Here @code{a5} is the name of the register that should be used.  Note
7585 that this is the same syntax used for defining global register
7586 variables, but for a local variable it appears within a function.
7588 Naturally the register name is cpu-dependent, but this is not a
7589 problem, since specific registers are most often useful with explicit
7590 assembler instructions (@pxref{Extended Asm}).  Both of these things
7591 generally require that you conditionalize your program according to
7592 cpu type.
7594 In addition, operating systems on one type of cpu may differ in how they
7595 name the registers; then you need additional conditionals.  For
7596 example, some 68000 operating systems call this register @code{%a5}.
7598 Defining such a register variable does not reserve the register; it
7599 remains available for other uses in places where flow control determines
7600 the variable's value is not live.
7602 This option does not guarantee that GCC generates code that has
7603 this variable in the register you specify at all times.  You may not
7604 code an explicit reference to this register in the @emph{assembler
7605 instruction template} part of an @code{asm} statement and assume it
7606 always refers to this variable.  However, using the variable as an
7607 @code{asm} @emph{operand} guarantees that the specified register is used
7608 for the operand.
7610 Stores into local register variables may be deleted when they appear to be dead
7611 according to dataflow analysis.  References to local register variables may
7612 be deleted or moved or simplified.
7614 As with global register variables, it is recommended that you choose a
7615 register that is normally saved and restored by function calls on
7616 your machine, so that library routines will not clobber it.  
7618 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
7619 specific register, but there's no matching constraint letter for that 
7620 register. To force the operand into that register, create a local variable 
7621 and specify the register in the variable's declaration. Then use the local 
7622 variable for the asm operand and specify any constraint letter that matches 
7623 the register:
7625 @smallexample
7626 register int *p1 asm ("r0") = @dots{};
7627 register int *p2 asm ("r1") = @dots{};
7628 register int *result asm ("r0");
7629 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7630 @end smallexample
7632 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
7633 call-clobbered by subsequent code, including function calls and library calls 
7634 for arithmetic operators on other variables (for example the initialization 
7635 of p2). In this case, use temporary variables for expressions between the 
7636 register assignments:
7638 @smallexample
7639 int t1 = @dots{};
7640 register int *p1 asm ("r0") = @dots{};
7641 register int *p2 asm ("r1") = t1;
7642 register int *result asm ("r0");
7643 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7644 @end smallexample
7646 @node Size of an asm
7647 @subsection Size of an @code{asm}
7649 Some targets require that GCC track the size of each instruction used
7650 in order to generate correct code.  Because the final length of the
7651 code produced by an @code{asm} statement is only known by the
7652 assembler, GCC must make an estimate as to how big it will be.  It
7653 does this by counting the number of instructions in the pattern of the
7654 @code{asm} and multiplying that by the length of the longest
7655 instruction supported by that processor.  (When working out the number
7656 of instructions, it assumes that any occurrence of a newline or of
7657 whatever statement separator character is supported by the assembler --
7658 typically @samp{;} --- indicates the end of an instruction.)
7660 Normally, GCC's estimate is adequate to ensure that correct
7661 code is generated, but it is possible to confuse the compiler if you use
7662 pseudo instructions or assembler macros that expand into multiple real
7663 instructions, or if you use assembler directives that expand to more
7664 space in the object file than is needed for a single instruction.
7665 If this happens then the assembler may produce a diagnostic saying that
7666 a label is unreachable.
7668 @node Alternate Keywords
7669 @section Alternate Keywords
7670 @cindex alternate keywords
7671 @cindex keywords, alternate
7673 @option{-ansi} and the various @option{-std} options disable certain
7674 keywords.  This causes trouble when you want to use GNU C extensions, or
7675 a general-purpose header file that should be usable by all programs,
7676 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
7677 @code{inline} are not available in programs compiled with
7678 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7679 program compiled with @option{-std=c99} or @option{-std=c11}).  The
7680 ISO C99 keyword
7681 @code{restrict} is only available when @option{-std=gnu99} (which will
7682 eventually be the default) or @option{-std=c99} (or the equivalent
7683 @option{-std=iso9899:1999}), or an option for a later standard
7684 version, is used.
7686 The way to solve these problems is to put @samp{__} at the beginning and
7687 end of each problematical keyword.  For example, use @code{__asm__}
7688 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7690 Other C compilers won't accept these alternative keywords; if you want to
7691 compile with another compiler, you can define the alternate keywords as
7692 macros to replace them with the customary keywords.  It looks like this:
7694 @smallexample
7695 #ifndef __GNUC__
7696 #define __asm__ asm
7697 #endif
7698 @end smallexample
7700 @findex __extension__
7701 @opindex pedantic
7702 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7703 You can
7704 prevent such warnings within one expression by writing
7705 @code{__extension__} before the expression.  @code{__extension__} has no
7706 effect aside from this.
7708 @node Incomplete Enums
7709 @section Incomplete @code{enum} Types
7711 You can define an @code{enum} tag without specifying its possible values.
7712 This results in an incomplete type, much like what you get if you write
7713 @code{struct foo} without describing the elements.  A later declaration
7714 that does specify the possible values completes the type.
7716 You can't allocate variables or storage using the type while it is
7717 incomplete.  However, you can work with pointers to that type.
7719 This extension may not be very useful, but it makes the handling of
7720 @code{enum} more consistent with the way @code{struct} and @code{union}
7721 are handled.
7723 This extension is not supported by GNU C++.
7725 @node Function Names
7726 @section Function Names as Strings
7727 @cindex @code{__func__} identifier
7728 @cindex @code{__FUNCTION__} identifier
7729 @cindex @code{__PRETTY_FUNCTION__} identifier
7731 GCC provides three magic variables that hold the name of the current
7732 function, as a string.  The first of these is @code{__func__}, which
7733 is part of the C99 standard:
7735 The identifier @code{__func__} is implicitly declared by the translator
7736 as if, immediately following the opening brace of each function
7737 definition, the declaration
7739 @smallexample
7740 static const char __func__[] = "function-name";
7741 @end smallexample
7743 @noindent
7744 appeared, where function-name is the name of the lexically-enclosing
7745 function.  This name is the unadorned name of the function.
7747 @code{__FUNCTION__} is another name for @code{__func__}.  Older
7748 versions of GCC recognize only this name.  However, it is not
7749 standardized.  For maximum portability, we recommend you use
7750 @code{__func__}, but provide a fallback definition with the
7751 preprocessor:
7753 @smallexample
7754 #if __STDC_VERSION__ < 199901L
7755 # if __GNUC__ >= 2
7756 #  define __func__ __FUNCTION__
7757 # else
7758 #  define __func__ "<unknown>"
7759 # endif
7760 #endif
7761 @end smallexample
7763 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7764 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
7765 the type signature of the function as well as its bare name.  For
7766 example, this program:
7768 @smallexample
7769 extern "C" @{
7770 extern int printf (char *, ...);
7773 class a @{
7774  public:
7775   void sub (int i)
7776     @{
7777       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7778       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7779     @}
7783 main (void)
7785   a ax;
7786   ax.sub (0);
7787   return 0;
7789 @end smallexample
7791 @noindent
7792 gives this output:
7794 @smallexample
7795 __FUNCTION__ = sub
7796 __PRETTY_FUNCTION__ = void a::sub(int)
7797 @end smallexample
7799 These identifiers are not preprocessor macros.  In GCC 3.3 and
7800 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7801 were treated as string literals; they could be used to initialize
7802 @code{char} arrays, and they could be concatenated with other string
7803 literals.  GCC 3.4 and later treat them as variables, like
7804 @code{__func__}.  In C++, @code{__FUNCTION__} and
7805 @code{__PRETTY_FUNCTION__} have always been variables.
7807 @node Return Address
7808 @section Getting the Return or Frame Address of a Function
7810 These functions may be used to get information about the callers of a
7811 function.
7813 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7814 This function returns the return address of the current function, or of
7815 one of its callers.  The @var{level} argument is number of frames to
7816 scan up the call stack.  A value of @code{0} yields the return address
7817 of the current function, a value of @code{1} yields the return address
7818 of the caller of the current function, and so forth.  When inlining
7819 the expected behavior is that the function returns the address of
7820 the function that is returned to.  To work around this behavior use
7821 the @code{noinline} function attribute.
7823 The @var{level} argument must be a constant integer.
7825 On some machines it may be impossible to determine the return address of
7826 any function other than the current one; in such cases, or when the top
7827 of the stack has been reached, this function returns @code{0} or a
7828 random value.  In addition, @code{__builtin_frame_address} may be used
7829 to determine if the top of the stack has been reached.
7831 Additional post-processing of the returned value may be needed, see
7832 @code{__builtin_extract_return_addr}.
7834 This function should only be used with a nonzero argument for debugging
7835 purposes.
7836 @end deftypefn
7838 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7839 The address as returned by @code{__builtin_return_address} may have to be fed
7840 through this function to get the actual encoded address.  For example, on the
7841 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7842 platforms an offset has to be added for the true next instruction to be
7843 executed.
7845 If no fixup is needed, this function simply passes through @var{addr}.
7846 @end deftypefn
7848 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7849 This function does the reverse of @code{__builtin_extract_return_addr}.
7850 @end deftypefn
7852 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7853 This function is similar to @code{__builtin_return_address}, but it
7854 returns the address of the function frame rather than the return address
7855 of the function.  Calling @code{__builtin_frame_address} with a value of
7856 @code{0} yields the frame address of the current function, a value of
7857 @code{1} yields the frame address of the caller of the current function,
7858 and so forth.
7860 The frame is the area on the stack that holds local variables and saved
7861 registers.  The frame address is normally the address of the first word
7862 pushed on to the stack by the function.  However, the exact definition
7863 depends upon the processor and the calling convention.  If the processor
7864 has a dedicated frame pointer register, and the function has a frame,
7865 then @code{__builtin_frame_address} returns the value of the frame
7866 pointer register.
7868 On some machines it may be impossible to determine the frame address of
7869 any function other than the current one; in such cases, or when the top
7870 of the stack has been reached, this function returns @code{0} if
7871 the first frame pointer is properly initialized by the startup code.
7873 This function should only be used with a nonzero argument for debugging
7874 purposes.
7875 @end deftypefn
7877 @node Vector Extensions
7878 @section Using Vector Instructions through Built-in Functions
7880 On some targets, the instruction set contains SIMD vector instructions which
7881 operate on multiple values contained in one large register at the same time.
7882 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7883 this way.
7885 The first step in using these extensions is to provide the necessary data
7886 types.  This should be done using an appropriate @code{typedef}:
7888 @smallexample
7889 typedef int v4si __attribute__ ((vector_size (16)));
7890 @end smallexample
7892 @noindent
7893 The @code{int} type specifies the base type, while the attribute specifies
7894 the vector size for the variable, measured in bytes.  For example, the
7895 declaration above causes the compiler to set the mode for the @code{v4si}
7896 type to be 16 bytes wide and divided into @code{int} sized units.  For
7897 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7898 corresponding mode of @code{foo} is @acronym{V4SI}.
7900 The @code{vector_size} attribute is only applicable to integral and
7901 float scalars, although arrays, pointers, and function return values
7902 are allowed in conjunction with this construct. Only sizes that are
7903 a power of two are currently allowed.
7905 All the basic integer types can be used as base types, both as signed
7906 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7907 @code{long long}.  In addition, @code{float} and @code{double} can be
7908 used to build floating-point vector types.
7910 Specifying a combination that is not valid for the current architecture
7911 causes GCC to synthesize the instructions using a narrower mode.
7912 For example, if you specify a variable of type @code{V4SI} and your
7913 architecture does not allow for this specific SIMD type, GCC
7914 produces code that uses 4 @code{SIs}.
7916 The types defined in this manner can be used with a subset of normal C
7917 operations.  Currently, GCC allows using the following operators
7918 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7920 The operations behave like C++ @code{valarrays}.  Addition is defined as
7921 the addition of the corresponding elements of the operands.  For
7922 example, in the code below, each of the 4 elements in @var{a} is
7923 added to the corresponding 4 elements in @var{b} and the resulting
7924 vector is stored in @var{c}.
7926 @smallexample
7927 typedef int v4si __attribute__ ((vector_size (16)));
7929 v4si a, b, c;
7931 c = a + b;
7932 @end smallexample
7934 Subtraction, multiplication, division, and the logical operations
7935 operate in a similar manner.  Likewise, the result of using the unary
7936 minus or complement operators on a vector type is a vector whose
7937 elements are the negative or complemented values of the corresponding
7938 elements in the operand.
7940 It is possible to use shifting operators @code{<<}, @code{>>} on
7941 integer-type vectors. The operation is defined as following: @code{@{a0,
7942 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7943 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7944 elements. 
7946 For convenience, it is allowed to use a binary vector operation
7947 where one operand is a scalar. In that case the compiler transforms
7948 the scalar operand into a vector where each element is the scalar from
7949 the operation. The transformation happens only if the scalar could be
7950 safely converted to the vector-element type.
7951 Consider the following code.
7953 @smallexample
7954 typedef int v4si __attribute__ ((vector_size (16)));
7956 v4si a, b, c;
7957 long l;
7959 a = b + 1;    /* a = b + @{1,1,1,1@}; */
7960 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
7962 a = l + a;    /* Error, cannot convert long to int. */
7963 @end smallexample
7965 Vectors can be subscripted as if the vector were an array with
7966 the same number of elements and base type.  Out of bound accesses
7967 invoke undefined behavior at run time.  Warnings for out of bound
7968 accesses for vector subscription can be enabled with
7969 @option{-Warray-bounds}.
7971 Vector comparison is supported with standard comparison
7972 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7973 vector expressions of integer-type or real-type. Comparison between
7974 integer-type vectors and real-type vectors are not supported.  The
7975 result of the comparison is a vector of the same width and number of
7976 elements as the comparison operands with a signed integral element
7977 type.
7979 Vectors are compared element-wise producing 0 when comparison is false
7980 and -1 (constant of the appropriate type where all bits are set)
7981 otherwise. Consider the following example.
7983 @smallexample
7984 typedef int v4si __attribute__ ((vector_size (16)));
7986 v4si a = @{1,2,3,4@};
7987 v4si b = @{3,2,1,4@};
7988 v4si c;
7990 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
7991 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
7992 @end smallexample
7994 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
7995 @code{b} and @code{c} are vectors of the same type and @code{a} is an
7996 integer vector with the same number of elements of the same size as @code{b}
7997 and @code{c}, computes all three arguments and creates a vector
7998 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
7999 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8000 As in the case of binary operations, this syntax is also accepted when
8001 one of @code{b} or @code{c} is a scalar that is then transformed into a
8002 vector. If both @code{b} and @code{c} are scalars and the type of
8003 @code{true?b:c} has the same size as the element type of @code{a}, then
8004 @code{b} and @code{c} are converted to a vector type whose elements have
8005 this type and with the same number of elements as @code{a}.
8007 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8008 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8009 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8010 For mixed operations between a scalar @code{s} and a vector @code{v},
8011 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8012 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8014 Vector shuffling is available using functions
8015 @code{__builtin_shuffle (vec, mask)} and
8016 @code{__builtin_shuffle (vec0, vec1, mask)}.
8017 Both functions construct a permutation of elements from one or two
8018 vectors and return a vector of the same type as the input vector(s).
8019 The @var{mask} is an integral vector with the same width (@var{W})
8020 and element count (@var{N}) as the output vector.
8022 The elements of the input vectors are numbered in memory ordering of
8023 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8024 elements of @var{mask} are considered modulo @var{N} in the single-operand
8025 case and modulo @math{2*@var{N}} in the two-operand case.
8027 Consider the following example,
8029 @smallexample
8030 typedef int v4si __attribute__ ((vector_size (16)));
8032 v4si a = @{1,2,3,4@};
8033 v4si b = @{5,6,7,8@};
8034 v4si mask1 = @{0,1,1,3@};
8035 v4si mask2 = @{0,4,2,5@};
8036 v4si res;
8038 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
8039 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
8040 @end smallexample
8042 Note that @code{__builtin_shuffle} is intentionally semantically
8043 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8045 You can declare variables and use them in function calls and returns, as
8046 well as in assignments and some casts.  You can specify a vector type as
8047 a return type for a function.  Vector types can also be used as function
8048 arguments.  It is possible to cast from one vector type to another,
8049 provided they are of the same size (in fact, you can also cast vectors
8050 to and from other datatypes of the same size).
8052 You cannot operate between vectors of different lengths or different
8053 signedness without a cast.
8055 @node Offsetof
8056 @section Offsetof
8057 @findex __builtin_offsetof
8059 GCC implements for both C and C++ a syntactic extension to implement
8060 the @code{offsetof} macro.
8062 @smallexample
8063 primary:
8064         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8066 offsetof_member_designator:
8067           @code{identifier}
8068         | offsetof_member_designator "." @code{identifier}
8069         | offsetof_member_designator "[" @code{expr} "]"
8070 @end smallexample
8072 This extension is sufficient such that
8074 @smallexample
8075 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8076 @end smallexample
8078 @noindent
8079 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8080 may be dependent.  In either case, @var{member} may consist of a single
8081 identifier, or a sequence of member accesses and array references.
8083 @node __sync Builtins
8084 @section Legacy __sync Built-in Functions for Atomic Memory Access
8086 The following built-in functions
8087 are intended to be compatible with those described
8088 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8089 section 7.4.  As such, they depart from the normal GCC practice of using
8090 the @samp{__builtin_} prefix, and further that they are overloaded such that
8091 they work on multiple types.
8093 The definition given in the Intel documentation allows only for the use of
8094 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
8095 counterparts.  GCC allows any integral scalar or pointer type that is
8096 1, 2, 4 or 8 bytes in length.
8098 Not all operations are supported by all target processors.  If a particular
8099 operation cannot be implemented on the target processor, a warning is
8100 generated and a call an external function is generated.  The external
8101 function carries the same name as the built-in version,
8102 with an additional suffix
8103 @samp{_@var{n}} where @var{n} is the size of the data type.
8105 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8106 @c useful for implementing the operation under the control of an external
8107 @c mutex.
8109 In most cases, these built-in functions are considered a @dfn{full barrier}.
8110 That is,
8111 no memory operand is moved across the operation, either forward or
8112 backward.  Further, instructions are issued as necessary to prevent the
8113 processor from speculating loads across the operation and from queuing stores
8114 after the operation.
8116 All of the routines are described in the Intel documentation to take
8117 ``an optional list of variables protected by the memory barrier''.  It's
8118 not clear what is meant by that; it could mean that @emph{only} the
8119 following variables are protected, or it could mean that these variables
8120 should in addition be protected.  At present GCC ignores this list and
8121 protects all variables that are globally accessible.  If in the future
8122 we make some use of this list, an empty list will continue to mean all
8123 globally accessible variables.
8125 @table @code
8126 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8127 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8128 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8129 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8130 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8131 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8132 @findex __sync_fetch_and_add
8133 @findex __sync_fetch_and_sub
8134 @findex __sync_fetch_and_or
8135 @findex __sync_fetch_and_and
8136 @findex __sync_fetch_and_xor
8137 @findex __sync_fetch_and_nand
8138 These built-in functions perform the operation suggested by the name, and
8139 returns the value that had previously been in memory.  That is,
8141 @smallexample
8142 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8143 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8144 @end smallexample
8146 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8147 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8149 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8150 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8151 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8152 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8153 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8154 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8155 @findex __sync_add_and_fetch
8156 @findex __sync_sub_and_fetch
8157 @findex __sync_or_and_fetch
8158 @findex __sync_and_and_fetch
8159 @findex __sync_xor_and_fetch
8160 @findex __sync_nand_and_fetch
8161 These built-in functions perform the operation suggested by the name, and
8162 return the new value.  That is,
8164 @smallexample
8165 @{ *ptr @var{op}= value; return *ptr; @}
8166 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8167 @end smallexample
8169 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8170 as @code{*ptr = ~(*ptr & value)} instead of
8171 @code{*ptr = ~*ptr & value}.
8173 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8174 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8175 @findex __sync_bool_compare_and_swap
8176 @findex __sync_val_compare_and_swap
8177 These built-in functions perform an atomic compare and swap.
8178 That is, if the current
8179 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8180 @code{*@var{ptr}}.
8182 The ``bool'' version returns true if the comparison is successful and
8183 @var{newval} is written.  The ``val'' version returns the contents
8184 of @code{*@var{ptr}} before the operation.
8186 @item __sync_synchronize (...)
8187 @findex __sync_synchronize
8188 This built-in function issues a full memory barrier.
8190 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8191 @findex __sync_lock_test_and_set
8192 This built-in function, as described by Intel, is not a traditional test-and-set
8193 operation, but rather an atomic exchange operation.  It writes @var{value}
8194 into @code{*@var{ptr}}, and returns the previous contents of
8195 @code{*@var{ptr}}.
8197 Many targets have only minimal support for such locks, and do not support
8198 a full exchange operation.  In this case, a target may support reduced
8199 functionality here by which the @emph{only} valid value to store is the
8200 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8201 is implementation defined.
8203 This built-in function is not a full barrier,
8204 but rather an @dfn{acquire barrier}.
8205 This means that references after the operation cannot move to (or be
8206 speculated to) before the operation, but previous memory stores may not
8207 be globally visible yet, and previous memory loads may not yet be
8208 satisfied.
8210 @item void __sync_lock_release (@var{type} *ptr, ...)
8211 @findex __sync_lock_release
8212 This built-in function releases the lock acquired by
8213 @code{__sync_lock_test_and_set}.
8214 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8216 This built-in function is not a full barrier,
8217 but rather a @dfn{release barrier}.
8218 This means that all previous memory stores are globally visible, and all
8219 previous memory loads have been satisfied, but following memory reads
8220 are not prevented from being speculated to before the barrier.
8221 @end table
8223 @node __atomic Builtins
8224 @section Built-in functions for memory model aware atomic operations
8226 The following built-in functions approximately match the requirements for
8227 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8228 functions, but all also have a memory model parameter.  These are all
8229 identified by being prefixed with @samp{__atomic}, and most are overloaded
8230 such that they work with multiple types.
8232 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8233 bytes in length. 16-byte integral types are also allowed if
8234 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8236 Target architectures are encouraged to provide their own patterns for
8237 each of these built-in functions.  If no target is provided, the original 
8238 non-memory model set of @samp{__sync} atomic built-in functions are
8239 utilized, along with any required synchronization fences surrounding it in
8240 order to achieve the proper behavior.  Execution in this case is subject
8241 to the same restrictions as those built-in functions.
8243 If there is no pattern or mechanism to provide a lock free instruction
8244 sequence, a call is made to an external routine with the same parameters
8245 to be resolved at run time.
8247 The four non-arithmetic functions (load, store, exchange, and 
8248 compare_exchange) all have a generic version as well.  This generic
8249 version works on any data type.  If the data type size maps to one
8250 of the integral sizes that may have lock free support, the generic
8251 version utilizes the lock free built-in function.  Otherwise an
8252 external call is left to be resolved at run time.  This external call is
8253 the same format with the addition of a @samp{size_t} parameter inserted
8254 as the first parameter indicating the size of the object being pointed to.
8255 All objects must be the same size.
8257 There are 6 different memory models that can be specified.  These map
8258 to the same names in the C++11 standard.  Refer there or to the
8259 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8260 atomic synchronization} for more detailed definitions.  These memory
8261 models integrate both barriers to code motion as well as synchronization
8262 requirements with other threads. These are listed in approximately
8263 ascending order of strength. It is also possible to use target specific
8264 flags for memory model flags, like Hardware Lock Elision.
8266 @table  @code
8267 @item __ATOMIC_RELAXED
8268 No barriers or synchronization.
8269 @item __ATOMIC_CONSUME
8270 Data dependency only for both barrier and synchronization with another
8271 thread.
8272 @item __ATOMIC_ACQUIRE
8273 Barrier to hoisting of code and synchronizes with release (or stronger)
8274 semantic stores from another thread.
8275 @item __ATOMIC_RELEASE
8276 Barrier to sinking of code and synchronizes with acquire (or stronger)
8277 semantic loads from another thread.
8278 @item __ATOMIC_ACQ_REL
8279 Full barrier in both directions and synchronizes with acquire loads and
8280 release stores in another thread.
8281 @item __ATOMIC_SEQ_CST
8282 Full barrier in both directions and synchronizes with acquire loads and
8283 release stores in all threads.
8284 @end table
8286 When implementing patterns for these built-in functions, the memory model
8287 parameter can be ignored as long as the pattern implements the most
8288 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8289 execute correctly with this memory model but they may not execute as
8290 efficiently as they could with a more appropriate implementation of the
8291 relaxed requirements.
8293 Note that the C++11 standard allows for the memory model parameter to be
8294 determined at run time rather than at compile time.  These built-in
8295 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8296 than invoke a runtime library call or inline a switch statement.  This is
8297 standard compliant, safe, and the simplest approach for now.
8299 The memory model parameter is a signed int, but only the lower 8 bits are
8300 reserved for the memory model.  The remainder of the signed int is reserved
8301 for future use and should be 0.  Use of the predefined atomic values
8302 ensures proper usage.
8304 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8305 This built-in function implements an atomic load operation.  It returns the
8306 contents of @code{*@var{ptr}}.
8308 The valid memory model variants are
8309 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8310 and @code{__ATOMIC_CONSUME}.
8312 @end deftypefn
8314 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8315 This is the generic version of an atomic load.  It returns the
8316 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8318 @end deftypefn
8320 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8321 This built-in function implements an atomic store operation.  It writes 
8322 @code{@var{val}} into @code{*@var{ptr}}.  
8324 The valid memory model variants are
8325 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8327 @end deftypefn
8329 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8330 This is the generic version of an atomic store.  It stores the value
8331 of @code{*@var{val}} into @code{*@var{ptr}}.
8333 @end deftypefn
8335 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8336 This built-in function implements an atomic exchange operation.  It writes
8337 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8338 @code{*@var{ptr}}.
8340 The valid memory model variants are
8341 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8342 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8344 @end deftypefn
8346 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8347 This is the generic version of an atomic exchange.  It stores the
8348 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8349 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8351 @end deftypefn
8353 @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)
8354 This built-in function implements an atomic compare and exchange operation.
8355 This compares the contents of @code{*@var{ptr}} with the contents of
8356 @code{*@var{expected}} and if equal, writes @var{desired} into
8357 @code{*@var{ptr}}.  If they are not equal, the current contents of
8358 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8359 for weak compare_exchange, and false for the strong variation.  Many targets 
8360 only offer the strong variation and ignore the parameter.  When in doubt, use
8361 the strong variation.
8363 True is returned if @var{desired} is written into
8364 @code{*@var{ptr}} and the execution is considered to conform to the
8365 memory model specified by @var{success_memmodel}.  There are no
8366 restrictions on what memory model can be used here.
8368 False is returned otherwise, and the execution is considered to conform
8369 to @var{failure_memmodel}. This memory model cannot be
8370 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8371 stronger model than that specified by @var{success_memmodel}.
8373 @end deftypefn
8375 @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)
8376 This built-in function implements the generic version of
8377 @code{__atomic_compare_exchange}.  The function is virtually identical to
8378 @code{__atomic_compare_exchange_n}, except the desired value is also a
8379 pointer.
8381 @end deftypefn
8383 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8384 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8385 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8386 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8387 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8388 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8389 These built-in functions perform the operation suggested by the name, and
8390 return the result of the operation. That is,
8392 @smallexample
8393 @{ *ptr @var{op}= val; return *ptr; @}
8394 @end smallexample
8396 All memory models are valid.
8398 @end deftypefn
8400 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8401 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8402 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8403 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8404 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8405 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8406 These built-in functions perform the operation suggested by the name, and
8407 return the value that had previously been in @code{*@var{ptr}}.  That is,
8409 @smallexample
8410 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8411 @end smallexample
8413 All memory models are valid.
8415 @end deftypefn
8417 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8419 This built-in function performs an atomic test-and-set operation on
8420 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
8421 defined nonzero ``set'' value and the return value is @code{true} if and only
8422 if the previous contents were ``set''.
8423 It should be only used for operands of type @code{bool} or @code{char}. For 
8424 other types only part of the value may be set.
8426 All memory models are valid.
8428 @end deftypefn
8430 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8432 This built-in function performs an atomic clear operation on
8433 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
8434 It should be only used for operands of type @code{bool} or @code{char} and 
8435 in conjunction with @code{__atomic_test_and_set}.
8436 For other types it may only clear partially. If the type is not @code{bool}
8437 prefer using @code{__atomic_store}.
8439 The valid memory model variants are
8440 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8441 @code{__ATOMIC_RELEASE}.
8443 @end deftypefn
8445 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8447 This built-in function acts as a synchronization fence between threads
8448 based on the specified memory model.
8450 All memory orders are valid.
8452 @end deftypefn
8454 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8456 This built-in function acts as a synchronization fence between a thread
8457 and signal handlers based in the same thread.
8459 All memory orders are valid.
8461 @end deftypefn
8463 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
8465 This built-in function returns true if objects of @var{size} bytes always
8466 generate lock free atomic instructions for the target architecture.  
8467 @var{size} must resolve to a compile-time constant and the result also
8468 resolves to a compile-time constant.
8470 @var{ptr} is an optional pointer to the object that may be used to determine
8471 alignment.  A value of 0 indicates typical alignment should be used.  The 
8472 compiler may also ignore this parameter.
8474 @smallexample
8475 if (_atomic_always_lock_free (sizeof (long long), 0))
8476 @end smallexample
8478 @end deftypefn
8480 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8482 This built-in function returns true if objects of @var{size} bytes always
8483 generate lock free atomic instructions for the target architecture.  If
8484 it is not known to be lock free a call is made to a runtime routine named
8485 @code{__atomic_is_lock_free}.
8487 @var{ptr} is an optional pointer to the object that may be used to determine
8488 alignment.  A value of 0 indicates typical alignment should be used.  The 
8489 compiler may also ignore this parameter.
8490 @end deftypefn
8492 @node Integer Overflow Builtins
8493 @section Built-in functions to perform arithmetics and arithmetic overflow checking.
8495 The following built-in functions allow performing simple arithmetic operations
8496 together with checking whether the operations overflowed.
8498 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8499 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
8500 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
8501 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
8502 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
8503 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8504 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8506 These built-in functions promote the first two operands into infinite precision signed
8507 type and perform addition on those promoted operands.  The result is then
8508 cast to the type the third pointer argument points to and stored there.
8509 If the stored result is equal to the infinite precision result, the built-in
8510 functions return false, otherwise they return true.  As the addition is
8511 performed in infinite signed precision, these built-in functions have fully defined
8512 behavior for all argument values.
8514 The first built-in function allows arbitrary integral types for operands and
8515 the result type must be pointer to some integer type, the rest of the built-in
8516 functions have explicit integer types.
8518 The compiler will attempt to use hardware instructions to implement
8519 these built-in functions where possible, like conditional jump on overflow
8520 after addition, conditional jump on carry etc.
8522 @end deftypefn
8524 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8525 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
8526 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
8527 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
8528 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
8529 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8530 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8532 These built-in functions are similar to the add overflow checking built-in
8533 functions above, except they perform subtraction, subtract the second argument
8534 from the first one, instead of addition.
8536 @end deftypefn
8538 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8539 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
8540 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
8541 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
8542 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
8543 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8544 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8546 These built-in functions are similar to the add overflow checking built-in
8547 functions above, except they perform multiplication, instead of addition.
8549 @end deftypefn
8551 @node x86 specific memory model extensions for transactional memory
8552 @section x86 specific memory model extensions for transactional memory
8554 The i386 architecture supports additional memory ordering flags
8555 to mark lock critical sections for hardware lock elision. 
8556 These must be specified in addition to an existing memory model to 
8557 atomic intrinsics.
8559 @table @code
8560 @item __ATOMIC_HLE_ACQUIRE
8561 Start lock elision on a lock variable.
8562 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8563 @item __ATOMIC_HLE_RELEASE
8564 End lock elision on a lock variable.
8565 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8566 @end table
8568 When a lock acquire fails it is required for good performance to abort
8569 the transaction quickly. This can be done with a @code{_mm_pause}
8571 @smallexample
8572 #include <immintrin.h> // For _mm_pause
8574 int lockvar;
8576 /* Acquire lock with lock elision */
8577 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8578     _mm_pause(); /* Abort failed transaction */
8580 /* Free lock with lock elision */
8581 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8582 @end smallexample
8584 @node Object Size Checking
8585 @section Object Size Checking Built-in Functions
8586 @findex __builtin_object_size
8587 @findex __builtin___memcpy_chk
8588 @findex __builtin___mempcpy_chk
8589 @findex __builtin___memmove_chk
8590 @findex __builtin___memset_chk
8591 @findex __builtin___strcpy_chk
8592 @findex __builtin___stpcpy_chk
8593 @findex __builtin___strncpy_chk
8594 @findex __builtin___strcat_chk
8595 @findex __builtin___strncat_chk
8596 @findex __builtin___sprintf_chk
8597 @findex __builtin___snprintf_chk
8598 @findex __builtin___vsprintf_chk
8599 @findex __builtin___vsnprintf_chk
8600 @findex __builtin___printf_chk
8601 @findex __builtin___vprintf_chk
8602 @findex __builtin___fprintf_chk
8603 @findex __builtin___vfprintf_chk
8605 GCC implements a limited buffer overflow protection mechanism
8606 that can prevent some buffer overflow attacks.
8608 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8609 is a built-in construct that returns a constant number of bytes from
8610 @var{ptr} to the end of the object @var{ptr} pointer points to
8611 (if known at compile time).  @code{__builtin_object_size} never evaluates
8612 its arguments for side-effects.  If there are any side-effects in them, it
8613 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8614 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
8615 point to and all of them are known at compile time, the returned number
8616 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8617 0 and minimum if nonzero.  If it is not possible to determine which objects
8618 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8619 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8620 for @var{type} 2 or 3.
8622 @var{type} is an integer constant from 0 to 3.  If the least significant
8623 bit is clear, objects are whole variables, if it is set, a closest
8624 surrounding subobject is considered the object a pointer points to.
8625 The second bit determines if maximum or minimum of remaining bytes
8626 is computed.
8628 @smallexample
8629 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8630 char *p = &var.buf1[1], *q = &var.b;
8632 /* Here the object p points to is var.  */
8633 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8634 /* The subobject p points to is var.buf1.  */
8635 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8636 /* The object q points to is var.  */
8637 assert (__builtin_object_size (q, 0)
8638         == (char *) (&var + 1) - (char *) &var.b);
8639 /* The subobject q points to is var.b.  */
8640 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8641 @end smallexample
8642 @end deftypefn
8644 There are built-in functions added for many common string operation
8645 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8646 built-in is provided.  This built-in has an additional last argument,
8647 which is the number of bytes remaining in object the @var{dest}
8648 argument points to or @code{(size_t) -1} if the size is not known.
8650 The built-in functions are optimized into the normal string functions
8651 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8652 it is known at compile time that the destination object will not
8653 be overflown.  If the compiler can determine at compile time the
8654 object will be always overflown, it issues a warning.
8656 The intended use can be e.g.@:
8658 @smallexample
8659 #undef memcpy
8660 #define bos0(dest) __builtin_object_size (dest, 0)
8661 #define memcpy(dest, src, n) \
8662   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8664 char *volatile p;
8665 char buf[10];
8666 /* It is unknown what object p points to, so this is optimized
8667    into plain memcpy - no checking is possible.  */
8668 memcpy (p, "abcde", n);
8669 /* Destination is known and length too.  It is known at compile
8670    time there will be no overflow.  */
8671 memcpy (&buf[5], "abcde", 5);
8672 /* Destination is known, but the length is not known at compile time.
8673    This will result in __memcpy_chk call that can check for overflow
8674    at run time.  */
8675 memcpy (&buf[5], "abcde", n);
8676 /* Destination is known and it is known at compile time there will
8677    be overflow.  There will be a warning and __memcpy_chk call that
8678    will abort the program at run time.  */
8679 memcpy (&buf[6], "abcde", 5);
8680 @end smallexample
8682 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8683 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8684 @code{strcat} and @code{strncat}.
8686 There are also checking built-in functions for formatted output functions.
8687 @smallexample
8688 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8689 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8690                               const char *fmt, ...);
8691 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8692                               va_list ap);
8693 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8694                                const char *fmt, va_list ap);
8695 @end smallexample
8697 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8698 etc.@: functions and can contain implementation specific flags on what
8699 additional security measures the checking function might take, such as
8700 handling @code{%n} differently.
8702 The @var{os} argument is the object size @var{s} points to, like in the
8703 other built-in functions.  There is a small difference in the behavior
8704 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8705 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8706 the checking function is called with @var{os} argument set to
8707 @code{(size_t) -1}.
8709 In addition to this, there are checking built-in functions
8710 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8711 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8712 These have just one additional argument, @var{flag}, right before
8713 format string @var{fmt}.  If the compiler is able to optimize them to
8714 @code{fputc} etc.@: functions, it does, otherwise the checking function
8715 is called and the @var{flag} argument passed to it.
8717 @node Pointer Bounds Checker builtins
8718 @section Pointer Bounds Checker Built-in Functions
8719 @findex __builtin___bnd_set_ptr_bounds
8720 @findex __builtin___bnd_narrow_ptr_bounds
8721 @findex __builtin___bnd_copy_ptr_bounds
8722 @findex __builtin___bnd_init_ptr_bounds
8723 @findex __builtin___bnd_null_ptr_bounds
8724 @findex __builtin___bnd_store_ptr_bounds
8725 @findex __builtin___bnd_chk_ptr_lbounds
8726 @findex __builtin___bnd_chk_ptr_ubounds
8727 @findex __builtin___bnd_chk_ptr_bounds
8728 @findex __builtin___bnd_get_ptr_lbound
8729 @findex __builtin___bnd_get_ptr_ubound
8731 GCC provides a set of built-in functions to control Pointer Bounds Checker
8732 instrumentation.  Note that all Pointer Bounds Checker builtins are allowed
8733 to use even if you compile with Pointer Bounds Checker off.  The builtins
8734 behavior may differ in such case as documented below.
8736 @deftypefn {Built-in Function} void * __builtin___bnd_set_ptr_bounds (const void * @var{q}, size_t @var{size})
8738 This built-in function returns a new pointer with the value of @var{q}, and
8739 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
8740 Bounds Checker off built-in function just returns the first argument.
8742 @smallexample
8743 extern void *__wrap_malloc (size_t n)
8745   void *p = (void *)__real_malloc (n);
8746   if (!p) return __builtin___bnd_null_ptr_bounds (p);
8747   return __builtin___bnd_set_ptr_bounds (p, n);
8749 @end smallexample
8751 @end deftypefn
8753 @deftypefn {Built-in Function} void * __builtin___bnd_narrow_ptr_bounds (const void * @var{p}, const void * @var{q}, size_t  @var{size})
8755 This built-in function returns a new pointer with the value of @var{p}
8756 and associate it with the narrowed bounds formed by the intersection
8757 of bounds associated with @var{q} and the [@var{p}, @var{p} + @var{size} - 1].
8758 With Pointer Bounds Checker off built-in function just returns the first
8759 argument.
8761 @smallexample
8762 void init_objects (object *objs, size_t size)
8764   size_t i;
8765   /* Initialize objects one-by-one passing pointers with bounds of an object,
8766      not the full array of objects.  */
8767   for (i = 0; i < size; i++)
8768     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, sizeof(object)));
8770 @end smallexample
8772 @end deftypefn
8774 @deftypefn {Built-in Function} void * __builtin___bnd_copy_ptr_bounds (const void * @var{q}, const void * @var{r})
8776 This built-in function returns a new pointer with the value of @var{q},
8777 and associate it with the bounds already associated with pointer @var{r}.
8778 With Pointer Bounds Checker off built-in function just returns the first
8779 argument.
8781 @smallexample
8782 /* Here is a way to get pointer to object's field but
8783    still with the full object's bounds.  */
8784 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_filed, objptr);
8785 @end smallexample
8787 @end deftypefn
8789 @deftypefn {Built-in Function} void * __builtin___bnd_init_ptr_bounds (const void * @var{q})
8791 This built-in function returns a new pointer with the value of @var{q}, and
8792 associate it with INIT (allowing full memory access) bounds. With Pointer
8793 Bounds Checker off built-in function just returns the first argument.
8795 @end deftypefn
8797 @deftypefn {Built-in Function} void * __builtin___bnd_null_ptr_bounds (const void * @var{q})
8799 This built-in function returns a new pointer with the value of @var{q}, and
8800 associate it with NULL (allowing no memory access) bounds. With Pointer
8801 Bounds Checker off built-in function just returns the first argument.
8803 @end deftypefn
8805 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void ** @var{ptr_addr}, const void * @var{ptr_val})
8807 This built-in function stores the bounds associated with pointer @var{ptr_val}
8808 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
8809 bounds from legacy code without touching the associated pointer's memory when
8810 pointers were copied as integers.  With Pointer Bounds Checker off built-in
8811 function call is ignored.
8813 @end deftypefn
8815 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void * @var{q})
8817 This built-in function checks if the pointer @var{q} is within the lower
8818 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8819 function call is ignored.
8821 @smallexample
8822 extern void *__wrap_memset (void *dst, int c, size_t len)
8824   if (len > 0)
8825     @{
8826       __builtin___bnd_chk_ptr_lbounds (dst);
8827       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
8828       __real_memset (dst, c, len);
8829     @}
8830   return dst;
8832 @end smallexample
8834 @end deftypefn
8836 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void * @var{q})
8838 This built-in function checks if the pointer @var{q} is within the upper
8839 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8840 function call is ignored.
8842 @end deftypefn
8844 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void * @var{q}, size_t @var{size})
8846 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
8847 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
8848 off built-in function call is ignored.
8850 @smallexample
8851 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
8853   if (n > 0)
8854     @{
8855       __bnd_chk_ptr_bounds (dst, n);
8856       __bnd_chk_ptr_bounds (src, n);
8857       __real_memcpy (dst, src, n);
8858     @}
8859   return dst;
8861 @end smallexample
8863 @end deftypefn
8865 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_lbound (const void * @var{q})
8867 This built-in function returns the lower bound (which is a pointer) associated
8868 with the pointer @var{q}.  This is at least useful for debugging using printf.
8869 With Pointer Bounds Checker off built-in function returns 0.
8871 @smallexample
8872 void *lb = __builtin___bnd_get_ptr_lbound (q);
8873 void *ub = __builtin___bnd_get_ptr_ubound (q);
8874 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
8875 @end smallexample
8877 @end deftypefn
8879 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_ubound (const void * @var{q})
8881 This built-in function returns the upper bound (which is a pointer) associated
8882 with the pointer @var{q}.  With Pointer Bounds Checker off built-in function
8883 returns -1.
8885 @end deftypefn
8887 @node Cilk Plus Builtins
8888 @section Cilk Plus C/C++ language extension Built-in Functions.
8890 GCC provides support for the following built-in reduction funtions if Cilk Plus
8891 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8893 @itemize @bullet
8894 @item __sec_implicit_index
8895 @item __sec_reduce
8896 @item __sec_reduce_add
8897 @item __sec_reduce_all_nonzero
8898 @item __sec_reduce_all_zero
8899 @item __sec_reduce_any_nonzero
8900 @item __sec_reduce_any_zero
8901 @item __sec_reduce_max
8902 @item __sec_reduce_min
8903 @item __sec_reduce_max_ind
8904 @item __sec_reduce_min_ind
8905 @item __sec_reduce_mul
8906 @item __sec_reduce_mutating
8907 @end itemize
8909 Further details and examples about these built-in functions are described 
8910 in the Cilk Plus language manual which can be found at 
8911 @uref{http://www.cilkplus.org}.
8913 @node Other Builtins
8914 @section Other Built-in Functions Provided by GCC
8915 @cindex built-in functions
8916 @findex __builtin_call_with_static_chain
8917 @findex __builtin_fpclassify
8918 @findex __builtin_isfinite
8919 @findex __builtin_isnormal
8920 @findex __builtin_isgreater
8921 @findex __builtin_isgreaterequal
8922 @findex __builtin_isinf_sign
8923 @findex __builtin_isless
8924 @findex __builtin_islessequal
8925 @findex __builtin_islessgreater
8926 @findex __builtin_isunordered
8927 @findex __builtin_powi
8928 @findex __builtin_powif
8929 @findex __builtin_powil
8930 @findex _Exit
8931 @findex _exit
8932 @findex abort
8933 @findex abs
8934 @findex acos
8935 @findex acosf
8936 @findex acosh
8937 @findex acoshf
8938 @findex acoshl
8939 @findex acosl
8940 @findex alloca
8941 @findex asin
8942 @findex asinf
8943 @findex asinh
8944 @findex asinhf
8945 @findex asinhl
8946 @findex asinl
8947 @findex atan
8948 @findex atan2
8949 @findex atan2f
8950 @findex atan2l
8951 @findex atanf
8952 @findex atanh
8953 @findex atanhf
8954 @findex atanhl
8955 @findex atanl
8956 @findex bcmp
8957 @findex bzero
8958 @findex cabs
8959 @findex cabsf
8960 @findex cabsl
8961 @findex cacos
8962 @findex cacosf
8963 @findex cacosh
8964 @findex cacoshf
8965 @findex cacoshl
8966 @findex cacosl
8967 @findex calloc
8968 @findex carg
8969 @findex cargf
8970 @findex cargl
8971 @findex casin
8972 @findex casinf
8973 @findex casinh
8974 @findex casinhf
8975 @findex casinhl
8976 @findex casinl
8977 @findex catan
8978 @findex catanf
8979 @findex catanh
8980 @findex catanhf
8981 @findex catanhl
8982 @findex catanl
8983 @findex cbrt
8984 @findex cbrtf
8985 @findex cbrtl
8986 @findex ccos
8987 @findex ccosf
8988 @findex ccosh
8989 @findex ccoshf
8990 @findex ccoshl
8991 @findex ccosl
8992 @findex ceil
8993 @findex ceilf
8994 @findex ceill
8995 @findex cexp
8996 @findex cexpf
8997 @findex cexpl
8998 @findex cimag
8999 @findex cimagf
9000 @findex cimagl
9001 @findex clog
9002 @findex clogf
9003 @findex clogl
9004 @findex conj
9005 @findex conjf
9006 @findex conjl
9007 @findex copysign
9008 @findex copysignf
9009 @findex copysignl
9010 @findex cos
9011 @findex cosf
9012 @findex cosh
9013 @findex coshf
9014 @findex coshl
9015 @findex cosl
9016 @findex cpow
9017 @findex cpowf
9018 @findex cpowl
9019 @findex cproj
9020 @findex cprojf
9021 @findex cprojl
9022 @findex creal
9023 @findex crealf
9024 @findex creall
9025 @findex csin
9026 @findex csinf
9027 @findex csinh
9028 @findex csinhf
9029 @findex csinhl
9030 @findex csinl
9031 @findex csqrt
9032 @findex csqrtf
9033 @findex csqrtl
9034 @findex ctan
9035 @findex ctanf
9036 @findex ctanh
9037 @findex ctanhf
9038 @findex ctanhl
9039 @findex ctanl
9040 @findex dcgettext
9041 @findex dgettext
9042 @findex drem
9043 @findex dremf
9044 @findex dreml
9045 @findex erf
9046 @findex erfc
9047 @findex erfcf
9048 @findex erfcl
9049 @findex erff
9050 @findex erfl
9051 @findex exit
9052 @findex exp
9053 @findex exp10
9054 @findex exp10f
9055 @findex exp10l
9056 @findex exp2
9057 @findex exp2f
9058 @findex exp2l
9059 @findex expf
9060 @findex expl
9061 @findex expm1
9062 @findex expm1f
9063 @findex expm1l
9064 @findex fabs
9065 @findex fabsf
9066 @findex fabsl
9067 @findex fdim
9068 @findex fdimf
9069 @findex fdiml
9070 @findex ffs
9071 @findex floor
9072 @findex floorf
9073 @findex floorl
9074 @findex fma
9075 @findex fmaf
9076 @findex fmal
9077 @findex fmax
9078 @findex fmaxf
9079 @findex fmaxl
9080 @findex fmin
9081 @findex fminf
9082 @findex fminl
9083 @findex fmod
9084 @findex fmodf
9085 @findex fmodl
9086 @findex fprintf
9087 @findex fprintf_unlocked
9088 @findex fputs
9089 @findex fputs_unlocked
9090 @findex frexp
9091 @findex frexpf
9092 @findex frexpl
9093 @findex fscanf
9094 @findex gamma
9095 @findex gammaf
9096 @findex gammal
9097 @findex gamma_r
9098 @findex gammaf_r
9099 @findex gammal_r
9100 @findex gettext
9101 @findex hypot
9102 @findex hypotf
9103 @findex hypotl
9104 @findex ilogb
9105 @findex ilogbf
9106 @findex ilogbl
9107 @findex imaxabs
9108 @findex index
9109 @findex isalnum
9110 @findex isalpha
9111 @findex isascii
9112 @findex isblank
9113 @findex iscntrl
9114 @findex isdigit
9115 @findex isgraph
9116 @findex islower
9117 @findex isprint
9118 @findex ispunct
9119 @findex isspace
9120 @findex isupper
9121 @findex iswalnum
9122 @findex iswalpha
9123 @findex iswblank
9124 @findex iswcntrl
9125 @findex iswdigit
9126 @findex iswgraph
9127 @findex iswlower
9128 @findex iswprint
9129 @findex iswpunct
9130 @findex iswspace
9131 @findex iswupper
9132 @findex iswxdigit
9133 @findex isxdigit
9134 @findex j0
9135 @findex j0f
9136 @findex j0l
9137 @findex j1
9138 @findex j1f
9139 @findex j1l
9140 @findex jn
9141 @findex jnf
9142 @findex jnl
9143 @findex labs
9144 @findex ldexp
9145 @findex ldexpf
9146 @findex ldexpl
9147 @findex lgamma
9148 @findex lgammaf
9149 @findex lgammal
9150 @findex lgamma_r
9151 @findex lgammaf_r
9152 @findex lgammal_r
9153 @findex llabs
9154 @findex llrint
9155 @findex llrintf
9156 @findex llrintl
9157 @findex llround
9158 @findex llroundf
9159 @findex llroundl
9160 @findex log
9161 @findex log10
9162 @findex log10f
9163 @findex log10l
9164 @findex log1p
9165 @findex log1pf
9166 @findex log1pl
9167 @findex log2
9168 @findex log2f
9169 @findex log2l
9170 @findex logb
9171 @findex logbf
9172 @findex logbl
9173 @findex logf
9174 @findex logl
9175 @findex lrint
9176 @findex lrintf
9177 @findex lrintl
9178 @findex lround
9179 @findex lroundf
9180 @findex lroundl
9181 @findex malloc
9182 @findex memchr
9183 @findex memcmp
9184 @findex memcpy
9185 @findex mempcpy
9186 @findex memset
9187 @findex modf
9188 @findex modff
9189 @findex modfl
9190 @findex nearbyint
9191 @findex nearbyintf
9192 @findex nearbyintl
9193 @findex nextafter
9194 @findex nextafterf
9195 @findex nextafterl
9196 @findex nexttoward
9197 @findex nexttowardf
9198 @findex nexttowardl
9199 @findex pow
9200 @findex pow10
9201 @findex pow10f
9202 @findex pow10l
9203 @findex powf
9204 @findex powl
9205 @findex printf
9206 @findex printf_unlocked
9207 @findex putchar
9208 @findex puts
9209 @findex remainder
9210 @findex remainderf
9211 @findex remainderl
9212 @findex remquo
9213 @findex remquof
9214 @findex remquol
9215 @findex rindex
9216 @findex rint
9217 @findex rintf
9218 @findex rintl
9219 @findex round
9220 @findex roundf
9221 @findex roundl
9222 @findex scalb
9223 @findex scalbf
9224 @findex scalbl
9225 @findex scalbln
9226 @findex scalblnf
9227 @findex scalblnf
9228 @findex scalbn
9229 @findex scalbnf
9230 @findex scanfnl
9231 @findex signbit
9232 @findex signbitf
9233 @findex signbitl
9234 @findex signbitd32
9235 @findex signbitd64
9236 @findex signbitd128
9237 @findex significand
9238 @findex significandf
9239 @findex significandl
9240 @findex sin
9241 @findex sincos
9242 @findex sincosf
9243 @findex sincosl
9244 @findex sinf
9245 @findex sinh
9246 @findex sinhf
9247 @findex sinhl
9248 @findex sinl
9249 @findex snprintf
9250 @findex sprintf
9251 @findex sqrt
9252 @findex sqrtf
9253 @findex sqrtl
9254 @findex sscanf
9255 @findex stpcpy
9256 @findex stpncpy
9257 @findex strcasecmp
9258 @findex strcat
9259 @findex strchr
9260 @findex strcmp
9261 @findex strcpy
9262 @findex strcspn
9263 @findex strdup
9264 @findex strfmon
9265 @findex strftime
9266 @findex strlen
9267 @findex strncasecmp
9268 @findex strncat
9269 @findex strncmp
9270 @findex strncpy
9271 @findex strndup
9272 @findex strpbrk
9273 @findex strrchr
9274 @findex strspn
9275 @findex strstr
9276 @findex tan
9277 @findex tanf
9278 @findex tanh
9279 @findex tanhf
9280 @findex tanhl
9281 @findex tanl
9282 @findex tgamma
9283 @findex tgammaf
9284 @findex tgammal
9285 @findex toascii
9286 @findex tolower
9287 @findex toupper
9288 @findex towlower
9289 @findex towupper
9290 @findex trunc
9291 @findex truncf
9292 @findex truncl
9293 @findex vfprintf
9294 @findex vfscanf
9295 @findex vprintf
9296 @findex vscanf
9297 @findex vsnprintf
9298 @findex vsprintf
9299 @findex vsscanf
9300 @findex y0
9301 @findex y0f
9302 @findex y0l
9303 @findex y1
9304 @findex y1f
9305 @findex y1l
9306 @findex yn
9307 @findex ynf
9308 @findex ynl
9310 GCC provides a large number of built-in functions other than the ones
9311 mentioned above.  Some of these are for internal use in the processing
9312 of exceptions or variable-length argument lists and are not
9313 documented here because they may change from time to time; we do not
9314 recommend general use of these functions.
9316 The remaining functions are provided for optimization purposes.
9318 @opindex fno-builtin
9319 GCC includes built-in versions of many of the functions in the standard
9320 C library.  The versions prefixed with @code{__builtin_} are always
9321 treated as having the same meaning as the C library function even if you
9322 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
9323 Many of these functions are only optimized in certain cases; if they are
9324 not optimized in a particular case, a call to the library function is
9325 emitted.
9327 @opindex ansi
9328 @opindex std
9329 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9330 @option{-std=c99} or @option{-std=c11}), the functions
9331 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9332 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9333 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9334 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9335 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9336 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9337 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9338 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9339 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9340 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9341 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9342 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9343 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9344 @code{significandl}, @code{significand}, @code{sincosf},
9345 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9346 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9347 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9348 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9349 @code{yn}
9350 may be handled as built-in functions.
9351 All these functions have corresponding versions
9352 prefixed with @code{__builtin_}, which may be used even in strict C90
9353 mode.
9355 The ISO C99 functions
9356 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9357 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9358 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9359 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9360 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9361 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9362 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9363 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9364 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9365 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9366 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9367 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9368 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9369 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9370 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9371 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9372 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9373 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9374 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9375 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9376 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9377 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9378 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9379 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9380 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9381 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9382 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9383 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9384 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9385 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9386 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9387 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9388 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9389 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9390 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9391 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9392 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9393 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9394 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9395 are handled as built-in functions
9396 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9398 There are also built-in versions of the ISO C99 functions
9399 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9400 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9401 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9402 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9403 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9404 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9405 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9406 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9407 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9408 that are recognized in any mode since ISO C90 reserves these names for
9409 the purpose to which ISO C99 puts them.  All these functions have
9410 corresponding versions prefixed with @code{__builtin_}.
9412 The ISO C94 functions
9413 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9414 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9415 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9416 @code{towupper}
9417 are handled as built-in functions
9418 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9420 The ISO C90 functions
9421 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9422 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9423 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9424 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9425 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9426 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9427 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9428 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9429 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9430 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9431 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9432 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9433 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9434 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9435 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9436 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9437 are all recognized as built-in functions unless
9438 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9439 is specified for an individual function).  All of these functions have
9440 corresponding versions prefixed with @code{__builtin_}.
9442 GCC provides built-in versions of the ISO C99 floating-point comparison
9443 macros that avoid raising exceptions for unordered operands.  They have
9444 the same names as the standard macros ( @code{isgreater},
9445 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9446 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9447 prefixed.  We intend for a library implementor to be able to simply
9448 @code{#define} each standard macro to its built-in equivalent.
9449 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9450 @code{isinf_sign} and @code{isnormal} built-ins used with
9451 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
9452 built-in functions appear both with and without the @code{__builtin_} prefix.
9454 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9456 You can use the built-in function @code{__builtin_types_compatible_p} to
9457 determine whether two types are the same.
9459 This built-in function returns 1 if the unqualified versions of the
9460 types @var{type1} and @var{type2} (which are types, not expressions) are
9461 compatible, 0 otherwise.  The result of this built-in function can be
9462 used in integer constant expressions.
9464 This built-in function ignores top level qualifiers (e.g., @code{const},
9465 @code{volatile}).  For example, @code{int} is equivalent to @code{const
9466 int}.
9468 The type @code{int[]} and @code{int[5]} are compatible.  On the other
9469 hand, @code{int} and @code{char *} are not compatible, even if the size
9470 of their types, on the particular architecture are the same.  Also, the
9471 amount of pointer indirection is taken into account when determining
9472 similarity.  Consequently, @code{short *} is not similar to
9473 @code{short **}.  Furthermore, two types that are typedefed are
9474 considered compatible if their underlying types are compatible.
9476 An @code{enum} type is not considered to be compatible with another
9477 @code{enum} type even if both are compatible with the same integer
9478 type; this is what the C standard specifies.
9479 For example, @code{enum @{foo, bar@}} is not similar to
9480 @code{enum @{hot, dog@}}.
9482 You typically use this function in code whose execution varies
9483 depending on the arguments' types.  For example:
9485 @smallexample
9486 #define foo(x)                                                  \
9487   (@{                                                           \
9488     typeof (x) tmp = (x);                                       \
9489     if (__builtin_types_compatible_p (typeof (x), long double)) \
9490       tmp = foo_long_double (tmp);                              \
9491     else if (__builtin_types_compatible_p (typeof (x), double)) \
9492       tmp = foo_double (tmp);                                   \
9493     else if (__builtin_types_compatible_p (typeof (x), float))  \
9494       tmp = foo_float (tmp);                                    \
9495     else                                                        \
9496       abort ();                                                 \
9497     tmp;                                                        \
9498   @})
9499 @end smallexample
9501 @emph{Note:} This construct is only available for C@.
9503 @end deftypefn
9505 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
9507 The @var{call_exp} expression must be a function call, and the
9508 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
9509 is passed to the function call in the target's static chain location.
9510 The result of builtin is the result of the function call.
9512 @emph{Note:} This builtin is only available for C@.
9513 This builtin can be used to call Go closures from C.
9515 @end deftypefn
9517 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9519 You can use the built-in function @code{__builtin_choose_expr} to
9520 evaluate code depending on the value of a constant expression.  This
9521 built-in function returns @var{exp1} if @var{const_exp}, which is an
9522 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
9524 This built-in function is analogous to the @samp{? :} operator in C,
9525 except that the expression returned has its type unaltered by promotion
9526 rules.  Also, the built-in function does not evaluate the expression
9527 that is not chosen.  For example, if @var{const_exp} evaluates to true,
9528 @var{exp2} is not evaluated even if it has side-effects.
9530 This built-in function can return an lvalue if the chosen argument is an
9531 lvalue.
9533 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9534 type.  Similarly, if @var{exp2} is returned, its return type is the same
9535 as @var{exp2}.
9537 Example:
9539 @smallexample
9540 #define foo(x)                                                    \
9541   __builtin_choose_expr (                                         \
9542     __builtin_types_compatible_p (typeof (x), double),            \
9543     foo_double (x),                                               \
9544     __builtin_choose_expr (                                       \
9545       __builtin_types_compatible_p (typeof (x), float),           \
9546       foo_float (x),                                              \
9547       /* @r{The void expression results in a compile-time error}  \
9548          @r{when assigning the result to something.}  */          \
9549       (void)0))
9550 @end smallexample
9552 @emph{Note:} This construct is only available for C@.  Furthermore, the
9553 unused expression (@var{exp1} or @var{exp2} depending on the value of
9554 @var{const_exp}) may still generate syntax errors.  This may change in
9555 future revisions.
9557 @end deftypefn
9559 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9561 The built-in function @code{__builtin_complex} is provided for use in
9562 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9563 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
9564 real binary floating-point type, and the result has the corresponding
9565 complex type with real and imaginary parts @var{real} and @var{imag}.
9566 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9567 infinities, NaNs and negative zeros are involved.
9569 @end deftypefn
9571 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9572 You can use the built-in function @code{__builtin_constant_p} to
9573 determine if a value is known to be constant at compile time and hence
9574 that GCC can perform constant-folding on expressions involving that
9575 value.  The argument of the function is the value to test.  The function
9576 returns the integer 1 if the argument is known to be a compile-time
9577 constant and 0 if it is not known to be a compile-time constant.  A
9578 return of 0 does not indicate that the value is @emph{not} a constant,
9579 but merely that GCC cannot prove it is a constant with the specified
9580 value of the @option{-O} option.
9582 You typically use this function in an embedded application where
9583 memory is a critical resource.  If you have some complex calculation,
9584 you may want it to be folded if it involves constants, but need to call
9585 a function if it does not.  For example:
9587 @smallexample
9588 #define Scale_Value(X)      \
9589   (__builtin_constant_p (X) \
9590   ? ((X) * SCALE + OFFSET) : Scale (X))
9591 @end smallexample
9593 You may use this built-in function in either a macro or an inline
9594 function.  However, if you use it in an inlined function and pass an
9595 argument of the function as the argument to the built-in, GCC 
9596 never returns 1 when you call the inline function with a string constant
9597 or compound literal (@pxref{Compound Literals}) and does not return 1
9598 when you pass a constant numeric value to the inline function unless you
9599 specify the @option{-O} option.
9601 You may also use @code{__builtin_constant_p} in initializers for static
9602 data.  For instance, you can write
9604 @smallexample
9605 static const int table[] = @{
9606    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9607    /* @r{@dots{}} */
9609 @end smallexample
9611 @noindent
9612 This is an acceptable initializer even if @var{EXPRESSION} is not a
9613 constant expression, including the case where
9614 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9615 folded to a constant but @var{EXPRESSION} contains operands that are
9616 not otherwise permitted in a static initializer (for example,
9617 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
9618 built-in in this case, because it has no opportunity to perform
9619 optimization.
9621 Previous versions of GCC did not accept this built-in in data
9622 initializers.  The earliest version where it is completely safe is
9623 3.0.1.
9624 @end deftypefn
9626 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9627 @opindex fprofile-arcs
9628 You may use @code{__builtin_expect} to provide the compiler with
9629 branch prediction information.  In general, you should prefer to
9630 use actual profile feedback for this (@option{-fprofile-arcs}), as
9631 programmers are notoriously bad at predicting how their programs
9632 actually perform.  However, there are applications in which this
9633 data is hard to collect.
9635 The return value is the value of @var{exp}, which should be an integral
9636 expression.  The semantics of the built-in are that it is expected that
9637 @var{exp} == @var{c}.  For example:
9639 @smallexample
9640 if (__builtin_expect (x, 0))
9641   foo ();
9642 @end smallexample
9644 @noindent
9645 indicates that we do not expect to call @code{foo}, since
9646 we expect @code{x} to be zero.  Since you are limited to integral
9647 expressions for @var{exp}, you should use constructions such as
9649 @smallexample
9650 if (__builtin_expect (ptr != NULL, 1))
9651   foo (*ptr);
9652 @end smallexample
9654 @noindent
9655 when testing pointer or floating-point values.
9656 @end deftypefn
9658 @deftypefn {Built-in Function} void __builtin_trap (void)
9659 This function causes the program to exit abnormally.  GCC implements
9660 this function by using a target-dependent mechanism (such as
9661 intentionally executing an illegal instruction) or by calling
9662 @code{abort}.  The mechanism used may vary from release to release so
9663 you should not rely on any particular implementation.
9664 @end deftypefn
9666 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9667 If control flow reaches the point of the @code{__builtin_unreachable},
9668 the program is undefined.  It is useful in situations where the
9669 compiler cannot deduce the unreachability of the code.
9671 One such case is immediately following an @code{asm} statement that
9672 either never terminates, or one that transfers control elsewhere
9673 and never returns.  In this example, without the
9674 @code{__builtin_unreachable}, GCC issues a warning that control
9675 reaches the end of a non-void function.  It also generates code
9676 to return after the @code{asm}.
9678 @smallexample
9679 int f (int c, int v)
9681   if (c)
9682     @{
9683       return v;
9684     @}
9685   else
9686     @{
9687       asm("jmp error_handler");
9688       __builtin_unreachable ();
9689     @}
9691 @end smallexample
9693 @noindent
9694 Because the @code{asm} statement unconditionally transfers control out
9695 of the function, control never reaches the end of the function
9696 body.  The @code{__builtin_unreachable} is in fact unreachable and
9697 communicates this fact to the compiler.
9699 Another use for @code{__builtin_unreachable} is following a call a
9700 function that never returns but that is not declared
9701 @code{__attribute__((noreturn))}, as in this example:
9703 @smallexample
9704 void function_that_never_returns (void);
9706 int g (int c)
9708   if (c)
9709     @{
9710       return 1;
9711     @}
9712   else
9713     @{
9714       function_that_never_returns ();
9715       __builtin_unreachable ();
9716     @}
9718 @end smallexample
9720 @end deftypefn
9722 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9723 This function returns its first argument, and allows the compiler
9724 to assume that the returned pointer is at least @var{align} bytes
9725 aligned.  This built-in can have either two or three arguments,
9726 if it has three, the third argument should have integer type, and
9727 if it is nonzero means misalignment offset.  For example:
9729 @smallexample
9730 void *x = __builtin_assume_aligned (arg, 16);
9731 @end smallexample
9733 @noindent
9734 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9735 16-byte aligned, while:
9737 @smallexample
9738 void *x = __builtin_assume_aligned (arg, 32, 8);
9739 @end smallexample
9741 @noindent
9742 means that the compiler can assume for @code{x}, set to @code{arg}, that
9743 @code{(char *) x - 8} is 32-byte aligned.
9744 @end deftypefn
9746 @deftypefn {Built-in Function} int __builtin_LINE ()
9747 This function is the equivalent to the preprocessor @code{__LINE__}
9748 macro and returns the line number of the invocation of the built-in.
9749 In a C++ default argument for a function @var{F}, it gets the line number of
9750 the call to @var{F}.
9751 @end deftypefn
9753 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9754 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9755 macro and returns the function name the invocation of the built-in is in.
9756 @end deftypefn
9758 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9759 This function is the equivalent to the preprocessor @code{__FILE__}
9760 macro and returns the file name the invocation of the built-in is in.
9761 In a C++ default argument for a function @var{F}, it gets the file name of
9762 the call to @var{F}.
9763 @end deftypefn
9765 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9766 This function is used to flush the processor's instruction cache for
9767 the region of memory between @var{begin} inclusive and @var{end}
9768 exclusive.  Some targets require that the instruction cache be
9769 flushed, after modifying memory containing code, in order to obtain
9770 deterministic behavior.
9772 If the target does not require instruction cache flushes,
9773 @code{__builtin___clear_cache} has no effect.  Otherwise either
9774 instructions are emitted in-line to clear the instruction cache or a
9775 call to the @code{__clear_cache} function in libgcc is made.
9776 @end deftypefn
9778 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9779 This function is used to minimize cache-miss latency by moving data into
9780 a cache before it is accessed.
9781 You can insert calls to @code{__builtin_prefetch} into code for which
9782 you know addresses of data in memory that is likely to be accessed soon.
9783 If the target supports them, data prefetch instructions are generated.
9784 If the prefetch is done early enough before the access then the data will
9785 be in the cache by the time it is accessed.
9787 The value of @var{addr} is the address of the memory to prefetch.
9788 There are two optional arguments, @var{rw} and @var{locality}.
9789 The value of @var{rw} is a compile-time constant one or zero; one
9790 means that the prefetch is preparing for a write to the memory address
9791 and zero, the default, means that the prefetch is preparing for a read.
9792 The value @var{locality} must be a compile-time constant integer between
9793 zero and three.  A value of zero means that the data has no temporal
9794 locality, so it need not be left in the cache after the access.  A value
9795 of three means that the data has a high degree of temporal locality and
9796 should be left in all levels of cache possible.  Values of one and two
9797 mean, respectively, a low or moderate degree of temporal locality.  The
9798 default is three.
9800 @smallexample
9801 for (i = 0; i < n; i++)
9802   @{
9803     a[i] = a[i] + b[i];
9804     __builtin_prefetch (&a[i+j], 1, 1);
9805     __builtin_prefetch (&b[i+j], 0, 1);
9806     /* @r{@dots{}} */
9807   @}
9808 @end smallexample
9810 Data prefetch does not generate faults if @var{addr} is invalid, but
9811 the address expression itself must be valid.  For example, a prefetch
9812 of @code{p->next} does not fault if @code{p->next} is not a valid
9813 address, but evaluation faults if @code{p} is not a valid address.
9815 If the target does not support data prefetch, the address expression
9816 is evaluated if it includes side effects but no other code is generated
9817 and GCC does not issue a warning.
9818 @end deftypefn
9820 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9821 Returns a positive infinity, if supported by the floating-point format,
9822 else @code{DBL_MAX}.  This function is suitable for implementing the
9823 ISO C macro @code{HUGE_VAL}.
9824 @end deftypefn
9826 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9827 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9828 @end deftypefn
9830 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9831 Similar to @code{__builtin_huge_val}, except the return
9832 type is @code{long double}.
9833 @end deftypefn
9835 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9836 This built-in implements the C99 fpclassify functionality.  The first
9837 five int arguments should be the target library's notion of the
9838 possible FP classes and are used for return values.  They must be
9839 constant values and they must appear in this order: @code{FP_NAN},
9840 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9841 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
9842 to classify.  GCC treats the last argument as type-generic, which
9843 means it does not do default promotion from float to double.
9844 @end deftypefn
9846 @deftypefn {Built-in Function} double __builtin_inf (void)
9847 Similar to @code{__builtin_huge_val}, except a warning is generated
9848 if the target floating-point format does not support infinities.
9849 @end deftypefn
9851 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9852 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9853 @end deftypefn
9855 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9856 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9857 @end deftypefn
9859 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9860 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9861 @end deftypefn
9863 @deftypefn {Built-in Function} float __builtin_inff (void)
9864 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9865 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9866 @end deftypefn
9868 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9869 Similar to @code{__builtin_inf}, except the return
9870 type is @code{long double}.
9871 @end deftypefn
9873 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9874 Similar to @code{isinf}, except the return value is -1 for
9875 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9876 Note while the parameter list is an
9877 ellipsis, this function only accepts exactly one floating-point
9878 argument.  GCC treats this parameter as type-generic, which means it
9879 does not do default promotion from float to double.
9880 @end deftypefn
9882 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9883 This is an implementation of the ISO C99 function @code{nan}.
9885 Since ISO C99 defines this function in terms of @code{strtod}, which we
9886 do not implement, a description of the parsing is in order.  The string
9887 is parsed as by @code{strtol}; that is, the base is recognized by
9888 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
9889 in the significand such that the least significant bit of the number
9890 is at the least significant bit of the significand.  The number is
9891 truncated to fit the significand field provided.  The significand is
9892 forced to be a quiet NaN@.
9894 This function, if given a string literal all of which would have been
9895 consumed by @code{strtol}, is evaluated early enough that it is considered a
9896 compile-time constant.
9897 @end deftypefn
9899 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9900 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9901 @end deftypefn
9903 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9904 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9905 @end deftypefn
9907 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9908 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9909 @end deftypefn
9911 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9912 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9913 @end deftypefn
9915 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9916 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9917 @end deftypefn
9919 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9920 Similar to @code{__builtin_nan}, except the significand is forced
9921 to be a signaling NaN@.  The @code{nans} function is proposed by
9922 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9923 @end deftypefn
9925 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9926 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9927 @end deftypefn
9929 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9930 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9931 @end deftypefn
9933 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9934 Returns one plus the index of the least significant 1-bit of @var{x}, or
9935 if @var{x} is zero, returns zero.
9936 @end deftypefn
9938 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9939 Returns the number of leading 0-bits in @var{x}, starting at the most
9940 significant bit position.  If @var{x} is 0, the result is undefined.
9941 @end deftypefn
9943 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9944 Returns the number of trailing 0-bits in @var{x}, starting at the least
9945 significant bit position.  If @var{x} is 0, the result is undefined.
9946 @end deftypefn
9948 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9949 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9950 number of bits following the most significant bit that are identical
9951 to it.  There are no special cases for 0 or other values. 
9952 @end deftypefn
9954 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9955 Returns the number of 1-bits in @var{x}.
9956 @end deftypefn
9958 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9959 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9960 modulo 2.
9961 @end deftypefn
9963 @deftypefn {Built-in Function} int __builtin_ffsl (long)
9964 Similar to @code{__builtin_ffs}, except the argument type is
9965 @code{long}.
9966 @end deftypefn
9968 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9969 Similar to @code{__builtin_clz}, except the argument type is
9970 @code{unsigned long}.
9971 @end deftypefn
9973 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9974 Similar to @code{__builtin_ctz}, except the argument type is
9975 @code{unsigned long}.
9976 @end deftypefn
9978 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
9979 Similar to @code{__builtin_clrsb}, except the argument type is
9980 @code{long}.
9981 @end deftypefn
9983 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
9984 Similar to @code{__builtin_popcount}, except the argument type is
9985 @code{unsigned long}.
9986 @end deftypefn
9988 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
9989 Similar to @code{__builtin_parity}, except the argument type is
9990 @code{unsigned long}.
9991 @end deftypefn
9993 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
9994 Similar to @code{__builtin_ffs}, except the argument type is
9995 @code{long long}.
9996 @end deftypefn
9998 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
9999 Similar to @code{__builtin_clz}, except the argument type is
10000 @code{unsigned long long}.
10001 @end deftypefn
10003 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
10004 Similar to @code{__builtin_ctz}, except the argument type is
10005 @code{unsigned long long}.
10006 @end deftypefn
10008 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
10009 Similar to @code{__builtin_clrsb}, except the argument type is
10010 @code{long long}.
10011 @end deftypefn
10013 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10014 Similar to @code{__builtin_popcount}, except the argument type is
10015 @code{unsigned long long}.
10016 @end deftypefn
10018 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10019 Similar to @code{__builtin_parity}, except the argument type is
10020 @code{unsigned long long}.
10021 @end deftypefn
10023 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10024 Returns the first argument raised to the power of the second.  Unlike the
10025 @code{pow} function no guarantees about precision and rounding are made.
10026 @end deftypefn
10028 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10029 Similar to @code{__builtin_powi}, except the argument and return types
10030 are @code{float}.
10031 @end deftypefn
10033 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10034 Similar to @code{__builtin_powi}, except the argument and return types
10035 are @code{long double}.
10036 @end deftypefn
10038 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10039 Returns @var{x} with the order of the bytes reversed; for example,
10040 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
10041 exactly 8 bits.
10042 @end deftypefn
10044 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10045 Similar to @code{__builtin_bswap16}, except the argument and return types
10046 are 32 bit.
10047 @end deftypefn
10049 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10050 Similar to @code{__builtin_bswap32}, except the argument and return types
10051 are 64 bit.
10052 @end deftypefn
10054 @node Target Builtins
10055 @section Built-in Functions Specific to Particular Target Machines
10057 On some target machines, GCC supports many built-in functions specific
10058 to those machines.  Generally these generate calls to specific machine
10059 instructions, but allow the compiler to schedule those calls.
10061 @menu
10062 * AArch64 Built-in Functions::
10063 * Alpha Built-in Functions::
10064 * Altera Nios II Built-in Functions::
10065 * ARC Built-in Functions::
10066 * ARC SIMD Built-in Functions::
10067 * ARM iWMMXt Built-in Functions::
10068 * ARM C Language Extensions (ACLE)::
10069 * ARM Floating Point Status and Control Intrinsics::
10070 * AVR Built-in Functions::
10071 * Blackfin Built-in Functions::
10072 * FR-V Built-in Functions::
10073 * X86 Built-in Functions::
10074 * X86 transactional memory intrinsics::
10075 * MIPS DSP Built-in Functions::
10076 * MIPS Paired-Single Support::
10077 * MIPS Loongson Built-in Functions::
10078 * Other MIPS Built-in Functions::
10079 * MSP430 Built-in Functions::
10080 * NDS32 Built-in Functions::
10081 * picoChip Built-in Functions::
10082 * PowerPC Built-in Functions::
10083 * PowerPC AltiVec/VSX Built-in Functions::
10084 * PowerPC Hardware Transactional Memory Built-in Functions::
10085 * RX Built-in Functions::
10086 * S/390 System z Built-in Functions::
10087 * SH Built-in Functions::
10088 * SPARC VIS Built-in Functions::
10089 * SPU Built-in Functions::
10090 * TI C6X Built-in Functions::
10091 * TILE-Gx Built-in Functions::
10092 * TILEPro Built-in Functions::
10093 @end menu
10095 @node AArch64 Built-in Functions
10096 @subsection AArch64 Built-in Functions
10098 These built-in functions are available for the AArch64 family of
10099 processors.
10100 @smallexample
10101 unsigned int __builtin_aarch64_get_fpcr ()
10102 void __builtin_aarch64_set_fpcr (unsigned int)
10103 unsigned int __builtin_aarch64_get_fpsr ()
10104 void __builtin_aarch64_set_fpsr (unsigned int)
10105 @end smallexample
10107 @node Alpha Built-in Functions
10108 @subsection Alpha Built-in Functions
10110 These built-in functions are available for the Alpha family of
10111 processors, depending on the command-line switches used.
10113 The following built-in functions are always available.  They
10114 all generate the machine instruction that is part of the name.
10116 @smallexample
10117 long __builtin_alpha_implver (void)
10118 long __builtin_alpha_rpcc (void)
10119 long __builtin_alpha_amask (long)
10120 long __builtin_alpha_cmpbge (long, long)
10121 long __builtin_alpha_extbl (long, long)
10122 long __builtin_alpha_extwl (long, long)
10123 long __builtin_alpha_extll (long, long)
10124 long __builtin_alpha_extql (long, long)
10125 long __builtin_alpha_extwh (long, long)
10126 long __builtin_alpha_extlh (long, long)
10127 long __builtin_alpha_extqh (long, long)
10128 long __builtin_alpha_insbl (long, long)
10129 long __builtin_alpha_inswl (long, long)
10130 long __builtin_alpha_insll (long, long)
10131 long __builtin_alpha_insql (long, long)
10132 long __builtin_alpha_inswh (long, long)
10133 long __builtin_alpha_inslh (long, long)
10134 long __builtin_alpha_insqh (long, long)
10135 long __builtin_alpha_mskbl (long, long)
10136 long __builtin_alpha_mskwl (long, long)
10137 long __builtin_alpha_mskll (long, long)
10138 long __builtin_alpha_mskql (long, long)
10139 long __builtin_alpha_mskwh (long, long)
10140 long __builtin_alpha_msklh (long, long)
10141 long __builtin_alpha_mskqh (long, long)
10142 long __builtin_alpha_umulh (long, long)
10143 long __builtin_alpha_zap (long, long)
10144 long __builtin_alpha_zapnot (long, long)
10145 @end smallexample
10147 The following built-in functions are always with @option{-mmax}
10148 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10149 later.  They all generate the machine instruction that is part
10150 of the name.
10152 @smallexample
10153 long __builtin_alpha_pklb (long)
10154 long __builtin_alpha_pkwb (long)
10155 long __builtin_alpha_unpkbl (long)
10156 long __builtin_alpha_unpkbw (long)
10157 long __builtin_alpha_minub8 (long, long)
10158 long __builtin_alpha_minsb8 (long, long)
10159 long __builtin_alpha_minuw4 (long, long)
10160 long __builtin_alpha_minsw4 (long, long)
10161 long __builtin_alpha_maxub8 (long, long)
10162 long __builtin_alpha_maxsb8 (long, long)
10163 long __builtin_alpha_maxuw4 (long, long)
10164 long __builtin_alpha_maxsw4 (long, long)
10165 long __builtin_alpha_perr (long, long)
10166 @end smallexample
10168 The following built-in functions are always with @option{-mcix}
10169 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10170 later.  They all generate the machine instruction that is part
10171 of the name.
10173 @smallexample
10174 long __builtin_alpha_cttz (long)
10175 long __builtin_alpha_ctlz (long)
10176 long __builtin_alpha_ctpop (long)
10177 @end smallexample
10179 The following built-in functions are available on systems that use the OSF/1
10180 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
10181 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10182 @code{rdval} and @code{wrval}.
10184 @smallexample
10185 void *__builtin_thread_pointer (void)
10186 void __builtin_set_thread_pointer (void *)
10187 @end smallexample
10189 @node Altera Nios II Built-in Functions
10190 @subsection Altera Nios II Built-in Functions
10192 These built-in functions are available for the Altera Nios II
10193 family of processors.
10195 The following built-in functions are always available.  They
10196 all generate the machine instruction that is part of the name.
10198 @example
10199 int __builtin_ldbio (volatile const void *)
10200 int __builtin_ldbuio (volatile const void *)
10201 int __builtin_ldhio (volatile const void *)
10202 int __builtin_ldhuio (volatile const void *)
10203 int __builtin_ldwio (volatile const void *)
10204 void __builtin_stbio (volatile void *, int)
10205 void __builtin_sthio (volatile void *, int)
10206 void __builtin_stwio (volatile void *, int)
10207 void __builtin_sync (void)
10208 int __builtin_rdctl (int) 
10209 void __builtin_wrctl (int, int)
10210 @end example
10212 The following built-in functions are always available.  They
10213 all generate a Nios II Custom Instruction. The name of the
10214 function represents the types that the function takes and
10215 returns. The letter before the @code{n} is the return type
10216 or void if absent. The @code{n} represents the first parameter
10217 to all the custom instructions, the custom instruction number.
10218 The two letters after the @code{n} represent the up to two
10219 parameters to the function.
10221 The letters represent the following data types:
10222 @table @code
10223 @item <no letter>
10224 @code{void} for return type and no parameter for parameter types.
10226 @item i
10227 @code{int} for return type and parameter type
10229 @item f
10230 @code{float} for return type and parameter type
10232 @item p
10233 @code{void *} for return type and parameter type
10235 @end table
10237 And the function names are:
10238 @example
10239 void __builtin_custom_n (void)
10240 void __builtin_custom_ni (int)
10241 void __builtin_custom_nf (float)
10242 void __builtin_custom_np (void *)
10243 void __builtin_custom_nii (int, int)
10244 void __builtin_custom_nif (int, float)
10245 void __builtin_custom_nip (int, void *)
10246 void __builtin_custom_nfi (float, int)
10247 void __builtin_custom_nff (float, float)
10248 void __builtin_custom_nfp (float, void *)
10249 void __builtin_custom_npi (void *, int)
10250 void __builtin_custom_npf (void *, float)
10251 void __builtin_custom_npp (void *, void *)
10252 int __builtin_custom_in (void)
10253 int __builtin_custom_ini (int)
10254 int __builtin_custom_inf (float)
10255 int __builtin_custom_inp (void *)
10256 int __builtin_custom_inii (int, int)
10257 int __builtin_custom_inif (int, float)
10258 int __builtin_custom_inip (int, void *)
10259 int __builtin_custom_infi (float, int)
10260 int __builtin_custom_inff (float, float)
10261 int __builtin_custom_infp (float, void *)
10262 int __builtin_custom_inpi (void *, int)
10263 int __builtin_custom_inpf (void *, float)
10264 int __builtin_custom_inpp (void *, void *)
10265 float __builtin_custom_fn (void)
10266 float __builtin_custom_fni (int)
10267 float __builtin_custom_fnf (float)
10268 float __builtin_custom_fnp (void *)
10269 float __builtin_custom_fnii (int, int)
10270 float __builtin_custom_fnif (int, float)
10271 float __builtin_custom_fnip (int, void *)
10272 float __builtin_custom_fnfi (float, int)
10273 float __builtin_custom_fnff (float, float)
10274 float __builtin_custom_fnfp (float, void *)
10275 float __builtin_custom_fnpi (void *, int)
10276 float __builtin_custom_fnpf (void *, float)
10277 float __builtin_custom_fnpp (void *, void *)
10278 void * __builtin_custom_pn (void)
10279 void * __builtin_custom_pni (int)
10280 void * __builtin_custom_pnf (float)
10281 void * __builtin_custom_pnp (void *)
10282 void * __builtin_custom_pnii (int, int)
10283 void * __builtin_custom_pnif (int, float)
10284 void * __builtin_custom_pnip (int, void *)
10285 void * __builtin_custom_pnfi (float, int)
10286 void * __builtin_custom_pnff (float, float)
10287 void * __builtin_custom_pnfp (float, void *)
10288 void * __builtin_custom_pnpi (void *, int)
10289 void * __builtin_custom_pnpf (void *, float)
10290 void * __builtin_custom_pnpp (void *, void *)
10291 @end example
10293 @node ARC Built-in Functions
10294 @subsection ARC Built-in Functions
10296 The following built-in functions are provided for ARC targets.  The
10297 built-ins generate the corresponding assembly instructions.  In the
10298 examples given below, the generated code often requires an operand or
10299 result to be in a register.  Where necessary further code will be
10300 generated to ensure this is true, but for brevity this is not
10301 described in each case.
10303 @emph{Note:} Using a built-in to generate an instruction not supported
10304 by a target may cause problems. At present the compiler is not
10305 guaranteed to detect such misuse, and as a result an internal compiler
10306 error may be generated.
10308 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10309 Return 1 if @var{val} is known to have the byte alignment given
10310 by @var{alignval}, otherwise return 0.
10311 Note that this is different from
10312 @smallexample
10313 __alignof__(*(char *)@var{val}) >= alignval
10314 @end smallexample
10315 because __alignof__ sees only the type of the dereference, whereas
10316 __builtin_arc_align uses alignment information from the pointer
10317 as well as from the pointed-to type.
10318 The information available will depend on optimization level.
10319 @end deftypefn
10321 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10322 Generates
10323 @example
10325 @end example
10326 @end deftypefn
10328 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10329 The operand is the number of a register to be read.  Generates:
10330 @example
10331 mov  @var{dest}, r@var{regno}
10332 @end example
10333 where the value in @var{dest} will be the result returned from the
10334 built-in.
10335 @end deftypefn
10337 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10338 The first operand is the number of a register to be written, the
10339 second operand is a compile time constant to write into that
10340 register.  Generates:
10341 @example
10342 mov  r@var{regno}, @var{val}
10343 @end example
10344 @end deftypefn
10346 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10347 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10348 Generates:
10349 @example
10350 divaw  @var{dest}, @var{a}, @var{b}
10351 @end example
10352 where the value in @var{dest} will be the result returned from the
10353 built-in.
10354 @end deftypefn
10356 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10357 Generates
10358 @example
10359 flag  @var{a}
10360 @end example
10361 @end deftypefn
10363 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10364 The operand, @var{auxv}, is the address of an auxiliary register and
10365 must be a compile time constant.  Generates:
10366 @example
10367 lr  @var{dest}, [@var{auxr}]
10368 @end example
10369 Where the value in @var{dest} will be the result returned from the
10370 built-in.
10371 @end deftypefn
10373 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10374 Only available with @option{-mmul64}.  Generates:
10375 @example
10376 mul64  @var{a}, @var{b}
10377 @end example
10378 @end deftypefn
10380 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10381 Only available with @option{-mmul64}.  Generates:
10382 @example
10383 mulu64  @var{a}, @var{b}
10384 @end example
10385 @end deftypefn
10387 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10388 Generates:
10389 @example
10391 @end example
10392 @end deftypefn
10394 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10395 Only valid if the @samp{norm} instruction is available through the
10396 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10397 Generates:
10398 @example
10399 norm  @var{dest}, @var{src}
10400 @end example
10401 Where the value in @var{dest} will be the result returned from the
10402 built-in.
10403 @end deftypefn
10405 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
10406 Only valid if the @samp{normw} instruction is available through the
10407 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10408 Generates:
10409 @example
10410 normw  @var{dest}, @var{src}
10411 @end example
10412 Where the value in @var{dest} will be the result returned from the
10413 built-in.
10414 @end deftypefn
10416 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
10417 Generates:
10418 @example
10419 rtie
10420 @end example
10421 @end deftypefn
10423 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
10424 Generates:
10425 @example
10426 sleep  @var{a}
10427 @end example
10428 @end deftypefn
10430 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10431 The first argument, @var{auxv}, is the address of an auxiliary
10432 register, the second argument, @var{val}, is a compile time constant
10433 to be written to the register.  Generates:
10434 @example
10435 sr  @var{auxr}, [@var{val}]
10436 @end example
10437 @end deftypefn
10439 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
10440 Only valid with @option{-mswap}.  Generates:
10441 @example
10442 swap  @var{dest}, @var{src}
10443 @end example
10444 Where the value in @var{dest} will be the result returned from the
10445 built-in.
10446 @end deftypefn
10448 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
10449 Generates:
10450 @example
10452 @end example
10453 @end deftypefn
10455 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
10456 Only available with @option{-mcpu=ARC700}.  Generates:
10457 @example
10458 sync
10459 @end example
10460 @end deftypefn
10462 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
10463 Only available with @option{-mcpu=ARC700}.  Generates:
10464 @example
10465 trap_s  @var{c}
10466 @end example
10467 @end deftypefn
10469 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
10470 Only available with @option{-mcpu=ARC700}.  Generates:
10471 @example
10472 unimp_s
10473 @end example
10474 @end deftypefn
10476 The instructions generated by the following builtins are not
10477 considered as candidates for scheduling.  They are not moved around by
10478 the compiler during scheduling, and thus can be expected to appear
10479 where they are put in the C code:
10480 @example
10481 __builtin_arc_brk()
10482 __builtin_arc_core_read()
10483 __builtin_arc_core_write()
10484 __builtin_arc_flag()
10485 __builtin_arc_lr()
10486 __builtin_arc_sleep()
10487 __builtin_arc_sr()
10488 __builtin_arc_swi()
10489 @end example
10491 @node ARC SIMD Built-in Functions
10492 @subsection ARC SIMD Built-in Functions
10494 SIMD builtins provided by the compiler can be used to generate the
10495 vector instructions.  This section describes the available builtins
10496 and their usage in programs.  With the @option{-msimd} option, the
10497 compiler provides 128-bit vector types, which can be specified using
10498 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
10499 can be included to use the following predefined types:
10500 @example
10501 typedef int __v4si   __attribute__((vector_size(16)));
10502 typedef short __v8hi __attribute__((vector_size(16)));
10503 @end example
10505 These types can be used to define 128-bit variables.  The built-in
10506 functions listed in the following section can be used on these
10507 variables to generate the vector operations.
10509 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10510 @file{arc-simd.h} also provides equivalent macros called
10511 @code{_@var{someinsn}} that can be used for programming ease and
10512 improved readability.  The following macros for DMA control are also
10513 provided:
10514 @example
10515 #define _setup_dma_in_channel_reg _vdiwr
10516 #define _setup_dma_out_channel_reg _vdowr
10517 @end example
10519 The following is a complete list of all the SIMD built-ins provided
10520 for ARC, grouped by calling signature.
10522 The following take two @code{__v8hi} arguments and return a
10523 @code{__v8hi} result:
10524 @example
10525 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10526 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10527 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10528 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10529 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10530 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10531 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10532 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10533 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10534 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10535 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10536 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10537 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10538 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10539 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10540 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10541 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10542 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10543 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10544 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10545 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10546 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10547 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10548 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10549 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10550 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10551 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10552 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10553 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10554 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10555 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10556 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10557 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10558 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10559 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10560 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10561 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10562 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10563 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10564 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10565 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10566 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10567 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10568 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10569 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10570 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10571 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10572 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10573 @end example
10575 The following take one @code{__v8hi} and one @code{int} argument and return a
10576 @code{__v8hi} result:
10578 @example
10579 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10580 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10581 __v8hi __builtin_arc_vbminw (__v8hi, int)
10582 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10583 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10584 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10585 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10586 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10587 @end example
10589 The following take one @code{__v8hi} argument and one @code{int} argument which
10590 must be a 3-bit compile time constant indicating a register number
10591 I0-I7.  They return a @code{__v8hi} result.
10592 @example
10593 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10594 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10595 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10596 @end example
10598 The following take one @code{__v8hi} argument and one @code{int}
10599 argument which must be a 6-bit compile time constant.  They return a
10600 @code{__v8hi} result.
10601 @example
10602 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10603 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10604 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10605 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10606 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10607 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10608 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10609 @end example
10611 The following take one @code{__v8hi} argument and one @code{int} argument which
10612 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10613 result.
10614 @example
10615 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10616 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10617 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10618 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10619 @end example
10621 The following take two @code{int} arguments, the second of which which
10622 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10623 result:
10624 @example
10625 __v8hi __builtin_arc_vmovaw (int, const int)
10626 __v8hi __builtin_arc_vmovw (int, const int)
10627 __v8hi __builtin_arc_vmovzw (int, const int)
10628 @end example
10630 The following take a single @code{__v8hi} argument and return a
10631 @code{__v8hi} result:
10632 @example
10633 __v8hi __builtin_arc_vabsaw (__v8hi)
10634 __v8hi __builtin_arc_vabsw (__v8hi)
10635 __v8hi __builtin_arc_vaddsuw (__v8hi)
10636 __v8hi __builtin_arc_vexch1 (__v8hi)
10637 __v8hi __builtin_arc_vexch2 (__v8hi)
10638 __v8hi __builtin_arc_vexch4 (__v8hi)
10639 __v8hi __builtin_arc_vsignw (__v8hi)
10640 __v8hi __builtin_arc_vupbaw (__v8hi)
10641 __v8hi __builtin_arc_vupbw (__v8hi)
10642 __v8hi __builtin_arc_vupsbaw (__v8hi)
10643 __v8hi __builtin_arc_vupsbw (__v8hi)
10644 @end example
10646 The followign take two @code{int} arguments and return no result:
10647 @example
10648 void __builtin_arc_vdirun (int, int)
10649 void __builtin_arc_vdorun (int, int)
10650 @end example
10652 The following take two @code{int} arguments and return no result.  The
10653 first argument must a 3-bit compile time constant indicating one of
10654 the DR0-DR7 DMA setup channels:
10655 @example
10656 void __builtin_arc_vdiwr (const int, int)
10657 void __builtin_arc_vdowr (const int, int)
10658 @end example
10660 The following take an @code{int} argument and return no result:
10661 @example
10662 void __builtin_arc_vendrec (int)
10663 void __builtin_arc_vrec (int)
10664 void __builtin_arc_vrecrun (int)
10665 void __builtin_arc_vrun (int)
10666 @end example
10668 The following take a @code{__v8hi} argument and two @code{int}
10669 arguments and return a @code{__v8hi} result.  The second argument must
10670 be a 3-bit compile time constants, indicating one the registers I0-I7,
10671 and the third argument must be an 8-bit compile time constant.
10673 @emph{Note:} Although the equivalent hardware instructions do not take
10674 an SIMD register as an operand, these builtins overwrite the relevant
10675 bits of the @code{__v8hi} register provided as the first argument with
10676 the value loaded from the @code{[Ib, u8]} location in the SDM.
10678 @example
10679 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10680 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10681 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10682 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10683 @end example
10685 The following take two @code{int} arguments and return a @code{__v8hi}
10686 result.  The first argument must be a 3-bit compile time constants,
10687 indicating one the registers I0-I7, and the second argument must be an
10688 8-bit compile time constant.
10690 @example
10691 __v8hi __builtin_arc_vld128 (const int, const int)
10692 __v8hi __builtin_arc_vld64w (const int, const int)
10693 @end example
10695 The following take a @code{__v8hi} argument and two @code{int}
10696 arguments and return no result.  The second argument must be a 3-bit
10697 compile time constants, indicating one the registers I0-I7, and the
10698 third argument must be an 8-bit compile time constant.
10700 @example
10701 void __builtin_arc_vst128 (__v8hi, const int, const int)
10702 void __builtin_arc_vst64 (__v8hi, const int, const int)
10703 @end example
10705 The following take a @code{__v8hi} argument and three @code{int}
10706 arguments and return no result.  The second argument must be a 3-bit
10707 compile-time constant, identifying the 16-bit sub-register to be
10708 stored, the third argument must be a 3-bit compile time constants,
10709 indicating one the registers I0-I7, and the fourth argument must be an
10710 8-bit compile time constant.
10712 @example
10713 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10714 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10715 @end example
10717 @node ARM iWMMXt Built-in Functions
10718 @subsection ARM iWMMXt Built-in Functions
10720 These built-in functions are available for the ARM family of
10721 processors when the @option{-mcpu=iwmmxt} switch is used:
10723 @smallexample
10724 typedef int v2si __attribute__ ((vector_size (8)));
10725 typedef short v4hi __attribute__ ((vector_size (8)));
10726 typedef char v8qi __attribute__ ((vector_size (8)));
10728 int __builtin_arm_getwcgr0 (void)
10729 void __builtin_arm_setwcgr0 (int)
10730 int __builtin_arm_getwcgr1 (void)
10731 void __builtin_arm_setwcgr1 (int)
10732 int __builtin_arm_getwcgr2 (void)
10733 void __builtin_arm_setwcgr2 (int)
10734 int __builtin_arm_getwcgr3 (void)
10735 void __builtin_arm_setwcgr3 (int)
10736 int __builtin_arm_textrmsb (v8qi, int)
10737 int __builtin_arm_textrmsh (v4hi, int)
10738 int __builtin_arm_textrmsw (v2si, int)
10739 int __builtin_arm_textrmub (v8qi, int)
10740 int __builtin_arm_textrmuh (v4hi, int)
10741 int __builtin_arm_textrmuw (v2si, int)
10742 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10743 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10744 v2si __builtin_arm_tinsrw (v2si, int, int)
10745 long long __builtin_arm_tmia (long long, int, int)
10746 long long __builtin_arm_tmiabb (long long, int, int)
10747 long long __builtin_arm_tmiabt (long long, int, int)
10748 long long __builtin_arm_tmiaph (long long, int, int)
10749 long long __builtin_arm_tmiatb (long long, int, int)
10750 long long __builtin_arm_tmiatt (long long, int, int)
10751 int __builtin_arm_tmovmskb (v8qi)
10752 int __builtin_arm_tmovmskh (v4hi)
10753 int __builtin_arm_tmovmskw (v2si)
10754 long long __builtin_arm_waccb (v8qi)
10755 long long __builtin_arm_wacch (v4hi)
10756 long long __builtin_arm_waccw (v2si)
10757 v8qi __builtin_arm_waddb (v8qi, v8qi)
10758 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10759 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10760 v4hi __builtin_arm_waddh (v4hi, v4hi)
10761 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10762 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10763 v2si __builtin_arm_waddw (v2si, v2si)
10764 v2si __builtin_arm_waddwss (v2si, v2si)
10765 v2si __builtin_arm_waddwus (v2si, v2si)
10766 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10767 long long __builtin_arm_wand(long long, long long)
10768 long long __builtin_arm_wandn (long long, long long)
10769 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10770 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10771 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10772 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10773 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10774 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10775 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10776 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10777 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10778 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10779 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10780 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10781 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10782 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10783 long long __builtin_arm_wmacsz (v4hi, v4hi)
10784 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10785 long long __builtin_arm_wmacuz (v4hi, v4hi)
10786 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10787 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10788 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10789 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10790 v2si __builtin_arm_wmaxsw (v2si, v2si)
10791 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10792 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10793 v2si __builtin_arm_wmaxuw (v2si, v2si)
10794 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10795 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10796 v2si __builtin_arm_wminsw (v2si, v2si)
10797 v8qi __builtin_arm_wminub (v8qi, v8qi)
10798 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10799 v2si __builtin_arm_wminuw (v2si, v2si)
10800 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10801 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10802 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10803 long long __builtin_arm_wor (long long, long long)
10804 v2si __builtin_arm_wpackdss (long long, long long)
10805 v2si __builtin_arm_wpackdus (long long, long long)
10806 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10807 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10808 v4hi __builtin_arm_wpackwss (v2si, v2si)
10809 v4hi __builtin_arm_wpackwus (v2si, v2si)
10810 long long __builtin_arm_wrord (long long, long long)
10811 long long __builtin_arm_wrordi (long long, int)
10812 v4hi __builtin_arm_wrorh (v4hi, long long)
10813 v4hi __builtin_arm_wrorhi (v4hi, int)
10814 v2si __builtin_arm_wrorw (v2si, long long)
10815 v2si __builtin_arm_wrorwi (v2si, int)
10816 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10817 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10818 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10819 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10820 v4hi __builtin_arm_wshufh (v4hi, int)
10821 long long __builtin_arm_wslld (long long, long long)
10822 long long __builtin_arm_wslldi (long long, int)
10823 v4hi __builtin_arm_wsllh (v4hi, long long)
10824 v4hi __builtin_arm_wsllhi (v4hi, int)
10825 v2si __builtin_arm_wsllw (v2si, long long)
10826 v2si __builtin_arm_wsllwi (v2si, int)
10827 long long __builtin_arm_wsrad (long long, long long)
10828 long long __builtin_arm_wsradi (long long, int)
10829 v4hi __builtin_arm_wsrah (v4hi, long long)
10830 v4hi __builtin_arm_wsrahi (v4hi, int)
10831 v2si __builtin_arm_wsraw (v2si, long long)
10832 v2si __builtin_arm_wsrawi (v2si, int)
10833 long long __builtin_arm_wsrld (long long, long long)
10834 long long __builtin_arm_wsrldi (long long, int)
10835 v4hi __builtin_arm_wsrlh (v4hi, long long)
10836 v4hi __builtin_arm_wsrlhi (v4hi, int)
10837 v2si __builtin_arm_wsrlw (v2si, long long)
10838 v2si __builtin_arm_wsrlwi (v2si, int)
10839 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10840 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10841 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10842 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10843 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10844 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10845 v2si __builtin_arm_wsubw (v2si, v2si)
10846 v2si __builtin_arm_wsubwss (v2si, v2si)
10847 v2si __builtin_arm_wsubwus (v2si, v2si)
10848 v4hi __builtin_arm_wunpckehsb (v8qi)
10849 v2si __builtin_arm_wunpckehsh (v4hi)
10850 long long __builtin_arm_wunpckehsw (v2si)
10851 v4hi __builtin_arm_wunpckehub (v8qi)
10852 v2si __builtin_arm_wunpckehuh (v4hi)
10853 long long __builtin_arm_wunpckehuw (v2si)
10854 v4hi __builtin_arm_wunpckelsb (v8qi)
10855 v2si __builtin_arm_wunpckelsh (v4hi)
10856 long long __builtin_arm_wunpckelsw (v2si)
10857 v4hi __builtin_arm_wunpckelub (v8qi)
10858 v2si __builtin_arm_wunpckeluh (v4hi)
10859 long long __builtin_arm_wunpckeluw (v2si)
10860 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10861 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10862 v2si __builtin_arm_wunpckihw (v2si, v2si)
10863 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10864 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10865 v2si __builtin_arm_wunpckilw (v2si, v2si)
10866 long long __builtin_arm_wxor (long long, long long)
10867 long long __builtin_arm_wzero ()
10868 @end smallexample
10871 @node ARM C Language Extensions (ACLE)
10872 @subsection ARM C Language Extensions (ACLE)
10874 GCC implements extensions for C as described in the ARM C Language
10875 Extensions (ACLE) specification, which can be found at
10876 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
10878 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
10879 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
10880 intrinsics can be found at
10881 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
10882 The built-in intrinsics for the Advanced SIMD extension are available when
10883 NEON is enabled.
10885 Currently, ARM and AArch64 back-ends do not support ACLE 2.0 fully.  Both
10886 back-ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM backend's
10887 16-bit floating-point Advanded SIMD Intrinsics currently comply to ACLE v1.1.
10888 AArch64's backend does not have support for 16-bit floating point Advanced SIMD
10889 Intrinsics yet.
10891 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
10892 availability of extensions.
10894 @node ARM Floating Point Status and Control Intrinsics
10895 @subsection ARM Floating Point Status and Control Intrinsics
10897 These built-in functions are available for the ARM family of
10898 processors with floating-point unit.
10900 @smallexample
10901 unsigned int __builtin_arm_get_fpscr ()
10902 void __builtin_arm_set_fpscr (unsigned int)
10903 @end smallexample
10905 @node AVR Built-in Functions
10906 @subsection AVR Built-in Functions
10908 For each built-in function for AVR, there is an equally named,
10909 uppercase built-in macro defined. That way users can easily query if
10910 or if not a specific built-in is implemented or not. For example, if
10911 @code{__builtin_avr_nop} is available the macro
10912 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10914 The following built-in functions map to the respective machine
10915 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10916 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10917 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10918 as library call if no hardware multiplier is available.
10920 @smallexample
10921 void __builtin_avr_nop (void)
10922 void __builtin_avr_sei (void)
10923 void __builtin_avr_cli (void)
10924 void __builtin_avr_sleep (void)
10925 void __builtin_avr_wdr (void)
10926 unsigned char __builtin_avr_swap (unsigned char)
10927 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10928 int __builtin_avr_fmuls (char, char)
10929 int __builtin_avr_fmulsu (char, unsigned char)
10930 @end smallexample
10932 In order to delay execution for a specific number of cycles, GCC
10933 implements
10934 @smallexample
10935 void __builtin_avr_delay_cycles (unsigned long ticks)
10936 @end smallexample
10938 @noindent
10939 @code{ticks} is the number of ticks to delay execution. Note that this
10940 built-in does not take into account the effect of interrupts that
10941 might increase delay time. @code{ticks} must be a compile-time
10942 integer constant; delays with a variable number of cycles are not supported.
10944 @smallexample
10945 char __builtin_avr_flash_segment (const __memx void*)
10946 @end smallexample
10948 @noindent
10949 This built-in takes a byte address to the 24-bit
10950 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10951 the number of the flash segment (the 64 KiB chunk) where the address
10952 points to.  Counting starts at @code{0}.
10953 If the address does not point to flash memory, return @code{-1}.
10955 @smallexample
10956 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10957 @end smallexample
10959 @noindent
10960 Insert bits from @var{bits} into @var{val} and return the resulting
10961 value. The nibbles of @var{map} determine how the insertion is
10962 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
10963 @enumerate
10964 @item If @var{X} is @code{0xf},
10965 then the @var{n}-th bit of @var{val} is returned unaltered.
10967 @item If X is in the range 0@dots{}7,
10968 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
10970 @item If X is in the range 8@dots{}@code{0xe},
10971 then the @var{n}-th result bit is undefined.
10972 @end enumerate
10974 @noindent
10975 One typical use case for this built-in is adjusting input and
10976 output values to non-contiguous port layouts. Some examples:
10978 @smallexample
10979 // same as val, bits is unused
10980 __builtin_avr_insert_bits (0xffffffff, bits, val)
10981 @end smallexample
10983 @smallexample
10984 // same as bits, val is unused
10985 __builtin_avr_insert_bits (0x76543210, bits, val)
10986 @end smallexample
10988 @smallexample
10989 // same as rotating bits by 4
10990 __builtin_avr_insert_bits (0x32107654, bits, 0)
10991 @end smallexample
10993 @smallexample
10994 // high nibble of result is the high nibble of val
10995 // low nibble of result is the low nibble of bits
10996 __builtin_avr_insert_bits (0xffff3210, bits, val)
10997 @end smallexample
10999 @smallexample
11000 // reverse the bit order of bits
11001 __builtin_avr_insert_bits (0x01234567, bits, 0)
11002 @end smallexample
11004 @node Blackfin Built-in Functions
11005 @subsection Blackfin Built-in Functions
11007 Currently, there are two Blackfin-specific built-in functions.  These are
11008 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
11009 using inline assembly; by using these built-in functions the compiler can
11010 automatically add workarounds for hardware errata involving these
11011 instructions.  These functions are named as follows:
11013 @smallexample
11014 void __builtin_bfin_csync (void)
11015 void __builtin_bfin_ssync (void)
11016 @end smallexample
11018 @node FR-V Built-in Functions
11019 @subsection FR-V Built-in Functions
11021 GCC provides many FR-V-specific built-in functions.  In general,
11022 these functions are intended to be compatible with those described
11023 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11024 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
11025 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11026 pointer rather than by value.
11028 Most of the functions are named after specific FR-V instructions.
11029 Such functions are said to be ``directly mapped'' and are summarized
11030 here in tabular form.
11032 @menu
11033 * Argument Types::
11034 * Directly-mapped Integer Functions::
11035 * Directly-mapped Media Functions::
11036 * Raw read/write Functions::
11037 * Other Built-in Functions::
11038 @end menu
11040 @node Argument Types
11041 @subsubsection Argument Types
11043 The arguments to the built-in functions can be divided into three groups:
11044 register numbers, compile-time constants and run-time values.  In order
11045 to make this classification clear at a glance, the arguments and return
11046 values are given the following pseudo types:
11048 @multitable @columnfractions .20 .30 .15 .35
11049 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11050 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11051 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11052 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11053 @item @code{uw2} @tab @code{unsigned long long} @tab No
11054 @tab an unsigned doubleword
11055 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11056 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11057 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11058 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11059 @end multitable
11061 These pseudo types are not defined by GCC, they are simply a notational
11062 convenience used in this manual.
11064 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11065 and @code{sw2} are evaluated at run time.  They correspond to
11066 register operands in the underlying FR-V instructions.
11068 @code{const} arguments represent immediate operands in the underlying
11069 FR-V instructions.  They must be compile-time constants.
11071 @code{acc} arguments are evaluated at compile time and specify the number
11072 of an accumulator register.  For example, an @code{acc} argument of 2
11073 selects the ACC2 register.
11075 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11076 number of an IACC register.  See @pxref{Other Built-in Functions}
11077 for more details.
11079 @node Directly-mapped Integer Functions
11080 @subsubsection Directly-mapped Integer Functions
11082 The functions listed below map directly to FR-V I-type instructions.
11084 @multitable @columnfractions .45 .32 .23
11085 @item Function prototype @tab Example usage @tab Assembly output
11086 @item @code{sw1 __ADDSS (sw1, sw1)}
11087 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11088 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11089 @item @code{sw1 __SCAN (sw1, sw1)}
11090 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11091 @tab @code{SCAN @var{a},@var{b},@var{c}}
11092 @item @code{sw1 __SCUTSS (sw1)}
11093 @tab @code{@var{b} = __SCUTSS (@var{a})}
11094 @tab @code{SCUTSS @var{a},@var{b}}
11095 @item @code{sw1 __SLASS (sw1, sw1)}
11096 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11097 @tab @code{SLASS @var{a},@var{b},@var{c}}
11098 @item @code{void __SMASS (sw1, sw1)}
11099 @tab @code{__SMASS (@var{a}, @var{b})}
11100 @tab @code{SMASS @var{a},@var{b}}
11101 @item @code{void __SMSSS (sw1, sw1)}
11102 @tab @code{__SMSSS (@var{a}, @var{b})}
11103 @tab @code{SMSSS @var{a},@var{b}}
11104 @item @code{void __SMU (sw1, sw1)}
11105 @tab @code{__SMU (@var{a}, @var{b})}
11106 @tab @code{SMU @var{a},@var{b}}
11107 @item @code{sw2 __SMUL (sw1, sw1)}
11108 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11109 @tab @code{SMUL @var{a},@var{b},@var{c}}
11110 @item @code{sw1 __SUBSS (sw1, sw1)}
11111 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11112 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11113 @item @code{uw2 __UMUL (uw1, uw1)}
11114 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11115 @tab @code{UMUL @var{a},@var{b},@var{c}}
11116 @end multitable
11118 @node Directly-mapped Media Functions
11119 @subsubsection Directly-mapped Media Functions
11121 The functions listed below map directly to FR-V M-type instructions.
11123 @multitable @columnfractions .45 .32 .23
11124 @item Function prototype @tab Example usage @tab Assembly output
11125 @item @code{uw1 __MABSHS (sw1)}
11126 @tab @code{@var{b} = __MABSHS (@var{a})}
11127 @tab @code{MABSHS @var{a},@var{b}}
11128 @item @code{void __MADDACCS (acc, acc)}
11129 @tab @code{__MADDACCS (@var{b}, @var{a})}
11130 @tab @code{MADDACCS @var{a},@var{b}}
11131 @item @code{sw1 __MADDHSS (sw1, sw1)}
11132 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11133 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11134 @item @code{uw1 __MADDHUS (uw1, uw1)}
11135 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11136 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11137 @item @code{uw1 __MAND (uw1, uw1)}
11138 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11139 @tab @code{MAND @var{a},@var{b},@var{c}}
11140 @item @code{void __MASACCS (acc, acc)}
11141 @tab @code{__MASACCS (@var{b}, @var{a})}
11142 @tab @code{MASACCS @var{a},@var{b}}
11143 @item @code{uw1 __MAVEH (uw1, uw1)}
11144 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11145 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11146 @item @code{uw2 __MBTOH (uw1)}
11147 @tab @code{@var{b} = __MBTOH (@var{a})}
11148 @tab @code{MBTOH @var{a},@var{b}}
11149 @item @code{void __MBTOHE (uw1 *, uw1)}
11150 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11151 @tab @code{MBTOHE @var{a},@var{b}}
11152 @item @code{void __MCLRACC (acc)}
11153 @tab @code{__MCLRACC (@var{a})}
11154 @tab @code{MCLRACC @var{a}}
11155 @item @code{void __MCLRACCA (void)}
11156 @tab @code{__MCLRACCA ()}
11157 @tab @code{MCLRACCA}
11158 @item @code{uw1 __Mcop1 (uw1, uw1)}
11159 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11160 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11161 @item @code{uw1 __Mcop2 (uw1, uw1)}
11162 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11163 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11164 @item @code{uw1 __MCPLHI (uw2, const)}
11165 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11166 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11167 @item @code{uw1 __MCPLI (uw2, const)}
11168 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11169 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11170 @item @code{void __MCPXIS (acc, sw1, sw1)}
11171 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11172 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11173 @item @code{void __MCPXIU (acc, uw1, uw1)}
11174 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11175 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11176 @item @code{void __MCPXRS (acc, sw1, sw1)}
11177 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11178 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11179 @item @code{void __MCPXRU (acc, uw1, uw1)}
11180 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11181 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11182 @item @code{uw1 __MCUT (acc, uw1)}
11183 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11184 @tab @code{MCUT @var{a},@var{b},@var{c}}
11185 @item @code{uw1 __MCUTSS (acc, sw1)}
11186 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11187 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11188 @item @code{void __MDADDACCS (acc, acc)}
11189 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11190 @tab @code{MDADDACCS @var{a},@var{b}}
11191 @item @code{void __MDASACCS (acc, acc)}
11192 @tab @code{__MDASACCS (@var{b}, @var{a})}
11193 @tab @code{MDASACCS @var{a},@var{b}}
11194 @item @code{uw2 __MDCUTSSI (acc, const)}
11195 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11196 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11197 @item @code{uw2 __MDPACKH (uw2, uw2)}
11198 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11199 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11200 @item @code{uw2 __MDROTLI (uw2, const)}
11201 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11202 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11203 @item @code{void __MDSUBACCS (acc, acc)}
11204 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11205 @tab @code{MDSUBACCS @var{a},@var{b}}
11206 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11207 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11208 @tab @code{MDUNPACKH @var{a},@var{b}}
11209 @item @code{uw2 __MEXPDHD (uw1, const)}
11210 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11211 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11212 @item @code{uw1 __MEXPDHW (uw1, const)}
11213 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11214 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11215 @item @code{uw1 __MHDSETH (uw1, const)}
11216 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11217 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11218 @item @code{sw1 __MHDSETS (const)}
11219 @tab @code{@var{b} = __MHDSETS (@var{a})}
11220 @tab @code{MHDSETS #@var{a},@var{b}}
11221 @item @code{uw1 __MHSETHIH (uw1, const)}
11222 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11223 @tab @code{MHSETHIH #@var{a},@var{b}}
11224 @item @code{sw1 __MHSETHIS (sw1, const)}
11225 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11226 @tab @code{MHSETHIS #@var{a},@var{b}}
11227 @item @code{uw1 __MHSETLOH (uw1, const)}
11228 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11229 @tab @code{MHSETLOH #@var{a},@var{b}}
11230 @item @code{sw1 __MHSETLOS (sw1, const)}
11231 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11232 @tab @code{MHSETLOS #@var{a},@var{b}}
11233 @item @code{uw1 __MHTOB (uw2)}
11234 @tab @code{@var{b} = __MHTOB (@var{a})}
11235 @tab @code{MHTOB @var{a},@var{b}}
11236 @item @code{void __MMACHS (acc, sw1, sw1)}
11237 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11238 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11239 @item @code{void __MMACHU (acc, uw1, uw1)}
11240 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11241 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11242 @item @code{void __MMRDHS (acc, sw1, sw1)}
11243 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11244 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11245 @item @code{void __MMRDHU (acc, uw1, uw1)}
11246 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11247 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11248 @item @code{void __MMULHS (acc, sw1, sw1)}
11249 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11250 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11251 @item @code{void __MMULHU (acc, uw1, uw1)}
11252 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11253 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11254 @item @code{void __MMULXHS (acc, sw1, sw1)}
11255 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11256 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11257 @item @code{void __MMULXHU (acc, uw1, uw1)}
11258 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11259 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11260 @item @code{uw1 __MNOT (uw1)}
11261 @tab @code{@var{b} = __MNOT (@var{a})}
11262 @tab @code{MNOT @var{a},@var{b}}
11263 @item @code{uw1 __MOR (uw1, uw1)}
11264 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11265 @tab @code{MOR @var{a},@var{b},@var{c}}
11266 @item @code{uw1 __MPACKH (uh, uh)}
11267 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11268 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11269 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11270 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11271 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11272 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11273 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11274 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11275 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11276 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11277 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11278 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11279 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11280 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11281 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11282 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11283 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11284 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11285 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11286 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11287 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11288 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11289 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11290 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11291 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11292 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11293 @item @code{void __MQMACHS (acc, sw2, sw2)}
11294 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11295 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11296 @item @code{void __MQMACHU (acc, uw2, uw2)}
11297 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11298 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11299 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11300 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11301 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11302 @item @code{void __MQMULHS (acc, sw2, sw2)}
11303 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11304 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11305 @item @code{void __MQMULHU (acc, uw2, uw2)}
11306 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11307 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11308 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11309 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11310 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11311 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11312 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11313 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11314 @item @code{sw2 __MQSATHS (sw2, sw2)}
11315 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11316 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11317 @item @code{uw2 __MQSLLHI (uw2, int)}
11318 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11319 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11320 @item @code{sw2 __MQSRAHI (sw2, int)}
11321 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11322 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11323 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11324 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11325 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11326 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11327 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11328 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11329 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11330 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11331 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11332 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11333 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11334 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11335 @item @code{uw1 __MRDACC (acc)}
11336 @tab @code{@var{b} = __MRDACC (@var{a})}
11337 @tab @code{MRDACC @var{a},@var{b}}
11338 @item @code{uw1 __MRDACCG (acc)}
11339 @tab @code{@var{b} = __MRDACCG (@var{a})}
11340 @tab @code{MRDACCG @var{a},@var{b}}
11341 @item @code{uw1 __MROTLI (uw1, const)}
11342 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11343 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11344 @item @code{uw1 __MROTRI (uw1, const)}
11345 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11346 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11347 @item @code{sw1 __MSATHS (sw1, sw1)}
11348 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11349 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11350 @item @code{uw1 __MSATHU (uw1, uw1)}
11351 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11352 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11353 @item @code{uw1 __MSLLHI (uw1, const)}
11354 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11355 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11356 @item @code{sw1 __MSRAHI (sw1, const)}
11357 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11358 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11359 @item @code{uw1 __MSRLHI (uw1, const)}
11360 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11361 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11362 @item @code{void __MSUBACCS (acc, acc)}
11363 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11364 @tab @code{MSUBACCS @var{a},@var{b}}
11365 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11366 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11367 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11368 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11369 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11370 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11371 @item @code{void __MTRAP (void)}
11372 @tab @code{__MTRAP ()}
11373 @tab @code{MTRAP}
11374 @item @code{uw2 __MUNPACKH (uw1)}
11375 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11376 @tab @code{MUNPACKH @var{a},@var{b}}
11377 @item @code{uw1 __MWCUT (uw2, uw1)}
11378 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11379 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11380 @item @code{void __MWTACC (acc, uw1)}
11381 @tab @code{__MWTACC (@var{b}, @var{a})}
11382 @tab @code{MWTACC @var{a},@var{b}}
11383 @item @code{void __MWTACCG (acc, uw1)}
11384 @tab @code{__MWTACCG (@var{b}, @var{a})}
11385 @tab @code{MWTACCG @var{a},@var{b}}
11386 @item @code{uw1 __MXOR (uw1, uw1)}
11387 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11388 @tab @code{MXOR @var{a},@var{b},@var{c}}
11389 @end multitable
11391 @node Raw read/write Functions
11392 @subsubsection Raw read/write Functions
11394 This sections describes built-in functions related to read and write
11395 instructions to access memory.  These functions generate
11396 @code{membar} instructions to flush the I/O load and stores where
11397 appropriate, as described in Fujitsu's manual described above.
11399 @table @code
11401 @item unsigned char __builtin_read8 (void *@var{data})
11402 @item unsigned short __builtin_read16 (void *@var{data})
11403 @item unsigned long __builtin_read32 (void *@var{data})
11404 @item unsigned long long __builtin_read64 (void *@var{data})
11406 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11407 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11408 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11409 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11410 @end table
11412 @node Other Built-in Functions
11413 @subsubsection Other Built-in Functions
11415 This section describes built-in functions that are not named after
11416 a specific FR-V instruction.
11418 @table @code
11419 @item sw2 __IACCreadll (iacc @var{reg})
11420 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
11421 for future expansion and must be 0.
11423 @item sw1 __IACCreadl (iacc @var{reg})
11424 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11425 Other values of @var{reg} are rejected as invalid.
11427 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11428 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
11429 is reserved for future expansion and must be 0.
11431 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11432 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11433 is 1.  Other values of @var{reg} are rejected as invalid.
11435 @item void __data_prefetch0 (const void *@var{x})
11436 Use the @code{dcpl} instruction to load the contents of address @var{x}
11437 into the data cache.
11439 @item void __data_prefetch (const void *@var{x})
11440 Use the @code{nldub} instruction to load the contents of address @var{x}
11441 into the data cache.  The instruction is issued in slot I1@.
11442 @end table
11444 @node X86 Built-in Functions
11445 @subsection X86 Built-in Functions
11447 These built-in functions are available for the i386 and x86-64 family
11448 of computers, depending on the command-line switches used.
11450 If you specify command-line switches such as @option{-msse},
11451 the compiler could use the extended instruction sets even if the built-ins
11452 are not used explicitly in the program.  For this reason, applications
11453 that perform run-time CPU detection must compile separate files for each
11454 supported architecture, using the appropriate flags.  In particular,
11455 the file containing the CPU detection code should be compiled without
11456 these options.
11458 The following machine modes are available for use with MMX built-in functions
11459 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11460 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11461 vector of eight 8-bit integers.  Some of the built-in functions operate on
11462 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11464 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11465 of two 32-bit floating-point values.
11467 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11468 floating-point values.  Some instructions use a vector of four 32-bit
11469 integers, these use @code{V4SI}.  Finally, some instructions operate on an
11470 entire vector register, interpreting it as a 128-bit integer, these use mode
11471 @code{TI}.
11473 In 64-bit mode, the x86-64 family of processors uses additional built-in
11474 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11475 floating point and @code{TC} 128-bit complex floating-point values.
11477 The following floating-point built-in functions are available in 64-bit
11478 mode.  All of them implement the function that is part of the name.
11480 @smallexample
11481 __float128 __builtin_fabsq (__float128)
11482 __float128 __builtin_copysignq (__float128, __float128)
11483 @end smallexample
11485 The following built-in function is always available.
11487 @table @code
11488 @item void __builtin_ia32_pause (void)
11489 Generates the @code{pause} machine instruction with a compiler memory
11490 barrier.
11491 @end table
11493 The following floating-point built-in functions are made available in the
11494 64-bit mode.
11496 @table @code
11497 @item __float128 __builtin_infq (void)
11498 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11499 @findex __builtin_infq
11501 @item __float128 __builtin_huge_valq (void)
11502 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11503 @findex __builtin_huge_valq
11504 @end table
11506 The following built-in functions are always available and can be used to
11507 check the target platform type.
11509 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11510 This function runs the CPU detection code to check the type of CPU and the
11511 features supported.  This built-in function needs to be invoked along with the built-in functions
11512 to check CPU type and features, @code{__builtin_cpu_is} and
11513 @code{__builtin_cpu_supports}, only when used in a function that is
11514 executed before any constructors are called.  The CPU detection code is
11515 automatically executed in a very high priority constructor.
11517 For example, this function has to be used in @code{ifunc} resolvers that
11518 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11519 and @code{__builtin_cpu_supports}, or in constructors on targets that
11520 don't support constructor priority.
11521 @smallexample
11523 static void (*resolve_memcpy (void)) (void)
11525   // ifunc resolvers fire before constructors, explicitly call the init
11526   // function.
11527   __builtin_cpu_init ();
11528   if (__builtin_cpu_supports ("ssse3"))
11529     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11530   else
11531     return default_memcpy;
11534 void *memcpy (void *, const void *, size_t)
11535      __attribute__ ((ifunc ("resolve_memcpy")));
11536 @end smallexample
11538 @end deftypefn
11540 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11541 This function returns a positive integer if the run-time CPU
11542 is of type @var{cpuname}
11543 and returns @code{0} otherwise. The following CPU names can be detected:
11545 @table @samp
11546 @item intel
11547 Intel CPU.
11549 @item atom
11550 Intel Atom CPU.
11552 @item core2
11553 Intel Core 2 CPU.
11555 @item corei7
11556 Intel Core i7 CPU.
11558 @item nehalem
11559 Intel Core i7 Nehalem CPU.
11561 @item westmere
11562 Intel Core i7 Westmere CPU.
11564 @item sandybridge
11565 Intel Core i7 Sandy Bridge CPU.
11567 @item amd
11568 AMD CPU.
11570 @item amdfam10h
11571 AMD Family 10h CPU.
11573 @item barcelona
11574 AMD Family 10h Barcelona CPU.
11576 @item shanghai
11577 AMD Family 10h Shanghai CPU.
11579 @item istanbul
11580 AMD Family 10h Istanbul CPU.
11582 @item btver1
11583 AMD Family 14h CPU.
11585 @item amdfam15h
11586 AMD Family 15h CPU.
11588 @item bdver1
11589 AMD Family 15h Bulldozer version 1.
11591 @item bdver2
11592 AMD Family 15h Bulldozer version 2.
11594 @item bdver3
11595 AMD Family 15h Bulldozer version 3.
11597 @item bdver4
11598 AMD Family 15h Bulldozer version 4.
11600 @item btver2
11601 AMD Family 16h CPU.
11602 @end table
11604 Here is an example:
11605 @smallexample
11606 if (__builtin_cpu_is ("corei7"))
11607   @{
11608      do_corei7 (); // Core i7 specific implementation.
11609   @}
11610 else
11611   @{
11612      do_generic (); // Generic implementation.
11613   @}
11614 @end smallexample
11615 @end deftypefn
11617 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11618 This function returns a positive integer if the run-time CPU
11619 supports @var{feature}
11620 and returns @code{0} otherwise. The following features can be detected:
11622 @table @samp
11623 @item cmov
11624 CMOV instruction.
11625 @item mmx
11626 MMX instructions.
11627 @item popcnt
11628 POPCNT instruction.
11629 @item sse
11630 SSE instructions.
11631 @item sse2
11632 SSE2 instructions.
11633 @item sse3
11634 SSE3 instructions.
11635 @item ssse3
11636 SSSE3 instructions.
11637 @item sse4.1
11638 SSE4.1 instructions.
11639 @item sse4.2
11640 SSE4.2 instructions.
11641 @item avx
11642 AVX instructions.
11643 @item avx2
11644 AVX2 instructions.
11645 @item avx512f
11646 AVX512F instructions.
11647 @end table
11649 Here is an example:
11650 @smallexample
11651 if (__builtin_cpu_supports ("popcnt"))
11652   @{
11653      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11654   @}
11655 else
11656   @{
11657      count = generic_countbits (n); //generic implementation.
11658   @}
11659 @end smallexample
11660 @end deftypefn
11663 The following built-in functions are made available by @option{-mmmx}.
11664 All of them generate the machine instruction that is part of the name.
11666 @smallexample
11667 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11668 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11669 v2si __builtin_ia32_paddd (v2si, v2si)
11670 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11671 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11672 v2si __builtin_ia32_psubd (v2si, v2si)
11673 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11674 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11675 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11676 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11677 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11678 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11679 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11680 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11681 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11682 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11683 di __builtin_ia32_pand (di, di)
11684 di __builtin_ia32_pandn (di,di)
11685 di __builtin_ia32_por (di, di)
11686 di __builtin_ia32_pxor (di, di)
11687 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11688 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11689 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11690 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11691 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11692 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11693 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11694 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11695 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11696 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11697 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11698 v2si __builtin_ia32_punpckldq (v2si, v2si)
11699 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11700 v4hi __builtin_ia32_packssdw (v2si, v2si)
11701 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11703 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11704 v2si __builtin_ia32_pslld (v2si, v2si)
11705 v1di __builtin_ia32_psllq (v1di, v1di)
11706 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11707 v2si __builtin_ia32_psrld (v2si, v2si)
11708 v1di __builtin_ia32_psrlq (v1di, v1di)
11709 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11710 v2si __builtin_ia32_psrad (v2si, v2si)
11711 v4hi __builtin_ia32_psllwi (v4hi, int)
11712 v2si __builtin_ia32_pslldi (v2si, int)
11713 v1di __builtin_ia32_psllqi (v1di, int)
11714 v4hi __builtin_ia32_psrlwi (v4hi, int)
11715 v2si __builtin_ia32_psrldi (v2si, int)
11716 v1di __builtin_ia32_psrlqi (v1di, int)
11717 v4hi __builtin_ia32_psrawi (v4hi, int)
11718 v2si __builtin_ia32_psradi (v2si, int)
11720 @end smallexample
11722 The following built-in functions are made available either with
11723 @option{-msse}, or with a combination of @option{-m3dnow} and
11724 @option{-march=athlon}.  All of them generate the machine
11725 instruction that is part of the name.
11727 @smallexample
11728 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11729 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11730 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11731 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11732 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11733 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11734 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11735 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11736 int __builtin_ia32_pmovmskb (v8qi)
11737 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11738 void __builtin_ia32_movntq (di *, di)
11739 void __builtin_ia32_sfence (void)
11740 @end smallexample
11742 The following built-in functions are available when @option{-msse} is used.
11743 All of them generate the machine instruction that is part of the name.
11745 @smallexample
11746 int __builtin_ia32_comieq (v4sf, v4sf)
11747 int __builtin_ia32_comineq (v4sf, v4sf)
11748 int __builtin_ia32_comilt (v4sf, v4sf)
11749 int __builtin_ia32_comile (v4sf, v4sf)
11750 int __builtin_ia32_comigt (v4sf, v4sf)
11751 int __builtin_ia32_comige (v4sf, v4sf)
11752 int __builtin_ia32_ucomieq (v4sf, v4sf)
11753 int __builtin_ia32_ucomineq (v4sf, v4sf)
11754 int __builtin_ia32_ucomilt (v4sf, v4sf)
11755 int __builtin_ia32_ucomile (v4sf, v4sf)
11756 int __builtin_ia32_ucomigt (v4sf, v4sf)
11757 int __builtin_ia32_ucomige (v4sf, v4sf)
11758 v4sf __builtin_ia32_addps (v4sf, v4sf)
11759 v4sf __builtin_ia32_subps (v4sf, v4sf)
11760 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11761 v4sf __builtin_ia32_divps (v4sf, v4sf)
11762 v4sf __builtin_ia32_addss (v4sf, v4sf)
11763 v4sf __builtin_ia32_subss (v4sf, v4sf)
11764 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11765 v4sf __builtin_ia32_divss (v4sf, v4sf)
11766 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11767 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11768 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11769 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11770 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11771 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11772 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11773 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11774 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11775 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11776 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11777 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11778 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11779 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11780 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11781 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11782 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11783 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11784 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11785 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11786 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11787 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11788 v4sf __builtin_ia32_minps (v4sf, v4sf)
11789 v4sf __builtin_ia32_minss (v4sf, v4sf)
11790 v4sf __builtin_ia32_andps (v4sf, v4sf)
11791 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11792 v4sf __builtin_ia32_orps (v4sf, v4sf)
11793 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11794 v4sf __builtin_ia32_movss (v4sf, v4sf)
11795 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11796 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11797 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11798 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11799 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11800 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11801 v2si __builtin_ia32_cvtps2pi (v4sf)
11802 int __builtin_ia32_cvtss2si (v4sf)
11803 v2si __builtin_ia32_cvttps2pi (v4sf)
11804 int __builtin_ia32_cvttss2si (v4sf)
11805 v4sf __builtin_ia32_rcpps (v4sf)
11806 v4sf __builtin_ia32_rsqrtps (v4sf)
11807 v4sf __builtin_ia32_sqrtps (v4sf)
11808 v4sf __builtin_ia32_rcpss (v4sf)
11809 v4sf __builtin_ia32_rsqrtss (v4sf)
11810 v4sf __builtin_ia32_sqrtss (v4sf)
11811 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11812 void __builtin_ia32_movntps (float *, v4sf)
11813 int __builtin_ia32_movmskps (v4sf)
11814 @end smallexample
11816 The following built-in functions are available when @option{-msse} is used.
11818 @table @code
11819 @item v4sf __builtin_ia32_loadups (float *)
11820 Generates the @code{movups} machine instruction as a load from memory.
11821 @item void __builtin_ia32_storeups (float *, v4sf)
11822 Generates the @code{movups} machine instruction as a store to memory.
11823 @item v4sf __builtin_ia32_loadss (float *)
11824 Generates the @code{movss} machine instruction as a load from memory.
11825 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11826 Generates the @code{movhps} machine instruction as a load from memory.
11827 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11828 Generates the @code{movlps} machine instruction as a load from memory
11829 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11830 Generates the @code{movhps} machine instruction as a store to memory.
11831 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11832 Generates the @code{movlps} machine instruction as a store to memory.
11833 @end table
11835 The following built-in functions are available when @option{-msse2} is used.
11836 All of them generate the machine instruction that is part of the name.
11838 @smallexample
11839 int __builtin_ia32_comisdeq (v2df, v2df)
11840 int __builtin_ia32_comisdlt (v2df, v2df)
11841 int __builtin_ia32_comisdle (v2df, v2df)
11842 int __builtin_ia32_comisdgt (v2df, v2df)
11843 int __builtin_ia32_comisdge (v2df, v2df)
11844 int __builtin_ia32_comisdneq (v2df, v2df)
11845 int __builtin_ia32_ucomisdeq (v2df, v2df)
11846 int __builtin_ia32_ucomisdlt (v2df, v2df)
11847 int __builtin_ia32_ucomisdle (v2df, v2df)
11848 int __builtin_ia32_ucomisdgt (v2df, v2df)
11849 int __builtin_ia32_ucomisdge (v2df, v2df)
11850 int __builtin_ia32_ucomisdneq (v2df, v2df)
11851 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11852 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11853 v2df __builtin_ia32_cmplepd (v2df, v2df)
11854 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11855 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11856 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11857 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11858 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11859 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11860 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11861 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11862 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11863 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11864 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11865 v2df __builtin_ia32_cmplesd (v2df, v2df)
11866 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11867 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11868 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11869 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11870 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11871 v2di __builtin_ia32_paddq (v2di, v2di)
11872 v2di __builtin_ia32_psubq (v2di, v2di)
11873 v2df __builtin_ia32_addpd (v2df, v2df)
11874 v2df __builtin_ia32_subpd (v2df, v2df)
11875 v2df __builtin_ia32_mulpd (v2df, v2df)
11876 v2df __builtin_ia32_divpd (v2df, v2df)
11877 v2df __builtin_ia32_addsd (v2df, v2df)
11878 v2df __builtin_ia32_subsd (v2df, v2df)
11879 v2df __builtin_ia32_mulsd (v2df, v2df)
11880 v2df __builtin_ia32_divsd (v2df, v2df)
11881 v2df __builtin_ia32_minpd (v2df, v2df)
11882 v2df __builtin_ia32_maxpd (v2df, v2df)
11883 v2df __builtin_ia32_minsd (v2df, v2df)
11884 v2df __builtin_ia32_maxsd (v2df, v2df)
11885 v2df __builtin_ia32_andpd (v2df, v2df)
11886 v2df __builtin_ia32_andnpd (v2df, v2df)
11887 v2df __builtin_ia32_orpd (v2df, v2df)
11888 v2df __builtin_ia32_xorpd (v2df, v2df)
11889 v2df __builtin_ia32_movsd (v2df, v2df)
11890 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11891 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11892 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11893 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11894 v4si __builtin_ia32_paddd128 (v4si, v4si)
11895 v2di __builtin_ia32_paddq128 (v2di, v2di)
11896 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11897 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11898 v4si __builtin_ia32_psubd128 (v4si, v4si)
11899 v2di __builtin_ia32_psubq128 (v2di, v2di)
11900 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11901 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11902 v2di __builtin_ia32_pand128 (v2di, v2di)
11903 v2di __builtin_ia32_pandn128 (v2di, v2di)
11904 v2di __builtin_ia32_por128 (v2di, v2di)
11905 v2di __builtin_ia32_pxor128 (v2di, v2di)
11906 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11907 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11908 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11909 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11910 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11911 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11912 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11913 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11914 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11915 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11916 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11917 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11918 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11919 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11920 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11921 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11922 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11923 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11924 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11925 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11926 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11927 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11928 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11929 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11930 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11931 v2df __builtin_ia32_loadupd (double *)
11932 void __builtin_ia32_storeupd (double *, v2df)
11933 v2df __builtin_ia32_loadhpd (v2df, double const *)
11934 v2df __builtin_ia32_loadlpd (v2df, double const *)
11935 int __builtin_ia32_movmskpd (v2df)
11936 int __builtin_ia32_pmovmskb128 (v16qi)
11937 void __builtin_ia32_movnti (int *, int)
11938 void __builtin_ia32_movnti64 (long long int *, long long int)
11939 void __builtin_ia32_movntpd (double *, v2df)
11940 void __builtin_ia32_movntdq (v2df *, v2df)
11941 v4si __builtin_ia32_pshufd (v4si, int)
11942 v8hi __builtin_ia32_pshuflw (v8hi, int)
11943 v8hi __builtin_ia32_pshufhw (v8hi, int)
11944 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11945 v2df __builtin_ia32_sqrtpd (v2df)
11946 v2df __builtin_ia32_sqrtsd (v2df)
11947 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11948 v2df __builtin_ia32_cvtdq2pd (v4si)
11949 v4sf __builtin_ia32_cvtdq2ps (v4si)
11950 v4si __builtin_ia32_cvtpd2dq (v2df)
11951 v2si __builtin_ia32_cvtpd2pi (v2df)
11952 v4sf __builtin_ia32_cvtpd2ps (v2df)
11953 v4si __builtin_ia32_cvttpd2dq (v2df)
11954 v2si __builtin_ia32_cvttpd2pi (v2df)
11955 v2df __builtin_ia32_cvtpi2pd (v2si)
11956 int __builtin_ia32_cvtsd2si (v2df)
11957 int __builtin_ia32_cvttsd2si (v2df)
11958 long long __builtin_ia32_cvtsd2si64 (v2df)
11959 long long __builtin_ia32_cvttsd2si64 (v2df)
11960 v4si __builtin_ia32_cvtps2dq (v4sf)
11961 v2df __builtin_ia32_cvtps2pd (v4sf)
11962 v4si __builtin_ia32_cvttps2dq (v4sf)
11963 v2df __builtin_ia32_cvtsi2sd (v2df, int)
11964 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
11965 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
11966 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
11967 void __builtin_ia32_clflush (const void *)
11968 void __builtin_ia32_lfence (void)
11969 void __builtin_ia32_mfence (void)
11970 v16qi __builtin_ia32_loaddqu (const char *)
11971 void __builtin_ia32_storedqu (char *, v16qi)
11972 v1di __builtin_ia32_pmuludq (v2si, v2si)
11973 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
11974 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
11975 v4si __builtin_ia32_pslld128 (v4si, v4si)
11976 v2di __builtin_ia32_psllq128 (v2di, v2di)
11977 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
11978 v4si __builtin_ia32_psrld128 (v4si, v4si)
11979 v2di __builtin_ia32_psrlq128 (v2di, v2di)
11980 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
11981 v4si __builtin_ia32_psrad128 (v4si, v4si)
11982 v2di __builtin_ia32_pslldqi128 (v2di, int)
11983 v8hi __builtin_ia32_psllwi128 (v8hi, int)
11984 v4si __builtin_ia32_pslldi128 (v4si, int)
11985 v2di __builtin_ia32_psllqi128 (v2di, int)
11986 v2di __builtin_ia32_psrldqi128 (v2di, int)
11987 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
11988 v4si __builtin_ia32_psrldi128 (v4si, int)
11989 v2di __builtin_ia32_psrlqi128 (v2di, int)
11990 v8hi __builtin_ia32_psrawi128 (v8hi, int)
11991 v4si __builtin_ia32_psradi128 (v4si, int)
11992 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
11993 v2di __builtin_ia32_movq128 (v2di)
11994 @end smallexample
11996 The following built-in functions are available when @option{-msse3} is used.
11997 All of them generate the machine instruction that is part of the name.
11999 @smallexample
12000 v2df __builtin_ia32_addsubpd (v2df, v2df)
12001 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
12002 v2df __builtin_ia32_haddpd (v2df, v2df)
12003 v4sf __builtin_ia32_haddps (v4sf, v4sf)
12004 v2df __builtin_ia32_hsubpd (v2df, v2df)
12005 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
12006 v16qi __builtin_ia32_lddqu (char const *)
12007 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
12008 v4sf __builtin_ia32_movshdup (v4sf)
12009 v4sf __builtin_ia32_movsldup (v4sf)
12010 void __builtin_ia32_mwait (unsigned int, unsigned int)
12011 @end smallexample
12013 The following built-in functions are available when @option{-mssse3} is used.
12014 All of them generate the machine instruction that is part of the name.
12016 @smallexample
12017 v2si __builtin_ia32_phaddd (v2si, v2si)
12018 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
12019 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
12020 v2si __builtin_ia32_phsubd (v2si, v2si)
12021 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
12022 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
12023 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
12024 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
12025 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
12026 v8qi __builtin_ia32_psignb (v8qi, v8qi)
12027 v2si __builtin_ia32_psignd (v2si, v2si)
12028 v4hi __builtin_ia32_psignw (v4hi, v4hi)
12029 v1di __builtin_ia32_palignr (v1di, v1di, int)
12030 v8qi __builtin_ia32_pabsb (v8qi)
12031 v2si __builtin_ia32_pabsd (v2si)
12032 v4hi __builtin_ia32_pabsw (v4hi)
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 v4si __builtin_ia32_phaddd128 (v4si, v4si)
12040 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
12041 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
12042 v4si __builtin_ia32_phsubd128 (v4si, v4si)
12043 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
12044 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
12045 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
12046 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
12047 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
12048 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
12049 v4si __builtin_ia32_psignd128 (v4si, v4si)
12050 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
12051 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
12052 v16qi __builtin_ia32_pabsb128 (v16qi)
12053 v4si __builtin_ia32_pabsd128 (v4si)
12054 v8hi __builtin_ia32_pabsw128 (v8hi)
12055 @end smallexample
12057 The following built-in functions are available when @option{-msse4.1} is
12058 used.  All of them generate the machine instruction that is part of the
12059 name.
12061 @smallexample
12062 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
12063 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
12064 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
12065 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
12066 v2df __builtin_ia32_dppd (v2df, v2df, const int)
12067 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
12068 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
12069 v2di __builtin_ia32_movntdqa (v2di *);
12070 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
12071 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
12072 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
12073 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
12074 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
12075 v8hi __builtin_ia32_phminposuw128 (v8hi)
12076 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
12077 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
12078 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
12079 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
12080 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
12081 v4si __builtin_ia32_pminsd128 (v4si, v4si)
12082 v4si __builtin_ia32_pminud128 (v4si, v4si)
12083 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
12084 v4si __builtin_ia32_pmovsxbd128 (v16qi)
12085 v2di __builtin_ia32_pmovsxbq128 (v16qi)
12086 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
12087 v2di __builtin_ia32_pmovsxdq128 (v4si)
12088 v4si __builtin_ia32_pmovsxwd128 (v8hi)
12089 v2di __builtin_ia32_pmovsxwq128 (v8hi)
12090 v4si __builtin_ia32_pmovzxbd128 (v16qi)
12091 v2di __builtin_ia32_pmovzxbq128 (v16qi)
12092 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
12093 v2di __builtin_ia32_pmovzxdq128 (v4si)
12094 v4si __builtin_ia32_pmovzxwd128 (v8hi)
12095 v2di __builtin_ia32_pmovzxwq128 (v8hi)
12096 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
12097 v4si __builtin_ia32_pmulld128 (v4si, v4si)
12098 int __builtin_ia32_ptestc128 (v2di, v2di)
12099 int __builtin_ia32_ptestnzc128 (v2di, v2di)
12100 int __builtin_ia32_ptestz128 (v2di, v2di)
12101 v2df __builtin_ia32_roundpd (v2df, const int)
12102 v4sf __builtin_ia32_roundps (v4sf, const int)
12103 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
12104 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
12105 @end smallexample
12107 The following built-in functions are available when @option{-msse4.1} is
12108 used.
12110 @table @code
12111 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
12112 Generates the @code{insertps} machine instruction.
12113 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
12114 Generates the @code{pextrb} machine instruction.
12115 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
12116 Generates the @code{pinsrb} machine instruction.
12117 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
12118 Generates the @code{pinsrd} machine instruction.
12119 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
12120 Generates the @code{pinsrq} machine instruction in 64bit mode.
12121 @end table
12123 The following built-in functions are changed to generate new SSE4.1
12124 instructions when @option{-msse4.1} is used.
12126 @table @code
12127 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
12128 Generates the @code{extractps} machine instruction.
12129 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
12130 Generates the @code{pextrd} machine instruction.
12131 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
12132 Generates the @code{pextrq} machine instruction in 64bit mode.
12133 @end table
12135 The following built-in functions are available when @option{-msse4.2} is
12136 used.  All of them generate the machine instruction that is part of the
12137 name.
12139 @smallexample
12140 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
12141 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
12142 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
12143 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
12144 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
12145 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
12146 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
12147 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
12148 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
12149 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
12150 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
12151 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
12152 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
12153 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
12154 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
12155 @end smallexample
12157 The following built-in functions are available when @option{-msse4.2} is
12158 used.
12160 @table @code
12161 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
12162 Generates the @code{crc32b} machine instruction.
12163 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
12164 Generates the @code{crc32w} machine instruction.
12165 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
12166 Generates the @code{crc32l} machine instruction.
12167 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
12168 Generates the @code{crc32q} machine instruction.
12169 @end table
12171 The following built-in functions are changed to generate new SSE4.2
12172 instructions when @option{-msse4.2} is used.
12174 @table @code
12175 @item int __builtin_popcount (unsigned int)
12176 Generates the @code{popcntl} machine instruction.
12177 @item int __builtin_popcountl (unsigned long)
12178 Generates the @code{popcntl} or @code{popcntq} machine instruction,
12179 depending on the size of @code{unsigned long}.
12180 @item int __builtin_popcountll (unsigned long long)
12181 Generates the @code{popcntq} machine instruction.
12182 @end table
12184 The following built-in functions are available when @option{-mavx} is
12185 used. All of them generate the machine instruction that is part of the
12186 name.
12188 @smallexample
12189 v4df __builtin_ia32_addpd256 (v4df,v4df)
12190 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
12191 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
12192 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
12193 v4df __builtin_ia32_andnpd256 (v4df,v4df)
12194 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
12195 v4df __builtin_ia32_andpd256 (v4df,v4df)
12196 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
12197 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
12198 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
12199 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
12200 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
12201 v2df __builtin_ia32_cmppd (v2df,v2df,int)
12202 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
12203 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
12204 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
12205 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
12206 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
12207 v4df __builtin_ia32_cvtdq2pd256 (v4si)
12208 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
12209 v4si __builtin_ia32_cvtpd2dq256 (v4df)
12210 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
12211 v8si __builtin_ia32_cvtps2dq256 (v8sf)
12212 v4df __builtin_ia32_cvtps2pd256 (v4sf)
12213 v4si __builtin_ia32_cvttpd2dq256 (v4df)
12214 v8si __builtin_ia32_cvttps2dq256 (v8sf)
12215 v4df __builtin_ia32_divpd256 (v4df,v4df)
12216 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
12217 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
12218 v4df __builtin_ia32_haddpd256 (v4df,v4df)
12219 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
12220 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
12221 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
12222 v32qi __builtin_ia32_lddqu256 (pcchar)
12223 v32qi __builtin_ia32_loaddqu256 (pcchar)
12224 v4df __builtin_ia32_loadupd256 (pcdouble)
12225 v8sf __builtin_ia32_loadups256 (pcfloat)
12226 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
12227 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
12228 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
12229 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
12230 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
12231 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
12232 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
12233 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
12234 v4df __builtin_ia32_maxpd256 (v4df,v4df)
12235 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
12236 v4df __builtin_ia32_minpd256 (v4df,v4df)
12237 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
12238 v4df __builtin_ia32_movddup256 (v4df)
12239 int __builtin_ia32_movmskpd256 (v4df)
12240 int __builtin_ia32_movmskps256 (v8sf)
12241 v8sf __builtin_ia32_movshdup256 (v8sf)
12242 v8sf __builtin_ia32_movsldup256 (v8sf)
12243 v4df __builtin_ia32_mulpd256 (v4df,v4df)
12244 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
12245 v4df __builtin_ia32_orpd256 (v4df,v4df)
12246 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
12247 v2df __builtin_ia32_pd_pd256 (v4df)
12248 v4df __builtin_ia32_pd256_pd (v2df)
12249 v4sf __builtin_ia32_ps_ps256 (v8sf)
12250 v8sf __builtin_ia32_ps256_ps (v4sf)
12251 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
12252 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
12253 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
12254 v8sf __builtin_ia32_rcpps256 (v8sf)
12255 v4df __builtin_ia32_roundpd256 (v4df,int)
12256 v8sf __builtin_ia32_roundps256 (v8sf,int)
12257 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
12258 v8sf __builtin_ia32_rsqrtps256 (v8sf)
12259 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
12260 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
12261 v4si __builtin_ia32_si_si256 (v8si)
12262 v8si __builtin_ia32_si256_si (v4si)
12263 v4df __builtin_ia32_sqrtpd256 (v4df)
12264 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
12265 v8sf __builtin_ia32_sqrtps256 (v8sf)
12266 void __builtin_ia32_storedqu256 (pchar,v32qi)
12267 void __builtin_ia32_storeupd256 (pdouble,v4df)
12268 void __builtin_ia32_storeups256 (pfloat,v8sf)
12269 v4df __builtin_ia32_subpd256 (v4df,v4df)
12270 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
12271 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
12272 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
12273 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
12274 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
12275 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
12276 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
12277 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
12278 v4sf __builtin_ia32_vbroadcastss (pcfloat)
12279 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
12280 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
12281 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
12282 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
12283 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
12284 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
12285 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
12286 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
12287 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
12288 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
12289 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
12290 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
12291 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
12292 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
12293 v2df __builtin_ia32_vpermilpd (v2df,int)
12294 v4df __builtin_ia32_vpermilpd256 (v4df,int)
12295 v4sf __builtin_ia32_vpermilps (v4sf,int)
12296 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
12297 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
12298 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
12299 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
12300 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
12301 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
12302 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
12303 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
12304 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
12305 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
12306 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
12307 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
12308 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
12309 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
12310 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
12311 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
12312 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
12313 void __builtin_ia32_vzeroall (void)
12314 void __builtin_ia32_vzeroupper (void)
12315 v4df __builtin_ia32_xorpd256 (v4df,v4df)
12316 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
12317 @end smallexample
12319 The following built-in functions are available when @option{-mavx2} is
12320 used. All of them generate the machine instruction that is part of the
12321 name.
12323 @smallexample
12324 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
12325 v32qi __builtin_ia32_pabsb256 (v32qi)
12326 v16hi __builtin_ia32_pabsw256 (v16hi)
12327 v8si __builtin_ia32_pabsd256 (v8si)
12328 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
12329 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
12330 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
12331 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
12332 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
12333 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
12334 v8si __builtin_ia32_paddd256 (v8si,v8si)
12335 v4di __builtin_ia32_paddq256 (v4di,v4di)
12336 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
12337 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
12338 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
12339 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
12340 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
12341 v4di __builtin_ia32_andsi256 (v4di,v4di)
12342 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
12343 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
12344 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
12345 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
12346 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
12347 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
12348 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
12349 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
12350 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
12351 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
12352 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
12353 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
12354 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
12355 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
12356 v8si __builtin_ia32_phaddd256 (v8si,v8si)
12357 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
12358 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
12359 v8si __builtin_ia32_phsubd256 (v8si,v8si)
12360 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
12361 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
12362 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
12363 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
12364 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
12365 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
12366 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
12367 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
12368 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
12369 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
12370 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
12371 v8si __builtin_ia32_pminsd256 (v8si,v8si)
12372 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
12373 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
12374 v8si __builtin_ia32_pminud256 (v8si,v8si)
12375 int __builtin_ia32_pmovmskb256 (v32qi)
12376 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
12377 v8si __builtin_ia32_pmovsxbd256 (v16qi)
12378 v4di __builtin_ia32_pmovsxbq256 (v16qi)
12379 v8si __builtin_ia32_pmovsxwd256 (v8hi)
12380 v4di __builtin_ia32_pmovsxwq256 (v8hi)
12381 v4di __builtin_ia32_pmovsxdq256 (v4si)
12382 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
12383 v8si __builtin_ia32_pmovzxbd256 (v16qi)
12384 v4di __builtin_ia32_pmovzxbq256 (v16qi)
12385 v8si __builtin_ia32_pmovzxwd256 (v8hi)
12386 v4di __builtin_ia32_pmovzxwq256 (v8hi)
12387 v4di __builtin_ia32_pmovzxdq256 (v4si)
12388 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12389 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12390 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12391 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12392 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12393 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12394 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12395 v4di __builtin_ia32_por256 (v4di,v4di)
12396 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12397 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12398 v8si __builtin_ia32_pshufd256 (v8si,int)
12399 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12400 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12401 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12402 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12403 v8si __builtin_ia32_psignd256 (v8si,v8si)
12404 v4di __builtin_ia32_pslldqi256 (v4di,int)
12405 v16hi __builtin_ia32_psllwi256 (16hi,int)
12406 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12407 v8si __builtin_ia32_pslldi256 (v8si,int)
12408 v8si __builtin_ia32_pslld256(v8si,v4si)
12409 v4di __builtin_ia32_psllqi256 (v4di,int)
12410 v4di __builtin_ia32_psllq256(v4di,v2di)
12411 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12412 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12413 v8si __builtin_ia32_psradi256 (v8si,int)
12414 v8si __builtin_ia32_psrad256 (v8si,v4si)
12415 v4di __builtin_ia32_psrldqi256 (v4di, int)
12416 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12417 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12418 v8si __builtin_ia32_psrldi256 (v8si,int)
12419 v8si __builtin_ia32_psrld256 (v8si,v4si)
12420 v4di __builtin_ia32_psrlqi256 (v4di,int)
12421 v4di __builtin_ia32_psrlq256(v4di,v2di)
12422 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12423 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12424 v8si __builtin_ia32_psubd256 (v8si,v8si)
12425 v4di __builtin_ia32_psubq256 (v4di,v4di)
12426 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12427 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12428 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12429 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12430 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12431 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12432 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12433 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12434 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12435 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12436 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12437 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12438 v4di __builtin_ia32_pxor256 (v4di,v4di)
12439 v4di __builtin_ia32_movntdqa256 (pv4di)
12440 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12441 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12442 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12443 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12444 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12445 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12446 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12447 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12448 v8si __builtin_ia32_pbroadcastd256 (v4si)
12449 v4di __builtin_ia32_pbroadcastq256 (v2di)
12450 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12451 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12452 v4si __builtin_ia32_pbroadcastd128 (v4si)
12453 v2di __builtin_ia32_pbroadcastq128 (v2di)
12454 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12455 v4df __builtin_ia32_permdf256 (v4df,int)
12456 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12457 v4di __builtin_ia32_permdi256 (v4di,int)
12458 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12459 v4di __builtin_ia32_extract128i256 (v4di,int)
12460 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12461 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12462 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12463 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12464 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12465 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12466 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12467 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12468 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12469 v8si __builtin_ia32_psllv8si (v8si,v8si)
12470 v4si __builtin_ia32_psllv4si (v4si,v4si)
12471 v4di __builtin_ia32_psllv4di (v4di,v4di)
12472 v2di __builtin_ia32_psllv2di (v2di,v2di)
12473 v8si __builtin_ia32_psrav8si (v8si,v8si)
12474 v4si __builtin_ia32_psrav4si (v4si,v4si)
12475 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12476 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12477 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12478 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12479 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12480 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12481 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12482 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12483 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12484 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12485 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12486 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12487 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12488 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12489 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12490 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12491 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12492 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12493 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12494 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12495 @end smallexample
12497 The following built-in functions are available when @option{-maes} is
12498 used.  All of them generate the machine instruction that is part of the
12499 name.
12501 @smallexample
12502 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12503 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12504 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12505 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12506 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12507 v2di __builtin_ia32_aesimc128 (v2di)
12508 @end smallexample
12510 The following built-in function is available when @option{-mpclmul} is
12511 used.
12513 @table @code
12514 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12515 Generates the @code{pclmulqdq} machine instruction.
12516 @end table
12518 The following built-in function is available when @option{-mfsgsbase} is
12519 used.  All of them generate the machine instruction that is part of the
12520 name.
12522 @smallexample
12523 unsigned int __builtin_ia32_rdfsbase32 (void)
12524 unsigned long long __builtin_ia32_rdfsbase64 (void)
12525 unsigned int __builtin_ia32_rdgsbase32 (void)
12526 unsigned long long __builtin_ia32_rdgsbase64 (void)
12527 void _writefsbase_u32 (unsigned int)
12528 void _writefsbase_u64 (unsigned long long)
12529 void _writegsbase_u32 (unsigned int)
12530 void _writegsbase_u64 (unsigned long long)
12531 @end smallexample
12533 The following built-in function is available when @option{-mrdrnd} is
12534 used.  All of them generate the machine instruction that is part of the
12535 name.
12537 @smallexample
12538 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12539 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12540 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12541 @end smallexample
12543 The following built-in functions are available when @option{-msse4a} is used.
12544 All of them generate the machine instruction that is part of the name.
12546 @smallexample
12547 void __builtin_ia32_movntsd (double *, v2df)
12548 void __builtin_ia32_movntss (float *, v4sf)
12549 v2di __builtin_ia32_extrq  (v2di, v16qi)
12550 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12551 v2di __builtin_ia32_insertq (v2di, v2di)
12552 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12553 @end smallexample
12555 The following built-in functions are available when @option{-mxop} is used.
12556 @smallexample
12557 v2df __builtin_ia32_vfrczpd (v2df)
12558 v4sf __builtin_ia32_vfrczps (v4sf)
12559 v2df __builtin_ia32_vfrczsd (v2df)
12560 v4sf __builtin_ia32_vfrczss (v4sf)
12561 v4df __builtin_ia32_vfrczpd256 (v4df)
12562 v8sf __builtin_ia32_vfrczps256 (v8sf)
12563 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12564 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12565 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12566 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12567 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12568 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12569 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12570 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12571 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12572 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12573 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12574 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12575 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12576 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12577 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12578 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12579 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12580 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12581 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12582 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12583 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12584 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12585 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12586 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12587 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12588 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12589 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12590 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12591 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12592 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12593 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12594 v4si __builtin_ia32_vpcomged (v4si, v4si)
12595 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12596 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12597 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12598 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12599 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12600 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12601 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12602 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12603 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12604 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12605 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12606 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12607 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12608 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12609 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12610 v4si __builtin_ia32_vpcomled (v4si, v4si)
12611 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12612 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12613 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12614 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12615 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12616 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12617 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12618 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12619 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12620 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12621 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12622 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12623 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12624 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12625 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12626 v4si __builtin_ia32_vpcomned (v4si, v4si)
12627 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12628 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12629 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12630 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12631 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12632 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12633 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12634 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12635 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12636 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12637 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12638 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12639 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12640 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12641 v4si __builtin_ia32_vphaddbd (v16qi)
12642 v2di __builtin_ia32_vphaddbq (v16qi)
12643 v8hi __builtin_ia32_vphaddbw (v16qi)
12644 v2di __builtin_ia32_vphadddq (v4si)
12645 v4si __builtin_ia32_vphaddubd (v16qi)
12646 v2di __builtin_ia32_vphaddubq (v16qi)
12647 v8hi __builtin_ia32_vphaddubw (v16qi)
12648 v2di __builtin_ia32_vphaddudq (v4si)
12649 v4si __builtin_ia32_vphadduwd (v8hi)
12650 v2di __builtin_ia32_vphadduwq (v8hi)
12651 v4si __builtin_ia32_vphaddwd (v8hi)
12652 v2di __builtin_ia32_vphaddwq (v8hi)
12653 v8hi __builtin_ia32_vphsubbw (v16qi)
12654 v2di __builtin_ia32_vphsubdq (v4si)
12655 v4si __builtin_ia32_vphsubwd (v8hi)
12656 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12657 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12658 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12659 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12660 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12661 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12662 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12663 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12664 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12665 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12666 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12667 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12668 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12669 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12670 v4si __builtin_ia32_vprotd (v4si, v4si)
12671 v2di __builtin_ia32_vprotq (v2di, v2di)
12672 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12673 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12674 v4si __builtin_ia32_vpshad (v4si, v4si)
12675 v2di __builtin_ia32_vpshaq (v2di, v2di)
12676 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12677 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12678 v4si __builtin_ia32_vpshld (v4si, v4si)
12679 v2di __builtin_ia32_vpshlq (v2di, v2di)
12680 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12681 @end smallexample
12683 The following built-in functions are available when @option{-mfma4} is used.
12684 All of them generate the machine instruction that is part of the name.
12686 @smallexample
12687 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12688 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12689 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12690 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12691 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12692 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12693 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12694 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12695 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12696 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12697 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12698 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12699 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12700 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12701 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12702 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12703 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
12704 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
12705 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
12706 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
12707 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12708 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12709 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12710 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12711 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12712 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12713 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12714 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12715 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12716 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12717 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12718 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12720 @end smallexample
12722 The following built-in functions are available when @option{-mlwp} is used.
12724 @smallexample
12725 void __builtin_ia32_llwpcb16 (void *);
12726 void __builtin_ia32_llwpcb32 (void *);
12727 void __builtin_ia32_llwpcb64 (void *);
12728 void * __builtin_ia32_llwpcb16 (void);
12729 void * __builtin_ia32_llwpcb32 (void);
12730 void * __builtin_ia32_llwpcb64 (void);
12731 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12732 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12733 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12734 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12735 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12736 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12737 @end smallexample
12739 The following built-in functions are available when @option{-mbmi} is used.
12740 All of them generate the machine instruction that is part of the name.
12741 @smallexample
12742 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12743 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12744 @end smallexample
12746 The following built-in functions are available when @option{-mbmi2} is used.
12747 All of them generate the machine instruction that is part of the name.
12748 @smallexample
12749 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12750 unsigned int _pdep_u32 (unsigned int, unsigned int)
12751 unsigned int _pext_u32 (unsigned int, unsigned int)
12752 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12753 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12754 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12755 @end smallexample
12757 The following built-in functions are available when @option{-mlzcnt} is used.
12758 All of them generate the machine instruction that is part of the name.
12759 @smallexample
12760 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12761 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12762 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12763 @end smallexample
12765 The following built-in functions are available when @option{-mfxsr} is used.
12766 All of them generate the machine instruction that is part of the name.
12767 @smallexample
12768 void __builtin_ia32_fxsave (void *)
12769 void __builtin_ia32_fxrstor (void *)
12770 void __builtin_ia32_fxsave64 (void *)
12771 void __builtin_ia32_fxrstor64 (void *)
12772 @end smallexample
12774 The following built-in functions are available when @option{-mxsave} is used.
12775 All of them generate the machine instruction that is part of the name.
12776 @smallexample
12777 void __builtin_ia32_xsave (void *, long long)
12778 void __builtin_ia32_xrstor (void *, long long)
12779 void __builtin_ia32_xsave64 (void *, long long)
12780 void __builtin_ia32_xrstor64 (void *, long long)
12781 @end smallexample
12783 The following built-in functions are available when @option{-mxsaveopt} is used.
12784 All of them generate the machine instruction that is part of the name.
12785 @smallexample
12786 void __builtin_ia32_xsaveopt (void *, long long)
12787 void __builtin_ia32_xsaveopt64 (void *, long long)
12788 @end smallexample
12790 The following built-in functions are available when @option{-mtbm} is used.
12791 Both of them generate the immediate form of the bextr machine instruction.
12792 @smallexample
12793 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12794 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12795 @end smallexample
12798 The following built-in functions are available when @option{-m3dnow} is used.
12799 All of them generate the machine instruction that is part of the name.
12801 @smallexample
12802 void __builtin_ia32_femms (void)
12803 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12804 v2si __builtin_ia32_pf2id (v2sf)
12805 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12806 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12807 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12808 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12809 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12810 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12811 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12812 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12813 v2sf __builtin_ia32_pfrcp (v2sf)
12814 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12815 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12816 v2sf __builtin_ia32_pfrsqrt (v2sf)
12817 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12818 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12819 v2sf __builtin_ia32_pi2fd (v2si)
12820 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12821 @end smallexample
12823 The following built-in functions are available when both @option{-m3dnow}
12824 and @option{-march=athlon} are used.  All of them generate the machine
12825 instruction that is part of the name.
12827 @smallexample
12828 v2si __builtin_ia32_pf2iw (v2sf)
12829 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12830 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12831 v2sf __builtin_ia32_pi2fw (v2si)
12832 v2sf __builtin_ia32_pswapdsf (v2sf)
12833 v2si __builtin_ia32_pswapdsi (v2si)
12834 @end smallexample
12836 The following built-in functions are available when @option{-mrtm} is used
12837 They are used for restricted transactional memory. These are the internal
12838 low level functions. Normally the functions in 
12839 @ref{X86 transactional memory intrinsics} should be used instead.
12841 @smallexample
12842 int __builtin_ia32_xbegin ()
12843 void __builtin_ia32_xend ()
12844 void __builtin_ia32_xabort (status)
12845 int __builtin_ia32_xtest ()
12846 @end smallexample
12848 @node X86 transactional memory intrinsics
12849 @subsection X86 transaction memory intrinsics
12851 Hardware transactional memory intrinsics for i386. These allow to use
12852 memory transactions with RTM (Restricted Transactional Memory).
12853 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12854 This support is enabled with the @option{-mrtm} option.
12856 A memory transaction commits all changes to memory in an atomic way,
12857 as visible to other threads. If the transaction fails it is rolled back
12858 and all side effects discarded.
12860 Generally there is no guarantee that a memory transaction ever succeeds
12861 and suitable fallback code always needs to be supplied.
12863 @deftypefn {RTM Function} {unsigned} _xbegin ()
12864 Start a RTM (Restricted Transactional Memory) transaction. 
12865 Returns _XBEGIN_STARTED when the transaction
12866 started successfully (note this is not 0, so the constant has to be 
12867 explicitely tested). When the transaction aborts all side effects
12868 are undone and an abort code is returned. There is no guarantee
12869 any transaction ever succeeds, so there always needs to be a valid
12870 tested fallback path.
12871 @end deftypefn
12873 @smallexample
12874 #include <immintrin.h>
12876 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12877     ... transaction code...
12878     _xend ();
12879 @} else @{
12880     ... non transactional fallback path...
12882 @end smallexample
12884 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12886 @table @code
12887 @item _XABORT_EXPLICIT
12888 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12889 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12890 @item _XABORT_RETRY
12891 Transaction retry is possible.
12892 @item _XABORT_CONFLICT
12893 Transaction abort due to a memory conflict with another thread
12894 @item _XABORT_CAPACITY
12895 Transaction abort due to the transaction using too much memory
12896 @item _XABORT_DEBUG
12897 Transaction abort due to a debug trap
12898 @item _XABORT_NESTED
12899 Transaction abort in a inner nested transaction
12900 @end table
12902 @deftypefn {RTM Function} {void} _xend ()
12903 Commit the current transaction. When no transaction is active this will
12904 fault. All memory side effects of the transactions will become visible
12905 to other threads in an atomic matter.
12906 @end deftypefn
12908 @deftypefn {RTM Function} {int} _xtest ()
12909 Return a value not zero when a transaction is currently active, otherwise 0.
12910 @end deftypefn
12912 @deftypefn {RTM Function} {void} _xabort (status)
12913 Abort the current transaction. When no transaction is active this is a no-op.
12914 status must be a 8bit constant, that is included in the status code returned
12915 by @code{_xbegin}
12916 @end deftypefn
12918 @node MIPS DSP Built-in Functions
12919 @subsection MIPS DSP Built-in Functions
12921 The MIPS DSP Application-Specific Extension (ASE) includes new
12922 instructions that are designed to improve the performance of DSP and
12923 media applications.  It provides instructions that operate on packed
12924 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12926 GCC supports MIPS DSP operations using both the generic
12927 vector extensions (@pxref{Vector Extensions}) and a collection of
12928 MIPS-specific built-in functions.  Both kinds of support are
12929 enabled by the @option{-mdsp} command-line option.
12931 Revision 2 of the ASE was introduced in the second half of 2006.
12932 This revision adds extra instructions to the original ASE, but is
12933 otherwise backwards-compatible with it.  You can select revision 2
12934 using the command-line option @option{-mdspr2}; this option implies
12935 @option{-mdsp}.
12937 The SCOUNT and POS bits of the DSP control register are global.  The
12938 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12939 POS bits.  During optimization, the compiler does not delete these
12940 instructions and it does not delete calls to functions containing
12941 these instructions.
12943 At present, GCC only provides support for operations on 32-bit
12944 vectors.  The vector type associated with 8-bit integer data is
12945 usually called @code{v4i8}, the vector type associated with Q7
12946 is usually called @code{v4q7}, the vector type associated with 16-bit
12947 integer data is usually called @code{v2i16}, and the vector type
12948 associated with Q15 is usually called @code{v2q15}.  They can be
12949 defined in C as follows:
12951 @smallexample
12952 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12953 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12954 typedef short v2i16 __attribute__ ((vector_size(4)));
12955 typedef short v2q15 __attribute__ ((vector_size(4)));
12956 @end smallexample
12958 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12959 initialized in the same way as aggregates.  For example:
12961 @smallexample
12962 v4i8 a = @{1, 2, 3, 4@};
12963 v4i8 b;
12964 b = (v4i8) @{5, 6, 7, 8@};
12966 v2q15 c = @{0x0fcb, 0x3a75@};
12967 v2q15 d;
12968 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12969 @end smallexample
12971 @emph{Note:} The CPU's endianness determines the order in which values
12972 are packed.  On little-endian targets, the first value is the least
12973 significant and the last value is the most significant.  The opposite
12974 order applies to big-endian targets.  For example, the code above
12975 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12976 and @code{4} on big-endian targets.
12978 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12979 representation.  As shown in this example, the integer representation
12980 of a Q7 value can be obtained by multiplying the fractional value by
12981 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
12982 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
12983 @code{0x1.0p31}.
12985 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12986 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
12987 and @code{c} and @code{d} are @code{v2q15} values.
12989 @multitable @columnfractions .50 .50
12990 @item C code @tab MIPS instruction
12991 @item @code{a + b} @tab @code{addu.qb}
12992 @item @code{c + d} @tab @code{addq.ph}
12993 @item @code{a - b} @tab @code{subu.qb}
12994 @item @code{c - d} @tab @code{subq.ph}
12995 @end multitable
12997 The table below lists the @code{v2i16} operation for which
12998 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
12999 @code{v2i16} values.
13001 @multitable @columnfractions .50 .50
13002 @item C code @tab MIPS instruction
13003 @item @code{e * f} @tab @code{mul.ph}
13004 @end multitable
13006 It is easier to describe the DSP built-in functions if we first define
13007 the following types:
13009 @smallexample
13010 typedef int q31;
13011 typedef int i32;
13012 typedef unsigned int ui32;
13013 typedef long long a64;
13014 @end smallexample
13016 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13017 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13018 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13019 @code{long long}, but we use @code{a64} to indicate values that are
13020 placed in one of the four DSP accumulators (@code{$ac0},
13021 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13023 Also, some built-in functions prefer or require immediate numbers as
13024 parameters, because the corresponding DSP instructions accept both immediate
13025 numbers and register operands, or accept immediate numbers only.  The
13026 immediate parameters are listed as follows.
13028 @smallexample
13029 imm0_3: 0 to 3.
13030 imm0_7: 0 to 7.
13031 imm0_15: 0 to 15.
13032 imm0_31: 0 to 31.
13033 imm0_63: 0 to 63.
13034 imm0_255: 0 to 255.
13035 imm_n32_31: -32 to 31.
13036 imm_n512_511: -512 to 511.
13037 @end smallexample
13039 The following built-in functions map directly to a particular MIPS DSP
13040 instruction.  Please refer to the architecture specification
13041 for details on what each instruction does.
13043 @smallexample
13044 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13045 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13046 q31 __builtin_mips_addq_s_w (q31, q31)
13047 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13048 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13049 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13050 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13051 q31 __builtin_mips_subq_s_w (q31, q31)
13052 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13053 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13054 i32 __builtin_mips_addsc (i32, i32)
13055 i32 __builtin_mips_addwc (i32, i32)
13056 i32 __builtin_mips_modsub (i32, i32)
13057 i32 __builtin_mips_raddu_w_qb (v4i8)
13058 v2q15 __builtin_mips_absq_s_ph (v2q15)
13059 q31 __builtin_mips_absq_s_w (q31)
13060 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13061 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13062 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13063 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13064 q31 __builtin_mips_preceq_w_phl (v2q15)
13065 q31 __builtin_mips_preceq_w_phr (v2q15)
13066 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13067 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13068 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13069 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13070 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13071 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13072 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13073 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13074 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13075 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13076 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13077 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13078 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13079 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13080 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13081 q31 __builtin_mips_shll_s_w (q31, i32)
13082 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13083 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13084 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13085 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13086 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13087 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13088 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13089 q31 __builtin_mips_shra_r_w (q31, i32)
13090 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13091 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13092 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13093 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13094 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13095 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13096 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13097 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13098 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13099 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13100 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13101 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13102 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13103 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13104 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13105 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13106 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13107 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13108 i32 __builtin_mips_bitrev (i32)
13109 i32 __builtin_mips_insv (i32, i32)
13110 v4i8 __builtin_mips_repl_qb (imm0_255)
13111 v4i8 __builtin_mips_repl_qb (i32)
13112 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13113 v2q15 __builtin_mips_repl_ph (i32)
13114 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13115 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13116 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13117 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13118 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13119 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13120 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13121 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13122 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13123 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13124 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13125 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13126 i32 __builtin_mips_extr_w (a64, imm0_31)
13127 i32 __builtin_mips_extr_w (a64, i32)
13128 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13129 i32 __builtin_mips_extr_s_h (a64, i32)
13130 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13131 i32 __builtin_mips_extr_rs_w (a64, i32)
13132 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13133 i32 __builtin_mips_extr_r_w (a64, i32)
13134 i32 __builtin_mips_extp (a64, imm0_31)
13135 i32 __builtin_mips_extp (a64, i32)
13136 i32 __builtin_mips_extpdp (a64, imm0_31)
13137 i32 __builtin_mips_extpdp (a64, i32)
13138 a64 __builtin_mips_shilo (a64, imm_n32_31)
13139 a64 __builtin_mips_shilo (a64, i32)
13140 a64 __builtin_mips_mthlip (a64, i32)
13141 void __builtin_mips_wrdsp (i32, imm0_63)
13142 i32 __builtin_mips_rddsp (imm0_63)
13143 i32 __builtin_mips_lbux (void *, i32)
13144 i32 __builtin_mips_lhx (void *, i32)
13145 i32 __builtin_mips_lwx (void *, i32)
13146 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13147 i32 __builtin_mips_bposge32 (void)
13148 a64 __builtin_mips_madd (a64, i32, i32);
13149 a64 __builtin_mips_maddu (a64, ui32, ui32);
13150 a64 __builtin_mips_msub (a64, i32, i32);
13151 a64 __builtin_mips_msubu (a64, ui32, ui32);
13152 a64 __builtin_mips_mult (i32, i32);
13153 a64 __builtin_mips_multu (ui32, ui32);
13154 @end smallexample
13156 The following built-in functions map directly to a particular MIPS DSP REV 2
13157 instruction.  Please refer to the architecture specification
13158 for details on what each instruction does.
13160 @smallexample
13161 v4q7 __builtin_mips_absq_s_qb (v4q7);
13162 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13163 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13164 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13165 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13166 i32 __builtin_mips_append (i32, i32, imm0_31);
13167 i32 __builtin_mips_balign (i32, i32, imm0_3);
13168 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13169 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13170 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13171 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13172 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13173 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13174 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13175 q31 __builtin_mips_mulq_rs_w (q31, q31);
13176 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13177 q31 __builtin_mips_mulq_s_w (q31, q31);
13178 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13179 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13180 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13181 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13182 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13183 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13184 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13185 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13186 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13187 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13188 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13189 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13190 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13191 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13192 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13193 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13194 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13195 q31 __builtin_mips_addqh_w (q31, q31);
13196 q31 __builtin_mips_addqh_r_w (q31, q31);
13197 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13198 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13199 q31 __builtin_mips_subqh_w (q31, q31);
13200 q31 __builtin_mips_subqh_r_w (q31, q31);
13201 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13202 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13203 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13204 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13205 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13206 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13207 @end smallexample
13210 @node MIPS Paired-Single Support
13211 @subsection MIPS Paired-Single Support
13213 The MIPS64 architecture includes a number of instructions that
13214 operate on pairs of single-precision floating-point values.
13215 Each pair is packed into a 64-bit floating-point register,
13216 with one element being designated the ``upper half'' and
13217 the other being designated the ``lower half''.
13219 GCC supports paired-single operations using both the generic
13220 vector extensions (@pxref{Vector Extensions}) and a collection of
13221 MIPS-specific built-in functions.  Both kinds of support are
13222 enabled by the @option{-mpaired-single} command-line option.
13224 The vector type associated with paired-single values is usually
13225 called @code{v2sf}.  It can be defined in C as follows:
13227 @smallexample
13228 typedef float v2sf __attribute__ ((vector_size (8)));
13229 @end smallexample
13231 @code{v2sf} values are initialized in the same way as aggregates.
13232 For example:
13234 @smallexample
13235 v2sf a = @{1.5, 9.1@};
13236 v2sf b;
13237 float e, f;
13238 b = (v2sf) @{e, f@};
13239 @end smallexample
13241 @emph{Note:} The CPU's endianness determines which value is stored in
13242 the upper half of a register and which value is stored in the lower half.
13243 On little-endian targets, the first value is the lower one and the second
13244 value is the upper one.  The opposite order applies to big-endian targets.
13245 For example, the code above sets the lower half of @code{a} to
13246 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13248 @node MIPS Loongson Built-in Functions
13249 @subsection MIPS Loongson Built-in Functions
13251 GCC provides intrinsics to access the SIMD instructions provided by the
13252 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
13253 available after inclusion of the @code{loongson.h} header file,
13254 operate on the following 64-bit vector types:
13256 @itemize
13257 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13258 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13259 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13260 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13261 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13262 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13263 @end itemize
13265 The intrinsics provided are listed below; each is named after the
13266 machine instruction to which it corresponds, with suffixes added as
13267 appropriate to distinguish intrinsics that expand to the same machine
13268 instruction yet have different argument types.  Refer to the architecture
13269 documentation for a description of the functionality of each
13270 instruction.
13272 @smallexample
13273 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13274 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13275 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13276 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13277 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13278 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13279 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13280 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13281 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13282 uint64_t paddd_u (uint64_t s, uint64_t t);
13283 int64_t paddd_s (int64_t s, int64_t t);
13284 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13285 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13286 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13287 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13288 uint64_t pandn_ud (uint64_t s, uint64_t t);
13289 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13290 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13291 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13292 int64_t pandn_sd (int64_t s, int64_t t);
13293 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13294 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13295 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13296 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13297 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13298 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13299 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13300 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13301 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13302 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13303 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13304 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13305 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13306 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13307 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13308 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13309 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13310 uint16x4_t pextrh_u (uint16x4_t s, int field);
13311 int16x4_t pextrh_s (int16x4_t s, int field);
13312 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13313 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13314 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13315 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13316 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13317 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13318 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13319 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13320 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13321 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13322 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13323 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13324 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13325 uint8x8_t pmovmskb_u (uint8x8_t s);
13326 int8x8_t pmovmskb_s (int8x8_t s);
13327 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13328 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13329 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13330 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13331 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13332 uint16x4_t biadd (uint8x8_t s);
13333 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13334 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13335 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13336 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13337 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13338 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13339 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13340 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13341 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13342 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13343 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13344 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13345 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13346 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13347 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13348 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13349 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13350 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13351 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13352 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13353 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13354 uint64_t psubd_u (uint64_t s, uint64_t t);
13355 int64_t psubd_s (int64_t s, int64_t t);
13356 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13357 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13358 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13359 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13360 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13361 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13362 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13363 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13364 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13365 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13366 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13367 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13368 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13369 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13370 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13371 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13372 @end smallexample
13374 @menu
13375 * Paired-Single Arithmetic::
13376 * Paired-Single Built-in Functions::
13377 * MIPS-3D Built-in Functions::
13378 @end menu
13380 @node Paired-Single Arithmetic
13381 @subsubsection Paired-Single Arithmetic
13383 The table below lists the @code{v2sf} operations for which hardware
13384 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
13385 values and @code{x} is an integral value.
13387 @multitable @columnfractions .50 .50
13388 @item C code @tab MIPS instruction
13389 @item @code{a + b} @tab @code{add.ps}
13390 @item @code{a - b} @tab @code{sub.ps}
13391 @item @code{-a} @tab @code{neg.ps}
13392 @item @code{a * b} @tab @code{mul.ps}
13393 @item @code{a * b + c} @tab @code{madd.ps}
13394 @item @code{a * b - c} @tab @code{msub.ps}
13395 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13396 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13397 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13398 @end multitable
13400 Note that the multiply-accumulate instructions can be disabled
13401 using the command-line option @code{-mno-fused-madd}.
13403 @node Paired-Single Built-in Functions
13404 @subsubsection Paired-Single Built-in Functions
13406 The following paired-single functions map directly to a particular
13407 MIPS instruction.  Please refer to the architecture specification
13408 for details on what each instruction does.
13410 @table @code
13411 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13412 Pair lower lower (@code{pll.ps}).
13414 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13415 Pair upper lower (@code{pul.ps}).
13417 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13418 Pair lower upper (@code{plu.ps}).
13420 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13421 Pair upper upper (@code{puu.ps}).
13423 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13424 Convert pair to paired single (@code{cvt.ps.s}).
13426 @item float __builtin_mips_cvt_s_pl (v2sf)
13427 Convert pair lower to single (@code{cvt.s.pl}).
13429 @item float __builtin_mips_cvt_s_pu (v2sf)
13430 Convert pair upper to single (@code{cvt.s.pu}).
13432 @item v2sf __builtin_mips_abs_ps (v2sf)
13433 Absolute value (@code{abs.ps}).
13435 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13436 Align variable (@code{alnv.ps}).
13438 @emph{Note:} The value of the third parameter must be 0 or 4
13439 modulo 8, otherwise the result is unpredictable.  Please read the
13440 instruction description for details.
13441 @end table
13443 The following multi-instruction functions are also available.
13444 In each case, @var{cond} can be any of the 16 floating-point conditions:
13445 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13446 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13447 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13449 @table @code
13450 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13451 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13452 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13453 @code{movt.ps}/@code{movf.ps}).
13455 The @code{movt} functions return the value @var{x} computed by:
13457 @smallexample
13458 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13459 mov.ps @var{x},@var{c}
13460 movt.ps @var{x},@var{d},@var{cc}
13461 @end smallexample
13463 The @code{movf} functions are similar but use @code{movf.ps} instead
13464 of @code{movt.ps}.
13466 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13467 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13468 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13469 @code{bc1t}/@code{bc1f}).
13471 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13472 and return either the upper or lower half of the result.  For example:
13474 @smallexample
13475 v2sf a, b;
13476 if (__builtin_mips_upper_c_eq_ps (a, b))
13477   upper_halves_are_equal ();
13478 else
13479   upper_halves_are_unequal ();
13481 if (__builtin_mips_lower_c_eq_ps (a, b))
13482   lower_halves_are_equal ();
13483 else
13484   lower_halves_are_unequal ();
13485 @end smallexample
13486 @end table
13488 @node MIPS-3D Built-in Functions
13489 @subsubsection MIPS-3D Built-in Functions
13491 The MIPS-3D Application-Specific Extension (ASE) includes additional
13492 paired-single instructions that are designed to improve the performance
13493 of 3D graphics operations.  Support for these instructions is controlled
13494 by the @option{-mips3d} command-line option.
13496 The functions listed below map directly to a particular MIPS-3D
13497 instruction.  Please refer to the architecture specification for
13498 more details on what each instruction does.
13500 @table @code
13501 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13502 Reduction add (@code{addr.ps}).
13504 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13505 Reduction multiply (@code{mulr.ps}).
13507 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13508 Convert paired single to paired word (@code{cvt.pw.ps}).
13510 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13511 Convert paired word to paired single (@code{cvt.ps.pw}).
13513 @item float __builtin_mips_recip1_s (float)
13514 @itemx double __builtin_mips_recip1_d (double)
13515 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13516 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13518 @item float __builtin_mips_recip2_s (float, float)
13519 @itemx double __builtin_mips_recip2_d (double, double)
13520 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13521 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13523 @item float __builtin_mips_rsqrt1_s (float)
13524 @itemx double __builtin_mips_rsqrt1_d (double)
13525 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13526 Reduced-precision reciprocal square root (sequence step 1)
13527 (@code{rsqrt1.@var{fmt}}).
13529 @item float __builtin_mips_rsqrt2_s (float, float)
13530 @itemx double __builtin_mips_rsqrt2_d (double, double)
13531 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13532 Reduced-precision reciprocal square root (sequence step 2)
13533 (@code{rsqrt2.@var{fmt}}).
13534 @end table
13536 The following multi-instruction functions are also available.
13537 In each case, @var{cond} can be any of the 16 floating-point conditions:
13538 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13539 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13540 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13542 @table @code
13543 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13544 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13545 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13546 @code{bc1t}/@code{bc1f}).
13548 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13549 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13550 For example:
13552 @smallexample
13553 float a, b;
13554 if (__builtin_mips_cabs_eq_s (a, b))
13555   true ();
13556 else
13557   false ();
13558 @end smallexample
13560 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13561 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13562 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13563 @code{bc1t}/@code{bc1f}).
13565 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13566 and return either the upper or lower half of the result.  For example:
13568 @smallexample
13569 v2sf a, b;
13570 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13571   upper_halves_are_equal ();
13572 else
13573   upper_halves_are_unequal ();
13575 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13576   lower_halves_are_equal ();
13577 else
13578   lower_halves_are_unequal ();
13579 @end smallexample
13581 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13582 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13583 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13584 @code{movt.ps}/@code{movf.ps}).
13586 The @code{movt} functions return the value @var{x} computed by:
13588 @smallexample
13589 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13590 mov.ps @var{x},@var{c}
13591 movt.ps @var{x},@var{d},@var{cc}
13592 @end smallexample
13594 The @code{movf} functions are similar but use @code{movf.ps} instead
13595 of @code{movt.ps}.
13597 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13598 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13599 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13600 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13601 Comparison of two paired-single values
13602 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13603 @code{bc1any2t}/@code{bc1any2f}).
13605 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13606 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13607 result is true and the @code{all} forms return true if both results are true.
13608 For example:
13610 @smallexample
13611 v2sf a, b;
13612 if (__builtin_mips_any_c_eq_ps (a, b))
13613   one_is_true ();
13614 else
13615   both_are_false ();
13617 if (__builtin_mips_all_c_eq_ps (a, b))
13618   both_are_true ();
13619 else
13620   one_is_false ();
13621 @end smallexample
13623 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13624 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13625 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13626 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13627 Comparison of four paired-single values
13628 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13629 @code{bc1any4t}/@code{bc1any4f}).
13631 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13632 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13633 The @code{any} forms return true if any of the four results are true
13634 and the @code{all} forms return true if all four results are true.
13635 For example:
13637 @smallexample
13638 v2sf a, b, c, d;
13639 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13640   some_are_true ();
13641 else
13642   all_are_false ();
13644 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13645   all_are_true ();
13646 else
13647   some_are_false ();
13648 @end smallexample
13649 @end table
13651 @node Other MIPS Built-in Functions
13652 @subsection Other MIPS Built-in Functions
13654 GCC provides other MIPS-specific built-in functions:
13656 @table @code
13657 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13658 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13659 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13660 when this function is available.
13662 @item unsigned int __builtin_mips_get_fcsr (void)
13663 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13664 Get and set the contents of the floating-point control and status register
13665 (FPU control register 31).  These functions are only available in hard-float
13666 code but can be called in both MIPS16 and non-MIPS16 contexts.
13668 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13669 register except the condition codes, which GCC assumes are preserved.
13670 @end table
13672 @node MSP430 Built-in Functions
13673 @subsection MSP430 Built-in Functions
13675 GCC provides a couple of special builtin functions to aid in the
13676 writing of interrupt handlers in C.
13678 @table @code
13679 @item __bic_SR_register_on_exit (int @var{mask})
13680 This clears the indicated bits in the saved copy of the status register
13681 currently residing on the stack.  This only works inside interrupt
13682 handlers and the changes to the status register will only take affect
13683 once the handler returns.
13685 @item __bis_SR_register_on_exit (int @var{mask})
13686 This sets the indicated bits in the saved copy of the status register
13687 currently residing on the stack.  This only works inside interrupt
13688 handlers and the changes to the status register will only take affect
13689 once the handler returns.
13691 @item __delay_cycles (long long @var{cycles})
13692 This inserts an instruction sequence that takes exactly @var{cycles}
13693 cycles (between 0 and about 17E9) to complete.  The inserted sequence
13694 may use jumps, loops, or no-ops, and does not interfere with any other
13695 instructions.  Note that @var{cycles} must be a compile-time constant
13696 integer - that is, you must pass a number, not a variable that may be
13697 optimized to a constant later.  The number of cycles delayed by this
13698 builtin is exact.
13699 @end table
13701 @node NDS32 Built-in Functions
13702 @subsection NDS32 Built-in Functions
13704 These built-in functions are available for the NDS32 target:
13706 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13707 Insert an ISYNC instruction into the instruction stream where
13708 @var{addr} is an instruction address for serialization.
13709 @end deftypefn
13711 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13712 Insert an ISB instruction into the instruction stream.
13713 @end deftypefn
13715 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13716 Return the content of a system register which is mapped by @var{sr}.
13717 @end deftypefn
13719 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13720 Return the content of a user space register which is mapped by @var{usr}.
13721 @end deftypefn
13723 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13724 Move the @var{value} to a system register which is mapped by @var{sr}.
13725 @end deftypefn
13727 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13728 Move the @var{value} to a user space register which is mapped by @var{usr}.
13729 @end deftypefn
13731 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13732 Enable global interrupt.
13733 @end deftypefn
13735 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13736 Disable global interrupt.
13737 @end deftypefn
13739 @node picoChip Built-in Functions
13740 @subsection picoChip Built-in Functions
13742 GCC provides an interface to selected machine instructions from the
13743 picoChip instruction set.
13745 @table @code
13746 @item int __builtin_sbc (int @var{value})
13747 Sign bit count.  Return the number of consecutive bits in @var{value}
13748 that have the same value as the sign bit.  The result is the number of
13749 leading sign bits minus one, giving the number of redundant sign bits in
13750 @var{value}.
13752 @item int __builtin_byteswap (int @var{value})
13753 Byte swap.  Return the result of swapping the upper and lower bytes of
13754 @var{value}.
13756 @item int __builtin_brev (int @var{value})
13757 Bit reversal.  Return the result of reversing the bits in
13758 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13759 and so on.
13761 @item int __builtin_adds (int @var{x}, int @var{y})
13762 Saturating addition.  Return the result of adding @var{x} and @var{y},
13763 storing the value 32767 if the result overflows.
13765 @item int __builtin_subs (int @var{x}, int @var{y})
13766 Saturating subtraction.  Return the result of subtracting @var{y} from
13767 @var{x}, storing the value @minus{}32768 if the result overflows.
13769 @item void __builtin_halt (void)
13770 Halt.  The processor stops execution.  This built-in is useful for
13771 implementing assertions.
13773 @end table
13775 @node PowerPC Built-in Functions
13776 @subsection PowerPC Built-in Functions
13778 These built-in functions are available for the PowerPC family of
13779 processors:
13780 @smallexample
13781 float __builtin_recipdivf (float, float);
13782 float __builtin_rsqrtf (float);
13783 double __builtin_recipdiv (double, double);
13784 double __builtin_rsqrt (double);
13785 uint64_t __builtin_ppc_get_timebase ();
13786 unsigned long __builtin_ppc_mftb ();
13787 double __builtin_unpack_longdouble (long double, int);
13788 long double __builtin_pack_longdouble (double, double);
13789 @end smallexample
13791 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13792 @code{__builtin_rsqrtf} functions generate multiple instructions to
13793 implement the reciprocal sqrt functionality using reciprocal sqrt
13794 estimate instructions.
13796 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13797 functions generate multiple instructions to implement division using
13798 the reciprocal estimate instructions.
13800 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13801 functions generate instructions to read the Time Base Register.  The
13802 @code{__builtin_ppc_get_timebase} function may generate multiple
13803 instructions and always returns the 64 bits of the Time Base Register.
13804 The @code{__builtin_ppc_mftb} function always generates one instruction and
13805 returns the Time Base Register value as an unsigned long, throwing away
13806 the most significant word on 32-bit environments.
13808 The following built-in functions are available for the PowerPC family
13809 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13810 or @option{-mpopcntd}):
13811 @smallexample
13812 long __builtin_bpermd (long, long);
13813 int __builtin_divwe (int, int);
13814 int __builtin_divweo (int, int);
13815 unsigned int __builtin_divweu (unsigned int, unsigned int);
13816 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13817 long __builtin_divde (long, long);
13818 long __builtin_divdeo (long, long);
13819 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13820 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13821 unsigned int cdtbcd (unsigned int);
13822 unsigned int cbcdtd (unsigned int);
13823 unsigned int addg6s (unsigned int, unsigned int);
13824 @end smallexample
13826 The @code{__builtin_divde}, @code{__builtin_divdeo},
13827 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13828 64-bit environment support ISA 2.06 or later.
13830 The following built-in functions are available for the PowerPC family
13831 of processors when hardware decimal floating point
13832 (@option{-mhard-dfp}) is available:
13833 @smallexample
13834 _Decimal64 __builtin_dxex (_Decimal64);
13835 _Decimal128 __builtin_dxexq (_Decimal128);
13836 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13837 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13838 _Decimal64 __builtin_denbcd (int, _Decimal64);
13839 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13840 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13841 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13842 _Decimal64 __builtin_dscli (_Decimal64, int);
13843 _Decimal128 __builitn_dscliq (_Decimal128, int);
13844 _Decimal64 __builtin_dscri (_Decimal64, int);
13845 _Decimal128 __builitn_dscriq (_Decimal128, int);
13846 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13847 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13848 @end smallexample
13850 The following built-in functions are available for the PowerPC family
13851 of processors when the Vector Scalar (vsx) instruction set is
13852 available:
13853 @smallexample
13854 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13855 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13856                                                 unsigned long long);
13857 @end smallexample
13859 @node PowerPC AltiVec/VSX Built-in Functions
13860 @subsection PowerPC AltiVec Built-in Functions
13862 GCC provides an interface for the PowerPC family of processors to access
13863 the AltiVec operations described in Motorola's AltiVec Programming
13864 Interface Manual.  The interface is made available by including
13865 @code{<altivec.h>} and using @option{-maltivec} and
13866 @option{-mabi=altivec}.  The interface supports the following vector
13867 types.
13869 @smallexample
13870 vector unsigned char
13871 vector signed char
13872 vector bool char
13874 vector unsigned short
13875 vector signed short
13876 vector bool short
13877 vector pixel
13879 vector unsigned int
13880 vector signed int
13881 vector bool int
13882 vector float
13883 @end smallexample
13885 If @option{-mvsx} is used the following additional vector types are
13886 implemented.
13888 @smallexample
13889 vector unsigned long
13890 vector signed long
13891 vector double
13892 @end smallexample
13894 The long types are only implemented for 64-bit code generation, and
13895 the long type is only used in the floating point/integer conversion
13896 instructions.
13898 GCC's implementation of the high-level language interface available from
13899 C and C++ code differs from Motorola's documentation in several ways.
13901 @itemize @bullet
13903 @item
13904 A vector constant is a list of constant expressions within curly braces.
13906 @item
13907 A vector initializer requires no cast if the vector constant is of the
13908 same type as the variable it is initializing.
13910 @item
13911 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13912 vector type is the default signedness of the base type.  The default
13913 varies depending on the operating system, so a portable program should
13914 always specify the signedness.
13916 @item
13917 Compiling with @option{-maltivec} adds keywords @code{__vector},
13918 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13919 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13920 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13921 disabled.  To use them, you must include @code{<altivec.h>} instead.
13923 @item
13924 GCC allows using a @code{typedef} name as the type specifier for a
13925 vector type.
13927 @item
13928 For C, overloaded functions are implemented with macros so the following
13929 does not work:
13931 @smallexample
13932   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13933 @end smallexample
13935 @noindent
13936 Since @code{vec_add} is a macro, the vector constant in the example
13937 is treated as four separate arguments.  Wrap the entire argument in
13938 parentheses for this to work.
13939 @end itemize
13941 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13942 Internally, GCC uses built-in functions to achieve the functionality in
13943 the aforementioned header file, but they are not supported and are
13944 subject to change without notice.
13946 The following interfaces are supported for the generic and specific
13947 AltiVec operations and the AltiVec predicates.  In cases where there
13948 is a direct mapping between generic and specific operations, only the
13949 generic names are shown here, although the specific operations can also
13950 be used.
13952 Arguments that are documented as @code{const int} require literal
13953 integral values within the range required for that operation.
13955 @smallexample
13956 vector signed char vec_abs (vector signed char);
13957 vector signed short vec_abs (vector signed short);
13958 vector signed int vec_abs (vector signed int);
13959 vector float vec_abs (vector float);
13961 vector signed char vec_abss (vector signed char);
13962 vector signed short vec_abss (vector signed short);
13963 vector signed int vec_abss (vector signed int);
13965 vector signed char vec_add (vector bool char, vector signed char);
13966 vector signed char vec_add (vector signed char, vector bool char);
13967 vector signed char vec_add (vector signed char, vector signed char);
13968 vector unsigned char vec_add (vector bool char, vector unsigned char);
13969 vector unsigned char vec_add (vector unsigned char, vector bool char);
13970 vector unsigned char vec_add (vector unsigned char,
13971                               vector unsigned char);
13972 vector signed short vec_add (vector bool short, vector signed short);
13973 vector signed short vec_add (vector signed short, vector bool short);
13974 vector signed short vec_add (vector signed short, vector signed short);
13975 vector unsigned short vec_add (vector bool short,
13976                                vector unsigned short);
13977 vector unsigned short vec_add (vector unsigned short,
13978                                vector bool short);
13979 vector unsigned short vec_add (vector unsigned short,
13980                                vector unsigned short);
13981 vector signed int vec_add (vector bool int, vector signed int);
13982 vector signed int vec_add (vector signed int, vector bool int);
13983 vector signed int vec_add (vector signed int, vector signed int);
13984 vector unsigned int vec_add (vector bool int, vector unsigned int);
13985 vector unsigned int vec_add (vector unsigned int, vector bool int);
13986 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13987 vector float vec_add (vector float, vector float);
13989 vector float vec_vaddfp (vector float, vector float);
13991 vector signed int vec_vadduwm (vector bool int, vector signed int);
13992 vector signed int vec_vadduwm (vector signed int, vector bool int);
13993 vector signed int vec_vadduwm (vector signed int, vector signed int);
13994 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13995 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13996 vector unsigned int vec_vadduwm (vector unsigned int,
13997                                  vector unsigned int);
13999 vector signed short vec_vadduhm (vector bool short,
14000                                  vector signed short);
14001 vector signed short vec_vadduhm (vector signed short,
14002                                  vector bool short);
14003 vector signed short vec_vadduhm (vector signed short,
14004                                  vector signed short);
14005 vector unsigned short vec_vadduhm (vector bool short,
14006                                    vector unsigned short);
14007 vector unsigned short vec_vadduhm (vector unsigned short,
14008                                    vector bool short);
14009 vector unsigned short vec_vadduhm (vector unsigned short,
14010                                    vector unsigned short);
14012 vector signed char vec_vaddubm (vector bool char, vector signed char);
14013 vector signed char vec_vaddubm (vector signed char, vector bool char);
14014 vector signed char vec_vaddubm (vector signed char, vector signed char);
14015 vector unsigned char vec_vaddubm (vector bool char,
14016                                   vector unsigned char);
14017 vector unsigned char vec_vaddubm (vector unsigned char,
14018                                   vector bool char);
14019 vector unsigned char vec_vaddubm (vector unsigned char,
14020                                   vector unsigned char);
14022 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14024 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14025 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14026 vector unsigned char vec_adds (vector unsigned char,
14027                                vector unsigned char);
14028 vector signed char vec_adds (vector bool char, vector signed char);
14029 vector signed char vec_adds (vector signed char, vector bool char);
14030 vector signed char vec_adds (vector signed char, vector signed char);
14031 vector unsigned short vec_adds (vector bool short,
14032                                 vector unsigned short);
14033 vector unsigned short vec_adds (vector unsigned short,
14034                                 vector bool short);
14035 vector unsigned short vec_adds (vector unsigned short,
14036                                 vector unsigned short);
14037 vector signed short vec_adds (vector bool short, vector signed short);
14038 vector signed short vec_adds (vector signed short, vector bool short);
14039 vector signed short vec_adds (vector signed short, vector signed short);
14040 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14041 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14042 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14043 vector signed int vec_adds (vector bool int, vector signed int);
14044 vector signed int vec_adds (vector signed int, vector bool int);
14045 vector signed int vec_adds (vector signed int, vector signed int);
14047 vector signed int vec_vaddsws (vector bool int, vector signed int);
14048 vector signed int vec_vaddsws (vector signed int, vector bool int);
14049 vector signed int vec_vaddsws (vector signed int, vector signed int);
14051 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14052 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14053 vector unsigned int vec_vadduws (vector unsigned int,
14054                                  vector unsigned int);
14056 vector signed short vec_vaddshs (vector bool short,
14057                                  vector signed short);
14058 vector signed short vec_vaddshs (vector signed short,
14059                                  vector bool short);
14060 vector signed short vec_vaddshs (vector signed short,
14061                                  vector signed short);
14063 vector unsigned short vec_vadduhs (vector bool short,
14064                                    vector unsigned short);
14065 vector unsigned short vec_vadduhs (vector unsigned short,
14066                                    vector bool short);
14067 vector unsigned short vec_vadduhs (vector unsigned short,
14068                                    vector unsigned short);
14070 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14071 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14072 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14074 vector unsigned char vec_vaddubs (vector bool char,
14075                                   vector unsigned char);
14076 vector unsigned char vec_vaddubs (vector unsigned char,
14077                                   vector bool char);
14078 vector unsigned char vec_vaddubs (vector unsigned char,
14079                                   vector unsigned char);
14081 vector float vec_and (vector float, vector float);
14082 vector float vec_and (vector float, vector bool int);
14083 vector float vec_and (vector bool int, vector float);
14084 vector bool int vec_and (vector bool int, vector bool int);
14085 vector signed int vec_and (vector bool int, vector signed int);
14086 vector signed int vec_and (vector signed int, vector bool int);
14087 vector signed int vec_and (vector signed int, vector signed int);
14088 vector unsigned int vec_and (vector bool int, vector unsigned int);
14089 vector unsigned int vec_and (vector unsigned int, vector bool int);
14090 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14091 vector bool short vec_and (vector bool short, vector bool short);
14092 vector signed short vec_and (vector bool short, vector signed short);
14093 vector signed short vec_and (vector signed short, vector bool short);
14094 vector signed short vec_and (vector signed short, vector signed short);
14095 vector unsigned short vec_and (vector bool short,
14096                                vector unsigned short);
14097 vector unsigned short vec_and (vector unsigned short,
14098                                vector bool short);
14099 vector unsigned short vec_and (vector unsigned short,
14100                                vector unsigned short);
14101 vector signed char vec_and (vector bool char, vector signed char);
14102 vector bool char vec_and (vector bool char, vector bool char);
14103 vector signed char vec_and (vector signed char, vector bool char);
14104 vector signed char vec_and (vector signed char, vector signed char);
14105 vector unsigned char vec_and (vector bool char, vector unsigned char);
14106 vector unsigned char vec_and (vector unsigned char, vector bool char);
14107 vector unsigned char vec_and (vector unsigned char,
14108                               vector unsigned char);
14110 vector float vec_andc (vector float, vector float);
14111 vector float vec_andc (vector float, vector bool int);
14112 vector float vec_andc (vector bool int, vector float);
14113 vector bool int vec_andc (vector bool int, vector bool int);
14114 vector signed int vec_andc (vector bool int, vector signed int);
14115 vector signed int vec_andc (vector signed int, vector bool int);
14116 vector signed int vec_andc (vector signed int, vector signed int);
14117 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14118 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14119 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14120 vector bool short vec_andc (vector bool short, vector bool short);
14121 vector signed short vec_andc (vector bool short, vector signed short);
14122 vector signed short vec_andc (vector signed short, vector bool short);
14123 vector signed short vec_andc (vector signed short, vector signed short);
14124 vector unsigned short vec_andc (vector bool short,
14125                                 vector unsigned short);
14126 vector unsigned short vec_andc (vector unsigned short,
14127                                 vector bool short);
14128 vector unsigned short vec_andc (vector unsigned short,
14129                                 vector unsigned short);
14130 vector signed char vec_andc (vector bool char, vector signed char);
14131 vector bool char vec_andc (vector bool char, vector bool char);
14132 vector signed char vec_andc (vector signed char, vector bool char);
14133 vector signed char vec_andc (vector signed char, vector signed char);
14134 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14135 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14136 vector unsigned char vec_andc (vector unsigned char,
14137                                vector unsigned char);
14139 vector unsigned char vec_avg (vector unsigned char,
14140                               vector unsigned char);
14141 vector signed char vec_avg (vector signed char, vector signed char);
14142 vector unsigned short vec_avg (vector unsigned short,
14143                                vector unsigned short);
14144 vector signed short vec_avg (vector signed short, vector signed short);
14145 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14146 vector signed int vec_avg (vector signed int, vector signed int);
14148 vector signed int vec_vavgsw (vector signed int, vector signed int);
14150 vector unsigned int vec_vavguw (vector unsigned int,
14151                                 vector unsigned int);
14153 vector signed short vec_vavgsh (vector signed short,
14154                                 vector signed short);
14156 vector unsigned short vec_vavguh (vector unsigned short,
14157                                   vector unsigned short);
14159 vector signed char vec_vavgsb (vector signed char, vector signed char);
14161 vector unsigned char vec_vavgub (vector unsigned char,
14162                                  vector unsigned char);
14164 vector float vec_copysign (vector float);
14166 vector float vec_ceil (vector float);
14168 vector signed int vec_cmpb (vector float, vector float);
14170 vector bool char vec_cmpeq (vector signed char, vector signed char);
14171 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14172 vector bool short vec_cmpeq (vector signed short, vector signed short);
14173 vector bool short vec_cmpeq (vector unsigned short,
14174                              vector unsigned short);
14175 vector bool int vec_cmpeq (vector signed int, vector signed int);
14176 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14177 vector bool int vec_cmpeq (vector float, vector float);
14179 vector bool int vec_vcmpeqfp (vector float, vector float);
14181 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14182 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14184 vector bool short vec_vcmpequh (vector signed short,
14185                                 vector signed short);
14186 vector bool short vec_vcmpequh (vector unsigned short,
14187                                 vector unsigned short);
14189 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14190 vector bool char vec_vcmpequb (vector unsigned char,
14191                                vector unsigned char);
14193 vector bool int vec_cmpge (vector float, vector float);
14195 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14196 vector bool char vec_cmpgt (vector signed char, vector signed char);
14197 vector bool short vec_cmpgt (vector unsigned short,
14198                              vector unsigned short);
14199 vector bool short vec_cmpgt (vector signed short, vector signed short);
14200 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14201 vector bool int vec_cmpgt (vector signed int, vector signed int);
14202 vector bool int vec_cmpgt (vector float, vector float);
14204 vector bool int vec_vcmpgtfp (vector float, vector float);
14206 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14208 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14210 vector bool short vec_vcmpgtsh (vector signed short,
14211                                 vector signed short);
14213 vector bool short vec_vcmpgtuh (vector unsigned short,
14214                                 vector unsigned short);
14216 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14218 vector bool char vec_vcmpgtub (vector unsigned char,
14219                                vector unsigned char);
14221 vector bool int vec_cmple (vector float, vector float);
14223 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14224 vector bool char vec_cmplt (vector signed char, vector signed char);
14225 vector bool short vec_cmplt (vector unsigned short,
14226                              vector unsigned short);
14227 vector bool short vec_cmplt (vector signed short, vector signed short);
14228 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14229 vector bool int vec_cmplt (vector signed int, vector signed int);
14230 vector bool int vec_cmplt (vector float, vector float);
14232 vector float vec_cpsgn (vector float, vector float);
14234 vector float vec_ctf (vector unsigned int, const int);
14235 vector float vec_ctf (vector signed int, const int);
14236 vector double vec_ctf (vector unsigned long, const int);
14237 vector double vec_ctf (vector signed long, const int);
14239 vector float vec_vcfsx (vector signed int, const int);
14241 vector float vec_vcfux (vector unsigned int, const int);
14243 vector signed int vec_cts (vector float, const int);
14244 vector signed long vec_cts (vector double, const int);
14246 vector unsigned int vec_ctu (vector float, const int);
14247 vector unsigned long vec_ctu (vector double, const int);
14249 void vec_dss (const int);
14251 void vec_dssall (void);
14253 void vec_dst (const vector unsigned char *, int, const int);
14254 void vec_dst (const vector signed char *, int, const int);
14255 void vec_dst (const vector bool char *, int, const int);
14256 void vec_dst (const vector unsigned short *, int, const int);
14257 void vec_dst (const vector signed short *, int, const int);
14258 void vec_dst (const vector bool short *, int, const int);
14259 void vec_dst (const vector pixel *, int, const int);
14260 void vec_dst (const vector unsigned int *, int, const int);
14261 void vec_dst (const vector signed int *, int, const int);
14262 void vec_dst (const vector bool int *, int, const int);
14263 void vec_dst (const vector float *, int, const int);
14264 void vec_dst (const unsigned char *, int, const int);
14265 void vec_dst (const signed char *, int, const int);
14266 void vec_dst (const unsigned short *, int, const int);
14267 void vec_dst (const short *, int, const int);
14268 void vec_dst (const unsigned int *, int, const int);
14269 void vec_dst (const int *, int, const int);
14270 void vec_dst (const unsigned long *, int, const int);
14271 void vec_dst (const long *, int, const int);
14272 void vec_dst (const float *, int, const int);
14274 void vec_dstst (const vector unsigned char *, int, const int);
14275 void vec_dstst (const vector signed char *, int, const int);
14276 void vec_dstst (const vector bool char *, int, const int);
14277 void vec_dstst (const vector unsigned short *, int, const int);
14278 void vec_dstst (const vector signed short *, int, const int);
14279 void vec_dstst (const vector bool short *, int, const int);
14280 void vec_dstst (const vector pixel *, int, const int);
14281 void vec_dstst (const vector unsigned int *, int, const int);
14282 void vec_dstst (const vector signed int *, int, const int);
14283 void vec_dstst (const vector bool int *, int, const int);
14284 void vec_dstst (const vector float *, int, const int);
14285 void vec_dstst (const unsigned char *, int, const int);
14286 void vec_dstst (const signed char *, int, const int);
14287 void vec_dstst (const unsigned short *, int, const int);
14288 void vec_dstst (const short *, int, const int);
14289 void vec_dstst (const unsigned int *, int, const int);
14290 void vec_dstst (const int *, int, const int);
14291 void vec_dstst (const unsigned long *, int, const int);
14292 void vec_dstst (const long *, int, const int);
14293 void vec_dstst (const float *, int, const int);
14295 void vec_dststt (const vector unsigned char *, int, const int);
14296 void vec_dststt (const vector signed char *, int, const int);
14297 void vec_dststt (const vector bool char *, int, const int);
14298 void vec_dststt (const vector unsigned short *, int, const int);
14299 void vec_dststt (const vector signed short *, int, const int);
14300 void vec_dststt (const vector bool short *, int, const int);
14301 void vec_dststt (const vector pixel *, int, const int);
14302 void vec_dststt (const vector unsigned int *, int, const int);
14303 void vec_dststt (const vector signed int *, int, const int);
14304 void vec_dststt (const vector bool int *, int, const int);
14305 void vec_dststt (const vector float *, int, const int);
14306 void vec_dststt (const unsigned char *, int, const int);
14307 void vec_dststt (const signed char *, int, const int);
14308 void vec_dststt (const unsigned short *, int, const int);
14309 void vec_dststt (const short *, int, const int);
14310 void vec_dststt (const unsigned int *, int, const int);
14311 void vec_dststt (const int *, int, const int);
14312 void vec_dststt (const unsigned long *, int, const int);
14313 void vec_dststt (const long *, int, const int);
14314 void vec_dststt (const float *, int, const int);
14316 void vec_dstt (const vector unsigned char *, int, const int);
14317 void vec_dstt (const vector signed char *, int, const int);
14318 void vec_dstt (const vector bool char *, int, const int);
14319 void vec_dstt (const vector unsigned short *, int, const int);
14320 void vec_dstt (const vector signed short *, int, const int);
14321 void vec_dstt (const vector bool short *, int, const int);
14322 void vec_dstt (const vector pixel *, int, const int);
14323 void vec_dstt (const vector unsigned int *, int, const int);
14324 void vec_dstt (const vector signed int *, int, const int);
14325 void vec_dstt (const vector bool int *, int, const int);
14326 void vec_dstt (const vector float *, int, const int);
14327 void vec_dstt (const unsigned char *, int, const int);
14328 void vec_dstt (const signed char *, int, const int);
14329 void vec_dstt (const unsigned short *, int, const int);
14330 void vec_dstt (const short *, int, const int);
14331 void vec_dstt (const unsigned int *, int, const int);
14332 void vec_dstt (const int *, int, const int);
14333 void vec_dstt (const unsigned long *, int, const int);
14334 void vec_dstt (const long *, int, const int);
14335 void vec_dstt (const float *, int, const int);
14337 vector float vec_expte (vector float);
14339 vector float vec_floor (vector float);
14341 vector float vec_ld (int, const vector float *);
14342 vector float vec_ld (int, const float *);
14343 vector bool int vec_ld (int, const vector bool int *);
14344 vector signed int vec_ld (int, const vector signed int *);
14345 vector signed int vec_ld (int, const int *);
14346 vector signed int vec_ld (int, const long *);
14347 vector unsigned int vec_ld (int, const vector unsigned int *);
14348 vector unsigned int vec_ld (int, const unsigned int *);
14349 vector unsigned int vec_ld (int, const unsigned long *);
14350 vector bool short vec_ld (int, const vector bool short *);
14351 vector pixel vec_ld (int, const vector pixel *);
14352 vector signed short vec_ld (int, const vector signed short *);
14353 vector signed short vec_ld (int, const short *);
14354 vector unsigned short vec_ld (int, const vector unsigned short *);
14355 vector unsigned short vec_ld (int, const unsigned short *);
14356 vector bool char vec_ld (int, const vector bool char *);
14357 vector signed char vec_ld (int, const vector signed char *);
14358 vector signed char vec_ld (int, const signed char *);
14359 vector unsigned char vec_ld (int, const vector unsigned char *);
14360 vector unsigned char vec_ld (int, const unsigned char *);
14362 vector signed char vec_lde (int, const signed char *);
14363 vector unsigned char vec_lde (int, const unsigned char *);
14364 vector signed short vec_lde (int, const short *);
14365 vector unsigned short vec_lde (int, const unsigned short *);
14366 vector float vec_lde (int, const float *);
14367 vector signed int vec_lde (int, const int *);
14368 vector unsigned int vec_lde (int, const unsigned int *);
14369 vector signed int vec_lde (int, const long *);
14370 vector unsigned int vec_lde (int, const unsigned long *);
14372 vector float vec_lvewx (int, float *);
14373 vector signed int vec_lvewx (int, int *);
14374 vector unsigned int vec_lvewx (int, unsigned int *);
14375 vector signed int vec_lvewx (int, long *);
14376 vector unsigned int vec_lvewx (int, unsigned long *);
14378 vector signed short vec_lvehx (int, short *);
14379 vector unsigned short vec_lvehx (int, unsigned short *);
14381 vector signed char vec_lvebx (int, char *);
14382 vector unsigned char vec_lvebx (int, unsigned char *);
14384 vector float vec_ldl (int, const vector float *);
14385 vector float vec_ldl (int, const float *);
14386 vector bool int vec_ldl (int, const vector bool int *);
14387 vector signed int vec_ldl (int, const vector signed int *);
14388 vector signed int vec_ldl (int, const int *);
14389 vector signed int vec_ldl (int, const long *);
14390 vector unsigned int vec_ldl (int, const vector unsigned int *);
14391 vector unsigned int vec_ldl (int, const unsigned int *);
14392 vector unsigned int vec_ldl (int, const unsigned long *);
14393 vector bool short vec_ldl (int, const vector bool short *);
14394 vector pixel vec_ldl (int, const vector pixel *);
14395 vector signed short vec_ldl (int, const vector signed short *);
14396 vector signed short vec_ldl (int, const short *);
14397 vector unsigned short vec_ldl (int, const vector unsigned short *);
14398 vector unsigned short vec_ldl (int, const unsigned short *);
14399 vector bool char vec_ldl (int, const vector bool char *);
14400 vector signed char vec_ldl (int, const vector signed char *);
14401 vector signed char vec_ldl (int, const signed char *);
14402 vector unsigned char vec_ldl (int, const vector unsigned char *);
14403 vector unsigned char vec_ldl (int, const unsigned char *);
14405 vector float vec_loge (vector float);
14407 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14408 vector unsigned char vec_lvsl (int, const volatile signed char *);
14409 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14410 vector unsigned char vec_lvsl (int, const volatile short *);
14411 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14412 vector unsigned char vec_lvsl (int, const volatile int *);
14413 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14414 vector unsigned char vec_lvsl (int, const volatile long *);
14415 vector unsigned char vec_lvsl (int, const volatile float *);
14417 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14418 vector unsigned char vec_lvsr (int, const volatile signed char *);
14419 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14420 vector unsigned char vec_lvsr (int, const volatile short *);
14421 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14422 vector unsigned char vec_lvsr (int, const volatile int *);
14423 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14424 vector unsigned char vec_lvsr (int, const volatile long *);
14425 vector unsigned char vec_lvsr (int, const volatile float *);
14427 vector float vec_madd (vector float, vector float, vector float);
14429 vector signed short vec_madds (vector signed short,
14430                                vector signed short,
14431                                vector signed short);
14433 vector unsigned char vec_max (vector bool char, vector unsigned char);
14434 vector unsigned char vec_max (vector unsigned char, vector bool char);
14435 vector unsigned char vec_max (vector unsigned char,
14436                               vector unsigned char);
14437 vector signed char vec_max (vector bool char, vector signed char);
14438 vector signed char vec_max (vector signed char, vector bool char);
14439 vector signed char vec_max (vector signed char, vector signed char);
14440 vector unsigned short vec_max (vector bool short,
14441                                vector unsigned short);
14442 vector unsigned short vec_max (vector unsigned short,
14443                                vector bool short);
14444 vector unsigned short vec_max (vector unsigned short,
14445                                vector unsigned short);
14446 vector signed short vec_max (vector bool short, vector signed short);
14447 vector signed short vec_max (vector signed short, vector bool short);
14448 vector signed short vec_max (vector signed short, vector signed short);
14449 vector unsigned int vec_max (vector bool int, vector unsigned int);
14450 vector unsigned int vec_max (vector unsigned int, vector bool int);
14451 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14452 vector signed int vec_max (vector bool int, vector signed int);
14453 vector signed int vec_max (vector signed int, vector bool int);
14454 vector signed int vec_max (vector signed int, vector signed int);
14455 vector float vec_max (vector float, vector float);
14457 vector float vec_vmaxfp (vector float, vector float);
14459 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14460 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14461 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14463 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14464 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14465 vector unsigned int vec_vmaxuw (vector unsigned int,
14466                                 vector unsigned int);
14468 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14469 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14470 vector signed short vec_vmaxsh (vector signed short,
14471                                 vector signed short);
14473 vector unsigned short vec_vmaxuh (vector bool short,
14474                                   vector unsigned short);
14475 vector unsigned short vec_vmaxuh (vector unsigned short,
14476                                   vector bool short);
14477 vector unsigned short vec_vmaxuh (vector unsigned short,
14478                                   vector unsigned short);
14480 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14481 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14482 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14484 vector unsigned char vec_vmaxub (vector bool char,
14485                                  vector unsigned char);
14486 vector unsigned char vec_vmaxub (vector unsigned char,
14487                                  vector bool char);
14488 vector unsigned char vec_vmaxub (vector unsigned char,
14489                                  vector unsigned char);
14491 vector bool char vec_mergeh (vector bool char, vector bool char);
14492 vector signed char vec_mergeh (vector signed char, vector signed char);
14493 vector unsigned char vec_mergeh (vector unsigned char,
14494                                  vector unsigned char);
14495 vector bool short vec_mergeh (vector bool short, vector bool short);
14496 vector pixel vec_mergeh (vector pixel, vector pixel);
14497 vector signed short vec_mergeh (vector signed short,
14498                                 vector signed short);
14499 vector unsigned short vec_mergeh (vector unsigned short,
14500                                   vector unsigned short);
14501 vector float vec_mergeh (vector float, vector float);
14502 vector bool int vec_mergeh (vector bool int, vector bool int);
14503 vector signed int vec_mergeh (vector signed int, vector signed int);
14504 vector unsigned int vec_mergeh (vector unsigned int,
14505                                 vector unsigned int);
14507 vector float vec_vmrghw (vector float, vector float);
14508 vector bool int vec_vmrghw (vector bool int, vector bool int);
14509 vector signed int vec_vmrghw (vector signed int, vector signed int);
14510 vector unsigned int vec_vmrghw (vector unsigned int,
14511                                 vector unsigned int);
14513 vector bool short vec_vmrghh (vector bool short, vector bool short);
14514 vector signed short vec_vmrghh (vector signed short,
14515                                 vector signed short);
14516 vector unsigned short vec_vmrghh (vector unsigned short,
14517                                   vector unsigned short);
14518 vector pixel vec_vmrghh (vector pixel, vector pixel);
14520 vector bool char vec_vmrghb (vector bool char, vector bool char);
14521 vector signed char vec_vmrghb (vector signed char, vector signed char);
14522 vector unsigned char vec_vmrghb (vector unsigned char,
14523                                  vector unsigned char);
14525 vector bool char vec_mergel (vector bool char, vector bool char);
14526 vector signed char vec_mergel (vector signed char, vector signed char);
14527 vector unsigned char vec_mergel (vector unsigned char,
14528                                  vector unsigned char);
14529 vector bool short vec_mergel (vector bool short, vector bool short);
14530 vector pixel vec_mergel (vector pixel, vector pixel);
14531 vector signed short vec_mergel (vector signed short,
14532                                 vector signed short);
14533 vector unsigned short vec_mergel (vector unsigned short,
14534                                   vector unsigned short);
14535 vector float vec_mergel (vector float, vector float);
14536 vector bool int vec_mergel (vector bool int, vector bool int);
14537 vector signed int vec_mergel (vector signed int, vector signed int);
14538 vector unsigned int vec_mergel (vector unsigned int,
14539                                 vector unsigned int);
14541 vector float vec_vmrglw (vector float, vector float);
14542 vector signed int vec_vmrglw (vector signed int, vector signed int);
14543 vector unsigned int vec_vmrglw (vector unsigned int,
14544                                 vector unsigned int);
14545 vector bool int vec_vmrglw (vector bool int, vector bool int);
14547 vector bool short vec_vmrglh (vector bool short, vector bool short);
14548 vector signed short vec_vmrglh (vector signed short,
14549                                 vector signed short);
14550 vector unsigned short vec_vmrglh (vector unsigned short,
14551                                   vector unsigned short);
14552 vector pixel vec_vmrglh (vector pixel, vector pixel);
14554 vector bool char vec_vmrglb (vector bool char, vector bool char);
14555 vector signed char vec_vmrglb (vector signed char, vector signed char);
14556 vector unsigned char vec_vmrglb (vector unsigned char,
14557                                  vector unsigned char);
14559 vector unsigned short vec_mfvscr (void);
14561 vector unsigned char vec_min (vector bool char, vector unsigned char);
14562 vector unsigned char vec_min (vector unsigned char, vector bool char);
14563 vector unsigned char vec_min (vector unsigned char,
14564                               vector unsigned char);
14565 vector signed char vec_min (vector bool char, vector signed char);
14566 vector signed char vec_min (vector signed char, vector bool char);
14567 vector signed char vec_min (vector signed char, vector signed char);
14568 vector unsigned short vec_min (vector bool short,
14569                                vector unsigned short);
14570 vector unsigned short vec_min (vector unsigned short,
14571                                vector bool short);
14572 vector unsigned short vec_min (vector unsigned short,
14573                                vector unsigned short);
14574 vector signed short vec_min (vector bool short, vector signed short);
14575 vector signed short vec_min (vector signed short, vector bool short);
14576 vector signed short vec_min (vector signed short, vector signed short);
14577 vector unsigned int vec_min (vector bool int, vector unsigned int);
14578 vector unsigned int vec_min (vector unsigned int, vector bool int);
14579 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14580 vector signed int vec_min (vector bool int, vector signed int);
14581 vector signed int vec_min (vector signed int, vector bool int);
14582 vector signed int vec_min (vector signed int, vector signed int);
14583 vector float vec_min (vector float, vector float);
14585 vector float vec_vminfp (vector float, vector float);
14587 vector signed int vec_vminsw (vector bool int, vector signed int);
14588 vector signed int vec_vminsw (vector signed int, vector bool int);
14589 vector signed int vec_vminsw (vector signed int, vector signed int);
14591 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14592 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14593 vector unsigned int vec_vminuw (vector unsigned int,
14594                                 vector unsigned int);
14596 vector signed short vec_vminsh (vector bool short, vector signed short);
14597 vector signed short vec_vminsh (vector signed short, vector bool short);
14598 vector signed short vec_vminsh (vector signed short,
14599                                 vector signed short);
14601 vector unsigned short vec_vminuh (vector bool short,
14602                                   vector unsigned short);
14603 vector unsigned short vec_vminuh (vector unsigned short,
14604                                   vector bool short);
14605 vector unsigned short vec_vminuh (vector unsigned short,
14606                                   vector unsigned short);
14608 vector signed char vec_vminsb (vector bool char, vector signed char);
14609 vector signed char vec_vminsb (vector signed char, vector bool char);
14610 vector signed char vec_vminsb (vector signed char, vector signed char);
14612 vector unsigned char vec_vminub (vector bool char,
14613                                  vector unsigned char);
14614 vector unsigned char vec_vminub (vector unsigned char,
14615                                  vector bool char);
14616 vector unsigned char vec_vminub (vector unsigned char,
14617                                  vector unsigned char);
14619 vector signed short vec_mladd (vector signed short,
14620                                vector signed short,
14621                                vector signed short);
14622 vector signed short vec_mladd (vector signed short,
14623                                vector unsigned short,
14624                                vector unsigned short);
14625 vector signed short vec_mladd (vector unsigned short,
14626                                vector signed short,
14627                                vector signed short);
14628 vector unsigned short vec_mladd (vector unsigned short,
14629                                  vector unsigned short,
14630                                  vector unsigned short);
14632 vector signed short vec_mradds (vector signed short,
14633                                 vector signed short,
14634                                 vector signed short);
14636 vector unsigned int vec_msum (vector unsigned char,
14637                               vector unsigned char,
14638                               vector unsigned int);
14639 vector signed int vec_msum (vector signed char,
14640                             vector unsigned char,
14641                             vector signed int);
14642 vector unsigned int vec_msum (vector unsigned short,
14643                               vector unsigned short,
14644                               vector unsigned int);
14645 vector signed int vec_msum (vector signed short,
14646                             vector signed short,
14647                             vector signed int);
14649 vector signed int vec_vmsumshm (vector signed short,
14650                                 vector signed short,
14651                                 vector signed int);
14653 vector unsigned int vec_vmsumuhm (vector unsigned short,
14654                                   vector unsigned short,
14655                                   vector unsigned int);
14657 vector signed int vec_vmsummbm (vector signed char,
14658                                 vector unsigned char,
14659                                 vector signed int);
14661 vector unsigned int vec_vmsumubm (vector unsigned char,
14662                                   vector unsigned char,
14663                                   vector unsigned int);
14665 vector unsigned int vec_msums (vector unsigned short,
14666                                vector unsigned short,
14667                                vector unsigned int);
14668 vector signed int vec_msums (vector signed short,
14669                              vector signed short,
14670                              vector signed int);
14672 vector signed int vec_vmsumshs (vector signed short,
14673                                 vector signed short,
14674                                 vector signed int);
14676 vector unsigned int vec_vmsumuhs (vector unsigned short,
14677                                   vector unsigned short,
14678                                   vector unsigned int);
14680 void vec_mtvscr (vector signed int);
14681 void vec_mtvscr (vector unsigned int);
14682 void vec_mtvscr (vector bool int);
14683 void vec_mtvscr (vector signed short);
14684 void vec_mtvscr (vector unsigned short);
14685 void vec_mtvscr (vector bool short);
14686 void vec_mtvscr (vector pixel);
14687 void vec_mtvscr (vector signed char);
14688 void vec_mtvscr (vector unsigned char);
14689 void vec_mtvscr (vector bool char);
14691 vector unsigned short vec_mule (vector unsigned char,
14692                                 vector unsigned char);
14693 vector signed short vec_mule (vector signed char,
14694                               vector signed char);
14695 vector unsigned int vec_mule (vector unsigned short,
14696                               vector unsigned short);
14697 vector signed int vec_mule (vector signed short, vector signed short);
14699 vector signed int vec_vmulesh (vector signed short,
14700                                vector signed short);
14702 vector unsigned int vec_vmuleuh (vector unsigned short,
14703                                  vector unsigned short);
14705 vector signed short vec_vmulesb (vector signed char,
14706                                  vector signed char);
14708 vector unsigned short vec_vmuleub (vector unsigned char,
14709                                   vector unsigned char);
14711 vector unsigned short vec_mulo (vector unsigned char,
14712                                 vector unsigned char);
14713 vector signed short vec_mulo (vector signed char, vector signed char);
14714 vector unsigned int vec_mulo (vector unsigned short,
14715                               vector unsigned short);
14716 vector signed int vec_mulo (vector signed short, vector signed short);
14718 vector signed int vec_vmulosh (vector signed short,
14719                                vector signed short);
14721 vector unsigned int vec_vmulouh (vector unsigned short,
14722                                  vector unsigned short);
14724 vector signed short vec_vmulosb (vector signed char,
14725                                  vector signed char);
14727 vector unsigned short vec_vmuloub (vector unsigned char,
14728                                    vector unsigned char);
14730 vector float vec_nmsub (vector float, vector float, vector float);
14732 vector float vec_nor (vector float, vector float);
14733 vector signed int vec_nor (vector signed int, vector signed int);
14734 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14735 vector bool int vec_nor (vector bool int, vector bool int);
14736 vector signed short vec_nor (vector signed short, vector signed short);
14737 vector unsigned short vec_nor (vector unsigned short,
14738                                vector unsigned short);
14739 vector bool short vec_nor (vector bool short, vector bool short);
14740 vector signed char vec_nor (vector signed char, vector signed char);
14741 vector unsigned char vec_nor (vector unsigned char,
14742                               vector unsigned char);
14743 vector bool char vec_nor (vector bool char, vector bool char);
14745 vector float vec_or (vector float, vector float);
14746 vector float vec_or (vector float, vector bool int);
14747 vector float vec_or (vector bool int, vector float);
14748 vector bool int vec_or (vector bool int, vector bool int);
14749 vector signed int vec_or (vector bool int, vector signed int);
14750 vector signed int vec_or (vector signed int, vector bool int);
14751 vector signed int vec_or (vector signed int, vector signed int);
14752 vector unsigned int vec_or (vector bool int, vector unsigned int);
14753 vector unsigned int vec_or (vector unsigned int, vector bool int);
14754 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14755 vector bool short vec_or (vector bool short, vector bool short);
14756 vector signed short vec_or (vector bool short, vector signed short);
14757 vector signed short vec_or (vector signed short, vector bool short);
14758 vector signed short vec_or (vector signed short, vector signed short);
14759 vector unsigned short vec_or (vector bool short, vector unsigned short);
14760 vector unsigned short vec_or (vector unsigned short, vector bool short);
14761 vector unsigned short vec_or (vector unsigned short,
14762                               vector unsigned short);
14763 vector signed char vec_or (vector bool char, vector signed char);
14764 vector bool char vec_or (vector bool char, vector bool char);
14765 vector signed char vec_or (vector signed char, vector bool char);
14766 vector signed char vec_or (vector signed char, vector signed char);
14767 vector unsigned char vec_or (vector bool char, vector unsigned char);
14768 vector unsigned char vec_or (vector unsigned char, vector bool char);
14769 vector unsigned char vec_or (vector unsigned char,
14770                              vector unsigned char);
14772 vector signed char vec_pack (vector signed short, vector signed short);
14773 vector unsigned char vec_pack (vector unsigned short,
14774                                vector unsigned short);
14775 vector bool char vec_pack (vector bool short, vector bool short);
14776 vector signed short vec_pack (vector signed int, vector signed int);
14777 vector unsigned short vec_pack (vector unsigned int,
14778                                 vector unsigned int);
14779 vector bool short vec_pack (vector bool int, vector bool int);
14781 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14782 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14783 vector unsigned short vec_vpkuwum (vector unsigned int,
14784                                    vector unsigned int);
14786 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14787 vector signed char vec_vpkuhum (vector signed short,
14788                                 vector signed short);
14789 vector unsigned char vec_vpkuhum (vector unsigned short,
14790                                   vector unsigned short);
14792 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14794 vector unsigned char vec_packs (vector unsigned short,
14795                                 vector unsigned short);
14796 vector signed char vec_packs (vector signed short, vector signed short);
14797 vector unsigned short vec_packs (vector unsigned int,
14798                                  vector unsigned int);
14799 vector signed short vec_packs (vector signed int, vector signed int);
14801 vector signed short vec_vpkswss (vector signed int, vector signed int);
14803 vector unsigned short vec_vpkuwus (vector unsigned int,
14804                                    vector unsigned int);
14806 vector signed char vec_vpkshss (vector signed short,
14807                                 vector signed short);
14809 vector unsigned char vec_vpkuhus (vector unsigned short,
14810                                   vector unsigned short);
14812 vector unsigned char vec_packsu (vector unsigned short,
14813                                  vector unsigned short);
14814 vector unsigned char vec_packsu (vector signed short,
14815                                  vector signed short);
14816 vector unsigned short vec_packsu (vector unsigned int,
14817                                   vector unsigned int);
14818 vector unsigned short vec_packsu (vector signed int, vector signed int);
14820 vector unsigned short vec_vpkswus (vector signed int,
14821                                    vector signed int);
14823 vector unsigned char vec_vpkshus (vector signed short,
14824                                   vector signed short);
14826 vector float vec_perm (vector float,
14827                        vector float,
14828                        vector unsigned char);
14829 vector signed int vec_perm (vector signed int,
14830                             vector signed int,
14831                             vector unsigned char);
14832 vector unsigned int vec_perm (vector unsigned int,
14833                               vector unsigned int,
14834                               vector unsigned char);
14835 vector bool int vec_perm (vector bool int,
14836                           vector bool int,
14837                           vector unsigned char);
14838 vector signed short vec_perm (vector signed short,
14839                               vector signed short,
14840                               vector unsigned char);
14841 vector unsigned short vec_perm (vector unsigned short,
14842                                 vector unsigned short,
14843                                 vector unsigned char);
14844 vector bool short vec_perm (vector bool short,
14845                             vector bool short,
14846                             vector unsigned char);
14847 vector pixel vec_perm (vector pixel,
14848                        vector pixel,
14849                        vector unsigned char);
14850 vector signed char vec_perm (vector signed char,
14851                              vector signed char,
14852                              vector unsigned char);
14853 vector unsigned char vec_perm (vector unsigned char,
14854                                vector unsigned char,
14855                                vector unsigned char);
14856 vector bool char vec_perm (vector bool char,
14857                            vector bool char,
14858                            vector unsigned char);
14860 vector float vec_re (vector float);
14862 vector signed char vec_rl (vector signed char,
14863                            vector unsigned char);
14864 vector unsigned char vec_rl (vector unsigned char,
14865                              vector unsigned char);
14866 vector signed short vec_rl (vector signed short, vector unsigned short);
14867 vector unsigned short vec_rl (vector unsigned short,
14868                               vector unsigned short);
14869 vector signed int vec_rl (vector signed int, vector unsigned int);
14870 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14872 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14873 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14875 vector signed short vec_vrlh (vector signed short,
14876                               vector unsigned short);
14877 vector unsigned short vec_vrlh (vector unsigned short,
14878                                 vector unsigned short);
14880 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14881 vector unsigned char vec_vrlb (vector unsigned char,
14882                                vector unsigned char);
14884 vector float vec_round (vector float);
14886 vector float vec_recip (vector float, vector float);
14888 vector float vec_rsqrt (vector float);
14890 vector float vec_rsqrte (vector float);
14892 vector float vec_sel (vector float, vector float, vector bool int);
14893 vector float vec_sel (vector float, vector float, vector unsigned int);
14894 vector signed int vec_sel (vector signed int,
14895                            vector signed int,
14896                            vector bool int);
14897 vector signed int vec_sel (vector signed int,
14898                            vector signed int,
14899                            vector unsigned int);
14900 vector unsigned int vec_sel (vector unsigned int,
14901                              vector unsigned int,
14902                              vector bool int);
14903 vector unsigned int vec_sel (vector unsigned int,
14904                              vector unsigned int,
14905                              vector unsigned int);
14906 vector bool int vec_sel (vector bool int,
14907                          vector bool int,
14908                          vector bool int);
14909 vector bool int vec_sel (vector bool int,
14910                          vector bool int,
14911                          vector unsigned int);
14912 vector signed short vec_sel (vector signed short,
14913                              vector signed short,
14914                              vector bool short);
14915 vector signed short vec_sel (vector signed short,
14916                              vector signed short,
14917                              vector unsigned short);
14918 vector unsigned short vec_sel (vector unsigned short,
14919                                vector unsigned short,
14920                                vector bool short);
14921 vector unsigned short vec_sel (vector unsigned short,
14922                                vector unsigned short,
14923                                vector unsigned short);
14924 vector bool short vec_sel (vector bool short,
14925                            vector bool short,
14926                            vector bool short);
14927 vector bool short vec_sel (vector bool short,
14928                            vector bool short,
14929                            vector unsigned short);
14930 vector signed char vec_sel (vector signed char,
14931                             vector signed char,
14932                             vector bool char);
14933 vector signed char vec_sel (vector signed char,
14934                             vector signed char,
14935                             vector unsigned char);
14936 vector unsigned char vec_sel (vector unsigned char,
14937                               vector unsigned char,
14938                               vector bool char);
14939 vector unsigned char vec_sel (vector unsigned char,
14940                               vector unsigned char,
14941                               vector unsigned char);
14942 vector bool char vec_sel (vector bool char,
14943                           vector bool char,
14944                           vector bool char);
14945 vector bool char vec_sel (vector bool char,
14946                           vector bool char,
14947                           vector unsigned char);
14949 vector signed char vec_sl (vector signed char,
14950                            vector unsigned char);
14951 vector unsigned char vec_sl (vector unsigned char,
14952                              vector unsigned char);
14953 vector signed short vec_sl (vector signed short, vector unsigned short);
14954 vector unsigned short vec_sl (vector unsigned short,
14955                               vector unsigned short);
14956 vector signed int vec_sl (vector signed int, vector unsigned int);
14957 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14959 vector signed int vec_vslw (vector signed int, vector unsigned int);
14960 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14962 vector signed short vec_vslh (vector signed short,
14963                               vector unsigned short);
14964 vector unsigned short vec_vslh (vector unsigned short,
14965                                 vector unsigned short);
14967 vector signed char vec_vslb (vector signed char, vector unsigned char);
14968 vector unsigned char vec_vslb (vector unsigned char,
14969                                vector unsigned char);
14971 vector float vec_sld (vector float, vector float, const int);
14972 vector signed int vec_sld (vector signed int,
14973                            vector signed int,
14974                            const int);
14975 vector unsigned int vec_sld (vector unsigned int,
14976                              vector unsigned int,
14977                              const int);
14978 vector bool int vec_sld (vector bool int,
14979                          vector bool int,
14980                          const int);
14981 vector signed short vec_sld (vector signed short,
14982                              vector signed short,
14983                              const int);
14984 vector unsigned short vec_sld (vector unsigned short,
14985                                vector unsigned short,
14986                                const int);
14987 vector bool short vec_sld (vector bool short,
14988                            vector bool short,
14989                            const int);
14990 vector pixel vec_sld (vector pixel,
14991                       vector pixel,
14992                       const int);
14993 vector signed char vec_sld (vector signed char,
14994                             vector signed char,
14995                             const int);
14996 vector unsigned char vec_sld (vector unsigned char,
14997                               vector unsigned char,
14998                               const int);
14999 vector bool char vec_sld (vector bool char,
15000                           vector bool char,
15001                           const int);
15003 vector signed int vec_sll (vector signed int,
15004                            vector unsigned int);
15005 vector signed int vec_sll (vector signed int,
15006                            vector unsigned short);
15007 vector signed int vec_sll (vector signed int,
15008                            vector unsigned char);
15009 vector unsigned int vec_sll (vector unsigned int,
15010                              vector unsigned int);
15011 vector unsigned int vec_sll (vector unsigned int,
15012                              vector unsigned short);
15013 vector unsigned int vec_sll (vector unsigned int,
15014                              vector unsigned char);
15015 vector bool int vec_sll (vector bool int,
15016                          vector unsigned int);
15017 vector bool int vec_sll (vector bool int,
15018                          vector unsigned short);
15019 vector bool int vec_sll (vector bool int,
15020                          vector unsigned char);
15021 vector signed short vec_sll (vector signed short,
15022                              vector unsigned int);
15023 vector signed short vec_sll (vector signed short,
15024                              vector unsigned short);
15025 vector signed short vec_sll (vector signed short,
15026                              vector unsigned char);
15027 vector unsigned short vec_sll (vector unsigned short,
15028                                vector unsigned int);
15029 vector unsigned short vec_sll (vector unsigned short,
15030                                vector unsigned short);
15031 vector unsigned short vec_sll (vector unsigned short,
15032                                vector unsigned char);
15033 vector bool short vec_sll (vector bool short, vector unsigned int);
15034 vector bool short vec_sll (vector bool short, vector unsigned short);
15035 vector bool short vec_sll (vector bool short, vector unsigned char);
15036 vector pixel vec_sll (vector pixel, vector unsigned int);
15037 vector pixel vec_sll (vector pixel, vector unsigned short);
15038 vector pixel vec_sll (vector pixel, vector unsigned char);
15039 vector signed char vec_sll (vector signed char, vector unsigned int);
15040 vector signed char vec_sll (vector signed char, vector unsigned short);
15041 vector signed char vec_sll (vector signed char, vector unsigned char);
15042 vector unsigned char vec_sll (vector unsigned char,
15043                               vector unsigned int);
15044 vector unsigned char vec_sll (vector unsigned char,
15045                               vector unsigned short);
15046 vector unsigned char vec_sll (vector unsigned char,
15047                               vector unsigned char);
15048 vector bool char vec_sll (vector bool char, vector unsigned int);
15049 vector bool char vec_sll (vector bool char, vector unsigned short);
15050 vector bool char vec_sll (vector bool char, vector unsigned char);
15052 vector float vec_slo (vector float, vector signed char);
15053 vector float vec_slo (vector float, vector unsigned char);
15054 vector signed int vec_slo (vector signed int, vector signed char);
15055 vector signed int vec_slo (vector signed int, vector unsigned char);
15056 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15057 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15058 vector signed short vec_slo (vector signed short, vector signed char);
15059 vector signed short vec_slo (vector signed short, vector unsigned char);
15060 vector unsigned short vec_slo (vector unsigned short,
15061                                vector signed char);
15062 vector unsigned short vec_slo (vector unsigned short,
15063                                vector unsigned char);
15064 vector pixel vec_slo (vector pixel, vector signed char);
15065 vector pixel vec_slo (vector pixel, vector unsigned char);
15066 vector signed char vec_slo (vector signed char, vector signed char);
15067 vector signed char vec_slo (vector signed char, vector unsigned char);
15068 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15069 vector unsigned char vec_slo (vector unsigned char,
15070                               vector unsigned char);
15072 vector signed char vec_splat (vector signed char, const int);
15073 vector unsigned char vec_splat (vector unsigned char, const int);
15074 vector bool char vec_splat (vector bool char, const int);
15075 vector signed short vec_splat (vector signed short, const int);
15076 vector unsigned short vec_splat (vector unsigned short, const int);
15077 vector bool short vec_splat (vector bool short, const int);
15078 vector pixel vec_splat (vector pixel, const int);
15079 vector float vec_splat (vector float, const int);
15080 vector signed int vec_splat (vector signed int, const int);
15081 vector unsigned int vec_splat (vector unsigned int, const int);
15082 vector bool int vec_splat (vector bool int, const int);
15083 vector signed long vec_splat (vector signed long, const int);
15084 vector unsigned long vec_splat (vector unsigned long, const int);
15086 vector signed char vec_splats (signed char);
15087 vector unsigned char vec_splats (unsigned char);
15088 vector signed short vec_splats (signed short);
15089 vector unsigned short vec_splats (unsigned short);
15090 vector signed int vec_splats (signed int);
15091 vector unsigned int vec_splats (unsigned int);
15092 vector float vec_splats (float);
15094 vector float vec_vspltw (vector float, const int);
15095 vector signed int vec_vspltw (vector signed int, const int);
15096 vector unsigned int vec_vspltw (vector unsigned int, const int);
15097 vector bool int vec_vspltw (vector bool int, const int);
15099 vector bool short vec_vsplth (vector bool short, const int);
15100 vector signed short vec_vsplth (vector signed short, const int);
15101 vector unsigned short vec_vsplth (vector unsigned short, const int);
15102 vector pixel vec_vsplth (vector pixel, const int);
15104 vector signed char vec_vspltb (vector signed char, const int);
15105 vector unsigned char vec_vspltb (vector unsigned char, const int);
15106 vector bool char vec_vspltb (vector bool char, const int);
15108 vector signed char vec_splat_s8 (const int);
15110 vector signed short vec_splat_s16 (const int);
15112 vector signed int vec_splat_s32 (const int);
15114 vector unsigned char vec_splat_u8 (const int);
15116 vector unsigned short vec_splat_u16 (const int);
15118 vector unsigned int vec_splat_u32 (const int);
15120 vector signed char vec_sr (vector signed char, vector unsigned char);
15121 vector unsigned char vec_sr (vector unsigned char,
15122                              vector unsigned char);
15123 vector signed short vec_sr (vector signed short,
15124                             vector unsigned short);
15125 vector unsigned short vec_sr (vector unsigned short,
15126                               vector unsigned short);
15127 vector signed int vec_sr (vector signed int, vector unsigned int);
15128 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15130 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15131 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15133 vector signed short vec_vsrh (vector signed short,
15134                               vector unsigned short);
15135 vector unsigned short vec_vsrh (vector unsigned short,
15136                                 vector unsigned short);
15138 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15139 vector unsigned char vec_vsrb (vector unsigned char,
15140                                vector unsigned char);
15142 vector signed char vec_sra (vector signed char, vector unsigned char);
15143 vector unsigned char vec_sra (vector unsigned char,
15144                               vector unsigned char);
15145 vector signed short vec_sra (vector signed short,
15146                              vector unsigned short);
15147 vector unsigned short vec_sra (vector unsigned short,
15148                                vector unsigned short);
15149 vector signed int vec_sra (vector signed int, vector unsigned int);
15150 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15152 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15153 vector unsigned int vec_vsraw (vector unsigned int,
15154                                vector unsigned int);
15156 vector signed short vec_vsrah (vector signed short,
15157                                vector unsigned short);
15158 vector unsigned short vec_vsrah (vector unsigned short,
15159                                  vector unsigned short);
15161 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15162 vector unsigned char vec_vsrab (vector unsigned char,
15163                                 vector unsigned char);
15165 vector signed int vec_srl (vector signed int, vector unsigned int);
15166 vector signed int vec_srl (vector signed int, vector unsigned short);
15167 vector signed int vec_srl (vector signed int, vector unsigned char);
15168 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15169 vector unsigned int vec_srl (vector unsigned int,
15170                              vector unsigned short);
15171 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15172 vector bool int vec_srl (vector bool int, vector unsigned int);
15173 vector bool int vec_srl (vector bool int, vector unsigned short);
15174 vector bool int vec_srl (vector bool int, vector unsigned char);
15175 vector signed short vec_srl (vector signed short, vector unsigned int);
15176 vector signed short vec_srl (vector signed short,
15177                              vector unsigned short);
15178 vector signed short vec_srl (vector signed short, vector unsigned char);
15179 vector unsigned short vec_srl (vector unsigned short,
15180                                vector unsigned int);
15181 vector unsigned short vec_srl (vector unsigned short,
15182                                vector unsigned short);
15183 vector unsigned short vec_srl (vector unsigned short,
15184                                vector unsigned char);
15185 vector bool short vec_srl (vector bool short, vector unsigned int);
15186 vector bool short vec_srl (vector bool short, vector unsigned short);
15187 vector bool short vec_srl (vector bool short, vector unsigned char);
15188 vector pixel vec_srl (vector pixel, vector unsigned int);
15189 vector pixel vec_srl (vector pixel, vector unsigned short);
15190 vector pixel vec_srl (vector pixel, vector unsigned char);
15191 vector signed char vec_srl (vector signed char, vector unsigned int);
15192 vector signed char vec_srl (vector signed char, vector unsigned short);
15193 vector signed char vec_srl (vector signed char, vector unsigned char);
15194 vector unsigned char vec_srl (vector unsigned char,
15195                               vector unsigned int);
15196 vector unsigned char vec_srl (vector unsigned char,
15197                               vector unsigned short);
15198 vector unsigned char vec_srl (vector unsigned char,
15199                               vector unsigned char);
15200 vector bool char vec_srl (vector bool char, vector unsigned int);
15201 vector bool char vec_srl (vector bool char, vector unsigned short);
15202 vector bool char vec_srl (vector bool char, vector unsigned char);
15204 vector float vec_sro (vector float, vector signed char);
15205 vector float vec_sro (vector float, vector unsigned char);
15206 vector signed int vec_sro (vector signed int, vector signed char);
15207 vector signed int vec_sro (vector signed int, vector unsigned char);
15208 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15209 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15210 vector signed short vec_sro (vector signed short, vector signed char);
15211 vector signed short vec_sro (vector signed short, vector unsigned char);
15212 vector unsigned short vec_sro (vector unsigned short,
15213                                vector signed char);
15214 vector unsigned short vec_sro (vector unsigned short,
15215                                vector unsigned char);
15216 vector pixel vec_sro (vector pixel, vector signed char);
15217 vector pixel vec_sro (vector pixel, vector unsigned char);
15218 vector signed char vec_sro (vector signed char, vector signed char);
15219 vector signed char vec_sro (vector signed char, vector unsigned char);
15220 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15221 vector unsigned char vec_sro (vector unsigned char,
15222                               vector unsigned char);
15224 void vec_st (vector float, int, vector float *);
15225 void vec_st (vector float, int, float *);
15226 void vec_st (vector signed int, int, vector signed int *);
15227 void vec_st (vector signed int, int, int *);
15228 void vec_st (vector unsigned int, int, vector unsigned int *);
15229 void vec_st (vector unsigned int, int, unsigned int *);
15230 void vec_st (vector bool int, int, vector bool int *);
15231 void vec_st (vector bool int, int, unsigned int *);
15232 void vec_st (vector bool int, int, int *);
15233 void vec_st (vector signed short, int, vector signed short *);
15234 void vec_st (vector signed short, int, short *);
15235 void vec_st (vector unsigned short, int, vector unsigned short *);
15236 void vec_st (vector unsigned short, int, unsigned short *);
15237 void vec_st (vector bool short, int, vector bool short *);
15238 void vec_st (vector bool short, int, unsigned short *);
15239 void vec_st (vector pixel, int, vector pixel *);
15240 void vec_st (vector pixel, int, unsigned short *);
15241 void vec_st (vector pixel, int, short *);
15242 void vec_st (vector bool short, int, short *);
15243 void vec_st (vector signed char, int, vector signed char *);
15244 void vec_st (vector signed char, int, signed char *);
15245 void vec_st (vector unsigned char, int, vector unsigned char *);
15246 void vec_st (vector unsigned char, int, unsigned char *);
15247 void vec_st (vector bool char, int, vector bool char *);
15248 void vec_st (vector bool char, int, unsigned char *);
15249 void vec_st (vector bool char, int, signed char *);
15251 void vec_ste (vector signed char, int, signed char *);
15252 void vec_ste (vector unsigned char, int, unsigned char *);
15253 void vec_ste (vector bool char, int, signed char *);
15254 void vec_ste (vector bool char, int, unsigned char *);
15255 void vec_ste (vector signed short, int, short *);
15256 void vec_ste (vector unsigned short, int, unsigned short *);
15257 void vec_ste (vector bool short, int, short *);
15258 void vec_ste (vector bool short, int, unsigned short *);
15259 void vec_ste (vector pixel, int, short *);
15260 void vec_ste (vector pixel, int, unsigned short *);
15261 void vec_ste (vector float, int, float *);
15262 void vec_ste (vector signed int, int, int *);
15263 void vec_ste (vector unsigned int, int, unsigned int *);
15264 void vec_ste (vector bool int, int, int *);
15265 void vec_ste (vector bool int, int, unsigned int *);
15267 void vec_stvewx (vector float, int, float *);
15268 void vec_stvewx (vector signed int, int, int *);
15269 void vec_stvewx (vector unsigned int, int, unsigned int *);
15270 void vec_stvewx (vector bool int, int, int *);
15271 void vec_stvewx (vector bool int, int, unsigned int *);
15273 void vec_stvehx (vector signed short, int, short *);
15274 void vec_stvehx (vector unsigned short, int, unsigned short *);
15275 void vec_stvehx (vector bool short, int, short *);
15276 void vec_stvehx (vector bool short, int, unsigned short *);
15277 void vec_stvehx (vector pixel, int, short *);
15278 void vec_stvehx (vector pixel, int, unsigned short *);
15280 void vec_stvebx (vector signed char, int, signed char *);
15281 void vec_stvebx (vector unsigned char, int, unsigned char *);
15282 void vec_stvebx (vector bool char, int, signed char *);
15283 void vec_stvebx (vector bool char, int, unsigned char *);
15285 void vec_stl (vector float, int, vector float *);
15286 void vec_stl (vector float, int, float *);
15287 void vec_stl (vector signed int, int, vector signed int *);
15288 void vec_stl (vector signed int, int, int *);
15289 void vec_stl (vector unsigned int, int, vector unsigned int *);
15290 void vec_stl (vector unsigned int, int, unsigned int *);
15291 void vec_stl (vector bool int, int, vector bool int *);
15292 void vec_stl (vector bool int, int, unsigned int *);
15293 void vec_stl (vector bool int, int, int *);
15294 void vec_stl (vector signed short, int, vector signed short *);
15295 void vec_stl (vector signed short, int, short *);
15296 void vec_stl (vector unsigned short, int, vector unsigned short *);
15297 void vec_stl (vector unsigned short, int, unsigned short *);
15298 void vec_stl (vector bool short, int, vector bool short *);
15299 void vec_stl (vector bool short, int, unsigned short *);
15300 void vec_stl (vector bool short, int, short *);
15301 void vec_stl (vector pixel, int, vector pixel *);
15302 void vec_stl (vector pixel, int, unsigned short *);
15303 void vec_stl (vector pixel, int, short *);
15304 void vec_stl (vector signed char, int, vector signed char *);
15305 void vec_stl (vector signed char, int, signed char *);
15306 void vec_stl (vector unsigned char, int, vector unsigned char *);
15307 void vec_stl (vector unsigned char, int, unsigned char *);
15308 void vec_stl (vector bool char, int, vector bool char *);
15309 void vec_stl (vector bool char, int, unsigned char *);
15310 void vec_stl (vector bool char, int, signed char *);
15312 vector signed char vec_sub (vector bool char, vector signed char);
15313 vector signed char vec_sub (vector signed char, vector bool char);
15314 vector signed char vec_sub (vector signed char, vector signed char);
15315 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15316 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15317 vector unsigned char vec_sub (vector unsigned char,
15318                               vector unsigned char);
15319 vector signed short vec_sub (vector bool short, vector signed short);
15320 vector signed short vec_sub (vector signed short, vector bool short);
15321 vector signed short vec_sub (vector signed short, vector signed short);
15322 vector unsigned short vec_sub (vector bool short,
15323                                vector unsigned short);
15324 vector unsigned short vec_sub (vector unsigned short,
15325                                vector bool short);
15326 vector unsigned short vec_sub (vector unsigned short,
15327                                vector unsigned short);
15328 vector signed int vec_sub (vector bool int, vector signed int);
15329 vector signed int vec_sub (vector signed int, vector bool int);
15330 vector signed int vec_sub (vector signed int, vector signed int);
15331 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15332 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15333 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15334 vector float vec_sub (vector float, vector float);
15336 vector float vec_vsubfp (vector float, vector float);
15338 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15339 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15340 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15341 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15342 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15343 vector unsigned int vec_vsubuwm (vector unsigned int,
15344                                  vector unsigned int);
15346 vector signed short vec_vsubuhm (vector bool short,
15347                                  vector signed short);
15348 vector signed short vec_vsubuhm (vector signed short,
15349                                  vector bool short);
15350 vector signed short vec_vsubuhm (vector signed short,
15351                                  vector signed short);
15352 vector unsigned short vec_vsubuhm (vector bool short,
15353                                    vector unsigned short);
15354 vector unsigned short vec_vsubuhm (vector unsigned short,
15355                                    vector bool short);
15356 vector unsigned short vec_vsubuhm (vector unsigned short,
15357                                    vector unsigned short);
15359 vector signed char vec_vsububm (vector bool char, vector signed char);
15360 vector signed char vec_vsububm (vector signed char, vector bool char);
15361 vector signed char vec_vsububm (vector signed char, vector signed char);
15362 vector unsigned char vec_vsububm (vector bool char,
15363                                   vector unsigned char);
15364 vector unsigned char vec_vsububm (vector unsigned char,
15365                                   vector bool char);
15366 vector unsigned char vec_vsububm (vector unsigned char,
15367                                   vector unsigned char);
15369 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15371 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15372 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15373 vector unsigned char vec_subs (vector unsigned char,
15374                                vector unsigned char);
15375 vector signed char vec_subs (vector bool char, vector signed char);
15376 vector signed char vec_subs (vector signed char, vector bool char);
15377 vector signed char vec_subs (vector signed char, vector signed char);
15378 vector unsigned short vec_subs (vector bool short,
15379                                 vector unsigned short);
15380 vector unsigned short vec_subs (vector unsigned short,
15381                                 vector bool short);
15382 vector unsigned short vec_subs (vector unsigned short,
15383                                 vector unsigned short);
15384 vector signed short vec_subs (vector bool short, vector signed short);
15385 vector signed short vec_subs (vector signed short, vector bool short);
15386 vector signed short vec_subs (vector signed short, vector signed short);
15387 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15388 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15389 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15390 vector signed int vec_subs (vector bool int, vector signed int);
15391 vector signed int vec_subs (vector signed int, vector bool int);
15392 vector signed int vec_subs (vector signed int, vector signed int);
15394 vector signed int vec_vsubsws (vector bool int, vector signed int);
15395 vector signed int vec_vsubsws (vector signed int, vector bool int);
15396 vector signed int vec_vsubsws (vector signed int, vector signed int);
15398 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15399 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15400 vector unsigned int vec_vsubuws (vector unsigned int,
15401                                  vector unsigned int);
15403 vector signed short vec_vsubshs (vector bool short,
15404                                  vector signed short);
15405 vector signed short vec_vsubshs (vector signed short,
15406                                  vector bool short);
15407 vector signed short vec_vsubshs (vector signed short,
15408                                  vector signed short);
15410 vector unsigned short vec_vsubuhs (vector bool short,
15411                                    vector unsigned short);
15412 vector unsigned short vec_vsubuhs (vector unsigned short,
15413                                    vector bool short);
15414 vector unsigned short vec_vsubuhs (vector unsigned short,
15415                                    vector unsigned short);
15417 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15418 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15419 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15421 vector unsigned char vec_vsububs (vector bool char,
15422                                   vector unsigned char);
15423 vector unsigned char vec_vsububs (vector unsigned char,
15424                                   vector bool char);
15425 vector unsigned char vec_vsububs (vector unsigned char,
15426                                   vector unsigned char);
15428 vector unsigned int vec_sum4s (vector unsigned char,
15429                                vector unsigned int);
15430 vector signed int vec_sum4s (vector signed char, vector signed int);
15431 vector signed int vec_sum4s (vector signed short, vector signed int);
15433 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15435 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15437 vector unsigned int vec_vsum4ubs (vector unsigned char,
15438                                   vector unsigned int);
15440 vector signed int vec_sum2s (vector signed int, vector signed int);
15442 vector signed int vec_sums (vector signed int, vector signed int);
15444 vector float vec_trunc (vector float);
15446 vector signed short vec_unpackh (vector signed char);
15447 vector bool short vec_unpackh (vector bool char);
15448 vector signed int vec_unpackh (vector signed short);
15449 vector bool int vec_unpackh (vector bool short);
15450 vector unsigned int vec_unpackh (vector pixel);
15452 vector bool int vec_vupkhsh (vector bool short);
15453 vector signed int vec_vupkhsh (vector signed short);
15455 vector unsigned int vec_vupkhpx (vector pixel);
15457 vector bool short vec_vupkhsb (vector bool char);
15458 vector signed short vec_vupkhsb (vector signed char);
15460 vector signed short vec_unpackl (vector signed char);
15461 vector bool short vec_unpackl (vector bool char);
15462 vector unsigned int vec_unpackl (vector pixel);
15463 vector signed int vec_unpackl (vector signed short);
15464 vector bool int vec_unpackl (vector bool short);
15466 vector unsigned int vec_vupklpx (vector pixel);
15468 vector bool int vec_vupklsh (vector bool short);
15469 vector signed int vec_vupklsh (vector signed short);
15471 vector bool short vec_vupklsb (vector bool char);
15472 vector signed short vec_vupklsb (vector signed char);
15474 vector float vec_xor (vector float, vector float);
15475 vector float vec_xor (vector float, vector bool int);
15476 vector float vec_xor (vector bool int, vector float);
15477 vector bool int vec_xor (vector bool int, vector bool int);
15478 vector signed int vec_xor (vector bool int, vector signed int);
15479 vector signed int vec_xor (vector signed int, vector bool int);
15480 vector signed int vec_xor (vector signed int, vector signed int);
15481 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15482 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15483 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15484 vector bool short vec_xor (vector bool short, vector bool short);
15485 vector signed short vec_xor (vector bool short, vector signed short);
15486 vector signed short vec_xor (vector signed short, vector bool short);
15487 vector signed short vec_xor (vector signed short, vector signed short);
15488 vector unsigned short vec_xor (vector bool short,
15489                                vector unsigned short);
15490 vector unsigned short vec_xor (vector unsigned short,
15491                                vector bool short);
15492 vector unsigned short vec_xor (vector unsigned short,
15493                                vector unsigned short);
15494 vector signed char vec_xor (vector bool char, vector signed char);
15495 vector bool char vec_xor (vector bool char, vector bool char);
15496 vector signed char vec_xor (vector signed char, vector bool char);
15497 vector signed char vec_xor (vector signed char, vector signed char);
15498 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15499 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15500 vector unsigned char vec_xor (vector unsigned char,
15501                               vector unsigned char);
15503 int vec_all_eq (vector signed char, vector bool char);
15504 int vec_all_eq (vector signed char, vector signed char);
15505 int vec_all_eq (vector unsigned char, vector bool char);
15506 int vec_all_eq (vector unsigned char, vector unsigned char);
15507 int vec_all_eq (vector bool char, vector bool char);
15508 int vec_all_eq (vector bool char, vector unsigned char);
15509 int vec_all_eq (vector bool char, vector signed char);
15510 int vec_all_eq (vector signed short, vector bool short);
15511 int vec_all_eq (vector signed short, vector signed short);
15512 int vec_all_eq (vector unsigned short, vector bool short);
15513 int vec_all_eq (vector unsigned short, vector unsigned short);
15514 int vec_all_eq (vector bool short, vector bool short);
15515 int vec_all_eq (vector bool short, vector unsigned short);
15516 int vec_all_eq (vector bool short, vector signed short);
15517 int vec_all_eq (vector pixel, vector pixel);
15518 int vec_all_eq (vector signed int, vector bool int);
15519 int vec_all_eq (vector signed int, vector signed int);
15520 int vec_all_eq (vector unsigned int, vector bool int);
15521 int vec_all_eq (vector unsigned int, vector unsigned int);
15522 int vec_all_eq (vector bool int, vector bool int);
15523 int vec_all_eq (vector bool int, vector unsigned int);
15524 int vec_all_eq (vector bool int, vector signed int);
15525 int vec_all_eq (vector float, vector float);
15527 int vec_all_ge (vector bool char, vector unsigned char);
15528 int vec_all_ge (vector unsigned char, vector bool char);
15529 int vec_all_ge (vector unsigned char, vector unsigned char);
15530 int vec_all_ge (vector bool char, vector signed char);
15531 int vec_all_ge (vector signed char, vector bool char);
15532 int vec_all_ge (vector signed char, vector signed char);
15533 int vec_all_ge (vector bool short, vector unsigned short);
15534 int vec_all_ge (vector unsigned short, vector bool short);
15535 int vec_all_ge (vector unsigned short, vector unsigned short);
15536 int vec_all_ge (vector signed short, vector signed short);
15537 int vec_all_ge (vector bool short, vector signed short);
15538 int vec_all_ge (vector signed short, vector bool short);
15539 int vec_all_ge (vector bool int, vector unsigned int);
15540 int vec_all_ge (vector unsigned int, vector bool int);
15541 int vec_all_ge (vector unsigned int, vector unsigned int);
15542 int vec_all_ge (vector bool int, vector signed int);
15543 int vec_all_ge (vector signed int, vector bool int);
15544 int vec_all_ge (vector signed int, vector signed int);
15545 int vec_all_ge (vector float, vector float);
15547 int vec_all_gt (vector bool char, vector unsigned char);
15548 int vec_all_gt (vector unsigned char, vector bool char);
15549 int vec_all_gt (vector unsigned char, vector unsigned char);
15550 int vec_all_gt (vector bool char, vector signed char);
15551 int vec_all_gt (vector signed char, vector bool char);
15552 int vec_all_gt (vector signed char, vector signed char);
15553 int vec_all_gt (vector bool short, vector unsigned short);
15554 int vec_all_gt (vector unsigned short, vector bool short);
15555 int vec_all_gt (vector unsigned short, vector unsigned short);
15556 int vec_all_gt (vector bool short, vector signed short);
15557 int vec_all_gt (vector signed short, vector bool short);
15558 int vec_all_gt (vector signed short, vector signed short);
15559 int vec_all_gt (vector bool int, vector unsigned int);
15560 int vec_all_gt (vector unsigned int, vector bool int);
15561 int vec_all_gt (vector unsigned int, vector unsigned int);
15562 int vec_all_gt (vector bool int, vector signed int);
15563 int vec_all_gt (vector signed int, vector bool int);
15564 int vec_all_gt (vector signed int, vector signed int);
15565 int vec_all_gt (vector float, vector float);
15567 int vec_all_in (vector float, vector float);
15569 int vec_all_le (vector bool char, vector unsigned char);
15570 int vec_all_le (vector unsigned char, vector bool char);
15571 int vec_all_le (vector unsigned char, vector unsigned char);
15572 int vec_all_le (vector bool char, vector signed char);
15573 int vec_all_le (vector signed char, vector bool char);
15574 int vec_all_le (vector signed char, vector signed char);
15575 int vec_all_le (vector bool short, vector unsigned short);
15576 int vec_all_le (vector unsigned short, vector bool short);
15577 int vec_all_le (vector unsigned short, vector unsigned short);
15578 int vec_all_le (vector bool short, vector signed short);
15579 int vec_all_le (vector signed short, vector bool short);
15580 int vec_all_le (vector signed short, vector signed short);
15581 int vec_all_le (vector bool int, vector unsigned int);
15582 int vec_all_le (vector unsigned int, vector bool int);
15583 int vec_all_le (vector unsigned int, vector unsigned int);
15584 int vec_all_le (vector bool int, vector signed int);
15585 int vec_all_le (vector signed int, vector bool int);
15586 int vec_all_le (vector signed int, vector signed int);
15587 int vec_all_le (vector float, vector float);
15589 int vec_all_lt (vector bool char, vector unsigned char);
15590 int vec_all_lt (vector unsigned char, vector bool char);
15591 int vec_all_lt (vector unsigned char, vector unsigned char);
15592 int vec_all_lt (vector bool char, vector signed char);
15593 int vec_all_lt (vector signed char, vector bool char);
15594 int vec_all_lt (vector signed char, vector signed char);
15595 int vec_all_lt (vector bool short, vector unsigned short);
15596 int vec_all_lt (vector unsigned short, vector bool short);
15597 int vec_all_lt (vector unsigned short, vector unsigned short);
15598 int vec_all_lt (vector bool short, vector signed short);
15599 int vec_all_lt (vector signed short, vector bool short);
15600 int vec_all_lt (vector signed short, vector signed short);
15601 int vec_all_lt (vector bool int, vector unsigned int);
15602 int vec_all_lt (vector unsigned int, vector bool int);
15603 int vec_all_lt (vector unsigned int, vector unsigned int);
15604 int vec_all_lt (vector bool int, vector signed int);
15605 int vec_all_lt (vector signed int, vector bool int);
15606 int vec_all_lt (vector signed int, vector signed int);
15607 int vec_all_lt (vector float, vector float);
15609 int vec_all_nan (vector float);
15611 int vec_all_ne (vector signed char, vector bool char);
15612 int vec_all_ne (vector signed char, vector signed char);
15613 int vec_all_ne (vector unsigned char, vector bool char);
15614 int vec_all_ne (vector unsigned char, vector unsigned char);
15615 int vec_all_ne (vector bool char, vector bool char);
15616 int vec_all_ne (vector bool char, vector unsigned char);
15617 int vec_all_ne (vector bool char, vector signed char);
15618 int vec_all_ne (vector signed short, vector bool short);
15619 int vec_all_ne (vector signed short, vector signed short);
15620 int vec_all_ne (vector unsigned short, vector bool short);
15621 int vec_all_ne (vector unsigned short, vector unsigned short);
15622 int vec_all_ne (vector bool short, vector bool short);
15623 int vec_all_ne (vector bool short, vector unsigned short);
15624 int vec_all_ne (vector bool short, vector signed short);
15625 int vec_all_ne (vector pixel, vector pixel);
15626 int vec_all_ne (vector signed int, vector bool int);
15627 int vec_all_ne (vector signed int, vector signed int);
15628 int vec_all_ne (vector unsigned int, vector bool int);
15629 int vec_all_ne (vector unsigned int, vector unsigned int);
15630 int vec_all_ne (vector bool int, vector bool int);
15631 int vec_all_ne (vector bool int, vector unsigned int);
15632 int vec_all_ne (vector bool int, vector signed int);
15633 int vec_all_ne (vector float, vector float);
15635 int vec_all_nge (vector float, vector float);
15637 int vec_all_ngt (vector float, vector float);
15639 int vec_all_nle (vector float, vector float);
15641 int vec_all_nlt (vector float, vector float);
15643 int vec_all_numeric (vector float);
15645 int vec_any_eq (vector signed char, vector bool char);
15646 int vec_any_eq (vector signed char, vector signed char);
15647 int vec_any_eq (vector unsigned char, vector bool char);
15648 int vec_any_eq (vector unsigned char, vector unsigned char);
15649 int vec_any_eq (vector bool char, vector bool char);
15650 int vec_any_eq (vector bool char, vector unsigned char);
15651 int vec_any_eq (vector bool char, vector signed char);
15652 int vec_any_eq (vector signed short, vector bool short);
15653 int vec_any_eq (vector signed short, vector signed short);
15654 int vec_any_eq (vector unsigned short, vector bool short);
15655 int vec_any_eq (vector unsigned short, vector unsigned short);
15656 int vec_any_eq (vector bool short, vector bool short);
15657 int vec_any_eq (vector bool short, vector unsigned short);
15658 int vec_any_eq (vector bool short, vector signed short);
15659 int vec_any_eq (vector pixel, vector pixel);
15660 int vec_any_eq (vector signed int, vector bool int);
15661 int vec_any_eq (vector signed int, vector signed int);
15662 int vec_any_eq (vector unsigned int, vector bool int);
15663 int vec_any_eq (vector unsigned int, vector unsigned int);
15664 int vec_any_eq (vector bool int, vector bool int);
15665 int vec_any_eq (vector bool int, vector unsigned int);
15666 int vec_any_eq (vector bool int, vector signed int);
15667 int vec_any_eq (vector float, vector float);
15669 int vec_any_ge (vector signed char, vector bool char);
15670 int vec_any_ge (vector unsigned char, vector bool char);
15671 int vec_any_ge (vector unsigned char, vector unsigned char);
15672 int vec_any_ge (vector signed char, vector signed char);
15673 int vec_any_ge (vector bool char, vector unsigned char);
15674 int vec_any_ge (vector bool char, vector signed char);
15675 int vec_any_ge (vector unsigned short, vector bool short);
15676 int vec_any_ge (vector unsigned short, vector unsigned short);
15677 int vec_any_ge (vector signed short, vector signed short);
15678 int vec_any_ge (vector signed short, vector bool short);
15679 int vec_any_ge (vector bool short, vector unsigned short);
15680 int vec_any_ge (vector bool short, vector signed short);
15681 int vec_any_ge (vector signed int, vector bool int);
15682 int vec_any_ge (vector unsigned int, vector bool int);
15683 int vec_any_ge (vector unsigned int, vector unsigned int);
15684 int vec_any_ge (vector signed int, vector signed int);
15685 int vec_any_ge (vector bool int, vector unsigned int);
15686 int vec_any_ge (vector bool int, vector signed int);
15687 int vec_any_ge (vector float, vector float);
15689 int vec_any_gt (vector bool char, vector unsigned char);
15690 int vec_any_gt (vector unsigned char, vector bool char);
15691 int vec_any_gt (vector unsigned char, vector unsigned char);
15692 int vec_any_gt (vector bool char, vector signed char);
15693 int vec_any_gt (vector signed char, vector bool char);
15694 int vec_any_gt (vector signed char, vector signed char);
15695 int vec_any_gt (vector bool short, vector unsigned short);
15696 int vec_any_gt (vector unsigned short, vector bool short);
15697 int vec_any_gt (vector unsigned short, vector unsigned short);
15698 int vec_any_gt (vector bool short, vector signed short);
15699 int vec_any_gt (vector signed short, vector bool short);
15700 int vec_any_gt (vector signed short, vector signed short);
15701 int vec_any_gt (vector bool int, vector unsigned int);
15702 int vec_any_gt (vector unsigned int, vector bool int);
15703 int vec_any_gt (vector unsigned int, vector unsigned int);
15704 int vec_any_gt (vector bool int, vector signed int);
15705 int vec_any_gt (vector signed int, vector bool int);
15706 int vec_any_gt (vector signed int, vector signed int);
15707 int vec_any_gt (vector float, vector float);
15709 int vec_any_le (vector bool char, vector unsigned char);
15710 int vec_any_le (vector unsigned char, vector bool char);
15711 int vec_any_le (vector unsigned char, vector unsigned char);
15712 int vec_any_le (vector bool char, vector signed char);
15713 int vec_any_le (vector signed char, vector bool char);
15714 int vec_any_le (vector signed char, vector signed char);
15715 int vec_any_le (vector bool short, vector unsigned short);
15716 int vec_any_le (vector unsigned short, vector bool short);
15717 int vec_any_le (vector unsigned short, vector unsigned short);
15718 int vec_any_le (vector bool short, vector signed short);
15719 int vec_any_le (vector signed short, vector bool short);
15720 int vec_any_le (vector signed short, vector signed short);
15721 int vec_any_le (vector bool int, vector unsigned int);
15722 int vec_any_le (vector unsigned int, vector bool int);
15723 int vec_any_le (vector unsigned int, vector unsigned int);
15724 int vec_any_le (vector bool int, vector signed int);
15725 int vec_any_le (vector signed int, vector bool int);
15726 int vec_any_le (vector signed int, vector signed int);
15727 int vec_any_le (vector float, vector float);
15729 int vec_any_lt (vector bool char, vector unsigned char);
15730 int vec_any_lt (vector unsigned char, vector bool char);
15731 int vec_any_lt (vector unsigned char, vector unsigned char);
15732 int vec_any_lt (vector bool char, vector signed char);
15733 int vec_any_lt (vector signed char, vector bool char);
15734 int vec_any_lt (vector signed char, vector signed char);
15735 int vec_any_lt (vector bool short, vector unsigned short);
15736 int vec_any_lt (vector unsigned short, vector bool short);
15737 int vec_any_lt (vector unsigned short, vector unsigned short);
15738 int vec_any_lt (vector bool short, vector signed short);
15739 int vec_any_lt (vector signed short, vector bool short);
15740 int vec_any_lt (vector signed short, vector signed short);
15741 int vec_any_lt (vector bool int, vector unsigned int);
15742 int vec_any_lt (vector unsigned int, vector bool int);
15743 int vec_any_lt (vector unsigned int, vector unsigned int);
15744 int vec_any_lt (vector bool int, vector signed int);
15745 int vec_any_lt (vector signed int, vector bool int);
15746 int vec_any_lt (vector signed int, vector signed int);
15747 int vec_any_lt (vector float, vector float);
15749 int vec_any_nan (vector float);
15751 int vec_any_ne (vector signed char, vector bool char);
15752 int vec_any_ne (vector signed char, vector signed char);
15753 int vec_any_ne (vector unsigned char, vector bool char);
15754 int vec_any_ne (vector unsigned char, vector unsigned char);
15755 int vec_any_ne (vector bool char, vector bool char);
15756 int vec_any_ne (vector bool char, vector unsigned char);
15757 int vec_any_ne (vector bool char, vector signed char);
15758 int vec_any_ne (vector signed short, vector bool short);
15759 int vec_any_ne (vector signed short, vector signed short);
15760 int vec_any_ne (vector unsigned short, vector bool short);
15761 int vec_any_ne (vector unsigned short, vector unsigned short);
15762 int vec_any_ne (vector bool short, vector bool short);
15763 int vec_any_ne (vector bool short, vector unsigned short);
15764 int vec_any_ne (vector bool short, vector signed short);
15765 int vec_any_ne (vector pixel, vector pixel);
15766 int vec_any_ne (vector signed int, vector bool int);
15767 int vec_any_ne (vector signed int, vector signed int);
15768 int vec_any_ne (vector unsigned int, vector bool int);
15769 int vec_any_ne (vector unsigned int, vector unsigned int);
15770 int vec_any_ne (vector bool int, vector bool int);
15771 int vec_any_ne (vector bool int, vector unsigned int);
15772 int vec_any_ne (vector bool int, vector signed int);
15773 int vec_any_ne (vector float, vector float);
15775 int vec_any_nge (vector float, vector float);
15777 int vec_any_ngt (vector float, vector float);
15779 int vec_any_nle (vector float, vector float);
15781 int vec_any_nlt (vector float, vector float);
15783 int vec_any_numeric (vector float);
15785 int vec_any_out (vector float, vector float);
15786 @end smallexample
15788 If the vector/scalar (VSX) instruction set is available, the following
15789 additional functions are available:
15791 @smallexample
15792 vector double vec_abs (vector double);
15793 vector double vec_add (vector double, vector double);
15794 vector double vec_and (vector double, vector double);
15795 vector double vec_and (vector double, vector bool long);
15796 vector double vec_and (vector bool long, vector double);
15797 vector long vec_and (vector long, vector long);
15798 vector long vec_and (vector long, vector bool long);
15799 vector long vec_and (vector bool long, vector long);
15800 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15801 vector unsigned long vec_and (vector unsigned long, vector bool long);
15802 vector unsigned long vec_and (vector bool long, vector unsigned long);
15803 vector double vec_andc (vector double, vector double);
15804 vector double vec_andc (vector double, vector bool long);
15805 vector double vec_andc (vector bool long, vector double);
15806 vector long vec_andc (vector long, vector long);
15807 vector long vec_andc (vector long, vector bool long);
15808 vector long vec_andc (vector bool long, vector long);
15809 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15810 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15811 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15812 vector double vec_ceil (vector double);
15813 vector bool long vec_cmpeq (vector double, vector double);
15814 vector bool long vec_cmpge (vector double, vector double);
15815 vector bool long vec_cmpgt (vector double, vector double);
15816 vector bool long vec_cmple (vector double, vector double);
15817 vector bool long vec_cmplt (vector double, vector double);
15818 vector double vec_cpsgn (vector double, vector double);
15819 vector float vec_div (vector float, vector float);
15820 vector double vec_div (vector double, vector double);
15821 vector long vec_div (vector long, vector long);
15822 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15823 vector double vec_floor (vector double);
15824 vector double vec_ld (int, const vector double *);
15825 vector double vec_ld (int, const double *);
15826 vector double vec_ldl (int, const vector double *);
15827 vector double vec_ldl (int, const double *);
15828 vector unsigned char vec_lvsl (int, const volatile double *);
15829 vector unsigned char vec_lvsr (int, const volatile double *);
15830 vector double vec_madd (vector double, vector double, vector double);
15831 vector double vec_max (vector double, vector double);
15832 vector signed long vec_mergeh (vector signed long, vector signed long);
15833 vector signed long vec_mergeh (vector signed long, vector bool long);
15834 vector signed long vec_mergeh (vector bool long, vector signed long);
15835 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15836 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15837 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15838 vector signed long vec_mergel (vector signed long, vector signed long);
15839 vector signed long vec_mergel (vector signed long, vector bool long);
15840 vector signed long vec_mergel (vector bool long, vector signed long);
15841 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15842 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15843 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15844 vector double vec_min (vector double, vector double);
15845 vector float vec_msub (vector float, vector float, vector float);
15846 vector double vec_msub (vector double, vector double, vector double);
15847 vector float vec_mul (vector float, vector float);
15848 vector double vec_mul (vector double, vector double);
15849 vector long vec_mul (vector long, vector long);
15850 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15851 vector float vec_nearbyint (vector float);
15852 vector double vec_nearbyint (vector double);
15853 vector float vec_nmadd (vector float, vector float, vector float);
15854 vector double vec_nmadd (vector double, vector double, vector double);
15855 vector double vec_nmsub (vector double, vector double, vector double);
15856 vector double vec_nor (vector double, vector double);
15857 vector long vec_nor (vector long, vector long);
15858 vector long vec_nor (vector long, vector bool long);
15859 vector long vec_nor (vector bool long, vector long);
15860 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15861 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15862 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15863 vector double vec_or (vector double, vector double);
15864 vector double vec_or (vector double, vector bool long);
15865 vector double vec_or (vector bool long, vector double);
15866 vector long vec_or (vector long, vector long);
15867 vector long vec_or (vector long, vector bool long);
15868 vector long vec_or (vector bool long, vector long);
15869 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15870 vector unsigned long vec_or (vector unsigned long, vector bool long);
15871 vector unsigned long vec_or (vector bool long, vector unsigned long);
15872 vector double vec_perm (vector double, vector double, vector unsigned char);
15873 vector long vec_perm (vector long, vector long, vector unsigned char);
15874 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15875                                vector unsigned char);
15876 vector double vec_rint (vector double);
15877 vector double vec_recip (vector double, vector double);
15878 vector double vec_rsqrt (vector double);
15879 vector double vec_rsqrte (vector double);
15880 vector double vec_sel (vector double, vector double, vector bool long);
15881 vector double vec_sel (vector double, vector double, vector unsigned long);
15882 vector long vec_sel (vector long, vector long, vector long);
15883 vector long vec_sel (vector long, vector long, vector unsigned long);
15884 vector long vec_sel (vector long, vector long, vector bool long);
15885 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15886                               vector long);
15887 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15888                               vector unsigned long);
15889 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15890                               vector bool long);
15891 vector double vec_splats (double);
15892 vector signed long vec_splats (signed long);
15893 vector unsigned long vec_splats (unsigned long);
15894 vector float vec_sqrt (vector float);
15895 vector double vec_sqrt (vector double);
15896 void vec_st (vector double, int, vector double *);
15897 void vec_st (vector double, int, double *);
15898 vector double vec_sub (vector double, vector double);
15899 vector double vec_trunc (vector double);
15900 vector double vec_xor (vector double, vector double);
15901 vector double vec_xor (vector double, vector bool long);
15902 vector double vec_xor (vector bool long, vector double);
15903 vector long vec_xor (vector long, vector long);
15904 vector long vec_xor (vector long, vector bool long);
15905 vector long vec_xor (vector bool long, vector long);
15906 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15907 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15908 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15909 int vec_all_eq (vector double, vector double);
15910 int vec_all_ge (vector double, vector double);
15911 int vec_all_gt (vector double, vector double);
15912 int vec_all_le (vector double, vector double);
15913 int vec_all_lt (vector double, vector double);
15914 int vec_all_nan (vector double);
15915 int vec_all_ne (vector double, vector double);
15916 int vec_all_nge (vector double, vector double);
15917 int vec_all_ngt (vector double, vector double);
15918 int vec_all_nle (vector double, vector double);
15919 int vec_all_nlt (vector double, vector double);
15920 int vec_all_numeric (vector double);
15921 int vec_any_eq (vector double, vector double);
15922 int vec_any_ge (vector double, vector double);
15923 int vec_any_gt (vector double, vector double);
15924 int vec_any_le (vector double, vector double);
15925 int vec_any_lt (vector double, vector double);
15926 int vec_any_nan (vector double);
15927 int vec_any_ne (vector double, vector double);
15928 int vec_any_nge (vector double, vector double);
15929 int vec_any_ngt (vector double, vector double);
15930 int vec_any_nle (vector double, vector double);
15931 int vec_any_nlt (vector double, vector double);
15932 int vec_any_numeric (vector double);
15934 vector double vec_vsx_ld (int, const vector double *);
15935 vector double vec_vsx_ld (int, const double *);
15936 vector float vec_vsx_ld (int, const vector float *);
15937 vector float vec_vsx_ld (int, const float *);
15938 vector bool int vec_vsx_ld (int, const vector bool int *);
15939 vector signed int vec_vsx_ld (int, const vector signed int *);
15940 vector signed int vec_vsx_ld (int, const int *);
15941 vector signed int vec_vsx_ld (int, const long *);
15942 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15943 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15944 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15945 vector bool short vec_vsx_ld (int, const vector bool short *);
15946 vector pixel vec_vsx_ld (int, const vector pixel *);
15947 vector signed short vec_vsx_ld (int, const vector signed short *);
15948 vector signed short vec_vsx_ld (int, const short *);
15949 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15950 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15951 vector bool char vec_vsx_ld (int, const vector bool char *);
15952 vector signed char vec_vsx_ld (int, const vector signed char *);
15953 vector signed char vec_vsx_ld (int, const signed char *);
15954 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15955 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15957 void vec_vsx_st (vector double, int, vector double *);
15958 void vec_vsx_st (vector double, int, double *);
15959 void vec_vsx_st (vector float, int, vector float *);
15960 void vec_vsx_st (vector float, int, float *);
15961 void vec_vsx_st (vector signed int, int, vector signed int *);
15962 void vec_vsx_st (vector signed int, int, int *);
15963 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15964 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15965 void vec_vsx_st (vector bool int, int, vector bool int *);
15966 void vec_vsx_st (vector bool int, int, unsigned int *);
15967 void vec_vsx_st (vector bool int, int, int *);
15968 void vec_vsx_st (vector signed short, int, vector signed short *);
15969 void vec_vsx_st (vector signed short, int, short *);
15970 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15971 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15972 void vec_vsx_st (vector bool short, int, vector bool short *);
15973 void vec_vsx_st (vector bool short, int, unsigned short *);
15974 void vec_vsx_st (vector pixel, int, vector pixel *);
15975 void vec_vsx_st (vector pixel, int, unsigned short *);
15976 void vec_vsx_st (vector pixel, int, short *);
15977 void vec_vsx_st (vector bool short, int, short *);
15978 void vec_vsx_st (vector signed char, int, vector signed char *);
15979 void vec_vsx_st (vector signed char, int, signed char *);
15980 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15981 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15982 void vec_vsx_st (vector bool char, int, vector bool char *);
15983 void vec_vsx_st (vector bool char, int, unsigned char *);
15984 void vec_vsx_st (vector bool char, int, signed char *);
15986 vector double vec_xxpermdi (vector double, vector double, int);
15987 vector float vec_xxpermdi (vector float, vector float, int);
15988 vector long long vec_xxpermdi (vector long long, vector long long, int);
15989 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15990                                         vector unsigned long long, int);
15991 vector int vec_xxpermdi (vector int, vector int, int);
15992 vector unsigned int vec_xxpermdi (vector unsigned int,
15993                                   vector unsigned int, int);
15994 vector short vec_xxpermdi (vector short, vector short, int);
15995 vector unsigned short vec_xxpermdi (vector unsigned short,
15996                                     vector unsigned short, int);
15997 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15998 vector unsigned char vec_xxpermdi (vector unsigned char,
15999                                    vector unsigned char, int);
16001 vector double vec_xxsldi (vector double, vector double, int);
16002 vector float vec_xxsldi (vector float, vector float, int);
16003 vector long long vec_xxsldi (vector long long, vector long long, int);
16004 vector unsigned long long vec_xxsldi (vector unsigned long long,
16005                                       vector unsigned long long, int);
16006 vector int vec_xxsldi (vector int, vector int, int);
16007 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
16008 vector short vec_xxsldi (vector short, vector short, int);
16009 vector unsigned short vec_xxsldi (vector unsigned short,
16010                                   vector unsigned short, int);
16011 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
16012 vector unsigned char vec_xxsldi (vector unsigned char,
16013                                  vector unsigned char, int);
16014 @end smallexample
16016 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16017 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16018 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
16019 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16020 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16022 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16023 instruction set is available, the following additional functions are
16024 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
16025 can use @var{vector long} instead of @var{vector long long},
16026 @var{vector bool long} instead of @var{vector bool long long}, and
16027 @var{vector unsigned long} instead of @var{vector unsigned long long}.
16029 @smallexample
16030 vector long long vec_abs (vector long long);
16032 vector long long vec_add (vector long long, vector long long);
16033 vector unsigned long long vec_add (vector unsigned long long,
16034                                    vector unsigned long long);
16036 int vec_all_eq (vector long long, vector long long);
16037 int vec_all_eq (vector unsigned long long, vector unsigned long long);
16038 int vec_all_ge (vector long long, vector long long);
16039 int vec_all_ge (vector unsigned long long, vector unsigned long long);
16040 int vec_all_gt (vector long long, vector long long);
16041 int vec_all_gt (vector unsigned long long, vector unsigned long long);
16042 int vec_all_le (vector long long, vector long long);
16043 int vec_all_le (vector unsigned long long, vector unsigned long long);
16044 int vec_all_lt (vector long long, vector long long);
16045 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16046 int vec_all_ne (vector long long, vector long long);
16047 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16049 int vec_any_eq (vector long long, vector long long);
16050 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16051 int vec_any_ge (vector long long, vector long long);
16052 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16053 int vec_any_gt (vector long long, vector long long);
16054 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16055 int vec_any_le (vector long long, vector long long);
16056 int vec_any_le (vector unsigned long long, vector unsigned long long);
16057 int vec_any_lt (vector long long, vector long long);
16058 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16059 int vec_any_ne (vector long long, vector long long);
16060 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16062 vector long long vec_eqv (vector long long, vector long long);
16063 vector long long vec_eqv (vector bool long long, vector long long);
16064 vector long long vec_eqv (vector long long, vector bool long long);
16065 vector unsigned long long vec_eqv (vector unsigned long long,
16066                                    vector unsigned long long);
16067 vector unsigned long long vec_eqv (vector bool long long,
16068                                    vector unsigned long long);
16069 vector unsigned long long vec_eqv (vector unsigned long long,
16070                                    vector bool long long);
16071 vector int vec_eqv (vector int, vector int);
16072 vector int vec_eqv (vector bool int, vector int);
16073 vector int vec_eqv (vector int, vector bool int);
16074 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16075 vector unsigned int vec_eqv (vector bool unsigned int,
16076                              vector unsigned int);
16077 vector unsigned int vec_eqv (vector unsigned int,
16078                              vector bool unsigned int);
16079 vector short vec_eqv (vector short, vector short);
16080 vector short vec_eqv (vector bool short, vector short);
16081 vector short vec_eqv (vector short, vector bool short);
16082 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16083 vector unsigned short vec_eqv (vector bool unsigned short,
16084                                vector unsigned short);
16085 vector unsigned short vec_eqv (vector unsigned short,
16086                                vector bool unsigned short);
16087 vector signed char vec_eqv (vector signed char, vector signed char);
16088 vector signed char vec_eqv (vector bool signed char, vector signed char);
16089 vector signed char vec_eqv (vector signed char, vector bool signed char);
16090 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16091 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16092 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16094 vector long long vec_max (vector long long, vector long long);
16095 vector unsigned long long vec_max (vector unsigned long long,
16096                                    vector unsigned long long);
16098 vector signed int vec_mergee (vector signed int, vector signed int);
16099 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16100 vector bool int vec_mergee (vector bool int, vector bool int);
16102 vector signed int vec_mergeo (vector signed int, vector signed int);
16103 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16104 vector bool int vec_mergeo (vector bool int, vector bool int);
16106 vector long long vec_min (vector long long, vector long long);
16107 vector unsigned long long vec_min (vector unsigned long long,
16108                                    vector unsigned long long);
16110 vector long long vec_nand (vector long long, vector long long);
16111 vector long long vec_nand (vector bool long long, vector long long);
16112 vector long long vec_nand (vector long long, vector bool long long);
16113 vector unsigned long long vec_nand (vector unsigned long long,
16114                                     vector unsigned long long);
16115 vector unsigned long long vec_nand (vector bool long long,
16116                                    vector unsigned long long);
16117 vector unsigned long long vec_nand (vector unsigned long long,
16118                                     vector bool long long);
16119 vector int vec_nand (vector int, vector int);
16120 vector int vec_nand (vector bool int, vector int);
16121 vector int vec_nand (vector int, vector bool int);
16122 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16123 vector unsigned int vec_nand (vector bool unsigned int,
16124                               vector unsigned int);
16125 vector unsigned int vec_nand (vector unsigned int,
16126                               vector bool unsigned int);
16127 vector short vec_nand (vector short, vector short);
16128 vector short vec_nand (vector bool short, vector short);
16129 vector short vec_nand (vector short, vector bool short);
16130 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16131 vector unsigned short vec_nand (vector bool unsigned short,
16132                                 vector unsigned short);
16133 vector unsigned short vec_nand (vector unsigned short,
16134                                 vector bool unsigned short);
16135 vector signed char vec_nand (vector signed char, vector signed char);
16136 vector signed char vec_nand (vector bool signed char, vector signed char);
16137 vector signed char vec_nand (vector signed char, vector bool signed char);
16138 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16139 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16140 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16142 vector long long vec_orc (vector long long, vector long long);
16143 vector long long vec_orc (vector bool long long, vector long long);
16144 vector long long vec_orc (vector long long, vector bool long long);
16145 vector unsigned long long vec_orc (vector unsigned long long,
16146                                    vector unsigned long long);
16147 vector unsigned long long vec_orc (vector bool long long,
16148                                    vector unsigned long long);
16149 vector unsigned long long vec_orc (vector unsigned long long,
16150                                    vector bool long long);
16151 vector int vec_orc (vector int, vector int);
16152 vector int vec_orc (vector bool int, vector int);
16153 vector int vec_orc (vector int, vector bool int);
16154 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16155 vector unsigned int vec_orc (vector bool unsigned int,
16156                              vector unsigned int);
16157 vector unsigned int vec_orc (vector unsigned int,
16158                              vector bool unsigned int);
16159 vector short vec_orc (vector short, vector short);
16160 vector short vec_orc (vector bool short, vector short);
16161 vector short vec_orc (vector short, vector bool short);
16162 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16163 vector unsigned short vec_orc (vector bool unsigned short,
16164                                vector unsigned short);
16165 vector unsigned short vec_orc (vector unsigned short,
16166                                vector bool unsigned short);
16167 vector signed char vec_orc (vector signed char, vector signed char);
16168 vector signed char vec_orc (vector bool signed char, vector signed char);
16169 vector signed char vec_orc (vector signed char, vector bool signed char);
16170 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16171 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16172 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16174 vector int vec_pack (vector long long, vector long long);
16175 vector unsigned int vec_pack (vector unsigned long long,
16176                               vector unsigned long long);
16177 vector bool int vec_pack (vector bool long long, vector bool long long);
16179 vector int vec_packs (vector long long, vector long long);
16180 vector unsigned int vec_packs (vector unsigned long long,
16181                                vector unsigned long long);
16183 vector unsigned int vec_packsu (vector long long, vector long long);
16184 vector unsigned int vec_packsu (vector unsigned long long,
16185                                 vector unsigned long long);
16187 vector long long vec_rl (vector long long,
16188                          vector unsigned long long);
16189 vector long long vec_rl (vector unsigned long long,
16190                          vector unsigned long long);
16192 vector long long vec_sl (vector long long, vector unsigned long long);
16193 vector long long vec_sl (vector unsigned long long,
16194                          vector unsigned long long);
16196 vector long long vec_sr (vector long long, vector unsigned long long);
16197 vector unsigned long long char vec_sr (vector unsigned long long,
16198                                        vector unsigned long long);
16200 vector long long vec_sra (vector long long, vector unsigned long long);
16201 vector unsigned long long vec_sra (vector unsigned long long,
16202                                    vector unsigned long long);
16204 vector long long vec_sub (vector long long, vector long long);
16205 vector unsigned long long vec_sub (vector unsigned long long,
16206                                    vector unsigned long long);
16208 vector long long vec_unpackh (vector int);
16209 vector unsigned long long vec_unpackh (vector unsigned int);
16211 vector long long vec_unpackl (vector int);
16212 vector unsigned long long vec_unpackl (vector unsigned int);
16214 vector long long vec_vaddudm (vector long long, vector long long);
16215 vector long long vec_vaddudm (vector bool long long, vector long long);
16216 vector long long vec_vaddudm (vector long long, vector bool long long);
16217 vector unsigned long long vec_vaddudm (vector unsigned long long,
16218                                        vector unsigned long long);
16219 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16220                                        vector unsigned long long);
16221 vector unsigned long long vec_vaddudm (vector unsigned long long,
16222                                        vector bool unsigned long long);
16224 vector long long vec_vbpermq (vector signed char, vector signed char);
16225 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16227 vector long long vec_cntlz (vector long long);
16228 vector unsigned long long vec_cntlz (vector unsigned long long);
16229 vector int vec_cntlz (vector int);
16230 vector unsigned int vec_cntlz (vector int);
16231 vector short vec_cntlz (vector short);
16232 vector unsigned short vec_cntlz (vector unsigned short);
16233 vector signed char vec_cntlz (vector signed char);
16234 vector unsigned char vec_cntlz (vector unsigned char);
16236 vector long long vec_vclz (vector long long);
16237 vector unsigned long long vec_vclz (vector unsigned long long);
16238 vector int vec_vclz (vector int);
16239 vector unsigned int vec_vclz (vector int);
16240 vector short vec_vclz (vector short);
16241 vector unsigned short vec_vclz (vector unsigned short);
16242 vector signed char vec_vclz (vector signed char);
16243 vector unsigned char vec_vclz (vector unsigned char);
16245 vector signed char vec_vclzb (vector signed char);
16246 vector unsigned char vec_vclzb (vector unsigned char);
16248 vector long long vec_vclzd (vector long long);
16249 vector unsigned long long vec_vclzd (vector unsigned long long);
16251 vector short vec_vclzh (vector short);
16252 vector unsigned short vec_vclzh (vector unsigned short);
16254 vector int vec_vclzw (vector int);
16255 vector unsigned int vec_vclzw (vector int);
16257 vector signed char vec_vgbbd (vector signed char);
16258 vector unsigned char vec_vgbbd (vector unsigned char);
16260 vector long long vec_vmaxsd (vector long long, vector long long);
16262 vector unsigned long long vec_vmaxud (vector unsigned long long,
16263                                       unsigned vector long long);
16265 vector long long vec_vminsd (vector long long, vector long long);
16267 vector unsigned long long vec_vminud (vector long long,
16268                                       vector long long);
16270 vector int vec_vpksdss (vector long long, vector long long);
16271 vector unsigned int vec_vpksdss (vector long long, vector long long);
16273 vector unsigned int vec_vpkudus (vector unsigned long long,
16274                                  vector unsigned long long);
16276 vector int vec_vpkudum (vector long long, vector long long);
16277 vector unsigned int vec_vpkudum (vector unsigned long long,
16278                                  vector unsigned long long);
16279 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16281 vector long long vec_vpopcnt (vector long long);
16282 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16283 vector int vec_vpopcnt (vector int);
16284 vector unsigned int vec_vpopcnt (vector int);
16285 vector short vec_vpopcnt (vector short);
16286 vector unsigned short vec_vpopcnt (vector unsigned short);
16287 vector signed char vec_vpopcnt (vector signed char);
16288 vector unsigned char vec_vpopcnt (vector unsigned char);
16290 vector signed char vec_vpopcntb (vector signed char);
16291 vector unsigned char vec_vpopcntb (vector unsigned char);
16293 vector long long vec_vpopcntd (vector long long);
16294 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16296 vector short vec_vpopcnth (vector short);
16297 vector unsigned short vec_vpopcnth (vector unsigned short);
16299 vector int vec_vpopcntw (vector int);
16300 vector unsigned int vec_vpopcntw (vector int);
16302 vector long long vec_vrld (vector long long, vector unsigned long long);
16303 vector unsigned long long vec_vrld (vector unsigned long long,
16304                                     vector unsigned long long);
16306 vector long long vec_vsld (vector long long, vector unsigned long long);
16307 vector long long vec_vsld (vector unsigned long long,
16308                            vector unsigned long long);
16310 vector long long vec_vsrad (vector long long, vector unsigned long long);
16311 vector unsigned long long vec_vsrad (vector unsigned long long,
16312                                      vector unsigned long long);
16314 vector long long vec_vsrd (vector long long, vector unsigned long long);
16315 vector unsigned long long char vec_vsrd (vector unsigned long long,
16316                                          vector unsigned long long);
16318 vector long long vec_vsubudm (vector long long, vector long long);
16319 vector long long vec_vsubudm (vector bool long long, vector long long);
16320 vector long long vec_vsubudm (vector long long, vector bool long long);
16321 vector unsigned long long vec_vsubudm (vector unsigned long long,
16322                                        vector unsigned long long);
16323 vector unsigned long long vec_vsubudm (vector bool long long,
16324                                        vector unsigned long long);
16325 vector unsigned long long vec_vsubudm (vector unsigned long long,
16326                                        vector bool long long);
16328 vector long long vec_vupkhsw (vector int);
16329 vector unsigned long long vec_vupkhsw (vector unsigned int);
16331 vector long long vec_vupklsw (vector int);
16332 vector unsigned long long vec_vupklsw (vector int);
16333 @end smallexample
16335 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16336 instruction set is available, the following additional functions are
16337 available for 64-bit targets.  New vector types
16338 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16339 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16340 builtins.
16342 The normal vector extract, and set operations work on
16343 @var{vector __int128_t} and @var{vector __uint128_t} types,
16344 but the index value must be 0.
16346 @smallexample
16347 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16348 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16350 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16351 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16353 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16354                                 vector __int128_t);
16355 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
16356                                  vector __uint128_t);
16358 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16359                                 vector __int128_t);
16360 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
16361                                  vector __uint128_t);
16363 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16364                                 vector __int128_t);
16365 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
16366                                  vector __uint128_t);
16368 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16369                                 vector __int128_t);
16370 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16371                                  vector __uint128_t);
16373 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16374 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16376 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16377 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16379 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16380 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16381 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16382 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16383 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16384 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16385 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16386 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16387 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16388 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16389 @end smallexample
16391 If the cryptographic instructions are enabled (@option{-mcrypto} or
16392 @option{-mcpu=power8}), the following builtins are enabled.
16394 @smallexample
16395 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16397 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16398                                                     vector unsigned long long);
16400 vector unsigned long long __builtin_crypto_vcipherlast
16401                                      (vector unsigned long long,
16402                                       vector unsigned long long);
16404 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16405                                                      vector unsigned long long);
16407 vector unsigned long long __builtin_crypto_vncipherlast
16408                                      (vector unsigned long long,
16409                                       vector unsigned long long);
16411 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16412                                                 vector unsigned char,
16413                                                 vector unsigned char);
16415 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16416                                                  vector unsigned short,
16417                                                  vector unsigned short);
16419 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16420                                                vector unsigned int,
16421                                                vector unsigned int);
16423 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16424                                                      vector unsigned long long,
16425                                                      vector unsigned long long);
16427 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16428                                                vector unsigned char);
16430 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16431                                                 vector unsigned short);
16433 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16434                                               vector unsigned int);
16436 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16437                                                     vector unsigned long long);
16439 vector unsigned long long __builtin_crypto_vshasigmad
16440                                (vector unsigned long long, int, int);
16442 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16443                                                  int, int);
16444 @end smallexample
16446 The second argument to the @var{__builtin_crypto_vshasigmad} and
16447 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16448 integer that is 0 or 1.  The third argument to these builtin functions
16449 must be a constant integer in the range of 0 to 15.
16451 @node PowerPC Hardware Transactional Memory Built-in Functions
16452 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16453 GCC provides two interfaces for accessing the Hardware Transactional
16454 Memory (HTM) instructions available on some of the PowerPC family
16455 of prcoessors (eg, POWER8).  The two interfaces come in a low level
16456 interface, consisting of built-in functions specific to PowerPC and a
16457 higher level interface consisting of inline functions that are common
16458 between PowerPC and S/390.
16460 @subsubsection PowerPC HTM Low Level Built-in Functions
16462 The following low level built-in functions are available with
16463 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16464 They all generate the machine instruction that is part of the name.
16466 The HTM built-ins return true or false depending on their success and
16467 their arguments match exactly the type and order of the associated
16468 hardware instruction's operands.  Refer to the ISA manual for a
16469 description of each instruction's operands.
16471 @smallexample
16472 unsigned int __builtin_tbegin (unsigned int)
16473 unsigned int __builtin_tend (unsigned int)
16475 unsigned int __builtin_tabort (unsigned int)
16476 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16477 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16478 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16479 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16481 unsigned int __builtin_tcheck (unsigned int)
16482 unsigned int __builtin_treclaim (unsigned int)
16483 unsigned int __builtin_trechkpt (void)
16484 unsigned int __builtin_tsr (unsigned int)
16485 @end smallexample
16487 In addition to the above HTM built-ins, we have added built-ins for
16488 some common extended mnemonics of the HTM instructions:
16490 @smallexample
16491 unsigned int __builtin_tendall (void)
16492 unsigned int __builtin_tresume (void)
16493 unsigned int __builtin_tsuspend (void)
16494 @end smallexample
16496 The following set of built-in functions are available to gain access
16497 to the HTM specific special purpose registers.
16499 @smallexample
16500 unsigned long __builtin_get_texasr (void)
16501 unsigned long __builtin_get_texasru (void)
16502 unsigned long __builtin_get_tfhar (void)
16503 unsigned long __builtin_get_tfiar (void)
16505 void __builtin_set_texasr (unsigned long);
16506 void __builtin_set_texasru (unsigned long);
16507 void __builtin_set_tfhar (unsigned long);
16508 void __builtin_set_tfiar (unsigned long);
16509 @end smallexample
16511 Example usage of these low level built-in functions may look like:
16513 @smallexample
16514 #include <htmintrin.h>
16516 int num_retries = 10;
16518 while (1)
16519   @{
16520     if (__builtin_tbegin (0))
16521       @{
16522         /* Transaction State Initiated.  */
16523         if (is_locked (lock))
16524           __builtin_tabort (0);
16525         ... transaction code...
16526         __builtin_tend (0);
16527         break;
16528       @}
16529     else
16530       @{
16531         /* Transaction State Failed.  Use locks if the transaction
16532            failure is "persistent" or we've tried too many times.  */
16533         if (num_retries-- <= 0
16534             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16535           @{
16536             acquire_lock (lock);
16537             ... non transactional fallback path...
16538             release_lock (lock);
16539             break;
16540           @}
16541       @}
16542   @}
16543 @end smallexample
16545 One final built-in function has been added that returns the value of
16546 the 2-bit Transaction State field of the Machine Status Register (MSR)
16547 as stored in @code{CR0}.
16549 @smallexample
16550 unsigned long __builtin_ttest (void)
16551 @end smallexample
16553 This built-in can be used to determine the current transaction state
16554 using the following code example:
16556 @smallexample
16557 #include <htmintrin.h>
16559 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16561 if (tx_state == _HTM_TRANSACTIONAL)
16562   @{
16563     /* Code to use in transactional state.  */
16564   @}
16565 else if (tx_state == _HTM_NONTRANSACTIONAL)
16566   @{
16567     /* Code to use in non-transactional state.  */
16568   @}
16569 else if (tx_state == _HTM_SUSPENDED)
16570   @{
16571     /* Code to use in transaction suspended state.  */
16572   @}
16573 @end smallexample
16575 @subsubsection PowerPC HTM High Level Inline Functions
16577 The following high level HTM interface is made available by including
16578 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16579 where CPU is `power8' or later.  This interface is common between PowerPC
16580 and S/390, allowing users to write one HTM source implementation that
16581 can be compiled and executed on either system.
16583 @smallexample
16584 long __TM_simple_begin (void)
16585 long __TM_begin (void* const TM_buff)
16586 long __TM_end (void)
16587 void __TM_abort (void)
16588 void __TM_named_abort (unsigned char const code)
16589 void __TM_resume (void)
16590 void __TM_suspend (void)
16592 long __TM_is_user_abort (void* const TM_buff)
16593 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16594 long __TM_is_illegal (void* const TM_buff)
16595 long __TM_is_footprint_exceeded (void* const TM_buff)
16596 long __TM_nesting_depth (void* const TM_buff)
16597 long __TM_is_nested_too_deep(void* const TM_buff)
16598 long __TM_is_conflict(void* const TM_buff)
16599 long __TM_is_failure_persistent(void* const TM_buff)
16600 long __TM_failure_address(void* const TM_buff)
16601 long long __TM_failure_code(void* const TM_buff)
16602 @end smallexample
16604 Using these common set of HTM inline functions, we can create
16605 a more portable version of the HTM example in the previous
16606 section that will work on either PowerPC or S/390:
16608 @smallexample
16609 #include <htmxlintrin.h>
16611 int num_retries = 10;
16612 TM_buff_type TM_buff;
16614 while (1)
16615   @{
16616     if (__TM_begin (TM_buff))
16617       @{
16618         /* Transaction State Initiated.  */
16619         if (is_locked (lock))
16620           __TM_abort ();
16621         ... transaction code...
16622         __TM_end ();
16623         break;
16624       @}
16625     else
16626       @{
16627         /* Transaction State Failed.  Use locks if the transaction
16628            failure is "persistent" or we've tried too many times.  */
16629         if (num_retries-- <= 0
16630             || __TM_is_failure_persistent (TM_buff))
16631           @{
16632             acquire_lock (lock);
16633             ... non transactional fallback path...
16634             release_lock (lock);
16635             break;
16636           @}
16637       @}
16638   @}
16639 @end smallexample
16641 @node RX Built-in Functions
16642 @subsection RX Built-in Functions
16643 GCC supports some of the RX instructions which cannot be expressed in
16644 the C programming language via the use of built-in functions.  The
16645 following functions are supported:
16647 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
16648 Generates the @code{brk} machine instruction.
16649 @end deftypefn
16651 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
16652 Generates the @code{clrpsw} machine instruction to clear the specified
16653 bit in the processor status word.
16654 @end deftypefn
16656 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
16657 Generates the @code{int} machine instruction to generate an interrupt
16658 with the specified value.
16659 @end deftypefn
16661 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
16662 Generates the @code{machi} machine instruction to add the result of
16663 multiplying the top 16 bits of the two arguments into the
16664 accumulator.
16665 @end deftypefn
16667 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
16668 Generates the @code{maclo} machine instruction to add the result of
16669 multiplying the bottom 16 bits of the two arguments into the
16670 accumulator.
16671 @end deftypefn
16673 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
16674 Generates the @code{mulhi} machine instruction to place the result of
16675 multiplying the top 16 bits of the two arguments into the
16676 accumulator.
16677 @end deftypefn
16679 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
16680 Generates the @code{mullo} machine instruction to place the result of
16681 multiplying the bottom 16 bits of the two arguments into the
16682 accumulator.
16683 @end deftypefn
16685 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
16686 Generates the @code{mvfachi} machine instruction to read the top
16687 32 bits of the accumulator.
16688 @end deftypefn
16690 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
16691 Generates the @code{mvfacmi} machine instruction to read the middle
16692 32 bits of the accumulator.
16693 @end deftypefn
16695 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
16696 Generates the @code{mvfc} machine instruction which reads the control
16697 register specified in its argument and returns its value.
16698 @end deftypefn
16700 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
16701 Generates the @code{mvtachi} machine instruction to set the top
16702 32 bits of the accumulator.
16703 @end deftypefn
16705 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
16706 Generates the @code{mvtaclo} machine instruction to set the bottom
16707 32 bits of the accumulator.
16708 @end deftypefn
16710 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
16711 Generates the @code{mvtc} machine instruction which sets control
16712 register number @code{reg} to @code{val}.
16713 @end deftypefn
16715 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
16716 Generates the @code{mvtipl} machine instruction set the interrupt
16717 priority level.
16718 @end deftypefn
16720 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
16721 Generates the @code{racw} machine instruction to round the accumulator
16722 according to the specified mode.
16723 @end deftypefn
16725 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
16726 Generates the @code{revw} machine instruction which swaps the bytes in
16727 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16728 and also bits 16--23 occupy bits 24--31 and vice versa.
16729 @end deftypefn
16731 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
16732 Generates the @code{rmpa} machine instruction which initiates a
16733 repeated multiply and accumulate sequence.
16734 @end deftypefn
16736 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
16737 Generates the @code{round} machine instruction which returns the
16738 floating-point argument rounded according to the current rounding mode
16739 set in the floating-point status word register.
16740 @end deftypefn
16742 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
16743 Generates the @code{sat} machine instruction which returns the
16744 saturated value of the argument.
16745 @end deftypefn
16747 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
16748 Generates the @code{setpsw} machine instruction to set the specified
16749 bit in the processor status word.
16750 @end deftypefn
16752 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
16753 Generates the @code{wait} machine instruction.
16754 @end deftypefn
16756 @node S/390 System z Built-in Functions
16757 @subsection S/390 System z Built-in Functions
16758 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16759 Generates the @code{tbegin} machine instruction starting a
16760 non-constraint hardware transaction.  If the parameter is non-NULL the
16761 memory area is used to store the transaction diagnostic buffer and
16762 will be passed as first operand to @code{tbegin}.  This buffer can be
16763 defined using the @code{struct __htm_tdb} C struct defined in
16764 @code{htmintrin.h} and must reside on a double-word boundary.  The
16765 second tbegin operand is set to @code{0xff0c}. This enables
16766 save/restore of all GPRs and disables aborts for FPR and AR
16767 manipulations inside the transaction body.  The condition code set by
16768 the tbegin instruction is returned as integer value.  The tbegin
16769 instruction by definition overwrites the content of all FPRs.  The
16770 compiler will generate code which saves and restores the FPRs.  For
16771 soft-float code it is recommended to used the @code{*_nofloat}
16772 variant.  In order to prevent a TDB from being written it is required
16773 to pass an constant zero value as parameter.  Passing the zero value
16774 through a variable is not sufficient.  Although modifications of
16775 access registers inside the transaction will not trigger an
16776 transaction abort it is not supported to actually modify them.  Access
16777 registers do not get saved when entering a transaction. They will have
16778 undefined state when reaching the abort code.
16779 @end deftypefn
16781 Macros for the possible return codes of tbegin are defined in the
16782 @code{htmintrin.h} header file:
16784 @table @code
16785 @item _HTM_TBEGIN_STARTED
16786 @code{tbegin} has been executed as part of normal processing.  The
16787 transaction body is supposed to be executed.
16788 @item _HTM_TBEGIN_INDETERMINATE
16789 The transaction was aborted due to an indeterminate condition which
16790 might be persistent.
16791 @item _HTM_TBEGIN_TRANSIENT
16792 The transaction aborted due to a transient failure.  The transaction
16793 should be re-executed in that case.
16794 @item _HTM_TBEGIN_PERSISTENT
16795 The transaction aborted due to a persistent failure.  Re-execution
16796 under same circumstances will not be productive.
16797 @end table
16799 @defmac _HTM_FIRST_USER_ABORT_CODE
16800 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16801 specifies the first abort code which can be used for
16802 @code{__builtin_tabort}.  Values below this threshold are reserved for
16803 machine use.
16804 @end defmac
16806 @deftp {Data type} {struct __htm_tdb}
16807 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16808 the structure of the transaction diagnostic block as specified in the
16809 Principles of Operation manual chapter 5-91.
16810 @end deftp
16812 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16813 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16814 Using this variant in code making use of FPRs will leave the FPRs in
16815 undefined state when entering the transaction abort handler code.
16816 @end deftypefn
16818 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16819 In addition to @code{__builtin_tbegin} a loop for transient failures
16820 is generated.  If tbegin returns a condition code of 2 the transaction
16821 will be retried as often as specified in the second argument.  The
16822 perform processor assist instruction is used to tell the CPU about the
16823 number of fails so far.
16824 @end deftypefn
16826 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16827 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16828 restores.  Using this variant in code making use of FPRs will leave
16829 the FPRs in undefined state when entering the transaction abort
16830 handler code.
16831 @end deftypefn
16833 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16834 Generates the @code{tbeginc} machine instruction starting a constraint
16835 hardware transaction.  The second operand is set to @code{0xff08}.
16836 @end deftypefn
16838 @deftypefn {Built-in Function} int __builtin_tend (void)
16839 Generates the @code{tend} machine instruction finishing a transaction
16840 and making the changes visible to other threads.  The condition code
16841 generated by tend is returned as integer value.
16842 @end deftypefn
16844 @deftypefn {Built-in Function} void __builtin_tabort (int)
16845 Generates the @code{tabort} machine instruction with the specified
16846 abort code.  Abort codes from 0 through 255 are reserved and will
16847 result in an error message.
16848 @end deftypefn
16850 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16851 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16852 integer parameter is loaded into rX and a value of zero is loaded into
16853 rY.  The integer parameter specifies the number of times the
16854 transaction repeatedly aborted.
16855 @end deftypefn
16857 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16858 Generates the @code{etnd} machine instruction.  The current nesting
16859 depth is returned as integer value.  For a nesting depth of 0 the code
16860 is not executed as part of an transaction.
16861 @end deftypefn
16863 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16865 Generates the @code{ntstg} machine instruction.  The second argument
16866 is written to the first arguments location.  The store operation will
16867 not be rolled-back in case of an transaction abort.
16868 @end deftypefn
16870 @node SH Built-in Functions
16871 @subsection SH Built-in Functions
16872 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16873 families of processors:
16875 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16876 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16877 used by system code that manages threads and execution contexts.  The compiler
16878 normally does not generate code that modifies the contents of @samp{GBR} and
16879 thus the value is preserved across function calls.  Changing the @samp{GBR}
16880 value in user code must be done with caution, since the compiler might use
16881 @samp{GBR} in order to access thread local variables.
16883 @end deftypefn
16885 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16886 Returns the value that is currently set in the @samp{GBR} register.
16887 Memory loads and stores that use the thread pointer as a base address are
16888 turned into @samp{GBR} based displacement loads and stores, if possible.
16889 For example:
16890 @smallexample
16891 struct my_tcb
16893    int a, b, c, d, e;
16896 int get_tcb_value (void)
16898   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16899   return ((my_tcb*)__builtin_thread_pointer ())->c;
16902 @end smallexample
16903 @end deftypefn
16905 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16906 Returns the value that is currently set in the @samp{FPSCR} register.
16907 @end deftypefn
16909 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16910 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16911 preserving the current values of the FR, SZ and PR bits.
16912 @end deftypefn
16914 @node SPARC VIS Built-in Functions
16915 @subsection SPARC VIS Built-in Functions
16917 GCC supports SIMD operations on the SPARC using both the generic vector
16918 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16919 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16920 switch, the VIS extension is exposed as the following built-in functions:
16922 @smallexample
16923 typedef int v1si __attribute__ ((vector_size (4)));
16924 typedef int v2si __attribute__ ((vector_size (8)));
16925 typedef short v4hi __attribute__ ((vector_size (8)));
16926 typedef short v2hi __attribute__ ((vector_size (4)));
16927 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16928 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16930 void __builtin_vis_write_gsr (int64_t);
16931 int64_t __builtin_vis_read_gsr (void);
16933 void * __builtin_vis_alignaddr (void *, long);
16934 void * __builtin_vis_alignaddrl (void *, long);
16935 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16936 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16937 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16938 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16940 v4hi __builtin_vis_fexpand (v4qi);
16942 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16943 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16944 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16945 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16946 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16947 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16948 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16950 v4qi __builtin_vis_fpack16 (v4hi);
16951 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16952 v2hi __builtin_vis_fpackfix (v2si);
16953 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16955 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16957 long __builtin_vis_edge8 (void *, void *);
16958 long __builtin_vis_edge8l (void *, void *);
16959 long __builtin_vis_edge16 (void *, void *);
16960 long __builtin_vis_edge16l (void *, void *);
16961 long __builtin_vis_edge32 (void *, void *);
16962 long __builtin_vis_edge32l (void *, void *);
16964 long __builtin_vis_fcmple16 (v4hi, v4hi);
16965 long __builtin_vis_fcmple32 (v2si, v2si);
16966 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16967 long __builtin_vis_fcmpne32 (v2si, v2si);
16968 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16969 long __builtin_vis_fcmpgt32 (v2si, v2si);
16970 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16971 long __builtin_vis_fcmpeq32 (v2si, v2si);
16973 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16974 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16975 v2si __builtin_vis_fpadd32 (v2si, v2si);
16976 v1si __builtin_vis_fpadd32s (v1si, v1si);
16977 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16978 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16979 v2si __builtin_vis_fpsub32 (v2si, v2si);
16980 v1si __builtin_vis_fpsub32s (v1si, v1si);
16982 long __builtin_vis_array8 (long, long);
16983 long __builtin_vis_array16 (long, long);
16984 long __builtin_vis_array32 (long, long);
16985 @end smallexample
16987 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16988 functions also become available:
16990 @smallexample
16991 long __builtin_vis_bmask (long, long);
16992 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16993 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16994 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16995 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16997 long __builtin_vis_edge8n (void *, void *);
16998 long __builtin_vis_edge8ln (void *, void *);
16999 long __builtin_vis_edge16n (void *, void *);
17000 long __builtin_vis_edge16ln (void *, void *);
17001 long __builtin_vis_edge32n (void *, void *);
17002 long __builtin_vis_edge32ln (void *, void *);
17003 @end smallexample
17005 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
17006 functions also become available:
17008 @smallexample
17009 void __builtin_vis_cmask8 (long);
17010 void __builtin_vis_cmask16 (long);
17011 void __builtin_vis_cmask32 (long);
17013 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
17015 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
17016 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
17017 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
17018 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
17019 v2si __builtin_vis_fsll16 (v2si, v2si);
17020 v2si __builtin_vis_fslas16 (v2si, v2si);
17021 v2si __builtin_vis_fsrl16 (v2si, v2si);
17022 v2si __builtin_vis_fsra16 (v2si, v2si);
17024 long __builtin_vis_pdistn (v8qi, v8qi);
17026 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
17028 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
17029 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
17031 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
17032 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
17033 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
17034 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
17035 v2si __builtin_vis_fpadds32 (v2si, v2si);
17036 v1si __builtin_vis_fpadds32s (v1si, v1si);
17037 v2si __builtin_vis_fpsubs32 (v2si, v2si);
17038 v1si __builtin_vis_fpsubs32s (v1si, v1si);
17040 long __builtin_vis_fucmple8 (v8qi, v8qi);
17041 long __builtin_vis_fucmpne8 (v8qi, v8qi);
17042 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
17043 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
17045 float __builtin_vis_fhadds (float, float);
17046 double __builtin_vis_fhaddd (double, double);
17047 float __builtin_vis_fhsubs (float, float);
17048 double __builtin_vis_fhsubd (double, double);
17049 float __builtin_vis_fnhadds (float, float);
17050 double __builtin_vis_fnhaddd (double, double);
17052 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17053 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17054 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17055 @end smallexample
17057 @node SPU Built-in Functions
17058 @subsection SPU Built-in Functions
17060 GCC provides extensions for the SPU processor as described in the
17061 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17062 found at @uref{http://cell.scei.co.jp/} or
17063 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
17064 implementation differs in several ways.
17066 @itemize @bullet
17068 @item
17069 The optional extension of specifying vector constants in parentheses is
17070 not supported.
17072 @item
17073 A vector initializer requires no cast if the vector constant is of the
17074 same type as the variable it is initializing.
17076 @item
17077 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17078 vector type is the default signedness of the base type.  The default
17079 varies depending on the operating system, so a portable program should
17080 always specify the signedness.
17082 @item
17083 By default, the keyword @code{__vector} is added. The macro
17084 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17085 undefined.
17087 @item
17088 GCC allows using a @code{typedef} name as the type specifier for a
17089 vector type.
17091 @item
17092 For C, overloaded functions are implemented with macros so the following
17093 does not work:
17095 @smallexample
17096   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17097 @end smallexample
17099 @noindent
17100 Since @code{spu_add} is a macro, the vector constant in the example
17101 is treated as four separate arguments.  Wrap the entire argument in
17102 parentheses for this to work.
17104 @item
17105 The extended version of @code{__builtin_expect} is not supported.
17107 @end itemize
17109 @emph{Note:} Only the interface described in the aforementioned
17110 specification is supported. Internally, GCC uses built-in functions to
17111 implement the required functionality, but these are not supported and
17112 are subject to change without notice.
17114 @node TI C6X Built-in Functions
17115 @subsection TI C6X Built-in Functions
17117 GCC provides intrinsics to access certain instructions of the TI C6X
17118 processors.  These intrinsics, listed below, are available after
17119 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
17120 to C6X instructions.
17122 @smallexample
17124 int _sadd (int, int)
17125 int _ssub (int, int)
17126 int _sadd2 (int, int)
17127 int _ssub2 (int, int)
17128 long long _mpy2 (int, int)
17129 long long _smpy2 (int, int)
17130 int _add4 (int, int)
17131 int _sub4 (int, int)
17132 int _saddu4 (int, int)
17134 int _smpy (int, int)
17135 int _smpyh (int, int)
17136 int _smpyhl (int, int)
17137 int _smpylh (int, int)
17139 int _sshl (int, int)
17140 int _subc (int, int)
17142 int _avg2 (int, int)
17143 int _avgu4 (int, int)
17145 int _clrr (int, int)
17146 int _extr (int, int)
17147 int _extru (int, int)
17148 int _abs (int)
17149 int _abs2 (int)
17151 @end smallexample
17153 @node TILE-Gx Built-in Functions
17154 @subsection TILE-Gx Built-in Functions
17156 GCC provides intrinsics to access every instruction of the TILE-Gx
17157 processor.  The intrinsics are of the form:
17159 @smallexample
17161 unsigned long long __insn_@var{op} (...)
17163 @end smallexample
17165 Where @var{op} is the name of the instruction.  Refer to the ISA manual
17166 for the complete list of instructions.
17168 GCC also provides intrinsics to directly access the network registers.
17169 The intrinsics are:
17171 @smallexample
17173 unsigned long long __tile_idn0_receive (void)
17174 unsigned long long __tile_idn1_receive (void)
17175 unsigned long long __tile_udn0_receive (void)
17176 unsigned long long __tile_udn1_receive (void)
17177 unsigned long long __tile_udn2_receive (void)
17178 unsigned long long __tile_udn3_receive (void)
17179 void __tile_idn_send (unsigned long long)
17180 void __tile_udn_send (unsigned long long)
17182 @end smallexample
17184 The intrinsic @code{void __tile_network_barrier (void)} is used to
17185 guarantee that no network operations before it are reordered with
17186 those after it.
17188 @node TILEPro Built-in Functions
17189 @subsection TILEPro Built-in Functions
17191 GCC provides intrinsics to access every instruction of the TILEPro
17192 processor.  The intrinsics are of the form:
17194 @smallexample
17196 unsigned __insn_@var{op} (...)
17198 @end smallexample
17200 @noindent
17201 where @var{op} is the name of the instruction.  Refer to the ISA manual
17202 for the complete list of instructions.
17204 GCC also provides intrinsics to directly access the network registers.
17205 The intrinsics are:
17207 @smallexample
17209 unsigned __tile_idn0_receive (void)
17210 unsigned __tile_idn1_receive (void)
17211 unsigned __tile_sn_receive (void)
17212 unsigned __tile_udn0_receive (void)
17213 unsigned __tile_udn1_receive (void)
17214 unsigned __tile_udn2_receive (void)
17215 unsigned __tile_udn3_receive (void)
17216 void __tile_idn_send (unsigned)
17217 void __tile_sn_send (unsigned)
17218 void __tile_udn_send (unsigned)
17220 @end smallexample
17222 The intrinsic @code{void __tile_network_barrier (void)} is used to
17223 guarantee that no network operations before it are reordered with
17224 those after it.
17226 @node Target Format Checks
17227 @section Format Checks Specific to Particular Target Machines
17229 For some target machines, GCC supports additional options to the
17230 format attribute
17231 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17233 @menu
17234 * Solaris Format Checks::
17235 * Darwin Format Checks::
17236 @end menu
17238 @node Solaris Format Checks
17239 @subsection Solaris Format Checks
17241 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17242 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
17243 conversions, and the two-argument @code{%b} conversion for displaying
17244 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
17246 @node Darwin Format Checks
17247 @subsection Darwin Format Checks
17249 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17250 attribute context.  Declarations made with such attribution are parsed for correct syntax
17251 and format argument types.  However, parsing of the format string itself is currently undefined
17252 and is not carried out by this version of the compiler.
17254 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17255 also be used as format arguments.  Note that the relevant headers are only likely to be
17256 available on Darwin (OSX) installations.  On such installations, the XCode and system
17257 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17258 associated functions.
17260 @node Pragmas
17261 @section Pragmas Accepted by GCC
17262 @cindex pragmas
17263 @cindex @code{#pragma}
17265 GCC supports several types of pragmas, primarily in order to compile
17266 code originally written for other compilers.  Note that in general
17267 we do not recommend the use of pragmas; @xref{Function Attributes},
17268 for further explanation.
17270 @menu
17271 * ARM Pragmas::
17272 * M32C Pragmas::
17273 * MeP Pragmas::
17274 * RS/6000 and PowerPC Pragmas::
17275 * Darwin Pragmas::
17276 * Solaris Pragmas::
17277 * Symbol-Renaming Pragmas::
17278 * Structure-Packing Pragmas::
17279 * Weak Pragmas::
17280 * Diagnostic Pragmas::
17281 * Visibility Pragmas::
17282 * Push/Pop Macro Pragmas::
17283 * Function Specific Option Pragmas::
17284 * Loop-Specific Pragmas::
17285 @end menu
17287 @node ARM Pragmas
17288 @subsection ARM Pragmas
17290 The ARM target defines pragmas for controlling the default addition of
17291 @code{long_call} and @code{short_call} attributes to functions.
17292 @xref{Function Attributes}, for information about the effects of these
17293 attributes.
17295 @table @code
17296 @item long_calls
17297 @cindex pragma, long_calls
17298 Set all subsequent functions to have the @code{long_call} attribute.
17300 @item no_long_calls
17301 @cindex pragma, no_long_calls
17302 Set all subsequent functions to have the @code{short_call} attribute.
17304 @item long_calls_off
17305 @cindex pragma, long_calls_off
17306 Do not affect the @code{long_call} or @code{short_call} attributes of
17307 subsequent functions.
17308 @end table
17310 @node M32C Pragmas
17311 @subsection M32C Pragmas
17313 @table @code
17314 @item GCC memregs @var{number}
17315 @cindex pragma, memregs
17316 Overrides the command-line option @code{-memregs=} for the current
17317 file.  Use with care!  This pragma must be before any function in the
17318 file, and mixing different memregs values in different objects may
17319 make them incompatible.  This pragma is useful when a
17320 performance-critical function uses a memreg for temporary values,
17321 as it may allow you to reduce the number of memregs used.
17323 @item ADDRESS @var{name} @var{address}
17324 @cindex pragma, address
17325 For any declared symbols matching @var{name}, this does three things
17326 to that symbol: it forces the symbol to be located at the given
17327 address (a number), it forces the symbol to be volatile, and it
17328 changes the symbol's scope to be static.  This pragma exists for
17329 compatibility with other compilers, but note that the common
17330 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17331 instead).  Example:
17333 @smallexample
17334 #pragma ADDRESS port3 0x103
17335 char port3;
17336 @end smallexample
17338 @end table
17340 @node MeP Pragmas
17341 @subsection MeP Pragmas
17343 @table @code
17345 @item custom io_volatile (on|off)
17346 @cindex pragma, custom io_volatile
17347 Overrides the command-line option @code{-mio-volatile} for the current
17348 file.  Note that for compatibility with future GCC releases, this
17349 option should only be used once before any @code{io} variables in each
17350 file.
17352 @item GCC coprocessor available @var{registers}
17353 @cindex pragma, coprocessor available
17354 Specifies which coprocessor registers are available to the register
17355 allocator.  @var{registers} may be a single register, register range
17356 separated by ellipses, or comma-separated list of those.  Example:
17358 @smallexample
17359 #pragma GCC coprocessor available $c0...$c10, $c28
17360 @end smallexample
17362 @item GCC coprocessor call_saved @var{registers}
17363 @cindex pragma, coprocessor call_saved
17364 Specifies which coprocessor registers are to be saved and restored by
17365 any function using them.  @var{registers} may be a single register,
17366 register range separated by ellipses, or comma-separated list of
17367 those.  Example:
17369 @smallexample
17370 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17371 @end smallexample
17373 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17374 @cindex pragma, coprocessor subclass
17375 Creates and defines a register class.  These register classes can be
17376 used by inline @code{asm} constructs.  @var{registers} may be a single
17377 register, register range separated by ellipses, or comma-separated
17378 list of those.  Example:
17380 @smallexample
17381 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17383 asm ("cpfoo %0" : "=B" (x));
17384 @end smallexample
17386 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17387 @cindex pragma, disinterrupt
17388 For the named functions, the compiler adds code to disable interrupts
17389 for the duration of those functions.  If any functions so named 
17390 are not encountered in the source, a warning is emitted that the pragma is
17391 not used.  Examples:
17393 @smallexample
17394 #pragma disinterrupt foo
17395 #pragma disinterrupt bar, grill
17396 int foo () @{ @dots{} @}
17397 @end smallexample
17399 @item GCC call @var{name} , @var{name} @dots{}
17400 @cindex pragma, call
17401 For the named functions, the compiler always uses a register-indirect
17402 call model when calling the named functions.  Examples:
17404 @smallexample
17405 extern int foo ();
17406 #pragma call foo
17407 @end smallexample
17409 @end table
17411 @node RS/6000 and PowerPC Pragmas
17412 @subsection RS/6000 and PowerPC Pragmas
17414 The RS/6000 and PowerPC targets define one pragma for controlling
17415 whether or not the @code{longcall} attribute is added to function
17416 declarations by default.  This pragma overrides the @option{-mlongcall}
17417 option, but not the @code{longcall} and @code{shortcall} attributes.
17418 @xref{RS/6000 and PowerPC Options}, for more information about when long
17419 calls are and are not necessary.
17421 @table @code
17422 @item longcall (1)
17423 @cindex pragma, longcall
17424 Apply the @code{longcall} attribute to all subsequent function
17425 declarations.
17427 @item longcall (0)
17428 Do not apply the @code{longcall} attribute to subsequent function
17429 declarations.
17430 @end table
17432 @c Describe h8300 pragmas here.
17433 @c Describe sh pragmas here.
17434 @c Describe v850 pragmas here.
17436 @node Darwin Pragmas
17437 @subsection Darwin Pragmas
17439 The following pragmas are available for all architectures running the
17440 Darwin operating system.  These are useful for compatibility with other
17441 Mac OS compilers.
17443 @table @code
17444 @item mark @var{tokens}@dots{}
17445 @cindex pragma, mark
17446 This pragma is accepted, but has no effect.
17448 @item options align=@var{alignment}
17449 @cindex pragma, options align
17450 This pragma sets the alignment of fields in structures.  The values of
17451 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17452 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
17453 properly; to restore the previous setting, use @code{reset} for the
17454 @var{alignment}.
17456 @item segment @var{tokens}@dots{}
17457 @cindex pragma, segment
17458 This pragma is accepted, but has no effect.
17460 @item unused (@var{var} [, @var{var}]@dots{})
17461 @cindex pragma, unused
17462 This pragma declares variables to be possibly unused.  GCC does not
17463 produce warnings for the listed variables.  The effect is similar to
17464 that of the @code{unused} attribute, except that this pragma may appear
17465 anywhere within the variables' scopes.
17466 @end table
17468 @node Solaris Pragmas
17469 @subsection Solaris Pragmas
17471 The Solaris target supports @code{#pragma redefine_extname}
17472 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
17473 @code{#pragma} directives for compatibility with the system compiler.
17475 @table @code
17476 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17477 @cindex pragma, align
17479 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17480 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17481 Attributes}).  Macro expansion occurs on the arguments to this pragma
17482 when compiling C and Objective-C@.  It does not currently occur when
17483 compiling C++, but this is a bug which may be fixed in a future
17484 release.
17486 @item fini (@var{function} [, @var{function}]...)
17487 @cindex pragma, fini
17489 This pragma causes each listed @var{function} to be called after
17490 main, or during shared module unloading, by adding a call to the
17491 @code{.fini} section.
17493 @item init (@var{function} [, @var{function}]...)
17494 @cindex pragma, init
17496 This pragma causes each listed @var{function} to be called during
17497 initialization (before @code{main}) or during shared module loading, by
17498 adding a call to the @code{.init} section.
17500 @end table
17502 @node Symbol-Renaming Pragmas
17503 @subsection Symbol-Renaming Pragmas
17505 GCC supports a @code{#pragma} directive that changes the name used in
17506 assembly for a given declaration. This effect can also be achieved
17507 using the asm labels extension (@pxref{Asm Labels}).
17509 @table @code
17510 @item redefine_extname @var{oldname} @var{newname}
17511 @cindex pragma, redefine_extname
17513 This pragma gives the C function @var{oldname} the assembly symbol
17514 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17515 is defined if this pragma is available (currently on all platforms).
17516 @end table
17518 This pragma and the asm labels extension interact in a complicated
17519 manner.  Here are some corner cases you may want to be aware of:
17521 @enumerate
17522 @item This pragma silently applies only to declarations with external
17523 linkage.  Asm labels do not have this restriction.
17525 @item In C++, this pragma silently applies only to declarations with
17526 ``C'' linkage.  Again, asm labels do not have this restriction.
17528 @item If either of the ways of changing the assembly name of a
17529 declaration are applied to a declaration whose assembly name has
17530 already been determined (either by a previous use of one of these
17531 features, or because the compiler needed the assembly name in order to
17532 generate code), and the new name is different, a warning issues and
17533 the name does not change.
17535 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17536 always the C-language name.
17537 @end enumerate
17539 @node Structure-Packing Pragmas
17540 @subsection Structure-Packing Pragmas
17542 For compatibility with Microsoft Windows compilers, GCC supports a
17543 set of @code{#pragma} directives that change the maximum alignment of
17544 members of structures (other than zero-width bit-fields), unions, and
17545 classes subsequently defined. The @var{n} value below always is required
17546 to be a small power of two and specifies the new alignment in bytes.
17548 @enumerate
17549 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17550 @item @code{#pragma pack()} sets the alignment to the one that was in
17551 effect when compilation started (see also command-line option
17552 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17553 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17554 setting on an internal stack and then optionally sets the new alignment.
17555 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17556 saved at the top of the internal stack (and removes that stack entry).
17557 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17558 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17559 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17560 @code{#pragma pack(pop)}.
17561 @end enumerate
17563 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
17564 @code{#pragma} which lays out a structure as the documented
17565 @code{__attribute__ ((ms_struct))}.
17566 @enumerate
17567 @item @code{#pragma ms_struct on} turns on the layout for structures
17568 declared.
17569 @item @code{#pragma ms_struct off} turns off the layout for structures
17570 declared.
17571 @item @code{#pragma ms_struct reset} goes back to the default layout.
17572 @end enumerate
17574 @node Weak Pragmas
17575 @subsection Weak Pragmas
17577 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17578 directives for declaring symbols to be weak, and defining weak
17579 aliases.
17581 @table @code
17582 @item #pragma weak @var{symbol}
17583 @cindex pragma, weak
17584 This pragma declares @var{symbol} to be weak, as if the declaration
17585 had the attribute of the same name.  The pragma may appear before
17586 or after the declaration of @var{symbol}.  It is not an error for
17587 @var{symbol} to never be defined at all.
17589 @item #pragma weak @var{symbol1} = @var{symbol2}
17590 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17591 It is an error if @var{symbol2} is not defined in the current
17592 translation unit.
17593 @end table
17595 @node Diagnostic Pragmas
17596 @subsection Diagnostic Pragmas
17598 GCC allows the user to selectively enable or disable certain types of
17599 diagnostics, and change the kind of the diagnostic.  For example, a
17600 project's policy might require that all sources compile with
17601 @option{-Werror} but certain files might have exceptions allowing
17602 specific types of warnings.  Or, a project might selectively enable
17603 diagnostics and treat them as errors depending on which preprocessor
17604 macros are defined.
17606 @table @code
17607 @item #pragma GCC diagnostic @var{kind} @var{option}
17608 @cindex pragma, diagnostic
17610 Modifies the disposition of a diagnostic.  Note that not all
17611 diagnostics are modifiable; at the moment only warnings (normally
17612 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17613 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17614 are controllable and which option controls them.
17616 @var{kind} is @samp{error} to treat this diagnostic as an error,
17617 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17618 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17619 @var{option} is a double quoted string that matches the command-line
17620 option.
17622 @smallexample
17623 #pragma GCC diagnostic warning "-Wformat"
17624 #pragma GCC diagnostic error "-Wformat"
17625 #pragma GCC diagnostic ignored "-Wformat"
17626 @end smallexample
17628 Note that these pragmas override any command-line options.  GCC keeps
17629 track of the location of each pragma, and issues diagnostics according
17630 to the state as of that point in the source file.  Thus, pragmas occurring
17631 after a line do not affect diagnostics caused by that line.
17633 @item #pragma GCC diagnostic push
17634 @itemx #pragma GCC diagnostic pop
17636 Causes GCC to remember the state of the diagnostics as of each
17637 @code{push}, and restore to that point at each @code{pop}.  If a
17638 @code{pop} has no matching @code{push}, the command-line options are
17639 restored.
17641 @smallexample
17642 #pragma GCC diagnostic error "-Wuninitialized"
17643   foo(a);                       /* error is given for this one */
17644 #pragma GCC diagnostic push
17645 #pragma GCC diagnostic ignored "-Wuninitialized"
17646   foo(b);                       /* no diagnostic for this one */
17647 #pragma GCC diagnostic pop
17648   foo(c);                       /* error is given for this one */
17649 #pragma GCC diagnostic pop
17650   foo(d);                       /* depends on command-line options */
17651 @end smallexample
17653 @end table
17655 GCC also offers a simple mechanism for printing messages during
17656 compilation.
17658 @table @code
17659 @item #pragma message @var{string}
17660 @cindex pragma, diagnostic
17662 Prints @var{string} as a compiler message on compilation.  The message
17663 is informational only, and is neither a compilation warning nor an error.
17665 @smallexample
17666 #pragma message "Compiling " __FILE__ "..."
17667 @end smallexample
17669 @var{string} may be parenthesized, and is printed with location
17670 information.  For example,
17672 @smallexample
17673 #define DO_PRAGMA(x) _Pragma (#x)
17674 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17676 TODO(Remember to fix this)
17677 @end smallexample
17679 @noindent
17680 prints @samp{/tmp/file.c:4: note: #pragma message:
17681 TODO - Remember to fix this}.
17683 @end table
17685 @node Visibility Pragmas
17686 @subsection Visibility Pragmas
17688 @table @code
17689 @item #pragma GCC visibility push(@var{visibility})
17690 @itemx #pragma GCC visibility pop
17691 @cindex pragma, visibility
17693 This pragma allows the user to set the visibility for multiple
17694 declarations without having to give each a visibility attribute
17695 (@pxref{Function Attributes}).
17697 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17698 declarations.  Class members and template specializations are not
17699 affected; if you want to override the visibility for a particular
17700 member or instantiation, you must use an attribute.
17702 @end table
17705 @node Push/Pop Macro Pragmas
17706 @subsection Push/Pop Macro Pragmas
17708 For compatibility with Microsoft Windows compilers, GCC supports
17709 @samp{#pragma push_macro(@var{"macro_name"})}
17710 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17712 @table @code
17713 @item #pragma push_macro(@var{"macro_name"})
17714 @cindex pragma, push_macro
17715 This pragma saves the value of the macro named as @var{macro_name} to
17716 the top of the stack for this macro.
17718 @item #pragma pop_macro(@var{"macro_name"})
17719 @cindex pragma, pop_macro
17720 This pragma sets the value of the macro named as @var{macro_name} to
17721 the value on top of the stack for this macro. If the stack for
17722 @var{macro_name} is empty, the value of the macro remains unchanged.
17723 @end table
17725 For example:
17727 @smallexample
17728 #define X  1
17729 #pragma push_macro("X")
17730 #undef X
17731 #define X -1
17732 #pragma pop_macro("X")
17733 int x [X];
17734 @end smallexample
17736 @noindent
17737 In this example, the definition of X as 1 is saved by @code{#pragma
17738 push_macro} and restored by @code{#pragma pop_macro}.
17740 @node Function Specific Option Pragmas
17741 @subsection Function Specific Option Pragmas
17743 @table @code
17744 @item #pragma GCC target (@var{"string"}...)
17745 @cindex pragma GCC target
17747 This pragma allows you to set target specific options for functions
17748 defined later in the source file.  One or more strings can be
17749 specified.  Each function that is defined after this point is as
17750 if @code{attribute((target("STRING")))} was specified for that
17751 function.  The parenthesis around the options is optional.
17752 @xref{Function Attributes}, for more information about the
17753 @code{target} attribute and the attribute syntax.
17755 The @code{#pragma GCC target} pragma is presently implemented for
17756 i386/x86_64, PowerPC, and Nios II targets only.
17757 @end table
17759 @table @code
17760 @item #pragma GCC optimize (@var{"string"}...)
17761 @cindex pragma GCC optimize
17763 This pragma allows you to set global optimization options for functions
17764 defined later in the source file.  One or more strings can be
17765 specified.  Each function that is defined after this point is as
17766 if @code{attribute((optimize("STRING")))} was specified for that
17767 function.  The parenthesis around the options is optional.
17768 @xref{Function Attributes}, for more information about the
17769 @code{optimize} attribute and the attribute syntax.
17771 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17772 versions earlier than 4.4.
17773 @end table
17775 @table @code
17776 @item #pragma GCC push_options
17777 @itemx #pragma GCC pop_options
17778 @cindex pragma GCC push_options
17779 @cindex pragma GCC pop_options
17781 These pragmas maintain a stack of the current target and optimization
17782 options.  It is intended for include files where you temporarily want
17783 to switch to using a different @samp{#pragma GCC target} or
17784 @samp{#pragma GCC optimize} and then to pop back to the previous
17785 options.
17787 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17788 pragmas are not implemented in GCC versions earlier than 4.4.
17789 @end table
17791 @table @code
17792 @item #pragma GCC reset_options
17793 @cindex pragma GCC reset_options
17795 This pragma clears the current @code{#pragma GCC target} and
17796 @code{#pragma GCC optimize} to use the default switches as specified
17797 on the command line.
17799 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17800 versions earlier than 4.4.
17801 @end table
17803 @node Loop-Specific Pragmas
17804 @subsection Loop-Specific Pragmas
17806 @table @code
17807 @item #pragma GCC ivdep
17808 @cindex pragma GCC ivdep
17809 @end table
17811 With this pragma, the programmer asserts that there are no loop-carried
17812 dependencies which would prevent that consecutive iterations of
17813 the following loop can be executed concurrently with SIMD
17814 (single instruction multiple data) instructions.
17816 For example, the compiler can only unconditionally vectorize the following
17817 loop with the pragma:
17819 @smallexample
17820 void foo (int n, int *a, int *b, int *c)
17822   int i, j;
17823 #pragma GCC ivdep
17824   for (i = 0; i < n; ++i)
17825     a[i] = b[i] + c[i];
17827 @end smallexample
17829 @noindent
17830 In this example, using the @code{restrict} qualifier had the same
17831 effect. In the following example, that would not be possible. Assume
17832 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17833 that it can unconditionally vectorize the following loop:
17835 @smallexample
17836 void ignore_vec_dep (int *a, int k, int c, int m)
17838 #pragma GCC ivdep
17839   for (int i = 0; i < m; i++)
17840     a[i] = a[i + k] * c;
17842 @end smallexample
17845 @node Unnamed Fields
17846 @section Unnamed struct/union fields within structs/unions
17847 @cindex @code{struct}
17848 @cindex @code{union}
17850 As permitted by ISO C11 and for compatibility with other compilers,
17851 GCC allows you to define
17852 a structure or union that contains, as fields, structures and unions
17853 without names.  For example:
17855 @smallexample
17856 struct @{
17857   int a;
17858   union @{
17859     int b;
17860     float c;
17861   @};
17862   int d;
17863 @} foo;
17864 @end smallexample
17866 @noindent
17867 In this example, you are able to access members of the unnamed
17868 union with code like @samp{foo.b}.  Note that only unnamed structs and
17869 unions are allowed, you may not have, for example, an unnamed
17870 @code{int}.
17872 You must never create such structures that cause ambiguous field definitions.
17873 For example, in this structure:
17875 @smallexample
17876 struct @{
17877   int a;
17878   struct @{
17879     int a;
17880   @};
17881 @} foo;
17882 @end smallexample
17884 @noindent
17885 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17886 The compiler gives errors for such constructs.
17888 @opindex fms-extensions
17889 Unless @option{-fms-extensions} is used, the unnamed field must be a
17890 structure or union definition without a tag (for example, @samp{struct
17891 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
17892 also be a definition with a tag such as @samp{struct foo @{ int a;
17893 @};}, a reference to a previously defined structure or union such as
17894 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17895 previously defined structure or union type.
17897 @opindex fplan9-extensions
17898 The option @option{-fplan9-extensions} enables
17899 @option{-fms-extensions} as well as two other extensions.  First, a
17900 pointer to a structure is automatically converted to a pointer to an
17901 anonymous field for assignments and function calls.  For example:
17903 @smallexample
17904 struct s1 @{ int a; @};
17905 struct s2 @{ struct s1; @};
17906 extern void f1 (struct s1 *);
17907 void f2 (struct s2 *p) @{ f1 (p); @}
17908 @end smallexample
17910 @noindent
17911 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17912 converted into a pointer to the anonymous field.
17914 Second, when the type of an anonymous field is a @code{typedef} for a
17915 @code{struct} or @code{union}, code may refer to the field using the
17916 name of the @code{typedef}.
17918 @smallexample
17919 typedef struct @{ int a; @} s1;
17920 struct s2 @{ s1; @};
17921 s1 f1 (struct s2 *p) @{ return p->s1; @}
17922 @end smallexample
17924 These usages are only permitted when they are not ambiguous.
17926 @node Thread-Local
17927 @section Thread-Local Storage
17928 @cindex Thread-Local Storage
17929 @cindex @acronym{TLS}
17930 @cindex @code{__thread}
17932 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17933 are allocated such that there is one instance of the variable per extant
17934 thread.  The runtime model GCC uses to implement this originates
17935 in the IA-64 processor-specific ABI, but has since been migrated
17936 to other processors as well.  It requires significant support from
17937 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17938 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17939 is not available everywhere.
17941 At the user level, the extension is visible with a new storage
17942 class keyword: @code{__thread}.  For example:
17944 @smallexample
17945 __thread int i;
17946 extern __thread struct state s;
17947 static __thread char *p;
17948 @end smallexample
17950 The @code{__thread} specifier may be used alone, with the @code{extern}
17951 or @code{static} specifiers, but with no other storage class specifier.
17952 When used with @code{extern} or @code{static}, @code{__thread} must appear
17953 immediately after the other storage class specifier.
17955 The @code{__thread} specifier may be applied to any global, file-scoped
17956 static, function-scoped static, or static data member of a class.  It may
17957 not be applied to block-scoped automatic or non-static data member.
17959 When the address-of operator is applied to a thread-local variable, it is
17960 evaluated at run time and returns the address of the current thread's
17961 instance of that variable.  An address so obtained may be used by any
17962 thread.  When a thread terminates, any pointers to thread-local variables
17963 in that thread become invalid.
17965 No static initialization may refer to the address of a thread-local variable.
17967 In C++, if an initializer is present for a thread-local variable, it must
17968 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
17969 standard.
17971 See @uref{http://www.akkadia.org/drepper/tls.pdf,
17972 ELF Handling For Thread-Local Storage} for a detailed explanation of
17973 the four thread-local storage addressing models, and how the runtime
17974 is expected to function.
17976 @menu
17977 * C99 Thread-Local Edits::
17978 * C++98 Thread-Local Edits::
17979 @end menu
17981 @node C99 Thread-Local Edits
17982 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
17984 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
17985 that document the exact semantics of the language extension.
17987 @itemize @bullet
17988 @item
17989 @cite{5.1.2  Execution environments}
17991 Add new text after paragraph 1
17993 @quotation
17994 Within either execution environment, a @dfn{thread} is a flow of
17995 control within a program.  It is implementation defined whether
17996 or not there may be more than one thread associated with a program.
17997 It is implementation defined how threads beyond the first are
17998 created, the name and type of the function called at thread
17999 startup, and how threads may be terminated.  However, objects
18000 with thread storage duration shall be initialized before thread
18001 startup.
18002 @end quotation
18004 @item
18005 @cite{6.2.4  Storage durations of objects}
18007 Add new text before paragraph 3
18009 @quotation
18010 An object whose identifier is declared with the storage-class
18011 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
18012 Its lifetime is the entire execution of the thread, and its
18013 stored value is initialized only once, prior to thread startup.
18014 @end quotation
18016 @item
18017 @cite{6.4.1  Keywords}
18019 Add @code{__thread}.
18021 @item
18022 @cite{6.7.1  Storage-class specifiers}
18024 Add @code{__thread} to the list of storage class specifiers in
18025 paragraph 1.
18027 Change paragraph 2 to
18029 @quotation
18030 With the exception of @code{__thread}, at most one storage-class
18031 specifier may be given [@dots{}].  The @code{__thread} specifier may
18032 be used alone, or immediately following @code{extern} or
18033 @code{static}.
18034 @end quotation
18036 Add new text after paragraph 6
18038 @quotation
18039 The declaration of an identifier for a variable that has
18040 block scope that specifies @code{__thread} shall also
18041 specify either @code{extern} or @code{static}.
18043 The @code{__thread} specifier shall be used only with
18044 variables.
18045 @end quotation
18046 @end itemize
18048 @node C++98 Thread-Local Edits
18049 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18051 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18052 that document the exact semantics of the language extension.
18054 @itemize @bullet
18055 @item
18056 @b{[intro.execution]}
18058 New text after paragraph 4
18060 @quotation
18061 A @dfn{thread} is a flow of control within the abstract machine.
18062 It is implementation defined whether or not there may be more than
18063 one thread.
18064 @end quotation
18066 New text after paragraph 7
18068 @quotation
18069 It is unspecified whether additional action must be taken to
18070 ensure when and whether side effects are visible to other threads.
18071 @end quotation
18073 @item
18074 @b{[lex.key]}
18076 Add @code{__thread}.
18078 @item
18079 @b{[basic.start.main]}
18081 Add after paragraph 5
18083 @quotation
18084 The thread that begins execution at the @code{main} function is called
18085 the @dfn{main thread}.  It is implementation defined how functions
18086 beginning threads other than the main thread are designated or typed.
18087 A function so designated, as well as the @code{main} function, is called
18088 a @dfn{thread startup function}.  It is implementation defined what
18089 happens if a thread startup function returns.  It is implementation
18090 defined what happens to other threads when any thread calls @code{exit}.
18091 @end quotation
18093 @item
18094 @b{[basic.start.init]}
18096 Add after paragraph 4
18098 @quotation
18099 The storage for an object of thread storage duration shall be
18100 statically initialized before the first statement of the thread startup
18101 function.  An object of thread storage duration shall not require
18102 dynamic initialization.
18103 @end quotation
18105 @item
18106 @b{[basic.start.term]}
18108 Add after paragraph 3
18110 @quotation
18111 The type of an object with thread storage duration shall not have a
18112 non-trivial destructor, nor shall it be an array type whose elements
18113 (directly or indirectly) have non-trivial destructors.
18114 @end quotation
18116 @item
18117 @b{[basic.stc]}
18119 Add ``thread storage duration'' to the list in paragraph 1.
18121 Change paragraph 2
18123 @quotation
18124 Thread, static, and automatic storage durations are associated with
18125 objects introduced by declarations [@dots{}].
18126 @end quotation
18128 Add @code{__thread} to the list of specifiers in paragraph 3.
18130 @item
18131 @b{[basic.stc.thread]}
18133 New section before @b{[basic.stc.static]}
18135 @quotation
18136 The keyword @code{__thread} applied to a non-local object gives the
18137 object thread storage duration.
18139 A local variable or class data member declared both @code{static}
18140 and @code{__thread} gives the variable or member thread storage
18141 duration.
18142 @end quotation
18144 @item
18145 @b{[basic.stc.static]}
18147 Change paragraph 1
18149 @quotation
18150 All objects that have neither thread storage duration, dynamic
18151 storage duration nor are local [@dots{}].
18152 @end quotation
18154 @item
18155 @b{[dcl.stc]}
18157 Add @code{__thread} to the list in paragraph 1.
18159 Change paragraph 1
18161 @quotation
18162 With the exception of @code{__thread}, at most one
18163 @var{storage-class-specifier} shall appear in a given
18164 @var{decl-specifier-seq}.  The @code{__thread} specifier may
18165 be used alone, or immediately following the @code{extern} or
18166 @code{static} specifiers.  [@dots{}]
18167 @end quotation
18169 Add after paragraph 5
18171 @quotation
18172 The @code{__thread} specifier can be applied only to the names of objects
18173 and to anonymous unions.
18174 @end quotation
18176 @item
18177 @b{[class.mem]}
18179 Add after paragraph 6
18181 @quotation
18182 Non-@code{static} members shall not be @code{__thread}.
18183 @end quotation
18184 @end itemize
18186 @node Binary constants
18187 @section Binary constants using the @samp{0b} prefix
18188 @cindex Binary constants using the @samp{0b} prefix
18190 Integer constants can be written as binary constants, consisting of a
18191 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18192 @samp{0B}.  This is particularly useful in environments that operate a
18193 lot on the bit level (like microcontrollers).
18195 The following statements are identical:
18197 @smallexample
18198 i =       42;
18199 i =     0x2a;
18200 i =      052;
18201 i = 0b101010;
18202 @end smallexample
18204 The type of these constants follows the same rules as for octal or
18205 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18206 can be applied.
18208 @node C++ Extensions
18209 @chapter Extensions to the C++ Language
18210 @cindex extensions, C++ language
18211 @cindex C++ language extensions
18213 The GNU compiler provides these extensions to the C++ language (and you
18214 can also use most of the C language extensions in your C++ programs).  If you
18215 want to write code that checks whether these features are available, you can
18216 test for the GNU compiler the same way as for C programs: check for a
18217 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
18218 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18219 Predefined Macros,cpp,The GNU C Preprocessor}).
18221 @menu
18222 * C++ Volatiles::       What constitutes an access to a volatile object.
18223 * Restricted Pointers:: C99 restricted pointers and references.
18224 * Vague Linkage::       Where G++ puts inlines, vtables and such.
18225 * C++ Interface::       You can use a single C++ header file for both
18226                         declarations and definitions.
18227 * Template Instantiation:: Methods for ensuring that exactly one copy of
18228                         each needed template instantiation is emitted.
18229 * Bound member functions:: You can extract a function pointer to the
18230                         method denoted by a @samp{->*} or @samp{.*} expression.
18231 * C++ Attributes::      Variable, function, and type attributes for C++ only.
18232 * Function Multiversioning::   Declaring multiple function versions.
18233 * Namespace Association:: Strong using-directives for namespace association.
18234 * Type Traits::         Compiler support for type traits
18235 * Java Exceptions::     Tweaking exception handling to work with Java.
18236 * Deprecated Features:: Things will disappear from G++.
18237 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18238 @end menu
18240 @node C++ Volatiles
18241 @section When is a Volatile C++ Object Accessed?
18242 @cindex accessing volatiles
18243 @cindex volatile read
18244 @cindex volatile write
18245 @cindex volatile access
18247 The C++ standard differs from the C standard in its treatment of
18248 volatile objects.  It fails to specify what constitutes a volatile
18249 access, except to say that C++ should behave in a similar manner to C
18250 with respect to volatiles, where possible.  However, the different
18251 lvalueness of expressions between C and C++ complicate the behavior.
18252 G++ behaves the same as GCC for volatile access, @xref{C
18253 Extensions,,Volatiles}, for a description of GCC's behavior.
18255 The C and C++ language specifications differ when an object is
18256 accessed in a void context:
18258 @smallexample
18259 volatile int *src = @var{somevalue};
18260 *src;
18261 @end smallexample
18263 The C++ standard specifies that such expressions do not undergo lvalue
18264 to rvalue conversion, and that the type of the dereferenced object may
18265 be incomplete.  The C++ standard does not specify explicitly that it
18266 is lvalue to rvalue conversion that is responsible for causing an
18267 access.  There is reason to believe that it is, because otherwise
18268 certain simple expressions become undefined.  However, because it
18269 would surprise most programmers, G++ treats dereferencing a pointer to
18270 volatile object of complete type as GCC would do for an equivalent
18271 type in C@.  When the object has incomplete type, G++ issues a
18272 warning; if you wish to force an error, you must force a conversion to
18273 rvalue with, for instance, a static cast.
18275 When using a reference to volatile, G++ does not treat equivalent
18276 expressions as accesses to volatiles, but instead issues a warning that
18277 no volatile is accessed.  The rationale for this is that otherwise it
18278 becomes difficult to determine where volatile access occur, and not
18279 possible to ignore the return value from functions returning volatile
18280 references.  Again, if you wish to force a read, cast the reference to
18281 an rvalue.
18283 G++ implements the same behavior as GCC does when assigning to a
18284 volatile object---there is no reread of the assigned-to object, the
18285 assigned rvalue is reused.  Note that in C++ assignment expressions
18286 are lvalues, and if used as an lvalue, the volatile object is
18287 referred to.  For instance, @var{vref} refers to @var{vobj}, as
18288 expected, in the following example:
18290 @smallexample
18291 volatile int vobj;
18292 volatile int &vref = vobj = @var{something};
18293 @end smallexample
18295 @node Restricted Pointers
18296 @section Restricting Pointer Aliasing
18297 @cindex restricted pointers
18298 @cindex restricted references
18299 @cindex restricted this pointer
18301 As with the C front end, G++ understands the C99 feature of restricted pointers,
18302 specified with the @code{__restrict__}, or @code{__restrict} type
18303 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
18304 language flag, @code{restrict} is not a keyword in C++.
18306 In addition to allowing restricted pointers, you can specify restricted
18307 references, which indicate that the reference is not aliased in the local
18308 context.
18310 @smallexample
18311 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18313   /* @r{@dots{}} */
18315 @end smallexample
18317 @noindent
18318 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18319 @var{rref} refers to a (different) unaliased integer.
18321 You may also specify whether a member function's @var{this} pointer is
18322 unaliased by using @code{__restrict__} as a member function qualifier.
18324 @smallexample
18325 void T::fn () __restrict__
18327   /* @r{@dots{}} */
18329 @end smallexample
18331 @noindent
18332 Within the body of @code{T::fn}, @var{this} has the effective
18333 definition @code{T *__restrict__ const this}.  Notice that the
18334 interpretation of a @code{__restrict__} member function qualifier is
18335 different to that of @code{const} or @code{volatile} qualifier, in that it
18336 is applied to the pointer rather than the object.  This is consistent with
18337 other compilers that implement restricted pointers.
18339 As with all outermost parameter qualifiers, @code{__restrict__} is
18340 ignored in function definition matching.  This means you only need to
18341 specify @code{__restrict__} in a function definition, rather than
18342 in a function prototype as well.
18344 @node Vague Linkage
18345 @section Vague Linkage
18346 @cindex vague linkage
18348 There are several constructs in C++ that require space in the object
18349 file but are not clearly tied to a single translation unit.  We say that
18350 these constructs have ``vague linkage''.  Typically such constructs are
18351 emitted wherever they are needed, though sometimes we can be more
18352 clever.
18354 @table @asis
18355 @item Inline Functions
18356 Inline functions are typically defined in a header file which can be
18357 included in many different compilations.  Hopefully they can usually be
18358 inlined, but sometimes an out-of-line copy is necessary, if the address
18359 of the function is taken or if inlining fails.  In general, we emit an
18360 out-of-line copy in all translation units where one is needed.  As an
18361 exception, we only emit inline virtual functions with the vtable, since
18362 it always requires a copy.
18364 Local static variables and string constants used in an inline function
18365 are also considered to have vague linkage, since they must be shared
18366 between all inlined and out-of-line instances of the function.
18368 @item VTables
18369 @cindex vtable
18370 C++ virtual functions are implemented in most compilers using a lookup
18371 table, known as a vtable.  The vtable contains pointers to the virtual
18372 functions provided by a class, and each object of the class contains a
18373 pointer to its vtable (or vtables, in some multiple-inheritance
18374 situations).  If the class declares any non-inline, non-pure virtual
18375 functions, the first one is chosen as the ``key method'' for the class,
18376 and the vtable is only emitted in the translation unit where the key
18377 method is defined.
18379 @emph{Note:} If the chosen key method is later defined as inline, the
18380 vtable is still emitted in every translation unit that defines it.
18381 Make sure that any inline virtuals are declared inline in the class
18382 body, even if they are not defined there.
18384 @item @code{type_info} objects
18385 @cindex @code{type_info}
18386 @cindex RTTI
18387 C++ requires information about types to be written out in order to
18388 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18389 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18390 object is written out along with the vtable so that @samp{dynamic_cast}
18391 can determine the dynamic type of a class object at run time.  For all
18392 other types, we write out the @samp{type_info} object when it is used: when
18393 applying @samp{typeid} to an expression, throwing an object, or
18394 referring to a type in a catch clause or exception specification.
18396 @item Template Instantiations
18397 Most everything in this section also applies to template instantiations,
18398 but there are other options as well.
18399 @xref{Template Instantiation,,Where's the Template?}.
18401 @end table
18403 When used with GNU ld version 2.8 or later on an ELF system such as
18404 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18405 these constructs will be discarded at link time.  This is known as
18406 COMDAT support.
18408 On targets that don't support COMDAT, but do support weak symbols, GCC
18409 uses them.  This way one copy overrides all the others, but
18410 the unused copies still take up space in the executable.
18412 For targets that do not support either COMDAT or weak symbols,
18413 most entities with vague linkage are emitted as local symbols to
18414 avoid duplicate definition errors from the linker.  This does not happen
18415 for local statics in inlines, however, as having multiple copies
18416 almost certainly breaks things.
18418 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18419 another way to control placement of these constructs.
18421 @node C++ Interface
18422 @section #pragma interface and implementation
18424 @cindex interface and implementation headers, C++
18425 @cindex C++ interface and implementation headers
18426 @cindex pragmas, interface and implementation
18428 @code{#pragma interface} and @code{#pragma implementation} provide the
18429 user with a way of explicitly directing the compiler to emit entities
18430 with vague linkage (and debugging information) in a particular
18431 translation unit.
18433 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
18434 most cases, because of COMDAT support and the ``key method'' heuristic
18435 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
18436 program to grow due to unnecessary out-of-line copies of inline
18437 functions.  Currently (3.4) the only benefit of these
18438 @code{#pragma}s is reduced duplication of debugging information, and
18439 that should be addressed soon on DWARF 2 targets with the use of
18440 COMDAT groups.
18442 @table @code
18443 @item #pragma interface
18444 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18445 @kindex #pragma interface
18446 Use this directive in @emph{header files} that define object classes, to save
18447 space in most of the object files that use those classes.  Normally,
18448 local copies of certain information (backup copies of inline member
18449 functions, debugging information, and the internal tables that implement
18450 virtual functions) must be kept in each object file that includes class
18451 definitions.  You can use this pragma to avoid such duplication.  When a
18452 header file containing @samp{#pragma interface} is included in a
18453 compilation, this auxiliary information is not generated (unless
18454 the main input source file itself uses @samp{#pragma implementation}).
18455 Instead, the object files contain references to be resolved at link
18456 time.
18458 The second form of this directive is useful for the case where you have
18459 multiple headers with the same name in different directories.  If you
18460 use this form, you must specify the same string to @samp{#pragma
18461 implementation}.
18463 @item #pragma implementation
18464 @itemx #pragma implementation "@var{objects}.h"
18465 @kindex #pragma implementation
18466 Use this pragma in a @emph{main input file}, when you want full output from
18467 included header files to be generated (and made globally visible).  The
18468 included header file, in turn, should use @samp{#pragma interface}.
18469 Backup copies of inline member functions, debugging information, and the
18470 internal tables used to implement virtual functions are all generated in
18471 implementation files.
18473 @cindex implied @code{#pragma implementation}
18474 @cindex @code{#pragma implementation}, implied
18475 @cindex naming convention, implementation headers
18476 If you use @samp{#pragma implementation} with no argument, it applies to
18477 an include file with the same basename@footnote{A file's @dfn{basename}
18478 is the name stripped of all leading path information and of trailing
18479 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18480 file.  For example, in @file{allclass.cc}, giving just
18481 @samp{#pragma implementation}
18482 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18484 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
18485 an implementation file whenever you would include it from
18486 @file{allclass.cc} even if you never specified @samp{#pragma
18487 implementation}.  This was deemed to be more trouble than it was worth,
18488 however, and disabled.
18490 Use the string argument if you want a single implementation file to
18491 include code from multiple header files.  (You must also use
18492 @samp{#include} to include the header file; @samp{#pragma
18493 implementation} only specifies how to use the file---it doesn't actually
18494 include it.)
18496 There is no way to split up the contents of a single header file into
18497 multiple implementation files.
18498 @end table
18500 @cindex inlining and C++ pragmas
18501 @cindex C++ pragmas, effect on inlining
18502 @cindex pragmas in C++, effect on inlining
18503 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18504 effect on function inlining.
18506 If you define a class in a header file marked with @samp{#pragma
18507 interface}, the effect on an inline function defined in that class is
18508 similar to an explicit @code{extern} declaration---the compiler emits
18509 no code at all to define an independent version of the function.  Its
18510 definition is used only for inlining with its callers.
18512 @opindex fno-implement-inlines
18513 Conversely, when you include the same header file in a main source file
18514 that declares it as @samp{#pragma implementation}, the compiler emits
18515 code for the function itself; this defines a version of the function
18516 that can be found via pointers (or by callers compiled without
18517 inlining).  If all calls to the function can be inlined, you can avoid
18518 emitting the function by compiling with @option{-fno-implement-inlines}.
18519 If any calls are not inlined, you will get linker errors.
18521 @node Template Instantiation
18522 @section Where's the Template?
18523 @cindex template instantiation
18525 C++ templates are the first language feature to require more
18526 intelligence from the environment than one usually finds on a UNIX
18527 system.  Somehow the compiler and linker have to make sure that each
18528 template instance occurs exactly once in the executable if it is needed,
18529 and not at all otherwise.  There are two basic approaches to this
18530 problem, which are referred to as the Borland model and the Cfront model.
18532 @table @asis
18533 @item Borland model
18534 Borland C++ solved the template instantiation problem by adding the code
18535 equivalent of common blocks to their linker; the compiler emits template
18536 instances in each translation unit that uses them, and the linker
18537 collapses them together.  The advantage of this model is that the linker
18538 only has to consider the object files themselves; there is no external
18539 complexity to worry about.  This disadvantage is that compilation time
18540 is increased because the template code is being compiled repeatedly.
18541 Code written for this model tends to include definitions of all
18542 templates in the header file, since they must be seen to be
18543 instantiated.
18545 @item Cfront model
18546 The AT&T C++ translator, Cfront, solved the template instantiation
18547 problem by creating the notion of a template repository, an
18548 automatically maintained place where template instances are stored.  A
18549 more modern version of the repository works as follows: As individual
18550 object files are built, the compiler places any template definitions and
18551 instantiations encountered in the repository.  At link time, the link
18552 wrapper adds in the objects in the repository and compiles any needed
18553 instances that were not previously emitted.  The advantages of this
18554 model are more optimal compilation speed and the ability to use the
18555 system linker; to implement the Borland model a compiler vendor also
18556 needs to replace the linker.  The disadvantages are vastly increased
18557 complexity, and thus potential for error; for some code this can be
18558 just as transparent, but in practice it can been very difficult to build
18559 multiple programs in one directory and one program in multiple
18560 directories.  Code written for this model tends to separate definitions
18561 of non-inline member templates into a separate file, which should be
18562 compiled separately.
18563 @end table
18565 When used with GNU ld version 2.8 or later on an ELF system such as
18566 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18567 Borland model.  On other systems, G++ implements neither automatic
18568 model.
18570 You have the following options for dealing with template instantiations:
18572 @enumerate
18573 @item
18574 @opindex frepo
18575 Compile your template-using code with @option{-frepo}.  The compiler
18576 generates files with the extension @samp{.rpo} listing all of the
18577 template instantiations used in the corresponding object files that
18578 could be instantiated there; the link wrapper, @samp{collect2},
18579 then updates the @samp{.rpo} files to tell the compiler where to place
18580 those instantiations and rebuild any affected object files.  The
18581 link-time overhead is negligible after the first pass, as the compiler
18582 continues to place the instantiations in the same files.
18584 This is your best option for application code written for the Borland
18585 model, as it just works.  Code written for the Cfront model 
18586 needs to be modified so that the template definitions are available at
18587 one or more points of instantiation; usually this is as simple as adding
18588 @code{#include <tmethods.cc>} to the end of each template header.
18590 For library code, if you want the library to provide all of the template
18591 instantiations it needs, just try to link all of its object files
18592 together; the link will fail, but cause the instantiations to be
18593 generated as a side effect.  Be warned, however, that this may cause
18594 conflicts if multiple libraries try to provide the same instantiations.
18595 For greater control, use explicit instantiation as described in the next
18596 option.
18598 @item
18599 @opindex fno-implicit-templates
18600 Compile your code with @option{-fno-implicit-templates} to disable the
18601 implicit generation of template instances, and explicitly instantiate
18602 all the ones you use.  This approach requires more knowledge of exactly
18603 which instances you need than do the others, but it's less
18604 mysterious and allows greater control.  You can scatter the explicit
18605 instantiations throughout your program, perhaps putting them in the
18606 translation units where the instances are used or the translation units
18607 that define the templates themselves; you can put all of the explicit
18608 instantiations you need into one big file; or you can create small files
18609 like
18611 @smallexample
18612 #include "Foo.h"
18613 #include "Foo.cc"
18615 template class Foo<int>;
18616 template ostream& operator <<
18617                 (ostream&, const Foo<int>&);
18618 @end smallexample
18620 @noindent
18621 for each of the instances you need, and create a template instantiation
18622 library from those.
18624 If you are using Cfront-model code, you can probably get away with not
18625 using @option{-fno-implicit-templates} when compiling files that don't
18626 @samp{#include} the member template definitions.
18628 If you use one big file to do the instantiations, you may want to
18629 compile it without @option{-fno-implicit-templates} so you get all of the
18630 instances required by your explicit instantiations (but not by any
18631 other files) without having to specify them as well.
18633 The ISO C++ 2011 standard allows forward declaration of explicit
18634 instantiations (with @code{extern}). G++ supports explicit instantiation
18635 declarations in C++98 mode and has extended the template instantiation
18636 syntax to support instantiation of the compiler support data for a
18637 template class (i.e.@: the vtable) without instantiating any of its
18638 members (with @code{inline}), and instantiation of only the static data
18639 members of a template class, without the support data or member
18640 functions (with @code{static}):
18642 @smallexample
18643 extern template int max (int, int);
18644 inline template class Foo<int>;
18645 static template class Foo<int>;
18646 @end smallexample
18648 @item
18649 Do nothing.  Pretend G++ does implement automatic instantiation
18650 management.  Code written for the Borland model works fine, but
18651 each translation unit contains instances of each of the templates it
18652 uses.  In a large program, this can lead to an unacceptable amount of code
18653 duplication.
18654 @end enumerate
18656 @node Bound member functions
18657 @section Extracting the function pointer from a bound pointer to member function
18658 @cindex pmf
18659 @cindex pointer to member function
18660 @cindex bound pointer to member function
18662 In C++, pointer to member functions (PMFs) are implemented using a wide
18663 pointer of sorts to handle all the possible call mechanisms; the PMF
18664 needs to store information about how to adjust the @samp{this} pointer,
18665 and if the function pointed to is virtual, where to find the vtable, and
18666 where in the vtable to look for the member function.  If you are using
18667 PMFs in an inner loop, you should really reconsider that decision.  If
18668 that is not an option, you can extract the pointer to the function that
18669 would be called for a given object/PMF pair and call it directly inside
18670 the inner loop, to save a bit of time.
18672 Note that you still pay the penalty for the call through a
18673 function pointer; on most modern architectures, such a call defeats the
18674 branch prediction features of the CPU@.  This is also true of normal
18675 virtual function calls.
18677 The syntax for this extension is
18679 @smallexample
18680 extern A a;
18681 extern int (A::*fp)();
18682 typedef int (*fptr)(A *);
18684 fptr p = (fptr)(a.*fp);
18685 @end smallexample
18687 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18688 no object is needed to obtain the address of the function.  They can be
18689 converted to function pointers directly:
18691 @smallexample
18692 fptr p1 = (fptr)(&A::foo);
18693 @end smallexample
18695 @opindex Wno-pmf-conversions
18696 You must specify @option{-Wno-pmf-conversions} to use this extension.
18698 @node C++ Attributes
18699 @section C++-Specific Variable, Function, and Type Attributes
18701 Some attributes only make sense for C++ programs.
18703 @table @code
18704 @item abi_tag ("@var{tag}", ...)
18705 @cindex @code{abi_tag} attribute
18706 The @code{abi_tag} attribute can be applied to a function or class
18707 declaration.  It modifies the mangled name of the function or class to
18708 incorporate the tag name, in order to distinguish the function or
18709 class from an earlier version with a different ABI; perhaps the class
18710 has changed size, or the function has a different return type that is
18711 not encoded in the mangled name.
18713 The argument can be a list of strings of arbitrary length.  The
18714 strings are sorted on output, so the order of the list is
18715 unimportant.
18717 A redeclaration of a function or class must not add new ABI tags,
18718 since doing so would change the mangled name.
18720 The ABI tags apply to a name, so all instantiations and
18721 specializations of a template have the same tags.  The attribute will
18722 be ignored if applied to an explicit specialization or instantiation.
18724 The @option{-Wabi-tag} flag enables a warning about a class which does
18725 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18726 that needs to coexist with an earlier ABI, using this option can help
18727 to find all affected types that need to be tagged.
18729 @item init_priority (@var{priority})
18730 @cindex @code{init_priority} attribute
18733 In Standard C++, objects defined at namespace scope are guaranteed to be
18734 initialized in an order in strict accordance with that of their definitions
18735 @emph{in a given translation unit}.  No guarantee is made for initializations
18736 across translation units.  However, GNU C++ allows users to control the
18737 order of initialization of objects defined at namespace scope with the
18738 @code{init_priority} attribute by specifying a relative @var{priority},
18739 a constant integral expression currently bounded between 101 and 65535
18740 inclusive.  Lower numbers indicate a higher priority.
18742 In the following example, @code{A} would normally be created before
18743 @code{B}, but the @code{init_priority} attribute reverses that order:
18745 @smallexample
18746 Some_Class  A  __attribute__ ((init_priority (2000)));
18747 Some_Class  B  __attribute__ ((init_priority (543)));
18748 @end smallexample
18750 @noindent
18751 Note that the particular values of @var{priority} do not matter; only their
18752 relative ordering.
18754 @item java_interface
18755 @cindex @code{java_interface} attribute
18757 This type attribute informs C++ that the class is a Java interface.  It may
18758 only be applied to classes declared within an @code{extern "Java"} block.
18759 Calls to methods declared in this interface are dispatched using GCJ's
18760 interface table mechanism, instead of regular virtual table dispatch.
18762 @item warn_unused
18763 @cindex @code{warn_unused} attribute
18765 For C++ types with non-trivial constructors and/or destructors it is
18766 impossible for the compiler to determine whether a variable of this
18767 type is truly unused if it is not referenced. This type attribute
18768 informs the compiler that variables of this type should be warned
18769 about if they appear to be unused, just like variables of fundamental
18770 types.
18772 This attribute is appropriate for types which just represent a value,
18773 such as @code{std::string}; it is not appropriate for types which
18774 control a resource, such as @code{std::mutex}.
18776 This attribute is also accepted in C, but it is unnecessary because C
18777 does not have constructors or destructors.
18779 @end table
18781 See also @ref{Namespace Association}.
18783 @node Function Multiversioning
18784 @section Function Multiversioning
18785 @cindex function versions
18787 With the GNU C++ front end, for target i386, you may specify multiple
18788 versions of a function, where each function is specialized for a
18789 specific target feature.  At runtime, the appropriate version of the
18790 function is automatically executed depending on the characteristics of
18791 the execution platform.  Here is an example.
18793 @smallexample
18794 __attribute__ ((target ("default")))
18795 int foo ()
18797   // The default version of foo.
18798   return 0;
18801 __attribute__ ((target ("sse4.2")))
18802 int foo ()
18804   // foo version for SSE4.2
18805   return 1;
18808 __attribute__ ((target ("arch=atom")))
18809 int foo ()
18811   // foo version for the Intel ATOM processor
18812   return 2;
18815 __attribute__ ((target ("arch=amdfam10")))
18816 int foo ()
18818   // foo version for the AMD Family 0x10 processors.
18819   return 3;
18822 int main ()
18824   int (*p)() = &foo;
18825   assert ((*p) () == foo ());
18826   return 0;
18828 @end smallexample
18830 In the above example, four versions of function foo are created. The
18831 first version of foo with the target attribute "default" is the default
18832 version.  This version gets executed when no other target specific
18833 version qualifies for execution on a particular platform. A new version
18834 of foo is created by using the same function signature but with a
18835 different target string.  Function foo is called or a pointer to it is
18836 taken just like a regular function.  GCC takes care of doing the
18837 dispatching to call the right version at runtime.  Refer to the
18838 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18839 Function Multiversioning} for more details.
18841 @node Namespace Association
18842 @section Namespace Association
18844 @strong{Caution:} The semantics of this extension are equivalent
18845 to C++ 2011 inline namespaces.  Users should use inline namespaces
18846 instead as this extension will be removed in future versions of G++.
18848 A using-directive with @code{__attribute ((strong))} is stronger
18849 than a normal using-directive in two ways:
18851 @itemize @bullet
18852 @item
18853 Templates from the used namespace can be specialized and explicitly
18854 instantiated as though they were members of the using namespace.
18856 @item
18857 The using namespace is considered an associated namespace of all
18858 templates in the used namespace for purposes of argument-dependent
18859 name lookup.
18860 @end itemize
18862 The used namespace must be nested within the using namespace so that
18863 normal unqualified lookup works properly.
18865 This is useful for composing a namespace transparently from
18866 implementation namespaces.  For example:
18868 @smallexample
18869 namespace std @{
18870   namespace debug @{
18871     template <class T> struct A @{ @};
18872   @}
18873   using namespace debug __attribute ((__strong__));
18874   template <> struct A<int> @{ @};   // @r{OK to specialize}
18876   template <class T> void f (A<T>);
18879 int main()
18881   f (std::A<float>());             // @r{lookup finds} std::f
18882   f (std::A<int>());
18884 @end smallexample
18886 @node Type Traits
18887 @section Type Traits
18889 The C++ front end implements syntactic extensions that allow
18890 compile-time determination of 
18891 various characteristics of a type (or of a
18892 pair of types).
18894 @table @code
18895 @item __has_nothrow_assign (type)
18896 If @code{type} is const qualified or is a reference type then the trait is
18897 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18898 is true, else if @code{type} is a cv class or union type with copy assignment
18899 operators that are known not to throw an exception then the trait is true,
18900 else it is false.  Requires: @code{type} shall be a complete type,
18901 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18903 @item __has_nothrow_copy (type)
18904 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18905 @code{type} is a cv class or union type with copy constructors that
18906 are known not to throw an exception then the trait is true, else it is false.
18907 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18908 @code{void}, or an array of unknown bound.
18910 @item __has_nothrow_constructor (type)
18911 If @code{__has_trivial_constructor (type)} is true then the trait is
18912 true, else if @code{type} is a cv class or union type (or array
18913 thereof) with a default constructor that is known not to throw an
18914 exception then the trait is true, else it is false.  Requires:
18915 @code{type} shall be a complete type, (possibly cv-qualified)
18916 @code{void}, or an array of unknown bound.
18918 @item __has_trivial_assign (type)
18919 If @code{type} is const qualified or is a reference type then the trait is
18920 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
18921 true, else if @code{type} is a cv class or union type with a trivial
18922 copy assignment ([class.copy]) then the trait is true, else it is
18923 false.  Requires: @code{type} shall be a complete type, (possibly
18924 cv-qualified) @code{void}, or an array of unknown bound.
18926 @item __has_trivial_copy (type)
18927 If @code{__is_pod (type)} is true or @code{type} is a reference type
18928 then the trait is true, else if @code{type} is a cv class or union type
18929 with a trivial copy constructor ([class.copy]) then the trait
18930 is true, else it is false.  Requires: @code{type} shall be a complete
18931 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18933 @item __has_trivial_constructor (type)
18934 If @code{__is_pod (type)} is true then the trait is true, else if
18935 @code{type} is a cv class or union type (or array thereof) with a
18936 trivial default constructor ([class.ctor]) then the trait is true,
18937 else it is false.  Requires: @code{type} shall be a complete
18938 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18940 @item __has_trivial_destructor (type)
18941 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18942 the trait is true, else if @code{type} is a cv class or union type (or
18943 array thereof) with a trivial destructor ([class.dtor]) then the trait
18944 is true, else it is false.  Requires: @code{type} shall be a complete
18945 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18947 @item __has_virtual_destructor (type)
18948 If @code{type} is a class type with a virtual destructor
18949 ([class.dtor]) then the trait is true, else it is false.  Requires:
18950 @code{type} shall be a complete type, (possibly cv-qualified)
18951 @code{void}, or an array of unknown bound.
18953 @item __is_abstract (type)
18954 If @code{type} is an abstract class ([class.abstract]) then the trait
18955 is true, else it is false.  Requires: @code{type} shall be a complete
18956 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18958 @item __is_base_of (base_type, derived_type)
18959 If @code{base_type} is a base class of @code{derived_type}
18960 ([class.derived]) then the trait is true, otherwise it is false.
18961 Top-level cv qualifications of @code{base_type} and
18962 @code{derived_type} are ignored.  For the purposes of this trait, a
18963 class type is considered is own base.  Requires: if @code{__is_class
18964 (base_type)} and @code{__is_class (derived_type)} are true and
18965 @code{base_type} and @code{derived_type} are not the same type
18966 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
18967 type.  Diagnostic is produced if this requirement is not met.
18969 @item __is_class (type)
18970 If @code{type} is a cv class type, and not a union type
18971 ([basic.compound]) the trait is true, else it is false.
18973 @item __is_empty (type)
18974 If @code{__is_class (type)} is false then the trait is false.
18975 Otherwise @code{type} is considered empty if and only if: @code{type}
18976 has no non-static data members, or all non-static data members, if
18977 any, are bit-fields of length 0, and @code{type} has no virtual
18978 members, and @code{type} has no virtual base classes, and @code{type}
18979 has no base classes @code{base_type} for which
18980 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
18981 be a complete type, (possibly cv-qualified) @code{void}, or an array
18982 of unknown bound.
18984 @item __is_enum (type)
18985 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
18986 true, else it is false.
18988 @item __is_literal_type (type)
18989 If @code{type} is a literal type ([basic.types]) the trait is
18990 true, else it is false.  Requires: @code{type} shall be a complete type,
18991 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18993 @item __is_pod (type)
18994 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
18995 else it is false.  Requires: @code{type} shall be a complete type,
18996 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18998 @item __is_polymorphic (type)
18999 If @code{type} is a polymorphic class ([class.virtual]) then the trait
19000 is true, else it is false.  Requires: @code{type} shall be a complete
19001 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19003 @item __is_standard_layout (type)
19004 If @code{type} is a standard-layout type ([basic.types]) the trait is
19005 true, else it is false.  Requires: @code{type} shall be a complete
19006 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19008 @item __is_trivial (type)
19009 If @code{type} is a trivial type ([basic.types]) the trait is
19010 true, else it is false.  Requires: @code{type} shall be a complete
19011 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19013 @item __is_union (type)
19014 If @code{type} is a cv union type ([basic.compound]) the trait is
19015 true, else it is false.
19017 @item __underlying_type (type)
19018 The underlying type of @code{type}.  Requires: @code{type} shall be
19019 an enumeration type ([dcl.enum]).
19021 @end table
19023 @node Java Exceptions
19024 @section Java Exceptions
19026 The Java language uses a slightly different exception handling model
19027 from C++.  Normally, GNU C++ automatically detects when you are
19028 writing C++ code that uses Java exceptions, and handle them
19029 appropriately.  However, if C++ code only needs to execute destructors
19030 when Java exceptions are thrown through it, GCC guesses incorrectly.
19031 Sample problematic code is:
19033 @smallexample
19034   struct S @{ ~S(); @};
19035   extern void bar();    // @r{is written in Java, and may throw exceptions}
19036   void foo()
19037   @{
19038     S s;
19039     bar();
19040   @}
19041 @end smallexample
19043 @noindent
19044 The usual effect of an incorrect guess is a link failure, complaining of
19045 a missing routine called @samp{__gxx_personality_v0}.
19047 You can inform the compiler that Java exceptions are to be used in a
19048 translation unit, irrespective of what it might think, by writing
19049 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
19050 @samp{#pragma} must appear before any functions that throw or catch
19051 exceptions, or run destructors when exceptions are thrown through them.
19053 You cannot mix Java and C++ exceptions in the same translation unit.  It
19054 is believed to be safe to throw a C++ exception from one file through
19055 another file compiled for the Java exception model, or vice versa, but
19056 there may be bugs in this area.
19058 @node Deprecated Features
19059 @section Deprecated Features
19061 In the past, the GNU C++ compiler was extended to experiment with new
19062 features, at a time when the C++ language was still evolving.  Now that
19063 the C++ standard is complete, some of those features are superseded by
19064 superior alternatives.  Using the old features might cause a warning in
19065 some cases that the feature will be dropped in the future.  In other
19066 cases, the feature might be gone already.
19068 While the list below is not exhaustive, it documents some of the options
19069 that are now deprecated:
19071 @table @code
19072 @item -fexternal-templates
19073 @itemx -falt-external-templates
19074 These are two of the many ways for G++ to implement template
19075 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
19076 defines how template definitions have to be organized across
19077 implementation units.  G++ has an implicit instantiation mechanism that
19078 should work just fine for standard-conforming code.
19080 @item -fstrict-prototype
19081 @itemx -fno-strict-prototype
19082 Previously it was possible to use an empty prototype parameter list to
19083 indicate an unspecified number of parameters (like C), rather than no
19084 parameters, as C++ demands.  This feature has been removed, except where
19085 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
19086 @end table
19088 G++ allows a virtual function returning @samp{void *} to be overridden
19089 by one returning a different pointer type.  This extension to the
19090 covariant return type rules is now deprecated and will be removed from a
19091 future version.
19093 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19094 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19095 and are now removed from G++.  Code using these operators should be
19096 modified to use @code{std::min} and @code{std::max} instead.
19098 The named return value extension has been deprecated, and is now
19099 removed from G++.
19101 The use of initializer lists with new expressions has been deprecated,
19102 and is now removed from G++.
19104 Floating and complex non-type template parameters have been deprecated,
19105 and are now removed from G++.
19107 The implicit typename extension has been deprecated and is now
19108 removed from G++.
19110 The use of default arguments in function pointers, function typedefs
19111 and other places where they are not permitted by the standard is
19112 deprecated and will be removed from a future version of G++.
19114 G++ allows floating-point literals to appear in integral constant expressions,
19115 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19116 This extension is deprecated and will be removed from a future version.
19118 G++ allows static data members of const floating-point type to be declared
19119 with an initializer in a class definition. The standard only allows
19120 initializers for static members of const integral types and const
19121 enumeration types so this extension has been deprecated and will be removed
19122 from a future version.
19124 @node Backwards Compatibility
19125 @section Backwards Compatibility
19126 @cindex Backwards Compatibility
19127 @cindex ARM [Annotated C++ Reference Manual]
19129 Now that there is a definitive ISO standard C++, G++ has a specification
19130 to adhere to.  The C++ language evolved over time, and features that
19131 used to be acceptable in previous drafts of the standard, such as the ARM
19132 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
19133 compilation of C++ written to such drafts, G++ contains some backwards
19134 compatibilities.  @emph{All such backwards compatibility features are
19135 liable to disappear in future versions of G++.} They should be considered
19136 deprecated.   @xref{Deprecated Features}.
19138 @table @code
19139 @item For scope
19140 If a variable is declared at for scope, it used to remain in scope until
19141 the end of the scope that contained the for statement (rather than just
19142 within the for scope).  G++ retains this, but issues a warning, if such a
19143 variable is accessed outside the for scope.
19145 @item Implicit C language
19146 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19147 scope to set the language.  On such systems, all header files are
19148 implicitly scoped inside a C language scope.  Also, an empty prototype
19149 @code{()} is treated as an unspecified number of arguments, rather
19150 than no arguments, as C++ demands.
19151 @end table
19153 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
19154 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign