2014-10-24 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / doc / extend.texi
blob6db142e4d6c3fa2ad0643d7523972cd5e63b95ac
1 @c Copyright (C) 1988-2014 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Initializers::        Non-constant initializers.
50 * Compound Literals::   Compound literals give structures, unions
51                         or arrays as values.
52 * Designated Inits::    Labeling elements of initializers.
53 * Case Ranges::         `case 1 ... 9' and such.
54 * Cast to Union::       Casting to union type from any member of the union.
55 * Mixed Declarations::  Mixing declarations and code.
56 * Function Attributes:: Declaring that functions have no side effects,
57                         or that they can never return.
58 * Label Attributes::    Specifying attributes on labels.
59 * Attribute Syntax::    Formal syntax for attributes.
60 * Function Prototypes:: Prototype declarations and old-style definitions.
61 * C++ Comments::        C++ comments are recognized.
62 * Dollar Signs::        Dollar sign is allowed in identifiers.
63 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
64 * Variable Attributes:: Specifying attributes of variables.
65 * Type Attributes::     Specifying attributes of types.
66 * Alignment::           Inquiring about the alignment of a type or variable.
67 * Inline::              Defining inline functions (as fast as macros).
68 * Volatiles::           What constitutes an access to a volatile object.
69 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
70 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
71 * Incomplete Enums::    @code{enum foo;}, with details to follow.
72 * Function Names::      Printable strings which are the name of the current
73                         function.
74 * Return Address::      Getting the return or frame address of a function.
75 * Vector Extensions::   Using vector instructions through built-in functions.
76 * Offsetof::            Special syntax for implementing @code{offsetof}.
77 * __sync Builtins::     Legacy built-in functions for atomic memory access.
78 * __atomic Builtins::   Atomic built-in functions with memory model.
79 * x86 specific memory model extensions for transactional memory:: x86 memory models.
80 * Object Size Checking:: Built-in functions for limited buffer overflow
81                         checking.
82 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
83 * Other Builtins::      Other built-in functions.
84 * Target Builtins::     Built-in functions specific to particular targets.
85 * Target Format Checks:: Format checks specific to particular targets.
86 * Pragmas::             Pragmas accepted by GCC.
87 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
88 * Thread-Local::        Per-thread variables.
89 * Binary constants::    Binary constants using the @samp{0b} prefix.
90 @end menu
92 @node Statement Exprs
93 @section Statements and Declarations in Expressions
94 @cindex statements inside expressions
95 @cindex declarations inside expressions
96 @cindex expressions containing statements
97 @cindex macros, statements in expressions
99 @c the above section title wrapped and causes an underfull hbox.. i
100 @c changed it from "within" to "in". --mew 4feb93
101 A compound statement enclosed in parentheses may appear as an expression
102 in GNU C@.  This allows you to use loops, switches, and local variables
103 within an expression.
105 Recall that a compound statement is a sequence of statements surrounded
106 by braces; in this construct, parentheses go around the braces.  For
107 example:
109 @smallexample
110 (@{ int y = foo (); int z;
111    if (y > 0) z = y;
112    else z = - y;
113    z; @})
114 @end smallexample
116 @noindent
117 is a valid (though slightly more complex than necessary) expression
118 for the absolute value of @code{foo ()}.
120 The last thing in the compound statement should be an expression
121 followed by a semicolon; the value of this subexpression serves as the
122 value of the entire construct.  (If you use some other kind of statement
123 last within the braces, the construct has type @code{void}, and thus
124 effectively no value.)
126 This feature is especially useful in making macro definitions ``safe'' (so
127 that they evaluate each operand exactly once).  For example, the
128 ``maximum'' function is commonly defined as a macro in standard C as
129 follows:
131 @smallexample
132 #define max(a,b) ((a) > (b) ? (a) : (b))
133 @end smallexample
135 @noindent
136 @cindex side effects, macro argument
137 But this definition computes either @var{a} or @var{b} twice, with bad
138 results if the operand has side effects.  In GNU C, if you know the
139 type of the operands (here taken as @code{int}), you can define
140 the macro safely as follows:
142 @smallexample
143 #define maxint(a,b) \
144   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
145 @end smallexample
147 Embedded statements are not allowed in constant expressions, such as
148 the value of an enumeration constant, the width of a bit-field, or
149 the initial value of a static variable.
151 If you don't know the type of the operand, you can still do this, but you
152 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
154 In G++, the result value of a statement expression undergoes array and
155 function pointer decay, and is returned by value to the enclosing
156 expression.  For instance, if @code{A} is a class, then
158 @smallexample
159         A a;
161         (@{a;@}).Foo ()
162 @end smallexample
164 @noindent
165 constructs a temporary @code{A} object to hold the result of the
166 statement expression, and that is used to invoke @code{Foo}.
167 Therefore the @code{this} pointer observed by @code{Foo} is not the
168 address of @code{a}.
170 In a statement expression, any temporaries created within a statement
171 are destroyed at that statement's end.  This makes statement
172 expressions inside macros slightly different from function calls.  In
173 the latter case temporaries introduced during argument evaluation are
174 destroyed at the end of the statement that includes the function
175 call.  In the statement expression case they are destroyed during
176 the statement expression.  For instance,
178 @smallexample
179 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
180 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
182 void foo ()
184   macro (X ());
185   function (X ());
187 @end smallexample
189 @noindent
190 has different places where temporaries are destroyed.  For the
191 @code{macro} case, the temporary @code{X} is destroyed just after
192 the initialization of @code{b}.  In the @code{function} case that
193 temporary is destroyed when the function returns.
195 These considerations mean that it is probably a bad idea to use
196 statement expressions of this form in header files that are designed to
197 work with C++.  (Note that some versions of the GNU C Library contained
198 header files using statement expressions that lead to precisely this
199 bug.)
201 Jumping into a statement expression with @code{goto} or using a
202 @code{switch} statement outside the statement expression with a
203 @code{case} or @code{default} label inside the statement expression is
204 not permitted.  Jumping into a statement expression with a computed
205 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
206 Jumping out of a statement expression is permitted, but if the
207 statement expression is part of a larger expression then it is
208 unspecified which other subexpressions of that expression have been
209 evaluated except where the language definition requires certain
210 subexpressions to be evaluated before or after the statement
211 expression.  In any case, as with a function call, the evaluation of a
212 statement expression is not interleaved with the evaluation of other
213 parts of the containing expression.  For example,
215 @smallexample
216   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
217 @end smallexample
219 @noindent
220 calls @code{foo} and @code{bar1} and does not call @code{baz} but
221 may or may not call @code{bar2}.  If @code{bar2} is called, it is
222 called after @code{foo} and before @code{bar1}.
224 @node Local Labels
225 @section Locally Declared Labels
226 @cindex local labels
227 @cindex macros, local labels
229 GCC allows you to declare @dfn{local labels} in any nested block
230 scope.  A local label is just like an ordinary label, but you can
231 only reference it (with a @code{goto} statement, or by taking its
232 address) within the block in which it is declared.
234 A local label declaration looks like this:
236 @smallexample
237 __label__ @var{label};
238 @end smallexample
240 @noindent
243 @smallexample
244 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
245 @end smallexample
247 Local label declarations must come at the beginning of the block,
248 before any ordinary declarations or statements.
250 The label declaration defines the label @emph{name}, but does not define
251 the label itself.  You must do this in the usual way, with
252 @code{@var{label}:}, within the statements of the statement expression.
254 The local label feature is useful for complex macros.  If a macro
255 contains nested loops, a @code{goto} can be useful for breaking out of
256 them.  However, an ordinary label whose scope is the whole function
257 cannot be used: if the macro can be expanded several times in one
258 function, the label is multiply defined in that function.  A
259 local label avoids this problem.  For example:
261 @smallexample
262 #define SEARCH(value, array, target)              \
263 do @{                                              \
264   __label__ found;                                \
265   typeof (target) _SEARCH_target = (target);      \
266   typeof (*(array)) *_SEARCH_array = (array);     \
267   int i, j;                                       \
268   int value;                                      \
269   for (i = 0; i < max; i++)                       \
270     for (j = 0; j < max; j++)                     \
271       if (_SEARCH_array[i][j] == _SEARCH_target)  \
272         @{ (value) = i; goto found; @}              \
273   (value) = -1;                                   \
274  found:;                                          \
275 @} while (0)
276 @end smallexample
278 This could also be written using a statement expression:
280 @smallexample
281 #define SEARCH(array, target)                     \
282 (@{                                                \
283   __label__ found;                                \
284   typeof (target) _SEARCH_target = (target);      \
285   typeof (*(array)) *_SEARCH_array = (array);     \
286   int i, j;                                       \
287   int value;                                      \
288   for (i = 0; i < max; i++)                       \
289     for (j = 0; j < max; j++)                     \
290       if (_SEARCH_array[i][j] == _SEARCH_target)  \
291         @{ value = i; goto found; @}                \
292   value = -1;                                     \
293  found:                                           \
294   value;                                          \
296 @end smallexample
298 Local label declarations also make the labels they declare visible to
299 nested functions, if there are any.  @xref{Nested Functions}, for details.
301 @node Labels as Values
302 @section Labels as Values
303 @cindex labels as values
304 @cindex computed gotos
305 @cindex goto with computed label
306 @cindex address of a label
308 You can get the address of a label defined in the current function
309 (or a containing function) with the unary operator @samp{&&}.  The
310 value has type @code{void *}.  This value is a constant and can be used
311 wherever a constant of that type is valid.  For example:
313 @smallexample
314 void *ptr;
315 /* @r{@dots{}} */
316 ptr = &&foo;
317 @end smallexample
319 To use these values, you need to be able to jump to one.  This is done
320 with the computed goto statement@footnote{The analogous feature in
321 Fortran is called an assigned goto, but that name seems inappropriate in
322 C, where one can do more than simply store label addresses in label
323 variables.}, @code{goto *@var{exp};}.  For example,
325 @smallexample
326 goto *ptr;
327 @end smallexample
329 @noindent
330 Any expression of type @code{void *} is allowed.
332 One way of using these constants is in initializing a static array that
333 serves as a jump table:
335 @smallexample
336 static void *array[] = @{ &&foo, &&bar, &&hack @};
337 @end smallexample
339 @noindent
340 Then you can select a label with indexing, like this:
342 @smallexample
343 goto *array[i];
344 @end smallexample
346 @noindent
347 Note that this does not check whether the subscript is in bounds---array
348 indexing in C never does that.
350 Such an array of label values serves a purpose much like that of the
351 @code{switch} statement.  The @code{switch} statement is cleaner, so
352 use that rather than an array unless the problem does not fit a
353 @code{switch} statement very well.
355 Another use of label values is in an interpreter for threaded code.
356 The labels within the interpreter function can be stored in the
357 threaded code for super-fast dispatching.
359 You may not use this mechanism to jump to code in a different function.
360 If you do that, totally unpredictable things happen.  The best way to
361 avoid this is to store the label address only in automatic variables and
362 never pass it as an argument.
364 An alternate way to write the above example is
366 @smallexample
367 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
368                              &&hack - &&foo @};
369 goto *(&&foo + array[i]);
370 @end smallexample
372 @noindent
373 This is more friendly to code living in shared libraries, as it reduces
374 the number of dynamic relocations that are needed, and by consequence,
375 allows the data to be read-only.
376 This alternative with label differences is not supported for the AVR target,
377 please use the first approach for AVR programs.
379 The @code{&&foo} expressions for the same label might have different
380 values if the containing function is inlined or cloned.  If a program
381 relies on them being always the same,
382 @code{__attribute__((__noinline__,__noclone__))} should be used to
383 prevent inlining and cloning.  If @code{&&foo} is used in a static
384 variable initializer, inlining and cloning is forbidden.
386 @node Nested Functions
387 @section Nested Functions
388 @cindex nested functions
389 @cindex downward funargs
390 @cindex thunks
392 A @dfn{nested function} is a function defined inside another function.
393 Nested functions are supported as an extension in GNU C, but are not
394 supported by GNU C++.
396 The nested function's name is local to the block where it is defined.
397 For example, here we define a nested function named @code{square}, and
398 call it twice:
400 @smallexample
401 @group
402 foo (double a, double b)
404   double square (double z) @{ return z * z; @}
406   return square (a) + square (b);
408 @end group
409 @end smallexample
411 The nested function can access all the variables of the containing
412 function that are visible at the point of its definition.  This is
413 called @dfn{lexical scoping}.  For example, here we show a nested
414 function which uses an inherited variable named @code{offset}:
416 @smallexample
417 @group
418 bar (int *array, int offset, int size)
420   int access (int *array, int index)
421     @{ return array[index + offset]; @}
422   int i;
423   /* @r{@dots{}} */
424   for (i = 0; i < size; i++)
425     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
427 @end group
428 @end smallexample
430 Nested function definitions are permitted within functions in the places
431 where variable definitions are allowed; that is, in any block, mixed
432 with the other declarations and statements in the block.
434 It is possible to call the nested function from outside the scope of its
435 name by storing its address or passing the address to another function:
437 @smallexample
438 hack (int *array, int size)
440   void store (int index, int value)
441     @{ array[index] = value; @}
443   intermediate (store, size);
445 @end smallexample
447 Here, the function @code{intermediate} receives the address of
448 @code{store} as an argument.  If @code{intermediate} calls @code{store},
449 the arguments given to @code{store} are used to store into @code{array}.
450 But this technique works only so long as the containing function
451 (@code{hack}, in this example) does not exit.
453 If you try to call the nested function through its address after the
454 containing function exits, all hell breaks loose.  If you try
455 to call it after a containing scope level exits, and if it refers
456 to some of the variables that are no longer in scope, you may be lucky,
457 but it's not wise to take the risk.  If, however, the nested function
458 does not refer to anything that has gone out of scope, you should be
459 safe.
461 GCC implements taking the address of a nested function using a technique
462 called @dfn{trampolines}.  This technique was described in
463 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
464 C++ Conference Proceedings, October 17-21, 1988).
466 A nested function can jump to a label inherited from a containing
467 function, provided the label is explicitly declared in the containing
468 function (@pxref{Local Labels}).  Such a jump returns instantly to the
469 containing function, exiting the nested function that did the
470 @code{goto} and any intermediate functions as well.  Here is an example:
472 @smallexample
473 @group
474 bar (int *array, int offset, int size)
476   __label__ failure;
477   int access (int *array, int index)
478     @{
479       if (index > size)
480         goto failure;
481       return array[index + offset];
482     @}
483   int i;
484   /* @r{@dots{}} */
485   for (i = 0; i < size; i++)
486     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
487   /* @r{@dots{}} */
488   return 0;
490  /* @r{Control comes here from @code{access}
491     if it detects an error.}  */
492  failure:
493   return -1;
495 @end group
496 @end smallexample
498 A nested function always has no linkage.  Declaring one with
499 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
500 before its definition, use @code{auto} (which is otherwise meaningless
501 for function declarations).
503 @smallexample
504 bar (int *array, int offset, int size)
506   __label__ failure;
507   auto int access (int *, int);
508   /* @r{@dots{}} */
509   int access (int *array, int index)
510     @{
511       if (index > size)
512         goto failure;
513       return array[index + offset];
514     @}
515   /* @r{@dots{}} */
517 @end smallexample
519 @node Constructing Calls
520 @section Constructing Function Calls
521 @cindex constructing calls
522 @cindex forwarding calls
524 Using the built-in functions described below, you can record
525 the arguments a function received, and call another function
526 with the same arguments, without knowing the number or types
527 of the arguments.
529 You can also record the return value of that function call,
530 and later return that value, without knowing what data type
531 the function tried to return (as long as your caller expects
532 that data type).
534 However, these built-in functions may interact badly with some
535 sophisticated features or other extensions of the language.  It
536 is, therefore, not recommended to use them outside very simple
537 functions acting as mere forwarders for their arguments.
539 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
540 This built-in function returns a pointer to data
541 describing how to perform a call with the same arguments as are passed
542 to the current function.
544 The function saves the arg pointer register, structure value address,
545 and all registers that might be used to pass arguments to a function
546 into a block of memory allocated on the stack.  Then it returns the
547 address of that block.
548 @end deftypefn
550 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
551 This built-in function invokes @var{function}
552 with a copy of the parameters described by @var{arguments}
553 and @var{size}.
555 The value of @var{arguments} should be the value returned by
556 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
557 of the stack argument data, in bytes.
559 This function returns a pointer to data describing
560 how to return whatever value is returned by @var{function}.  The data
561 is saved in a block of memory allocated on the stack.
563 It is not always simple to compute the proper value for @var{size}.  The
564 value is used by @code{__builtin_apply} to compute the amount of data
565 that should be pushed on the stack and copied from the incoming argument
566 area.
567 @end deftypefn
569 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
570 This built-in function returns the value described by @var{result} from
571 the containing function.  You should specify, for @var{result}, a value
572 returned by @code{__builtin_apply}.
573 @end deftypefn
575 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
576 This built-in function represents all anonymous arguments of an inline
577 function.  It can be used only in inline functions that are always
578 inlined, never compiled as a separate function, such as those using
579 @code{__attribute__ ((__always_inline__))} or
580 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
581 It must be only passed as last argument to some other function
582 with variable arguments.  This is useful for writing small wrapper
583 inlines for variable argument functions, when using preprocessor
584 macros is undesirable.  For example:
585 @smallexample
586 extern int myprintf (FILE *f, const char *format, ...);
587 extern inline __attribute__ ((__gnu_inline__)) int
588 myprintf (FILE *f, const char *format, ...)
590   int r = fprintf (f, "myprintf: ");
591   if (r < 0)
592     return r;
593   int s = fprintf (f, format, __builtin_va_arg_pack ());
594   if (s < 0)
595     return s;
596   return r + s;
598 @end smallexample
599 @end deftypefn
601 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
602 This built-in function returns the number of anonymous arguments of
603 an inline function.  It can be used only in inline functions that
604 are always inlined, never compiled as a separate function, such
605 as those using @code{__attribute__ ((__always_inline__))} or
606 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
607 For example following does link- or run-time checking of open
608 arguments for optimized code:
609 @smallexample
610 #ifdef __OPTIMIZE__
611 extern inline __attribute__((__gnu_inline__)) int
612 myopen (const char *path, int oflag, ...)
614   if (__builtin_va_arg_pack_len () > 1)
615     warn_open_too_many_arguments ();
617   if (__builtin_constant_p (oflag))
618     @{
619       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
620         @{
621           warn_open_missing_mode ();
622           return __open_2 (path, oflag);
623         @}
624       return open (path, oflag, __builtin_va_arg_pack ());
625     @}
627   if (__builtin_va_arg_pack_len () < 1)
628     return __open_2 (path, oflag);
630   return open (path, oflag, __builtin_va_arg_pack ());
632 #endif
633 @end smallexample
634 @end deftypefn
636 @node Typeof
637 @section Referring to a Type with @code{typeof}
638 @findex typeof
639 @findex sizeof
640 @cindex macros, types of arguments
642 Another way to refer to the type of an expression is with @code{typeof}.
643 The syntax of using of this keyword looks like @code{sizeof}, but the
644 construct acts semantically like a type name defined with @code{typedef}.
646 There are two ways of writing the argument to @code{typeof}: with an
647 expression or with a type.  Here is an example with an expression:
649 @smallexample
650 typeof (x[0](1))
651 @end smallexample
653 @noindent
654 This assumes that @code{x} is an array of pointers to functions;
655 the type described is that of the values of the functions.
657 Here is an example with a typename as the argument:
659 @smallexample
660 typeof (int *)
661 @end smallexample
663 @noindent
664 Here the type described is that of pointers to @code{int}.
666 If you are writing a header file that must work when included in ISO C
667 programs, write @code{__typeof__} instead of @code{typeof}.
668 @xref{Alternate Keywords}.
670 A @code{typeof} construct can be used anywhere a typedef name can be
671 used.  For example, you can use it in a declaration, in a cast, or inside
672 of @code{sizeof} or @code{typeof}.
674 The operand of @code{typeof} is evaluated for its side effects if and
675 only if it is an expression of variably modified type or the name of
676 such a type.
678 @code{typeof} is often useful in conjunction with
679 statement expressions (@pxref{Statement Exprs}).
680 Here is how the two together can
681 be used to define a safe ``maximum'' macro which operates on any
682 arithmetic type and evaluates each of its arguments exactly once:
684 @smallexample
685 #define max(a,b) \
686   (@{ typeof (a) _a = (a); \
687       typeof (b) _b = (b); \
688     _a > _b ? _a : _b; @})
689 @end smallexample
691 @cindex underscores in variables in macros
692 @cindex @samp{_} in variables in macros
693 @cindex local variables in macros
694 @cindex variables, local, in macros
695 @cindex macros, local variables in
697 The reason for using names that start with underscores for the local
698 variables is to avoid conflicts with variable names that occur within the
699 expressions that are substituted for @code{a} and @code{b}.  Eventually we
700 hope to design a new form of declaration syntax that allows you to declare
701 variables whose scopes start only after their initializers; this will be a
702 more reliable way to prevent such conflicts.
704 @noindent
705 Some more examples of the use of @code{typeof}:
707 @itemize @bullet
708 @item
709 This declares @code{y} with the type of what @code{x} points to.
711 @smallexample
712 typeof (*x) y;
713 @end smallexample
715 @item
716 This declares @code{y} as an array of such values.
718 @smallexample
719 typeof (*x) y[4];
720 @end smallexample
722 @item
723 This declares @code{y} as an array of pointers to characters:
725 @smallexample
726 typeof (typeof (char *)[4]) y;
727 @end smallexample
729 @noindent
730 It is equivalent to the following traditional C declaration:
732 @smallexample
733 char *y[4];
734 @end smallexample
736 To see the meaning of the declaration using @code{typeof}, and why it
737 might be a useful way to write, rewrite it with these macros:
739 @smallexample
740 #define pointer(T)  typeof(T *)
741 #define array(T, N) typeof(T [N])
742 @end smallexample
744 @noindent
745 Now the declaration can be rewritten this way:
747 @smallexample
748 array (pointer (char), 4) y;
749 @end smallexample
751 @noindent
752 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
753 pointers to @code{char}.
754 @end itemize
756 In GNU C, but not GNU C++, you may also declare the type of a variable
757 as @code{__auto_type}.  In that case, the declaration must declare
758 only one variable, whose declarator must just be an identifier, the
759 declaration must be initialized, and the type of the variable is
760 determined by the initializer; the name of the variable is not in
761 scope until after the initializer.  (In C++, you should use C++11
762 @code{auto} for this purpose.)  Using @code{__auto_type}, the
763 ``maximum'' macro above could be written as:
765 @smallexample
766 #define max(a,b) \
767   (@{ __auto_type _a = (a); \
768       __auto_type _b = (b); \
769     _a > _b ? _a : _b; @})
770 @end smallexample
772 Using @code{__auto_type} instead of @code{typeof} has two advantages:
774 @itemize @bullet
775 @item Each argument to the macro appears only once in the expansion of
776 the macro.  This prevents the size of the macro expansion growing
777 exponentially when calls to such macros are nested inside arguments of
778 such macros.
780 @item If the argument to the macro has variably modified type, it is
781 evaluated only once when using @code{__auto_type}, but twice if
782 @code{typeof} is used.
783 @end itemize
785 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
786 a more limited extension that permitted one to write
788 @smallexample
789 typedef @var{T} = @var{expr};
790 @end smallexample
792 @noindent
793 with the effect of declaring @var{T} to have the type of the expression
794 @var{expr}.  This extension does not work with GCC 3 (versions between
795 3.0 and 3.2 crash; 3.2.1 and later give an error).  Code that
796 relies on it should be rewritten to use @code{typeof}:
798 @smallexample
799 typedef typeof(@var{expr}) @var{T};
800 @end smallexample
802 @noindent
803 This works with all versions of GCC@.
805 @node Conditionals
806 @section Conditionals with Omitted Operands
807 @cindex conditional expressions, extensions
808 @cindex omitted middle-operands
809 @cindex middle-operands, omitted
810 @cindex extensions, @code{?:}
811 @cindex @code{?:} extensions
813 The middle operand in a conditional expression may be omitted.  Then
814 if the first operand is nonzero, its value is the value of the conditional
815 expression.
817 Therefore, the expression
819 @smallexample
820 x ? : y
821 @end smallexample
823 @noindent
824 has the value of @code{x} if that is nonzero; otherwise, the value of
825 @code{y}.
827 This example is perfectly equivalent to
829 @smallexample
830 x ? x : y
831 @end smallexample
833 @cindex side effect in @code{?:}
834 @cindex @code{?:} side effect
835 @noindent
836 In this simple case, the ability to omit the middle operand is not
837 especially useful.  When it becomes useful is when the first operand does,
838 or may (if it is a macro argument), contain a side effect.  Then repeating
839 the operand in the middle would perform the side effect twice.  Omitting
840 the middle operand uses the value already computed without the undesirable
841 effects of recomputing it.
843 @node __int128
844 @section 128-bit integers
845 @cindex @code{__int128} data types
847 As an extension the integer scalar type @code{__int128} is supported for
848 targets which have an integer mode wide enough to hold 128 bits.
849 Simply write @code{__int128} for a signed 128-bit integer, or
850 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
851 support in GCC for expressing an integer constant of type @code{__int128}
852 for targets with @code{long long} integer less than 128 bits wide.
854 @node Long Long
855 @section Double-Word Integers
856 @cindex @code{long long} data types
857 @cindex double-word arithmetic
858 @cindex multiprecision arithmetic
859 @cindex @code{LL} integer suffix
860 @cindex @code{ULL} integer suffix
862 ISO C99 supports data types for integers that are at least 64 bits wide,
863 and as an extension GCC supports them in C90 mode and in C++.
864 Simply write @code{long long int} for a signed integer, or
865 @code{unsigned long long int} for an unsigned integer.  To make an
866 integer constant of type @code{long long int}, add the suffix @samp{LL}
867 to the integer.  To make an integer constant of type @code{unsigned long
868 long int}, add the suffix @samp{ULL} to the integer.
870 You can use these types in arithmetic like any other integer types.
871 Addition, subtraction, and bitwise boolean operations on these types
872 are open-coded on all types of machines.  Multiplication is open-coded
873 if the machine supports a fullword-to-doubleword widening multiply
874 instruction.  Division and shifts are open-coded only on machines that
875 provide special support.  The operations that are not open-coded use
876 special library routines that come with GCC@.
878 There may be pitfalls when you use @code{long long} types for function
879 arguments without function prototypes.  If a function
880 expects type @code{int} for its argument, and you pass a value of type
881 @code{long long int}, confusion results because the caller and the
882 subroutine disagree about the number of bytes for the argument.
883 Likewise, if the function expects @code{long long int} and you pass
884 @code{int}.  The best way to avoid such problems is to use prototypes.
886 @node Complex
887 @section Complex Numbers
888 @cindex complex numbers
889 @cindex @code{_Complex} keyword
890 @cindex @code{__complex__} keyword
892 ISO C99 supports complex floating data types, and as an extension GCC
893 supports them in C90 mode and in C++.  GCC also supports complex integer data
894 types which are not part of ISO C99.  You can declare complex types
895 using the keyword @code{_Complex}.  As an extension, the older GNU
896 keyword @code{__complex__} is also supported.
898 For example, @samp{_Complex double x;} declares @code{x} as a
899 variable whose real part and imaginary part are both of type
900 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
901 have real and imaginary parts of type @code{short int}; this is not
902 likely to be useful, but it shows that the set of complex types is
903 complete.
905 To write a constant with a complex data type, use the suffix @samp{i} or
906 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
907 has type @code{_Complex float} and @code{3i} has type
908 @code{_Complex int}.  Such a constant always has a pure imaginary
909 value, but you can form any complex value you like by adding one to a
910 real constant.  This is a GNU extension; if you have an ISO C99
911 conforming C library (such as the GNU C Library), and want to construct complex
912 constants of floating type, you should include @code{<complex.h>} and
913 use the macros @code{I} or @code{_Complex_I} instead.
915 @cindex @code{__real__} keyword
916 @cindex @code{__imag__} keyword
917 To extract the real part of a complex-valued expression @var{exp}, write
918 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
919 extract the imaginary part.  This is a GNU extension; for values of
920 floating type, you should use the ISO C99 functions @code{crealf},
921 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
922 @code{cimagl}, declared in @code{<complex.h>} and also provided as
923 built-in functions by GCC@.
925 @cindex complex conjugation
926 The operator @samp{~} performs complex conjugation when used on a value
927 with a complex type.  This is a GNU extension; for values of
928 floating type, you should use the ISO C99 functions @code{conjf},
929 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
930 provided as built-in functions by GCC@.
932 GCC can allocate complex automatic variables in a noncontiguous
933 fashion; it's even possible for the real part to be in a register while
934 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
935 debug info format can represent this, so use of DWARF 2 is recommended.
936 If you are using the stabs debug info format, GCC describes a noncontiguous
937 complex variable as if it were two separate variables of noncomplex type.
938 If the variable's actual name is @code{foo}, the two fictitious
939 variables are named @code{foo$real} and @code{foo$imag}.  You can
940 examine and set these two fictitious variables with your debugger.
942 @node Floating Types
943 @section Additional Floating Types
944 @cindex additional floating types
945 @cindex @code{__float80} data type
946 @cindex @code{__float128} data type
947 @cindex @code{w} floating point suffix
948 @cindex @code{q} floating point suffix
949 @cindex @code{W} floating point suffix
950 @cindex @code{Q} floating point suffix
952 As an extension, GNU C supports additional floating
953 types, @code{__float80} and @code{__float128} to support 80-bit
954 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
955 Support for additional types includes the arithmetic operators:
956 add, subtract, multiply, divide; unary arithmetic operators;
957 relational operators; equality operators; and conversions to and from
958 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
959 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
960 for @code{_float128}.  You can declare complex types using the
961 corresponding internal complex type, @code{XCmode} for @code{__float80}
962 type and @code{TCmode} for @code{__float128} type:
964 @smallexample
965 typedef _Complex float __attribute__((mode(TC))) _Complex128;
966 typedef _Complex float __attribute__((mode(XC))) _Complex80;
967 @end smallexample
969 Not all targets support additional floating-point types.  @code{__float80}
970 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
971 The @code{__float128} type is supported on hppa HP-UX targets.
973 @node Half-Precision
974 @section Half-Precision Floating Point
975 @cindex half-precision floating point
976 @cindex @code{__fp16} data type
978 On ARM targets, GCC supports half-precision (16-bit) floating point via
979 the @code{__fp16} type.  You must enable this type explicitly
980 with the @option{-mfp16-format} command-line option in order to use it.
982 ARM supports two incompatible representations for half-precision
983 floating-point values.  You must choose one of the representations and
984 use it consistently in your program.
986 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
987 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
988 There are 11 bits of significand precision, approximately 3
989 decimal digits.
991 Specifying @option{-mfp16-format=alternative} selects the ARM
992 alternative format.  This representation is similar to the IEEE
993 format, but does not support infinities or NaNs.  Instead, the range
994 of exponents is extended, so that this format can represent normalized
995 values in the range of @math{2^{-14}} to 131008.
997 The @code{__fp16} type is a storage format only.  For purposes
998 of arithmetic and other operations, @code{__fp16} values in C or C++
999 expressions are automatically promoted to @code{float}.  In addition,
1000 you cannot declare a function with a return value or parameters
1001 of type @code{__fp16}.
1003 Note that conversions from @code{double} to @code{__fp16}
1004 involve an intermediate conversion to @code{float}.  Because
1005 of rounding, this can sometimes produce a different result than a
1006 direct conversion.
1008 ARM provides hardware support for conversions between
1009 @code{__fp16} and @code{float} values
1010 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
1011 code using these hardware instructions if you compile with
1012 options to select an FPU that provides them;
1013 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1014 in addition to the @option{-mfp16-format} option to select
1015 a half-precision format.
1017 Language-level support for the @code{__fp16} data type is
1018 independent of whether GCC generates code using hardware floating-point
1019 instructions.  In cases where hardware support is not specified, GCC
1020 implements conversions between @code{__fp16} and @code{float} values
1021 as library calls.
1023 @node Decimal Float
1024 @section Decimal Floating Types
1025 @cindex decimal floating types
1026 @cindex @code{_Decimal32} data type
1027 @cindex @code{_Decimal64} data type
1028 @cindex @code{_Decimal128} data type
1029 @cindex @code{df} integer suffix
1030 @cindex @code{dd} integer suffix
1031 @cindex @code{dl} integer suffix
1032 @cindex @code{DF} integer suffix
1033 @cindex @code{DD} integer suffix
1034 @cindex @code{DL} integer suffix
1036 As an extension, GNU C supports decimal floating types as
1037 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1038 floating types in GCC will evolve as the draft technical report changes.
1039 Calling conventions for any target might also change.  Not all targets
1040 support decimal floating types.
1042 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1043 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1044 @code{float}, @code{double}, and @code{long double} whose radix is not
1045 specified by the C standard but is usually two.
1047 Support for decimal floating types includes the arithmetic operators
1048 add, subtract, multiply, divide; unary arithmetic operators;
1049 relational operators; equality operators; and conversions to and from
1050 integer and other floating types.  Use a suffix @samp{df} or
1051 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1052 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1053 @code{_Decimal128}.
1055 GCC support of decimal float as specified by the draft technical report
1056 is incomplete:
1058 @itemize @bullet
1059 @item
1060 When the value of a decimal floating type cannot be represented in the
1061 integer type to which it is being converted, the result is undefined
1062 rather than the result value specified by the draft technical report.
1064 @item
1065 GCC does not provide the C library functionality associated with
1066 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1067 @file{wchar.h}, which must come from a separate C library implementation.
1068 Because of this the GNU C compiler does not define macro
1069 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1070 the technical report.
1071 @end itemize
1073 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1074 are supported by the DWARF 2 debug information format.
1076 @node Hex Floats
1077 @section Hex Floats
1078 @cindex hex floats
1080 ISO C99 supports floating-point numbers written not only in the usual
1081 decimal notation, such as @code{1.55e1}, but also numbers such as
1082 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1083 supports this in C90 mode (except in some cases when strictly
1084 conforming) and in C++.  In that format the
1085 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1086 mandatory.  The exponent is a decimal number that indicates the power of
1087 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1088 @tex
1089 $1 {15\over16}$,
1090 @end tex
1091 @ifnottex
1092 1 15/16,
1093 @end ifnottex
1094 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1095 is the same as @code{1.55e1}.
1097 Unlike for floating-point numbers in the decimal notation the exponent
1098 is always required in the hexadecimal notation.  Otherwise the compiler
1099 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1100 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1101 extension for floating-point constants of type @code{float}.
1103 @node Fixed-Point
1104 @section Fixed-Point Types
1105 @cindex fixed-point types
1106 @cindex @code{_Fract} data type
1107 @cindex @code{_Accum} data type
1108 @cindex @code{_Sat} data type
1109 @cindex @code{hr} fixed-suffix
1110 @cindex @code{r} fixed-suffix
1111 @cindex @code{lr} fixed-suffix
1112 @cindex @code{llr} fixed-suffix
1113 @cindex @code{uhr} fixed-suffix
1114 @cindex @code{ur} fixed-suffix
1115 @cindex @code{ulr} fixed-suffix
1116 @cindex @code{ullr} fixed-suffix
1117 @cindex @code{hk} fixed-suffix
1118 @cindex @code{k} fixed-suffix
1119 @cindex @code{lk} fixed-suffix
1120 @cindex @code{llk} fixed-suffix
1121 @cindex @code{uhk} fixed-suffix
1122 @cindex @code{uk} fixed-suffix
1123 @cindex @code{ulk} fixed-suffix
1124 @cindex @code{ullk} fixed-suffix
1125 @cindex @code{HR} fixed-suffix
1126 @cindex @code{R} fixed-suffix
1127 @cindex @code{LR} fixed-suffix
1128 @cindex @code{LLR} fixed-suffix
1129 @cindex @code{UHR} fixed-suffix
1130 @cindex @code{UR} fixed-suffix
1131 @cindex @code{ULR} fixed-suffix
1132 @cindex @code{ULLR} fixed-suffix
1133 @cindex @code{HK} fixed-suffix
1134 @cindex @code{K} fixed-suffix
1135 @cindex @code{LK} fixed-suffix
1136 @cindex @code{LLK} fixed-suffix
1137 @cindex @code{UHK} fixed-suffix
1138 @cindex @code{UK} fixed-suffix
1139 @cindex @code{ULK} fixed-suffix
1140 @cindex @code{ULLK} fixed-suffix
1142 As an extension, GNU C supports fixed-point types as
1143 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1144 types in GCC will evolve as the draft technical report changes.
1145 Calling conventions for any target might also change.  Not all targets
1146 support fixed-point types.
1148 The fixed-point types are
1149 @code{short _Fract},
1150 @code{_Fract},
1151 @code{long _Fract},
1152 @code{long long _Fract},
1153 @code{unsigned short _Fract},
1154 @code{unsigned _Fract},
1155 @code{unsigned long _Fract},
1156 @code{unsigned long long _Fract},
1157 @code{_Sat short _Fract},
1158 @code{_Sat _Fract},
1159 @code{_Sat long _Fract},
1160 @code{_Sat long long _Fract},
1161 @code{_Sat unsigned short _Fract},
1162 @code{_Sat unsigned _Fract},
1163 @code{_Sat unsigned long _Fract},
1164 @code{_Sat unsigned long long _Fract},
1165 @code{short _Accum},
1166 @code{_Accum},
1167 @code{long _Accum},
1168 @code{long long _Accum},
1169 @code{unsigned short _Accum},
1170 @code{unsigned _Accum},
1171 @code{unsigned long _Accum},
1172 @code{unsigned long long _Accum},
1173 @code{_Sat short _Accum},
1174 @code{_Sat _Accum},
1175 @code{_Sat long _Accum},
1176 @code{_Sat long long _Accum},
1177 @code{_Sat unsigned short _Accum},
1178 @code{_Sat unsigned _Accum},
1179 @code{_Sat unsigned long _Accum},
1180 @code{_Sat unsigned long long _Accum}.
1182 Fixed-point data values contain fractional and optional integral parts.
1183 The format of fixed-point data varies and depends on the target machine.
1185 Support for fixed-point types includes:
1186 @itemize @bullet
1187 @item
1188 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1189 @item
1190 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1191 @item
1192 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1193 @item
1194 binary shift operators (@code{<<}, @code{>>})
1195 @item
1196 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1197 @item
1198 equality operators (@code{==}, @code{!=})
1199 @item
1200 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1201 @code{<<=}, @code{>>=})
1202 @item
1203 conversions to and from integer, floating-point, or fixed-point types
1204 @end itemize
1206 Use a suffix in a fixed-point literal constant:
1207 @itemize
1208 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1209 @code{_Sat short _Fract}
1210 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1211 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1212 @code{_Sat long _Fract}
1213 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1214 @code{_Sat long long _Fract}
1215 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1216 @code{_Sat unsigned short _Fract}
1217 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1218 @code{_Sat unsigned _Fract}
1219 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1220 @code{_Sat unsigned long _Fract}
1221 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1222 and @code{_Sat unsigned long long _Fract}
1223 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1224 @code{_Sat short _Accum}
1225 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1226 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1227 @code{_Sat long _Accum}
1228 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1229 @code{_Sat long long _Accum}
1230 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1231 @code{_Sat unsigned short _Accum}
1232 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1233 @code{_Sat unsigned _Accum}
1234 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1235 @code{_Sat unsigned long _Accum}
1236 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1237 and @code{_Sat unsigned long long _Accum}
1238 @end itemize
1240 GCC support of fixed-point types as specified by the draft technical report
1241 is incomplete:
1243 @itemize @bullet
1244 @item
1245 Pragmas to control overflow and rounding behaviors are not implemented.
1246 @end itemize
1248 Fixed-point types are supported by the DWARF 2 debug information format.
1250 @node Named Address Spaces
1251 @section Named Address Spaces
1252 @cindex Named Address Spaces
1254 As an extension, GNU C supports named address spaces as
1255 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1256 address spaces in GCC will evolve as the draft technical report
1257 changes.  Calling conventions for any target might also change.  At
1258 present, only the AVR, SPU, M32C, and RL78 targets support address
1259 spaces other than the generic address space.
1261 Address space identifiers may be used exactly like any other C type
1262 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1263 document for more details.
1265 @anchor{AVR Named Address Spaces}
1266 @subsection AVR Named Address Spaces
1268 On the AVR target, there are several address spaces that can be used
1269 in order to put read-only data into the flash memory and access that
1270 data by means of the special instructions @code{LPM} or @code{ELPM}
1271 needed to read from flash.
1273 Per default, any data including read-only data is located in RAM
1274 (the generic address space) so that non-generic address spaces are
1275 needed to locate read-only data in flash memory
1276 @emph{and} to generate the right instructions to access this data
1277 without using (inline) assembler code.
1279 @table @code
1280 @item __flash
1281 @cindex @code{__flash} AVR Named Address Spaces
1282 The @code{__flash} qualifier locates data in the
1283 @code{.progmem.data} section. Data is read using the @code{LPM}
1284 instruction. Pointers to this address space are 16 bits wide.
1286 @item __flash1
1287 @itemx __flash2
1288 @itemx __flash3
1289 @itemx __flash4
1290 @itemx __flash5
1291 @cindex @code{__flash1} AVR Named Address Spaces
1292 @cindex @code{__flash2} AVR Named Address Spaces
1293 @cindex @code{__flash3} AVR Named Address Spaces
1294 @cindex @code{__flash4} AVR Named Address Spaces
1295 @cindex @code{__flash5} AVR Named Address Spaces
1296 These are 16-bit address spaces locating data in section
1297 @code{.progmem@var{N}.data} where @var{N} refers to
1298 address space @code{__flash@var{N}}.
1299 The compiler sets the @code{RAMPZ} segment register appropriately 
1300 before reading data by means of the @code{ELPM} instruction.
1302 @item __memx
1303 @cindex @code{__memx} AVR Named Address Spaces
1304 This is a 24-bit address space that linearizes flash and RAM:
1305 If the high bit of the address is set, data is read from
1306 RAM using the lower two bytes as RAM address.
1307 If the high bit of the address is clear, data is read from flash
1308 with @code{RAMPZ} set according to the high byte of the address.
1309 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1311 Objects in this address space are located in @code{.progmemx.data}.
1312 @end table
1314 @b{Example}
1316 @smallexample
1317 char my_read (const __flash char ** p)
1319     /* p is a pointer to RAM that points to a pointer to flash.
1320        The first indirection of p reads that flash pointer
1321        from RAM and the second indirection reads a char from this
1322        flash address.  */
1324     return **p;
1327 /* Locate array[] in flash memory */
1328 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1330 int i = 1;
1332 int main (void)
1334    /* Return 17 by reading from flash memory */
1335    return array[array[i]];
1337 @end smallexample
1339 @noindent
1340 For each named address space supported by avr-gcc there is an equally
1341 named but uppercase built-in macro defined. 
1342 The purpose is to facilitate testing if respective address space
1343 support is available or not:
1345 @smallexample
1346 #ifdef __FLASH
1347 const __flash int var = 1;
1349 int read_var (void)
1351     return var;
1353 #else
1354 #include <avr/pgmspace.h> /* From AVR-LibC */
1356 const int var PROGMEM = 1;
1358 int read_var (void)
1360     return (int) pgm_read_word (&var);
1362 #endif /* __FLASH */
1363 @end smallexample
1365 @noindent
1366 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1367 locates data in flash but
1368 accesses to these data read from generic address space, i.e.@:
1369 from RAM,
1370 so that you need special accessors like @code{pgm_read_byte}
1371 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1372 together with attribute @code{progmem}.
1374 @noindent
1375 @b{Limitations and caveats}
1377 @itemize
1378 @item
1379 Reading across the 64@tie{}KiB section boundary of
1380 the @code{__flash} or @code{__flash@var{N}} address spaces
1381 shows undefined behavior. The only address space that
1382 supports reading across the 64@tie{}KiB flash segment boundaries is
1383 @code{__memx}.
1385 @item
1386 If you use one of the @code{__flash@var{N}} address spaces
1387 you must arrange your linker script to locate the
1388 @code{.progmem@var{N}.data} sections according to your needs.
1390 @item
1391 Any data or pointers to the non-generic address spaces must
1392 be qualified as @code{const}, i.e.@: as read-only data.
1393 This still applies if the data in one of these address
1394 spaces like software version number or calibration lookup table are intended to
1395 be changed after load time by, say, a boot loader. In this case
1396 the right qualification is @code{const} @code{volatile} so that the compiler
1397 must not optimize away known values or insert them
1398 as immediates into operands of instructions.
1400 @item
1401 The following code initializes a variable @code{pfoo}
1402 located in static storage with a 24-bit address:
1403 @smallexample
1404 extern const __memx char foo;
1405 const __memx void *pfoo = &foo;
1406 @end smallexample
1408 @noindent
1409 Such code requires at least binutils 2.23, see
1410 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1412 @end itemize
1414 @subsection M32C Named Address Spaces
1415 @cindex @code{__far} M32C Named Address Spaces
1417 On the M32C target, with the R8C and M16C CPU variants, variables
1418 qualified with @code{__far} are accessed using 32-bit addresses in
1419 order to access memory beyond the first 64@tie{}Ki bytes.  If
1420 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1421 effect.
1423 @subsection RL78 Named Address Spaces
1424 @cindex @code{__far} RL78 Named Address Spaces
1426 On the RL78 target, variables qualified with @code{__far} are accessed
1427 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1428 addresses.  Non-far variables are assumed to appear in the topmost
1429 64@tie{}KiB of the address space.
1431 @subsection SPU Named Address Spaces
1432 @cindex @code{__ea} SPU Named Address Spaces
1434 On the SPU target variables may be declared as
1435 belonging to another address space by qualifying the type with the
1436 @code{__ea} address space identifier:
1438 @smallexample
1439 extern int __ea i;
1440 @end smallexample
1442 @noindent 
1443 The compiler generates special code to access the variable @code{i}.
1444 It may use runtime library
1445 support, or generate special machine instructions to access that address
1446 space.
1448 @node Zero Length
1449 @section Arrays of Length Zero
1450 @cindex arrays of length zero
1451 @cindex zero-length arrays
1452 @cindex length-zero arrays
1453 @cindex flexible array members
1455 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1456 last element of a structure that is really a header for a variable-length
1457 object:
1459 @smallexample
1460 struct line @{
1461   int length;
1462   char contents[0];
1465 struct line *thisline = (struct line *)
1466   malloc (sizeof (struct line) + this_length);
1467 thisline->length = this_length;
1468 @end smallexample
1470 In ISO C90, you would have to give @code{contents} a length of 1, which
1471 means either you waste space or complicate the argument to @code{malloc}.
1473 In ISO C99, you would use a @dfn{flexible array member}, which is
1474 slightly different in syntax and semantics:
1476 @itemize @bullet
1477 @item
1478 Flexible array members are written as @code{contents[]} without
1479 the @code{0}.
1481 @item
1482 Flexible array members have incomplete type, and so the @code{sizeof}
1483 operator may not be applied.  As a quirk of the original implementation
1484 of zero-length arrays, @code{sizeof} evaluates to zero.
1486 @item
1487 Flexible array members may only appear as the last member of a
1488 @code{struct} that is otherwise non-empty.
1490 @item
1491 A structure containing a flexible array member, or a union containing
1492 such a structure (possibly recursively), may not be a member of a
1493 structure or an element of an array.  (However, these uses are
1494 permitted by GCC as extensions.)
1495 @end itemize
1497 GCC versions before 3.0 allowed zero-length arrays to be statically
1498 initialized, as if they were flexible arrays.  In addition to those
1499 cases that were useful, it also allowed initializations in situations
1500 that would corrupt later data.  Non-empty initialization of zero-length
1501 arrays is now treated like any case where there are more initializer
1502 elements than the array holds, in that a suitable warning about ``excess
1503 elements in array'' is given, and the excess elements (all of them, in
1504 this case) are ignored.
1506 Instead GCC allows static initialization of flexible array members.
1507 This is equivalent to defining a new structure containing the original
1508 structure followed by an array of sufficient size to contain the data.
1509 E.g.@: in the following, @code{f1} is constructed as if it were declared
1510 like @code{f2}.
1512 @smallexample
1513 struct f1 @{
1514   int x; int y[];
1515 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1517 struct f2 @{
1518   struct f1 f1; int data[3];
1519 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1520 @end smallexample
1522 @noindent
1523 The convenience of this extension is that @code{f1} has the desired
1524 type, eliminating the need to consistently refer to @code{f2.f1}.
1526 This has symmetry with normal static arrays, in that an array of
1527 unknown size is also written with @code{[]}.
1529 Of course, this extension only makes sense if the extra data comes at
1530 the end of a top-level object, as otherwise we would be overwriting
1531 data at subsequent offsets.  To avoid undue complication and confusion
1532 with initialization of deeply nested arrays, we simply disallow any
1533 non-empty initialization except when the structure is the top-level
1534 object.  For example:
1536 @smallexample
1537 struct foo @{ int x; int y[]; @};
1538 struct bar @{ struct foo z; @};
1540 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1541 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1542 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1543 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1544 @end smallexample
1546 @node Empty Structures
1547 @section Structures With No Members
1548 @cindex empty structures
1549 @cindex zero-size structures
1551 GCC permits a C structure to have no members:
1553 @smallexample
1554 struct empty @{
1556 @end smallexample
1558 The structure has size zero.  In C++, empty structures are part
1559 of the language.  G++ treats empty structures as if they had a single
1560 member of type @code{char}.
1562 @node Variable Length
1563 @section Arrays of Variable Length
1564 @cindex variable-length arrays
1565 @cindex arrays of variable length
1566 @cindex VLAs
1568 Variable-length automatic arrays are allowed in ISO C99, and as an
1569 extension GCC accepts them in C90 mode and in C++.  These arrays are
1570 declared like any other automatic arrays, but with a length that is not
1571 a constant expression.  The storage is allocated at the point of
1572 declaration and deallocated when the block scope containing the declaration
1573 exits.  For
1574 example:
1576 @smallexample
1577 FILE *
1578 concat_fopen (char *s1, char *s2, char *mode)
1580   char str[strlen (s1) + strlen (s2) + 1];
1581   strcpy (str, s1);
1582   strcat (str, s2);
1583   return fopen (str, mode);
1585 @end smallexample
1587 @cindex scope of a variable length array
1588 @cindex variable-length array scope
1589 @cindex deallocating variable length arrays
1590 Jumping or breaking out of the scope of the array name deallocates the
1591 storage.  Jumping into the scope is not allowed; you get an error
1592 message for it.
1594 @cindex variable-length array in a structure
1595 As an extension, GCC accepts variable-length arrays as a member of
1596 a structure or a union.  For example:
1598 @smallexample
1599 void
1600 foo (int n)
1602   struct S @{ int x[n]; @};
1604 @end smallexample
1606 @cindex @code{alloca} vs variable-length arrays
1607 You can use the function @code{alloca} to get an effect much like
1608 variable-length arrays.  The function @code{alloca} is available in
1609 many other C implementations (but not in all).  On the other hand,
1610 variable-length arrays are more elegant.
1612 There are other differences between these two methods.  Space allocated
1613 with @code{alloca} exists until the containing @emph{function} returns.
1614 The space for a variable-length array is deallocated as soon as the array
1615 name's scope ends.  (If you use both variable-length arrays and
1616 @code{alloca} in the same function, deallocation of a variable-length array
1617 also deallocates anything more recently allocated with @code{alloca}.)
1619 You can also use variable-length arrays as arguments to functions:
1621 @smallexample
1622 struct entry
1623 tester (int len, char data[len][len])
1625   /* @r{@dots{}} */
1627 @end smallexample
1629 The length of an array is computed once when the storage is allocated
1630 and is remembered for the scope of the array in case you access it with
1631 @code{sizeof}.
1633 If you want to pass the array first and the length afterward, you can
1634 use a forward declaration in the parameter list---another GNU extension.
1636 @smallexample
1637 struct entry
1638 tester (int len; char data[len][len], int len)
1640   /* @r{@dots{}} */
1642 @end smallexample
1644 @cindex parameter forward declaration
1645 The @samp{int len} before the semicolon is a @dfn{parameter forward
1646 declaration}, and it serves the purpose of making the name @code{len}
1647 known when the declaration of @code{data} is parsed.
1649 You can write any number of such parameter forward declarations in the
1650 parameter list.  They can be separated by commas or semicolons, but the
1651 last one must end with a semicolon, which is followed by the ``real''
1652 parameter declarations.  Each forward declaration must match a ``real''
1653 declaration in parameter name and data type.  ISO C99 does not support
1654 parameter forward declarations.
1656 @node Variadic Macros
1657 @section Macros with a Variable Number of Arguments.
1658 @cindex variable number of arguments
1659 @cindex macro with variable arguments
1660 @cindex rest argument (in macro)
1661 @cindex variadic macros
1663 In the ISO C standard of 1999, a macro can be declared to accept a
1664 variable number of arguments much as a function can.  The syntax for
1665 defining the macro is similar to that of a function.  Here is an
1666 example:
1668 @smallexample
1669 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1670 @end smallexample
1672 @noindent
1673 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1674 such a macro, it represents the zero or more tokens until the closing
1675 parenthesis that ends the invocation, including any commas.  This set of
1676 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1677 wherever it appears.  See the CPP manual for more information.
1679 GCC has long supported variadic macros, and used a different syntax that
1680 allowed you to give a name to the variable arguments just like any other
1681 argument.  Here is an example:
1683 @smallexample
1684 #define debug(format, args...) fprintf (stderr, format, args)
1685 @end smallexample
1687 @noindent
1688 This is in all ways equivalent to the ISO C example above, but arguably
1689 more readable and descriptive.
1691 GNU CPP has two further variadic macro extensions, and permits them to
1692 be used with either of the above forms of macro definition.
1694 In standard C, you are not allowed to leave the variable argument out
1695 entirely; but you are allowed to pass an empty argument.  For example,
1696 this invocation is invalid in ISO C, because there is no comma after
1697 the string:
1699 @smallexample
1700 debug ("A message")
1701 @end smallexample
1703 GNU CPP permits you to completely omit the variable arguments in this
1704 way.  In the above examples, the compiler would complain, though since
1705 the expansion of the macro still has the extra comma after the format
1706 string.
1708 To help solve this problem, CPP behaves specially for variable arguments
1709 used with the token paste operator, @samp{##}.  If instead you write
1711 @smallexample
1712 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1713 @end smallexample
1715 @noindent
1716 and if the variable arguments are omitted or empty, the @samp{##}
1717 operator causes the preprocessor to remove the comma before it.  If you
1718 do provide some variable arguments in your macro invocation, GNU CPP
1719 does not complain about the paste operation and instead places the
1720 variable arguments after the comma.  Just like any other pasted macro
1721 argument, these arguments are not macro expanded.
1723 @node Escaped Newlines
1724 @section Slightly Looser Rules for Escaped Newlines
1725 @cindex escaped newlines
1726 @cindex newlines (escaped)
1728 Recently, the preprocessor has relaxed its treatment of escaped
1729 newlines.  Previously, the newline had to immediately follow a
1730 backslash.  The current implementation allows whitespace in the form
1731 of spaces, horizontal and vertical tabs, and form feeds between the
1732 backslash and the subsequent newline.  The preprocessor issues a
1733 warning, but treats it as a valid escaped newline and combines the two
1734 lines to form a single logical line.  This works within comments and
1735 tokens, as well as between tokens.  Comments are @emph{not} treated as
1736 whitespace for the purposes of this relaxation, since they have not
1737 yet been replaced with spaces.
1739 @node Subscripting
1740 @section Non-Lvalue Arrays May Have Subscripts
1741 @cindex subscripting
1742 @cindex arrays, non-lvalue
1744 @cindex subscripting and function values
1745 In ISO C99, arrays that are not lvalues still decay to pointers, and
1746 may be subscripted, although they may not be modified or used after
1747 the next sequence point and the unary @samp{&} operator may not be
1748 applied to them.  As an extension, GNU C allows such arrays to be
1749 subscripted in C90 mode, though otherwise they do not decay to
1750 pointers outside C99 mode.  For example,
1751 this is valid in GNU C though not valid in C90:
1753 @smallexample
1754 @group
1755 struct foo @{int a[4];@};
1757 struct foo f();
1759 bar (int index)
1761   return f().a[index];
1763 @end group
1764 @end smallexample
1766 @node Pointer Arith
1767 @section Arithmetic on @code{void}- and Function-Pointers
1768 @cindex void pointers, arithmetic
1769 @cindex void, size of pointer to
1770 @cindex function pointers, arithmetic
1771 @cindex function, size of pointer to
1773 In GNU C, addition and subtraction operations are supported on pointers to
1774 @code{void} and on pointers to functions.  This is done by treating the
1775 size of a @code{void} or of a function as 1.
1777 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1778 and on function types, and returns 1.
1780 @opindex Wpointer-arith
1781 The option @option{-Wpointer-arith} requests a warning if these extensions
1782 are used.
1784 @node Initializers
1785 @section Non-Constant Initializers
1786 @cindex initializers, non-constant
1787 @cindex non-constant initializers
1789 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1790 automatic variable are not required to be constant expressions in GNU C@.
1791 Here is an example of an initializer with run-time varying elements:
1793 @smallexample
1794 foo (float f, float g)
1796   float beat_freqs[2] = @{ f-g, f+g @};
1797   /* @r{@dots{}} */
1799 @end smallexample
1801 @node Compound Literals
1802 @section Compound Literals
1803 @cindex constructor expressions
1804 @cindex initializations in expressions
1805 @cindex structures, constructor expression
1806 @cindex expressions, constructor
1807 @cindex compound literals
1808 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1810 ISO C99 supports compound literals.  A compound literal looks like
1811 a cast containing an initializer.  Its value is an object of the
1812 type specified in the cast, containing the elements specified in
1813 the initializer; it is an lvalue.  As an extension, GCC supports
1814 compound literals in C90 mode and in C++, though the semantics are
1815 somewhat different in C++.
1817 Usually, the specified type is a structure.  Assume that
1818 @code{struct foo} and @code{structure} are declared as shown:
1820 @smallexample
1821 struct foo @{int a; char b[2];@} structure;
1822 @end smallexample
1824 @noindent
1825 Here is an example of constructing a @code{struct foo} with a compound literal:
1827 @smallexample
1828 structure = ((struct foo) @{x + y, 'a', 0@});
1829 @end smallexample
1831 @noindent
1832 This is equivalent to writing the following:
1834 @smallexample
1836   struct foo temp = @{x + y, 'a', 0@};
1837   structure = temp;
1839 @end smallexample
1841 You can also construct an array, though this is dangerous in C++, as
1842 explained below.  If all the elements of the compound literal are
1843 (made up of) simple constant expressions, suitable for use in
1844 initializers of objects of static storage duration, then the compound
1845 literal can be coerced to a pointer to its first element and used in
1846 such an initializer, as shown here:
1848 @smallexample
1849 char **foo = (char *[]) @{ "x", "y", "z" @};
1850 @end smallexample
1852 Compound literals for scalar types and union types are
1853 also allowed, but then the compound literal is equivalent
1854 to a cast.
1856 As a GNU extension, GCC allows initialization of objects with static storage
1857 duration by compound literals (which is not possible in ISO C99, because
1858 the initializer is not a constant).
1859 It is handled as if the object is initialized only with the bracket
1860 enclosed list if the types of the compound literal and the object match.
1861 The initializer list of the compound literal must be constant.
1862 If the object being initialized has array type of unknown size, the size is
1863 determined by compound literal size.
1865 @smallexample
1866 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1867 static int y[] = (int []) @{1, 2, 3@};
1868 static int z[] = (int [3]) @{1@};
1869 @end smallexample
1871 @noindent
1872 The above lines are equivalent to the following:
1873 @smallexample
1874 static struct foo x = @{1, 'a', 'b'@};
1875 static int y[] = @{1, 2, 3@};
1876 static int z[] = @{1, 0, 0@};
1877 @end smallexample
1879 In C, a compound literal designates an unnamed object with static or
1880 automatic storage duration.  In C++, a compound literal designates a
1881 temporary object, which only lives until the end of its
1882 full-expression.  As a result, well-defined C code that takes the
1883 address of a subobject of a compound literal can be undefined in C++.
1884 For instance, if the array compound literal example above appeared
1885 inside a function, any subsequent use of @samp{foo} in C++ has
1886 undefined behavior because the lifetime of the array ends after the
1887 declaration of @samp{foo}.  As a result, the C++ compiler now rejects
1888 the conversion of a temporary array to a pointer.
1890 As an optimization, the C++ compiler sometimes gives array compound
1891 literals longer lifetimes: when the array either appears outside a
1892 function or has const-qualified type.  If @samp{foo} and its
1893 initializer had elements of @samp{char *const} type rather than
1894 @samp{char *}, or if @samp{foo} were a global variable, the array
1895 would have static storage duration.  But it is probably safest just to
1896 avoid the use of array compound literals in code compiled as C++.
1898 @node Designated Inits
1899 @section Designated Initializers
1900 @cindex initializers with labeled elements
1901 @cindex labeled elements in initializers
1902 @cindex case labels in initializers
1903 @cindex designated initializers
1905 Standard C90 requires the elements of an initializer to appear in a fixed
1906 order, the same as the order of the elements in the array or structure
1907 being initialized.
1909 In ISO C99 you can give the elements in any order, specifying the array
1910 indices or structure field names they apply to, and GNU C allows this as
1911 an extension in C90 mode as well.  This extension is not
1912 implemented in GNU C++.
1914 To specify an array index, write
1915 @samp{[@var{index}] =} before the element value.  For example,
1917 @smallexample
1918 int a[6] = @{ [4] = 29, [2] = 15 @};
1919 @end smallexample
1921 @noindent
1922 is equivalent to
1924 @smallexample
1925 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1926 @end smallexample
1928 @noindent
1929 The index values must be constant expressions, even if the array being
1930 initialized is automatic.
1932 An alternative syntax for this that has been obsolete since GCC 2.5 but
1933 GCC still accepts is to write @samp{[@var{index}]} before the element
1934 value, with no @samp{=}.
1936 To initialize a range of elements to the same value, write
1937 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1938 extension.  For example,
1940 @smallexample
1941 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1942 @end smallexample
1944 @noindent
1945 If the value in it has side-effects, the side-effects happen only once,
1946 not for each initialized field by the range initializer.
1948 @noindent
1949 Note that the length of the array is the highest value specified
1950 plus one.
1952 In a structure initializer, specify the name of a field to initialize
1953 with @samp{.@var{fieldname} =} before the element value.  For example,
1954 given the following structure,
1956 @smallexample
1957 struct point @{ int x, y; @};
1958 @end smallexample
1960 @noindent
1961 the following initialization
1963 @smallexample
1964 struct point p = @{ .y = yvalue, .x = xvalue @};
1965 @end smallexample
1967 @noindent
1968 is equivalent to
1970 @smallexample
1971 struct point p = @{ xvalue, yvalue @};
1972 @end smallexample
1974 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1975 @samp{@var{fieldname}:}, as shown here:
1977 @smallexample
1978 struct point p = @{ y: yvalue, x: xvalue @};
1979 @end smallexample
1981 Omitted field members are implicitly initialized the same as objects
1982 that have static storage duration.
1984 @cindex designators
1985 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1986 @dfn{designator}.  You can also use a designator (or the obsolete colon
1987 syntax) when initializing a union, to specify which element of the union
1988 should be used.  For example,
1990 @smallexample
1991 union foo @{ int i; double d; @};
1993 union foo f = @{ .d = 4 @};
1994 @end smallexample
1996 @noindent
1997 converts 4 to a @code{double} to store it in the union using
1998 the second element.  By contrast, casting 4 to type @code{union foo}
1999 stores it into the union as the integer @code{i}, since it is
2000 an integer.  (@xref{Cast to Union}.)
2002 You can combine this technique of naming elements with ordinary C
2003 initialization of successive elements.  Each initializer element that
2004 does not have a designator applies to the next consecutive element of the
2005 array or structure.  For example,
2007 @smallexample
2008 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2009 @end smallexample
2011 @noindent
2012 is equivalent to
2014 @smallexample
2015 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2016 @end smallexample
2018 Labeling the elements of an array initializer is especially useful
2019 when the indices are characters or belong to an @code{enum} type.
2020 For example:
2022 @smallexample
2023 int whitespace[256]
2024   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2025       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2026 @end smallexample
2028 @cindex designator lists
2029 You can also write a series of @samp{.@var{fieldname}} and
2030 @samp{[@var{index}]} designators before an @samp{=} to specify a
2031 nested subobject to initialize; the list is taken relative to the
2032 subobject corresponding to the closest surrounding brace pair.  For
2033 example, with the @samp{struct point} declaration above:
2035 @smallexample
2036 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2037 @end smallexample
2039 @noindent
2040 If the same field is initialized multiple times, it has the value from
2041 the last initialization.  If any such overridden initialization has
2042 side-effect, it is unspecified whether the side-effect happens or not.
2043 Currently, GCC discards them and issues a warning.
2045 @node Case Ranges
2046 @section Case Ranges
2047 @cindex case ranges
2048 @cindex ranges in case statements
2050 You can specify a range of consecutive values in a single @code{case} label,
2051 like this:
2053 @smallexample
2054 case @var{low} ... @var{high}:
2055 @end smallexample
2057 @noindent
2058 This has the same effect as the proper number of individual @code{case}
2059 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2061 This feature is especially useful for ranges of ASCII character codes:
2063 @smallexample
2064 case 'A' ... 'Z':
2065 @end smallexample
2067 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2068 it may be parsed wrong when you use it with integer values.  For example,
2069 write this:
2071 @smallexample
2072 case 1 ... 5:
2073 @end smallexample
2075 @noindent
2076 rather than this:
2078 @smallexample
2079 case 1...5:
2080 @end smallexample
2082 @node Cast to Union
2083 @section Cast to a Union Type
2084 @cindex cast to a union
2085 @cindex union, casting to a
2087 A cast to union type is similar to other casts, except that the type
2088 specified is a union type.  You can specify the type either with
2089 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2090 a constructor, not a cast, and hence does not yield an lvalue like
2091 normal casts.  (@xref{Compound Literals}.)
2093 The types that may be cast to the union type are those of the members
2094 of the union.  Thus, given the following union and variables:
2096 @smallexample
2097 union foo @{ int i; double d; @};
2098 int x;
2099 double y;
2100 @end smallexample
2102 @noindent
2103 both @code{x} and @code{y} can be cast to type @code{union foo}.
2105 Using the cast as the right-hand side of an assignment to a variable of
2106 union type is equivalent to storing in a member of the union:
2108 @smallexample
2109 union foo u;
2110 /* @r{@dots{}} */
2111 u = (union foo) x  @equiv{}  u.i = x
2112 u = (union foo) y  @equiv{}  u.d = y
2113 @end smallexample
2115 You can also use the union cast as a function argument:
2117 @smallexample
2118 void hack (union foo);
2119 /* @r{@dots{}} */
2120 hack ((union foo) x);
2121 @end smallexample
2123 @node Mixed Declarations
2124 @section Mixed Declarations and Code
2125 @cindex mixed declarations and code
2126 @cindex declarations, mixed with code
2127 @cindex code, mixed with declarations
2129 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2130 within compound statements.  As an extension, GNU C also allows this in
2131 C90 mode.  For example, you could do:
2133 @smallexample
2134 int i;
2135 /* @r{@dots{}} */
2136 i++;
2137 int j = i + 2;
2138 @end smallexample
2140 Each identifier is visible from where it is declared until the end of
2141 the enclosing block.
2143 @node Function Attributes
2144 @section Declaring Attributes of Functions
2145 @cindex function attributes
2146 @cindex declaring attributes of functions
2147 @cindex functions that never return
2148 @cindex functions that return more than once
2149 @cindex functions that have no side effects
2150 @cindex functions in arbitrary sections
2151 @cindex functions that behave like malloc
2152 @cindex @code{volatile} applied to function
2153 @cindex @code{const} applied to function
2154 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2155 @cindex functions with non-null pointer arguments
2156 @cindex functions that are passed arguments in registers on the 386
2157 @cindex functions that pop the argument stack on the 386
2158 @cindex functions that do not pop the argument stack on the 386
2159 @cindex functions that have different compilation options on the 386
2160 @cindex functions that have different optimization options
2161 @cindex functions that are dynamically resolved
2163 In GNU C, you declare certain things about functions called in your program
2164 which help the compiler optimize function calls and check your code more
2165 carefully.
2167 The keyword @code{__attribute__} allows you to specify special
2168 attributes when making a declaration.  This keyword is followed by an
2169 attribute specification inside double parentheses.  The following
2170 attributes are currently defined for functions on all targets:
2171 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2172 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2173 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2174 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2175 @code{no_instrument_function}, @code{no_split_stack},
2176 @code{section}, @code{constructor},
2177 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2178 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2179 @code{warn_unused_result}, @code{nonnull},
2180 @code{returns_nonnull}, @code{gnu_inline},
2181 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2182 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2183 @code{no_sanitize_undefined}, @code{no_reorder},
2184 @code{error} and @code{warning}.
2185 Several other attributes are defined for functions on particular
2186 target systems.  Other attributes, including @code{section} are
2187 supported for variables declarations (@pxref{Variable Attributes}),
2188 labels (@pxref{Label Attributes})
2189 and for types (@pxref{Type Attributes}).
2191 GCC plugins may provide their own attributes.
2193 You may also specify attributes with @samp{__} preceding and following
2194 each keyword.  This allows you to use them in header files without
2195 being concerned about a possible macro of the same name.  For example,
2196 you may use @code{__noreturn__} instead of @code{noreturn}.
2198 @xref{Attribute Syntax}, for details of the exact syntax for using
2199 attributes.
2201 @table @code
2202 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2204 @item alias ("@var{target}")
2205 @cindex @code{alias} attribute
2206 The @code{alias} attribute causes the declaration to be emitted as an
2207 alias for another symbol, which must be specified.  For instance,
2209 @smallexample
2210 void __f () @{ /* @r{Do something.} */; @}
2211 void f () __attribute__ ((weak, alias ("__f")));
2212 @end smallexample
2214 @noindent
2215 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2216 mangled name for the target must be used.  It is an error if @samp{__f}
2217 is not defined in the same translation unit.
2219 Not all target machines support this attribute.
2221 @item aligned (@var{alignment})
2222 @cindex @code{aligned} attribute
2223 This attribute specifies a minimum alignment for the function,
2224 measured in bytes.
2226 You cannot use this attribute to decrease the alignment of a function,
2227 only to increase it.  However, when you explicitly specify a function
2228 alignment this overrides the effect of the
2229 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2230 function.
2232 Note that the effectiveness of @code{aligned} attributes may be
2233 limited by inherent limitations in your linker.  On many systems, the
2234 linker is only able to arrange for functions to be aligned up to a
2235 certain maximum alignment.  (For some linkers, the maximum supported
2236 alignment may be very very small.)  See your linker documentation for
2237 further information.
2239 The @code{aligned} attribute can also be used for variables and fields
2240 (@pxref{Variable Attributes}.)
2242 @item alloc_size
2243 @cindex @code{alloc_size} attribute
2244 The @code{alloc_size} attribute is used to tell the compiler that the
2245 function return value points to memory, where the size is given by
2246 one or two of the functions parameters.  GCC uses this
2247 information to improve the correctness of @code{__builtin_object_size}.
2249 The function parameter(s) denoting the allocated size are specified by
2250 one or two integer arguments supplied to the attribute.  The allocated size
2251 is either the value of the single function argument specified or the product
2252 of the two function arguments specified.  Argument numbering starts at
2253 one.
2255 For instance,
2257 @smallexample
2258 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2259 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2260 @end smallexample
2262 @noindent
2263 declares that @code{my_calloc} returns memory of the size given by
2264 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2265 of the size given by parameter 2.
2267 @item alloc_align
2268 @cindex @code{alloc_align} attribute
2269 The @code{alloc_align} attribute is used to tell the compiler that the
2270 function return value points to memory, where the returned pointer minimum
2271 alignment is given by one of the functions parameters.  GCC uses this
2272 information to improve pointer alignment analysis.
2274 The function parameter denoting the allocated alignment is specified by
2275 one integer argument, whose number is the argument of the attribute.
2276 Argument numbering starts at one.
2278 For instance,
2280 @smallexample
2281 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2282 @end smallexample
2284 @noindent
2285 declares that @code{my_memalign} returns memory with minimum alignment
2286 given by parameter 1.
2288 @item assume_aligned
2289 @cindex @code{assume_aligned} attribute
2290 The @code{assume_aligned} attribute is used to tell the compiler that the
2291 function return value points to memory, where the returned pointer minimum
2292 alignment is given by the first argument.
2293 If the attribute has two arguments, the second argument is misalignment offset.
2295 For instance
2297 @smallexample
2298 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2299 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2300 @end smallexample
2302 @noindent
2303 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2304 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2305 to 8.
2307 @item always_inline
2308 @cindex @code{always_inline} function attribute
2309 Generally, functions are not inlined unless optimization is specified.
2310 For functions declared inline, this attribute inlines the function
2311 independent of any restrictions that otherwise apply to inlining.
2312 Failure to inline such a function is diagnosed as an error.
2313 Note that if such a function is called indirectly the compiler may
2314 or may not inline it depending on optimization level and a failure
2315 to inline an indirect call may or may not be diagnosed.
2317 @item gnu_inline
2318 @cindex @code{gnu_inline} function attribute
2319 This attribute should be used with a function that is also declared
2320 with the @code{inline} keyword.  It directs GCC to treat the function
2321 as if it were defined in gnu90 mode even when compiling in C99 or
2322 gnu99 mode.
2324 If the function is declared @code{extern}, then this definition of the
2325 function is used only for inlining.  In no case is the function
2326 compiled as a standalone function, not even if you take its address
2327 explicitly.  Such an address becomes an external reference, as if you
2328 had only declared the function, and had not defined it.  This has
2329 almost the effect of a macro.  The way to use this is to put a
2330 function definition in a header file with this attribute, and put
2331 another copy of the function, without @code{extern}, in a library
2332 file.  The definition in the header file causes most calls to the
2333 function to be inlined.  If any uses of the function remain, they
2334 refer to the single copy in the library.  Note that the two
2335 definitions of the functions need not be precisely the same, although
2336 if they do not have the same effect your program may behave oddly.
2338 In C, if the function is neither @code{extern} nor @code{static}, then
2339 the function is compiled as a standalone function, as well as being
2340 inlined where possible.
2342 This is how GCC traditionally handled functions declared
2343 @code{inline}.  Since ISO C99 specifies a different semantics for
2344 @code{inline}, this function attribute is provided as a transition
2345 measure and as a useful feature in its own right.  This attribute is
2346 available in GCC 4.1.3 and later.  It is available if either of the
2347 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2348 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2349 Function is As Fast As a Macro}.
2351 In C++, this attribute does not depend on @code{extern} in any way,
2352 but it still requires the @code{inline} keyword to enable its special
2353 behavior.
2355 @item artificial
2356 @cindex @code{artificial} function attribute
2357 This attribute is useful for small inline wrappers that if possible
2358 should appear during debugging as a unit.  Depending on the debug
2359 info format it either means marking the function as artificial
2360 or using the caller location for all instructions within the inlined
2361 body.
2363 @item bank_switch
2364 @cindex interrupt handler functions
2365 When added to an interrupt handler with the M32C port, causes the
2366 prologue and epilogue to use bank switching to preserve the registers
2367 rather than saving them on the stack.
2369 @item flatten
2370 @cindex @code{flatten} function attribute
2371 Generally, inlining into a function is limited.  For a function marked with
2372 this attribute, every call inside this function is inlined, if possible.
2373 Whether the function itself is considered for inlining depends on its size and
2374 the current inlining parameters.
2376 @item error ("@var{message}")
2377 @cindex @code{error} function attribute
2378 If this attribute is used on a function declaration and a call to such a function
2379 is not eliminated through dead code elimination or other optimizations, an error
2380 that includes @var{message} is diagnosed.  This is useful
2381 for compile-time checking, especially together with @code{__builtin_constant_p}
2382 and inline functions where checking the inline function arguments is not
2383 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2384 While it is possible to leave the function undefined and thus invoke
2385 a link failure, when using this attribute the problem is diagnosed
2386 earlier and with exact location of the call even in presence of inline
2387 functions or when not emitting debugging information.
2389 @item warning ("@var{message}")
2390 @cindex @code{warning} function attribute
2391 If this attribute is used on a function declaration and a call to such a function
2392 is not eliminated through dead code elimination or other optimizations, a warning
2393 that includes @var{message} is diagnosed.  This is useful
2394 for compile-time checking, especially together with @code{__builtin_constant_p}
2395 and inline functions.  While it is possible to define the function with
2396 a message in @code{.gnu.warning*} section, when using this attribute the problem
2397 is diagnosed earlier and with exact location of the call even in presence
2398 of inline functions or when not emitting debugging information.
2400 @item cdecl
2401 @cindex functions that do pop the argument stack on the 386
2402 @opindex mrtd
2403 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2404 assume that the calling function pops off the stack space used to
2405 pass arguments.  This is
2406 useful to override the effects of the @option{-mrtd} switch.
2408 @item const
2409 @cindex @code{const} function attribute
2410 Many functions do not examine any values except their arguments, and
2411 have no effects except the return value.  Basically this is just slightly
2412 more strict class than the @code{pure} attribute below, since function is not
2413 allowed to read global memory.
2415 @cindex pointer arguments
2416 Note that a function that has pointer arguments and examines the data
2417 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2418 function that calls a non-@code{const} function usually must not be
2419 @code{const}.  It does not make sense for a @code{const} function to
2420 return @code{void}.
2422 The attribute @code{const} is not implemented in GCC versions earlier
2423 than 2.5.  An alternative way to declare that a function has no side
2424 effects, which works in the current version and in some older versions,
2425 is as follows:
2427 @smallexample
2428 typedef int intfn ();
2430 extern const intfn square;
2431 @end smallexample
2433 @noindent
2434 This approach does not work in GNU C++ from 2.6.0 on, since the language
2435 specifies that the @samp{const} must be attached to the return value.
2437 @item constructor
2438 @itemx destructor
2439 @itemx constructor (@var{priority})
2440 @itemx destructor (@var{priority})
2441 @cindex @code{constructor} function attribute
2442 @cindex @code{destructor} function attribute
2443 The @code{constructor} attribute causes the function to be called
2444 automatically before execution enters @code{main ()}.  Similarly, the
2445 @code{destructor} attribute causes the function to be called
2446 automatically after @code{main ()} completes or @code{exit ()} is
2447 called.  Functions with these attributes are useful for
2448 initializing data that is used implicitly during the execution of
2449 the program.
2451 You may provide an optional integer priority to control the order in
2452 which constructor and destructor functions are run.  A constructor
2453 with a smaller priority number runs before a constructor with a larger
2454 priority number; the opposite relationship holds for destructors.  So,
2455 if you have a constructor that allocates a resource and a destructor
2456 that deallocates the same resource, both functions typically have the
2457 same priority.  The priorities for constructor and destructor
2458 functions are the same as those specified for namespace-scope C++
2459 objects (@pxref{C++ Attributes}).
2461 These attributes are not currently implemented for Objective-C@.
2463 @item deprecated
2464 @itemx deprecated (@var{msg})
2465 @cindex @code{deprecated} attribute.
2466 The @code{deprecated} attribute results in a warning if the function
2467 is used anywhere in the source file.  This is useful when identifying
2468 functions that are expected to be removed in a future version of a
2469 program.  The warning also includes the location of the declaration
2470 of the deprecated function, to enable users to easily find further
2471 information about why the function is deprecated, or what they should
2472 do instead.  Note that the warnings only occurs for uses:
2474 @smallexample
2475 int old_fn () __attribute__ ((deprecated));
2476 int old_fn ();
2477 int (*fn_ptr)() = old_fn;
2478 @end smallexample
2480 @noindent
2481 results in a warning on line 3 but not line 2.  The optional @var{msg}
2482 argument, which must be a string, is printed in the warning if
2483 present.
2485 The @code{deprecated} attribute can also be used for variables and
2486 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2488 @item disinterrupt
2489 @cindex @code{disinterrupt} attribute
2490 On Epiphany and MeP targets, this attribute causes the compiler to emit
2491 instructions to disable interrupts for the duration of the given
2492 function.
2494 @item dllexport
2495 @cindex @code{__declspec(dllexport)}
2496 On Microsoft Windows targets and Symbian OS targets the
2497 @code{dllexport} attribute causes the compiler to provide a global
2498 pointer to a pointer in a DLL, so that it can be referenced with the
2499 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2500 name is formed by combining @code{_imp__} and the function or variable
2501 name.
2503 You can use @code{__declspec(dllexport)} as a synonym for
2504 @code{__attribute__ ((dllexport))} for compatibility with other
2505 compilers.
2507 On systems that support the @code{visibility} attribute, this
2508 attribute also implies ``default'' visibility.  It is an error to
2509 explicitly specify any other visibility.
2511 In previous versions of GCC, the @code{dllexport} attribute was ignored
2512 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2513 had been used.  The default behavior now is to emit all dllexported
2514 inline functions; however, this can cause object file-size bloat, in
2515 which case the old behavior can be restored by using
2516 @option{-fno-keep-inline-dllexport}.
2518 The attribute is also ignored for undefined symbols.
2520 When applied to C++ classes, the attribute marks defined non-inlined
2521 member functions and static data members as exports.  Static consts
2522 initialized in-class are not marked unless they are also defined
2523 out-of-class.
2525 For Microsoft Windows targets there are alternative methods for
2526 including the symbol in the DLL's export table such as using a
2527 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2528 the @option{--export-all} linker flag.
2530 @item dllimport
2531 @cindex @code{__declspec(dllimport)}
2532 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2533 attribute causes the compiler to reference a function or variable via
2534 a global pointer to a pointer that is set up by the DLL exporting the
2535 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2536 targets, the pointer name is formed by combining @code{_imp__} and the
2537 function or variable name.
2539 You can use @code{__declspec(dllimport)} as a synonym for
2540 @code{__attribute__ ((dllimport))} for compatibility with other
2541 compilers.
2543 On systems that support the @code{visibility} attribute, this
2544 attribute also implies ``default'' visibility.  It is an error to
2545 explicitly specify any other visibility.
2547 Currently, the attribute is ignored for inlined functions.  If the
2548 attribute is applied to a symbol @emph{definition}, an error is reported.
2549 If a symbol previously declared @code{dllimport} is later defined, the
2550 attribute is ignored in subsequent references, and a warning is emitted.
2551 The attribute is also overridden by a subsequent declaration as
2552 @code{dllexport}.
2554 When applied to C++ classes, the attribute marks non-inlined
2555 member functions and static data members as imports.  However, the
2556 attribute is ignored for virtual methods to allow creation of vtables
2557 using thunks.
2559 On the SH Symbian OS target the @code{dllimport} attribute also has
2560 another affect---it can cause the vtable and run-time type information
2561 for a class to be exported.  This happens when the class has a
2562 dllimported constructor or a non-inline, non-pure virtual function
2563 and, for either of those two conditions, the class also has an inline
2564 constructor or destructor and has a key function that is defined in
2565 the current translation unit.
2567 For Microsoft Windows targets the use of the @code{dllimport}
2568 attribute on functions is not necessary, but provides a small
2569 performance benefit by eliminating a thunk in the DLL@.  The use of the
2570 @code{dllimport} attribute on imported variables was required on older
2571 versions of the GNU linker, but can now be avoided by passing the
2572 @option{--enable-auto-import} switch to the GNU linker.  As with
2573 functions, using the attribute for a variable eliminates a thunk in
2574 the DLL@.
2576 One drawback to using this attribute is that a pointer to a
2577 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2578 address. However, a pointer to a @emph{function} with the
2579 @code{dllimport} attribute can be used as a constant initializer; in
2580 this case, the address of a stub function in the import lib is
2581 referenced.  On Microsoft Windows targets, the attribute can be disabled
2582 for functions by setting the @option{-mnop-fun-dllimport} flag.
2584 @item eightbit_data
2585 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2586 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2587 variable should be placed into the eight-bit data section.
2588 The compiler generates more efficient code for certain operations
2589 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2590 256 bytes of data.
2592 You must use GAS and GLD from GNU binutils version 2.7 or later for
2593 this attribute to work correctly.
2595 @item exception
2596 @cindex exception handler functions
2597 Use this attribute on the NDS32 target to indicate that the specified function
2598 is an exception handler.  The compiler will generate corresponding sections
2599 for use in an exception handler.
2601 @item exception_handler
2602 @cindex exception handler functions on the Blackfin processor
2603 Use this attribute on the Blackfin to indicate that the specified function
2604 is an exception handler.  The compiler generates function entry and
2605 exit sequences suitable for use in an exception handler when this
2606 attribute is present.
2608 @item externally_visible
2609 @cindex @code{externally_visible} attribute.
2610 This attribute, attached to a global variable or function, nullifies
2611 the effect of the @option{-fwhole-program} command-line option, so the
2612 object remains visible outside the current compilation unit.
2614 If @option{-fwhole-program} is used together with @option{-flto} and 
2615 @command{gold} is used as the linker plugin, 
2616 @code{externally_visible} attributes are automatically added to functions 
2617 (not variable yet due to a current @command{gold} issue) 
2618 that are accessed outside of LTO objects according to resolution file
2619 produced by @command{gold}.
2620 For other linkers that cannot generate resolution file,
2621 explicit @code{externally_visible} attributes are still necessary.
2623 @item far
2624 @cindex functions that handle memory bank switching
2625 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2626 use a calling convention that takes care of switching memory banks when
2627 entering and leaving a function.  This calling convention is also the
2628 default when using the @option{-mlong-calls} option.
2630 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2631 to call and return from a function.
2633 On 68HC11 the compiler generates a sequence of instructions
2634 to invoke a board-specific routine to switch the memory bank and call the
2635 real function.  The board-specific routine simulates a @code{call}.
2636 At the end of a function, it jumps to a board-specific routine
2637 instead of using @code{rts}.  The board-specific return routine simulates
2638 the @code{rtc}.
2640 On MeP targets this causes the compiler to use a calling convention
2641 that assumes the called function is too far away for the built-in
2642 addressing modes.
2644 @item fast_interrupt
2645 @cindex interrupt handler functions
2646 Use this attribute on the M32C and RX ports to indicate that the specified
2647 function is a fast interrupt handler.  This is just like the
2648 @code{interrupt} attribute, except that @code{freit} is used to return
2649 instead of @code{reit}.
2651 @item fastcall
2652 @cindex functions that pop the argument stack on the 386
2653 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2654 pass the first argument (if of integral type) in the register ECX and
2655 the second argument (if of integral type) in the register EDX@.  Subsequent
2656 and other typed arguments are passed on the stack.  The called function
2657 pops the arguments off the stack.  If the number of arguments is variable all
2658 arguments are pushed on the stack.
2660 @item thiscall
2661 @cindex functions that pop the argument stack on the 386
2662 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2663 pass the first argument (if of integral type) in the register ECX.
2664 Subsequent and other typed arguments are passed on the stack. The called
2665 function pops the arguments off the stack.
2666 If the number of arguments is variable all arguments are pushed on the
2667 stack.
2668 The @code{thiscall} attribute is intended for C++ non-static member functions.
2669 As a GCC extension, this calling convention can be used for C functions
2670 and for static member methods.
2672 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2673 @cindex @code{format} function attribute
2674 @opindex Wformat
2675 The @code{format} attribute specifies that a function takes @code{printf},
2676 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2677 should be type-checked against a format string.  For example, the
2678 declaration:
2680 @smallexample
2681 extern int
2682 my_printf (void *my_object, const char *my_format, ...)
2683       __attribute__ ((format (printf, 2, 3)));
2684 @end smallexample
2686 @noindent
2687 causes the compiler to check the arguments in calls to @code{my_printf}
2688 for consistency with the @code{printf} style format string argument
2689 @code{my_format}.
2691 The parameter @var{archetype} determines how the format string is
2692 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2693 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2694 @code{strfmon}.  (You can also use @code{__printf__},
2695 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2696 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2697 @code{ms_strftime} are also present.
2698 @var{archetype} values such as @code{printf} refer to the formats accepted
2699 by the system's C runtime library,
2700 while values prefixed with @samp{gnu_} always refer
2701 to the formats accepted by the GNU C Library.  On Microsoft Windows
2702 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2703 @file{msvcrt.dll} library.
2704 The parameter @var{string-index}
2705 specifies which argument is the format string argument (starting
2706 from 1), while @var{first-to-check} is the number of the first
2707 argument to check against the format string.  For functions
2708 where the arguments are not available to be checked (such as
2709 @code{vprintf}), specify the third parameter as zero.  In this case the
2710 compiler only checks the format string for consistency.  For
2711 @code{strftime} formats, the third parameter is required to be zero.
2712 Since non-static C++ methods have an implicit @code{this} argument, the
2713 arguments of such methods should be counted from two, not one, when
2714 giving values for @var{string-index} and @var{first-to-check}.
2716 In the example above, the format string (@code{my_format}) is the second
2717 argument of the function @code{my_print}, and the arguments to check
2718 start with the third argument, so the correct parameters for the format
2719 attribute are 2 and 3.
2721 @opindex ffreestanding
2722 @opindex fno-builtin
2723 The @code{format} attribute allows you to identify your own functions
2724 that take format strings as arguments, so that GCC can check the
2725 calls to these functions for errors.  The compiler always (unless
2726 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2727 for the standard library functions @code{printf}, @code{fprintf},
2728 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2729 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2730 warnings are requested (using @option{-Wformat}), so there is no need to
2731 modify the header file @file{stdio.h}.  In C99 mode, the functions
2732 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2733 @code{vsscanf} are also checked.  Except in strictly conforming C
2734 standard modes, the X/Open function @code{strfmon} is also checked as
2735 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2736 @xref{C Dialect Options,,Options Controlling C Dialect}.
2738 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2739 recognized in the same context.  Declarations including these format attributes
2740 are parsed for correct syntax, however the result of checking of such format
2741 strings is not yet defined, and is not carried out by this version of the
2742 compiler.
2744 The target may also provide additional types of format checks.
2745 @xref{Target Format Checks,,Format Checks Specific to Particular
2746 Target Machines}.
2748 @item format_arg (@var{string-index})
2749 @cindex @code{format_arg} function attribute
2750 @opindex Wformat-nonliteral
2751 The @code{format_arg} attribute specifies that a function takes a format
2752 string for a @code{printf}, @code{scanf}, @code{strftime} or
2753 @code{strfmon} style function and modifies it (for example, to translate
2754 it into another language), so the result can be passed to a
2755 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2756 function (with the remaining arguments to the format function the same
2757 as they would have been for the unmodified string).  For example, the
2758 declaration:
2760 @smallexample
2761 extern char *
2762 my_dgettext (char *my_domain, const char *my_format)
2763       __attribute__ ((format_arg (2)));
2764 @end smallexample
2766 @noindent
2767 causes the compiler to check the arguments in calls to a @code{printf},
2768 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2769 format string argument is a call to the @code{my_dgettext} function, for
2770 consistency with the format string argument @code{my_format}.  If the
2771 @code{format_arg} attribute had not been specified, all the compiler
2772 could tell in such calls to format functions would be that the format
2773 string argument is not constant; this would generate a warning when
2774 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2775 without the attribute.
2777 The parameter @var{string-index} specifies which argument is the format
2778 string argument (starting from one).  Since non-static C++ methods have
2779 an implicit @code{this} argument, the arguments of such methods should
2780 be counted from two.
2782 The @code{format_arg} attribute allows you to identify your own
2783 functions that modify format strings, so that GCC can check the
2784 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2785 type function whose operands are a call to one of your own function.
2786 The compiler always treats @code{gettext}, @code{dgettext}, and
2787 @code{dcgettext} in this manner except when strict ISO C support is
2788 requested by @option{-ansi} or an appropriate @option{-std} option, or
2789 @option{-ffreestanding} or @option{-fno-builtin}
2790 is used.  @xref{C Dialect Options,,Options
2791 Controlling C Dialect}.
2793 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2794 @code{NSString} reference for compatibility with the @code{format} attribute
2795 above.
2797 The target may also allow additional types in @code{format-arg} attributes.
2798 @xref{Target Format Checks,,Format Checks Specific to Particular
2799 Target Machines}.
2801 @item function_vector
2802 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2803 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2804 function should be called through the function vector.  Calling a
2805 function through the function vector reduces code size, however;
2806 the function vector has a limited size (maximum 128 entries on the H8/300
2807 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2809 On SH2A targets, this attribute declares a function to be called using the
2810 TBR relative addressing mode.  The argument to this attribute is the entry
2811 number of the same function in a vector table containing all the TBR
2812 relative addressable functions.  For correct operation the TBR must be setup
2813 accordingly to point to the start of the vector table before any functions with
2814 this attribute are invoked.  Usually a good place to do the initialization is
2815 the startup routine.  The TBR relative vector table can have at max 256 function
2816 entries.  The jumps to these functions are generated using a SH2A specific,
2817 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2818 from GNU binutils version 2.7 or later for this attribute to work correctly.
2820 Please refer the example of M16C target, to see the use of this
2821 attribute while declaring a function,
2823 In an application, for a function being called once, this attribute
2824 saves at least 8 bytes of code; and if other successive calls are being
2825 made to the same function, it saves 2 bytes of code per each of these
2826 calls.
2828 On M16C/M32C targets, the @code{function_vector} attribute declares a
2829 special page subroutine call function. Use of this attribute reduces
2830 the code size by 2 bytes for each call generated to the
2831 subroutine. The argument to the attribute is the vector number entry
2832 from the special page vector table which contains the 16 low-order
2833 bits of the subroutine's entry address. Each vector table has special
2834 page number (18 to 255) that is used in @code{jsrs} instructions.
2835 Jump addresses of the routines are generated by adding 0x0F0000 (in
2836 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2837 2-byte addresses set in the vector table. Therefore you need to ensure
2838 that all the special page vector routines should get mapped within the
2839 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2840 (for M32C).
2842 In the following example 2 bytes are saved for each call to
2843 function @code{foo}.
2845 @smallexample
2846 void foo (void) __attribute__((function_vector(0x18)));
2847 void foo (void)
2851 void bar (void)
2853     foo();
2855 @end smallexample
2857 If functions are defined in one file and are called in another file,
2858 then be sure to write this declaration in both files.
2860 This attribute is ignored for R8C target.
2862 @item ifunc ("@var{resolver}")
2863 @cindex @code{ifunc} attribute
2864 The @code{ifunc} attribute is used to mark a function as an indirect
2865 function using the STT_GNU_IFUNC symbol type extension to the ELF
2866 standard.  This allows the resolution of the symbol value to be
2867 determined dynamically at load time, and an optimized version of the
2868 routine can be selected for the particular processor or other system
2869 characteristics determined then.  To use this attribute, first define
2870 the implementation functions available, and a resolver function that
2871 returns a pointer to the selected implementation function.  The
2872 implementation functions' declarations must match the API of the
2873 function being implemented, the resolver's declaration is be a
2874 function returning pointer to void function returning void:
2876 @smallexample
2877 void *my_memcpy (void *dst, const void *src, size_t len)
2879   @dots{}
2882 static void (*resolve_memcpy (void)) (void)
2884   return my_memcpy; // we'll just always select this routine
2886 @end smallexample
2888 @noindent
2889 The exported header file declaring the function the user calls would
2890 contain:
2892 @smallexample
2893 extern void *memcpy (void *, const void *, size_t);
2894 @end smallexample
2896 @noindent
2897 allowing the user to call this as a regular function, unaware of the
2898 implementation.  Finally, the indirect function needs to be defined in
2899 the same translation unit as the resolver function:
2901 @smallexample
2902 void *memcpy (void *, const void *, size_t)
2903      __attribute__ ((ifunc ("resolve_memcpy")));
2904 @end smallexample
2906 Indirect functions cannot be weak, and require a recent binutils (at
2907 least version 2.20.1), and GNU C library (at least version 2.11.1).
2909 @item interrupt
2910 @cindex interrupt handler functions
2911 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2912 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2913 the specified function is an
2914 interrupt handler.  The compiler generates function entry and exit
2915 sequences suitable for use in an interrupt handler when this attribute
2916 is present.  With Epiphany targets it may also generate a special section with
2917 code to initialize the interrupt vector table.
2919 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2920 and SH processors can be specified via the @code{interrupt_handler} attribute.
2922 Note, on the ARC, you must specify the kind of interrupt to be handled
2923 in a parameter to the interrupt attribute like this:
2925 @smallexample
2926 void f () __attribute__ ((interrupt ("ilink1")));
2927 @end smallexample
2929 Permissible values for this parameter are: @w{@code{ilink1}} and
2930 @w{@code{ilink2}}.
2932 Note, on the AVR, the hardware globally disables interrupts when an
2933 interrupt is executed.  The first instruction of an interrupt handler
2934 declared with this attribute is a @code{SEI} instruction to
2935 re-enable interrupts.  See also the @code{signal} function attribute
2936 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2937 @code{interrupt} are specified for the same function, @code{signal}
2938 is silently ignored.
2940 Note, for the ARM, you can specify the kind of interrupt to be handled by
2941 adding an optional parameter to the interrupt attribute like this:
2943 @smallexample
2944 void f () __attribute__ ((interrupt ("IRQ")));
2945 @end smallexample
2947 @noindent
2948 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2949 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2951 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2952 may be called with a word-aligned stack pointer.
2954 Note, for the MSP430 you can provide an argument to the interrupt
2955 attribute which specifies a name or number.  If the argument is a
2956 number it indicates the slot in the interrupt vector table (0 - 31) to
2957 which this handler should be assigned.  If the argument is a name it
2958 is treated as a symbolic name for the vector slot.  These names should
2959 match up with appropriate entries in the linker script.  By default
2960 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2961 @code{reset} for vector 31 are recognised.
2963 You can also use the following function attributes to modify how
2964 normal functions interact with interrupt functions:
2966 @table @code
2967 @item critical
2968 @cindex @code{critical} attribute
2969 Critical functions disable interrupts upon entry and restore the
2970 previous interrupt state upon exit.  Critical functions cannot also
2971 have the @code{naked} or @code{reentrant} attributes.  They can have
2972 the @code{interrupt} attribute.
2974 @item reentrant
2975 @cindex @code{reentrant} attribute
2976 Reentrant functions disable interrupts upon entry and enable them
2977 upon exit.  Reentrant functions cannot also have the @code{naked}
2978 or @code{critical} attributes.  They can have the @code{interrupt}
2979 attribute.
2981 @item wakeup
2982 @cindex @code{wakeup} attribute
2983 This attribute only applies to interrupt functions.  It is silently
2984 ignored if applied to a non-interrupt function.  A wakeup interrupt
2985 function will rouse the processor from any low-power state that it
2986 might be in when the function exits.
2988 @end table
2990 On Epiphany targets one or more optional parameters can be added like this:
2992 @smallexample
2993 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2994 @end smallexample
2996 Permissible values for these parameters are: @w{@code{reset}},
2997 @w{@code{software_exception}}, @w{@code{page_miss}},
2998 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2999 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3000 Multiple parameters indicate that multiple entries in the interrupt
3001 vector table should be initialized for this function, i.e.@: for each
3002 parameter @w{@var{name}}, a jump to the function is emitted in
3003 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3004 entirely, in which case no interrupt vector table entry is provided.
3006 Note, on Epiphany targets, interrupts are enabled inside the function
3007 unless the @code{disinterrupt} attribute is also specified.
3009 On Epiphany targets, you can also use the following attribute to
3010 modify the behavior of an interrupt handler:
3011 @table @code
3012 @item forwarder_section
3013 @cindex @code{forwarder_section} attribute
3014 The interrupt handler may be in external memory which cannot be
3015 reached by a branch instruction, so generate a local memory trampoline
3016 to transfer control.  The single parameter identifies the section where
3017 the trampoline is placed.
3018 @end table
3020 The following examples are all valid uses of these attributes on
3021 Epiphany targets:
3022 @smallexample
3023 void __attribute__ ((interrupt)) universal_handler ();
3024 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3025 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3026 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3027   fast_timer_handler ();
3028 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3029   external_dma_handler ();
3030 @end smallexample
3032 On MIPS targets, you can use the following attributes to modify the behavior
3033 of an interrupt handler:
3034 @table @code
3035 @item use_shadow_register_set
3036 @cindex @code{use_shadow_register_set} attribute
3037 Assume that the handler uses a shadow register set, instead of
3038 the main general-purpose registers.
3040 @item keep_interrupts_masked
3041 @cindex @code{keep_interrupts_masked} attribute
3042 Keep interrupts masked for the whole function.  Without this attribute,
3043 GCC tries to reenable interrupts for as much of the function as it can.
3045 @item use_debug_exception_return
3046 @cindex @code{use_debug_exception_return} attribute
3047 Return using the @code{deret} instruction.  Interrupt handlers that don't
3048 have this attribute return using @code{eret} instead.
3049 @end table
3051 You can use any combination of these attributes, as shown below:
3052 @smallexample
3053 void __attribute__ ((interrupt)) v0 ();
3054 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3055 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3056 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3057 void __attribute__ ((interrupt, use_shadow_register_set,
3058                      keep_interrupts_masked)) v4 ();
3059 void __attribute__ ((interrupt, use_shadow_register_set,
3060                      use_debug_exception_return)) v5 ();
3061 void __attribute__ ((interrupt, keep_interrupts_masked,
3062                      use_debug_exception_return)) v6 ();
3063 void __attribute__ ((interrupt, use_shadow_register_set,
3064                      keep_interrupts_masked,
3065                      use_debug_exception_return)) v7 ();
3066 @end smallexample
3068 On NDS32 target, this attribute is to indicate that the specified function
3069 is an interrupt handler.  The compiler will generate corresponding sections
3070 for use in an interrupt handler.  You can use the following attributes
3071 to modify the behavior:
3072 @table @code
3073 @item nested
3074 @cindex @code{nested} attribute
3075 This interrupt service routine is interruptible.
3076 @item not_nested
3077 @cindex @code{not_nested} attribute
3078 This interrupt service routine is not interruptible.
3079 @item nested_ready
3080 @cindex @code{nested_ready} attribute
3081 This interrupt service routine is interruptible after @code{PSW.GIE}
3082 (global interrupt enable) is set.  This allows interrupt service routine to
3083 finish some short critical code before enabling interrupts.
3084 @item save_all
3085 @cindex @code{save_all} attribute
3086 The system will help save all registers into stack before entering
3087 interrupt handler.
3088 @item partial_save
3089 @cindex @code{partial_save} attribute
3090 The system will help save caller registers into stack before entering
3091 interrupt handler.
3092 @end table
3094 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3095 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3096 that must end with @code{RETB} instead of @code{RETI}).
3098 On RX targets, you may specify one or more vector numbers as arguments
3099 to the attribute, as well as naming an alternate table name.
3100 Parameters are handled sequentially, so one handler can be assigned to
3101 multiple entries in multiple tables.  One may also pass the magic
3102 string @code{"$default"} which causes the function to be used for any
3103 unfilled slots in the current table.
3105 This example shows a simple assignment of a function to one vector in
3106 the default table (note that preprocessor macros may be used for
3107 chip-specific symbolic vector names):
3108 @smallexample
3109 void __attribute__ ((interrupt (5))) txd1_handler ();
3110 @end smallexample
3112 This example assigns a function to two slots in the default table
3113 (using preprocessor macros defined elsewhere) and makes it the default
3114 for the @code{dct} table:
3115 @smallexample
3116 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3117         txd1_handler ();
3118 @end smallexample
3120 @item interrupt_handler
3121 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3122 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3123 indicate that the specified function is an interrupt handler.  The compiler
3124 generates function entry and exit sequences suitable for use in an
3125 interrupt handler when this attribute is present.
3127 @item interrupt_thread
3128 @cindex interrupt thread functions on fido
3129 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3130 that the specified function is an interrupt handler that is designed
3131 to run as a thread.  The compiler omits generate prologue/epilogue
3132 sequences and replaces the return instruction with a @code{sleep}
3133 instruction.  This attribute is available only on fido.
3135 @item isr
3136 @cindex interrupt service routines on ARM
3137 Use this attribute on ARM to write Interrupt Service Routines. This is an
3138 alias to the @code{interrupt} attribute above.
3140 @item kspisusp
3141 @cindex User stack pointer in interrupts on the Blackfin
3142 When used together with @code{interrupt_handler}, @code{exception_handler}
3143 or @code{nmi_handler}, code is generated to load the stack pointer
3144 from the USP register in the function prologue.
3146 @item l1_text
3147 @cindex @code{l1_text} function attribute
3148 This attribute specifies a function to be placed into L1 Instruction
3149 SRAM@. The function is put into a specific section named @code{.l1.text}.
3150 With @option{-mfdpic}, function calls with a such function as the callee
3151 or caller uses inlined PLT.
3153 @item l2
3154 @cindex @code{l2} function attribute
3155 On the Blackfin, this attribute specifies a function to be placed into L2
3156 SRAM. The function is put into a specific section named
3157 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3158 an inlined PLT.
3160 @item leaf
3161 @cindex @code{leaf} function attribute
3162 Calls to external functions with this attribute must return to the current
3163 compilation unit only by return or by exception handling.  In particular, leaf
3164 functions are not allowed to call callback function passed to it from the current
3165 compilation unit or directly call functions exported by the unit or longjmp
3166 into the unit.  Leaf function might still call functions from other compilation
3167 units and thus they are not necessarily leaf in the sense that they contain no
3168 function calls at all.
3170 The attribute is intended for library functions to improve dataflow analysis.
3171 The compiler takes the hint that any data not escaping the current compilation unit can
3172 not be used or modified by the leaf function.  For example, the @code{sin} function
3173 is a leaf function, but @code{qsort} is not.
3175 Note that leaf functions might invoke signals and signal handlers might be
3176 defined in the current compilation unit and use static variables.  The only
3177 compliant way to write such a signal handler is to declare such variables
3178 @code{volatile}.
3180 The attribute has no effect on functions defined within the current compilation
3181 unit.  This is to allow easy merging of multiple compilation units into one,
3182 for example, by using the link-time optimization.  For this reason the
3183 attribute is not allowed on types to annotate indirect calls.
3185 @item long_call/medium_call/short_call
3186 @cindex indirect calls on ARC
3187 @cindex indirect calls on ARM
3188 @cindex indirect calls on Epiphany
3189 These attributes specify how a particular function is called on
3190 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3191 These attributes override the
3192 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3193 and @option{-mmedium-calls} (@pxref{ARC Options})
3194 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3195 @code{long_call} attribute indicates that the function might be far
3196 away from the call site and require a different (more expensive)
3197 calling sequence.   The @code{short_call} attribute always places
3198 the offset to the function from the call site into the @samp{BL}
3199 instruction directly.
3201 For ARC, a function marked with the @code{long_call} attribute is
3202 always called using register-indirect jump-and-link instructions,
3203 thereby enabling the called function to be placed anywhere within the
3204 32-bit address space.  A function marked with the @code{medium_call}
3205 attribute will always be close enough to be called with an unconditional
3206 branch-and-link instruction, which has a 25-bit offset from
3207 the call site.  A function marked with the @code{short_call}
3208 attribute will always be close enough to be called with a conditional
3209 branch-and-link instruction, which has a 21-bit offset from
3210 the call site.
3212 @item longcall/shortcall
3213 @cindex functions called via pointer on the RS/6000 and PowerPC
3214 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3215 indicates that the function might be far away from the call site and
3216 require a different (more expensive) calling sequence.  The
3217 @code{shortcall} attribute indicates that the function is always close
3218 enough for the shorter calling sequence to be used.  These attributes
3219 override both the @option{-mlongcall} switch and, on the RS/6000 and
3220 PowerPC, the @code{#pragma longcall} setting.
3222 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3223 calls are necessary.
3225 @item long_call/near/far
3226 @cindex indirect calls on MIPS
3227 These attributes specify how a particular function is called on MIPS@.
3228 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3229 command-line switch.  The @code{long_call} and @code{far} attributes are
3230 synonyms, and cause the compiler to always call
3231 the function by first loading its address into a register, and then using
3232 the contents of that register.  The @code{near} attribute has the opposite
3233 effect; it specifies that non-PIC calls should be made using the more
3234 efficient @code{jal} instruction.
3236 @item malloc
3237 @cindex @code{malloc} attribute
3238 This tells the compiler that a function is @code{malloc}-like, i.e.,
3239 that the pointer @var{P} returned by the function cannot alias any
3240 other pointer valid when the function returns, and moreover no
3241 pointers to valid objects occur in any storage addressed by @var{P}.
3243 Using this attribute can improve optimization.  Functions like
3244 @code{malloc} and @code{calloc} have this property because they return
3245 a pointer to uninitialized or zeroed-out storage.  However, functions
3246 like @code{realloc} do not have this property, as they can return a
3247 pointer to storage containing pointers.
3249 @item mips16/nomips16
3250 @cindex @code{mips16} attribute
3251 @cindex @code{nomips16} attribute
3253 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3254 function attributes to locally select or turn off MIPS16 code generation.
3255 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3256 while MIPS16 code generation is disabled for functions with the
3257 @code{nomips16} attribute.  These attributes override the
3258 @option{-mips16} and @option{-mno-mips16} options on the command line
3259 (@pxref{MIPS Options}).
3261 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3262 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3263 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3264 may interact badly with some GCC extensions such as @code{__builtin_apply}
3265 (@pxref{Constructing Calls}).
3267 @item micromips/nomicromips
3268 @cindex @code{micromips} attribute
3269 @cindex @code{nomicromips} attribute
3271 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3272 function attributes to locally select or turn off microMIPS code generation.
3273 A function with the @code{micromips} attribute is emitted as microMIPS code,
3274 while microMIPS code generation is disabled for functions with the
3275 @code{nomicromips} attribute.  These attributes override the
3276 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3277 (@pxref{MIPS Options}).
3279 When compiling files containing mixed microMIPS and non-microMIPS code, the
3280 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3281 command line,
3282 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3283 may interact badly with some GCC extensions such as @code{__builtin_apply}
3284 (@pxref{Constructing Calls}).
3286 @item model (@var{model-name})
3287 @cindex function addressability on the M32R/D
3288 @cindex variable addressability on the IA-64
3290 On the M32R/D, use this attribute to set the addressability of an
3291 object, and of the code generated for a function.  The identifier
3292 @var{model-name} is one of @code{small}, @code{medium}, or
3293 @code{large}, representing each of the code models.
3295 Small model objects live in the lower 16MB of memory (so that their
3296 addresses can be loaded with the @code{ld24} instruction), and are
3297 callable with the @code{bl} instruction.
3299 Medium model objects may live anywhere in the 32-bit address space (the
3300 compiler generates @code{seth/add3} instructions to load their addresses),
3301 and are callable with the @code{bl} instruction.
3303 Large 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 may not be reachable with the @code{bl} instruction (the compiler
3306 generates the much slower @code{seth/add3/jl} instruction sequence).
3308 On IA-64, use this attribute to set the addressability of an object.
3309 At present, the only supported identifier for @var{model-name} is
3310 @code{small}, indicating addressability via ``small'' (22-bit)
3311 addresses (so that their addresses can be loaded with the @code{addl}
3312 instruction).  Caveat: such addressing is by definition not position
3313 independent and hence this attribute must not be used for objects
3314 defined by shared libraries.
3316 @item ms_abi/sysv_abi
3317 @cindex @code{ms_abi} attribute
3318 @cindex @code{sysv_abi} attribute
3320 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3321 to indicate which calling convention should be used for a function.  The
3322 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3323 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3324 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3325 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3327 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3328 requires the @option{-maccumulate-outgoing-args} option.
3330 @item callee_pop_aggregate_return (@var{number})
3331 @cindex @code{callee_pop_aggregate_return} attribute
3333 On 32-bit i?86-*-* targets, you can use this attribute to control how
3334 aggregates are returned in memory.  If the caller is responsible for
3335 popping the hidden pointer together with the rest of the arguments, specify
3336 @var{number} equal to zero.  If callee is responsible for popping the
3337 hidden pointer, specify @var{number} equal to one.  
3339 The default i386 ABI assumes that the callee pops the
3340 stack for hidden pointer.  However, on 32-bit i386 Microsoft Windows targets,
3341 the compiler assumes that the
3342 caller pops the stack for hidden pointer.
3344 @item ms_hook_prologue
3345 @cindex @code{ms_hook_prologue} attribute
3347 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3348 this function attribute to make GCC generate the ``hot-patching'' function
3349 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3350 and newer.
3352 @item hotpatch [(@var{prologue-halfwords})]
3353 @cindex @code{hotpatch} attribute
3355 On S/390 System z targets, you can use this function attribute to
3356 make GCC generate a ``hot-patching'' function prologue.  The
3357 @code{hotpatch} has no effect on funtions that are explicitly
3358 inline.  If the @option{-mhotpatch} or @option{-mno-hotpatch}
3359 command-line option is used at the same time, the @code{hotpatch}
3360 attribute takes precedence.  If an argument is given, the maximum
3361 allowed value is 1000000.
3363 @item naked
3364 @cindex function without a prologue/epilogue code
3365 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3366 RL78, RX and SPU ports.  It allows the compiler to construct the
3367 requisite function declaration, while allowing the body of the
3368 function to be assembly code. The specified function will not have
3369 prologue/epilogue sequences generated by the compiler. Only Basic
3370 @code{asm} statements can safely be included in naked functions
3371 (@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
3372 Basic @code{asm} and ``C'' code may appear to work, they cannot be
3373 depended upon to work reliably and are not supported.
3375 @item near
3376 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3377 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3378 use the normal calling convention based on @code{jsr} and @code{rts}.
3379 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3380 option.
3382 On MeP targets this attribute causes the compiler to assume the called
3383 function is close enough to use the normal calling convention,
3384 overriding the @option{-mtf} command-line option.
3386 @item nesting
3387 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3388 Use this attribute together with @code{interrupt_handler},
3389 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3390 entry code should enable nested interrupts or exceptions.
3392 @item nmi_handler
3393 @cindex NMI handler functions on the Blackfin processor
3394 Use this attribute on the Blackfin to indicate that the specified function
3395 is an NMI handler.  The compiler generates function entry and
3396 exit sequences suitable for use in an NMI handler when this
3397 attribute is present.
3399 @item nocompression
3400 @cindex @code{nocompression} attribute
3401 On MIPS targets, you can use the @code{nocompression} function attribute
3402 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3403 overrides the @option{-mips16} and @option{-mmicromips} options on the
3404 command line (@pxref{MIPS Options}).
3406 @item no_instrument_function
3407 @cindex @code{no_instrument_function} function attribute
3408 @opindex finstrument-functions
3409 If @option{-finstrument-functions} is given, profiling function calls are
3410 generated at entry and exit of most user-compiled functions.
3411 Functions with this attribute are not so instrumented.
3413 @item no_split_stack
3414 @cindex @code{no_split_stack} function attribute
3415 @opindex fsplit-stack
3416 If @option{-fsplit-stack} is given, functions have a small
3417 prologue which decides whether to split the stack.  Functions with the
3418 @code{no_split_stack} attribute do not have that prologue, and thus
3419 may run with only a small amount of stack space available.
3421 @item noinline
3422 @cindex @code{noinline} function attribute
3423 This function attribute prevents a function from being considered for
3424 inlining.
3425 @c Don't enumerate the optimizations by name here; we try to be
3426 @c future-compatible with this mechanism.
3427 If the function does not have side-effects, there are optimizations
3428 other than inlining that cause function calls to be optimized away,
3429 although the function call is live.  To keep such calls from being
3430 optimized away, put
3431 @smallexample
3432 asm ("");
3433 @end smallexample
3435 @noindent
3436 (@pxref{Extended Asm}) in the called function, to serve as a special
3437 side-effect.
3439 @item noclone
3440 @cindex @code{noclone} function attribute
3441 This function attribute prevents a function from being considered for
3442 cloning---a mechanism that produces specialized copies of functions
3443 and which is (currently) performed by interprocedural constant
3444 propagation.
3446 @item nonnull (@var{arg-index}, @dots{})
3447 @cindex @code{nonnull} function attribute
3448 The @code{nonnull} attribute specifies that some function parameters should
3449 be non-null pointers.  For instance, the declaration:
3451 @smallexample
3452 extern void *
3453 my_memcpy (void *dest, const void *src, size_t len)
3454         __attribute__((nonnull (1, 2)));
3455 @end smallexample
3457 @noindent
3458 causes the compiler to check that, in calls to @code{my_memcpy},
3459 arguments @var{dest} and @var{src} are non-null.  If the compiler
3460 determines that a null pointer is passed in an argument slot marked
3461 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3462 is issued.  The compiler may also choose to make optimizations based
3463 on the knowledge that certain function arguments will never be null.
3465 If no argument index list is given to the @code{nonnull} attribute,
3466 all pointer arguments are marked as non-null.  To illustrate, the
3467 following declaration is equivalent to the previous example:
3469 @smallexample
3470 extern void *
3471 my_memcpy (void *dest, const void *src, size_t len)
3472         __attribute__((nonnull));
3473 @end smallexample
3475 @item no_reorder
3476 @cindex @code{no_reorder} function or variable attribute
3477 Do not reorder functions or variables marked @code{no_reorder}
3478 against each other or top level assembler statements the executable.
3479 The actual order in the program will depend on the linker command
3480 line. Static variables marked like this are also not removed.
3481 This has a similar effect
3482 as the @option{-fno-toplevel-reorder} option, but only applies to the
3483 marked symbols.
3485 @item returns_nonnull
3486 @cindex @code{returns_nonnull} function attribute
3487 The @code{returns_nonnull} attribute specifies that the function
3488 return value should be a non-null pointer.  For instance, the declaration:
3490 @smallexample
3491 extern void *
3492 mymalloc (size_t len) __attribute__((returns_nonnull));
3493 @end smallexample
3495 @noindent
3496 lets the compiler optimize callers based on the knowledge
3497 that the return value will never be null.
3499 @item noreturn
3500 @cindex @code{noreturn} function attribute
3501 A few standard library functions, such as @code{abort} and @code{exit},
3502 cannot return.  GCC knows this automatically.  Some programs define
3503 their own functions that never return.  You can declare them
3504 @code{noreturn} to tell the compiler this fact.  For example,
3506 @smallexample
3507 @group
3508 void fatal () __attribute__ ((noreturn));
3510 void
3511 fatal (/* @r{@dots{}} */)
3513   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3514   exit (1);
3516 @end group
3517 @end smallexample
3519 The @code{noreturn} keyword tells the compiler to assume that
3520 @code{fatal} cannot return.  It can then optimize without regard to what
3521 would happen if @code{fatal} ever did return.  This makes slightly
3522 better code.  More importantly, it helps avoid spurious warnings of
3523 uninitialized variables.
3525 The @code{noreturn} keyword does not affect the exceptional path when that
3526 applies: a @code{noreturn}-marked function may still return to the caller
3527 by throwing an exception or calling @code{longjmp}.
3529 Do not assume that registers saved by the calling function are
3530 restored before calling the @code{noreturn} function.
3532 It does not make sense for a @code{noreturn} function to have a return
3533 type other than @code{void}.
3535 The attribute @code{noreturn} is not implemented in GCC versions
3536 earlier than 2.5.  An alternative way to declare that a function does
3537 not return, which works in the current version and in some older
3538 versions, is as follows:
3540 @smallexample
3541 typedef void voidfn ();
3543 volatile voidfn fatal;
3544 @end smallexample
3546 @noindent
3547 This approach does not work in GNU C++.
3549 @item nothrow
3550 @cindex @code{nothrow} function attribute
3551 The @code{nothrow} attribute is used to inform the compiler that a
3552 function cannot throw an exception.  For example, most functions in
3553 the standard C library can be guaranteed not to throw an exception
3554 with the notable exceptions of @code{qsort} and @code{bsearch} that
3555 take function pointer arguments.  The @code{nothrow} attribute is not
3556 implemented in GCC versions earlier than 3.3.
3558 @item nosave_low_regs
3559 @cindex @code{nosave_low_regs} attribute
3560 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3561 function should not save and restore registers R0..R7.  This can be used on SH3*
3562 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3563 interrupt handlers.
3565 @item optimize
3566 @cindex @code{optimize} function attribute
3567 The @code{optimize} attribute is used to specify that a function is to
3568 be compiled with different optimization options than specified on the
3569 command line.  Arguments can either be numbers or strings.  Numbers
3570 are assumed to be an optimization level.  Strings that begin with
3571 @code{O} are assumed to be an optimization option, while other options
3572 are assumed to be used with a @code{-f} prefix.  You can also use the
3573 @samp{#pragma GCC optimize} pragma to set the optimization options
3574 that affect more than one function.
3575 @xref{Function Specific Option Pragmas}, for details about the
3576 @samp{#pragma GCC optimize} pragma.
3578 This can be used for instance to have frequently-executed functions
3579 compiled with more aggressive optimization options that produce faster
3580 and larger code, while other functions can be compiled with less
3581 aggressive options.
3583 @item OS_main/OS_task
3584 @cindex @code{OS_main} AVR function attribute
3585 @cindex @code{OS_task} AVR function attribute
3586 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3587 do not save/restore any call-saved register in their prologue/epilogue.
3589 The @code{OS_main} attribute can be used when there @emph{is
3590 guarantee} that interrupts are disabled at the time when the function
3591 is entered.  This saves resources when the stack pointer has to be
3592 changed to set up a frame for local variables.
3594 The @code{OS_task} attribute can be used when there is @emph{no
3595 guarantee} that interrupts are disabled at that time when the function
3596 is entered like for, e@.g@. task functions in a multi-threading operating
3597 system. In that case, changing the stack pointer register is
3598 guarded by save/clear/restore of the global interrupt enable flag.
3600 The differences to the @code{naked} function attribute are:
3601 @itemize @bullet
3602 @item @code{naked} functions do not have a return instruction whereas 
3603 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3604 @code{RETI} return instruction.
3605 @item @code{naked} functions do not set up a frame for local variables
3606 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3607 as needed.
3608 @end itemize
3610 @item pcs
3611 @cindex @code{pcs} function attribute
3613 The @code{pcs} attribute can be used to control the calling convention
3614 used for a function on ARM.  The attribute takes an argument that specifies
3615 the calling convention to use.
3617 When compiling using the AAPCS ABI (or a variant of it) then valid
3618 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3619 order to use a variant other than @code{"aapcs"} then the compiler must
3620 be permitted to use the appropriate co-processor registers (i.e., the
3621 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3622 For example,
3624 @smallexample
3625 /* Argument passed in r0, and result returned in r0+r1.  */
3626 double f2d (float) __attribute__((pcs("aapcs")));
3627 @end smallexample
3629 Variadic functions always use the @code{"aapcs"} calling convention and
3630 the compiler rejects attempts to specify an alternative.
3632 @item pure
3633 @cindex @code{pure} function attribute
3634 Many functions have no effects except the return value and their
3635 return value depends only on the parameters and/or global variables.
3636 Such a function can be subject
3637 to common subexpression elimination and loop optimization just as an
3638 arithmetic operator would be.  These functions should be declared
3639 with the attribute @code{pure}.  For example,
3641 @smallexample
3642 int square (int) __attribute__ ((pure));
3643 @end smallexample
3645 @noindent
3646 says that the hypothetical function @code{square} is safe to call
3647 fewer times than the program says.
3649 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3650 Interesting non-pure functions are functions with infinite loops or those
3651 depending on volatile memory or other system resource, that may change between
3652 two consecutive calls (such as @code{feof} in a multithreading environment).
3654 The attribute @code{pure} is not implemented in GCC versions earlier
3655 than 2.96.
3657 @item hot
3658 @cindex @code{hot} function attribute
3659 The @code{hot} attribute on a function is used to inform the compiler that
3660 the function is a hot spot of the compiled program.  The function is
3661 optimized more aggressively and on many targets it is placed into a special
3662 subsection of the text section so all hot functions appear close together,
3663 improving locality.
3665 When profile feedback is available, via @option{-fprofile-use}, hot functions
3666 are automatically detected and this attribute is ignored.
3668 The @code{hot} attribute on functions is not implemented in GCC versions
3669 earlier than 4.3.
3671 @item cold
3672 @cindex @code{cold} function attribute
3673 The @code{cold} attribute on functions is used to inform the compiler that
3674 the function is unlikely to be executed.  The function is optimized for
3675 size rather than speed and on many targets it is placed into a special
3676 subsection of the text section so all cold functions appear close together,
3677 improving code locality of non-cold parts of program.  The paths leading
3678 to calls of cold functions within code are marked as unlikely by the branch
3679 prediction mechanism.  It is thus useful to mark functions used to handle
3680 unlikely conditions, such as @code{perror}, as cold to improve optimization
3681 of hot functions that do call marked functions in rare occasions.
3683 When profile feedback is available, via @option{-fprofile-use}, cold functions
3684 are automatically detected and this attribute is ignored.
3686 The @code{cold} attribute on functions is not implemented in GCC versions
3687 earlier than 4.3.
3689 @item no_sanitize_address
3690 @itemx no_address_safety_analysis
3691 @cindex @code{no_sanitize_address} function attribute
3692 The @code{no_sanitize_address} attribute on functions is used
3693 to inform the compiler that it should not instrument memory accesses
3694 in the function when compiling with the @option{-fsanitize=address} option.
3695 The @code{no_address_safety_analysis} is a deprecated alias of the
3696 @code{no_sanitize_address} attribute, new code should use
3697 @code{no_sanitize_address}.
3699 @item no_sanitize_undefined
3700 @cindex @code{no_sanitize_undefined} function attribute
3701 The @code{no_sanitize_undefined} attribute on functions is used
3702 to inform the compiler that it should not check for undefined behavior
3703 in the function when compiling with the @option{-fsanitize=undefined} option.
3705 @item regparm (@var{number})
3706 @cindex @code{regparm} attribute
3707 @cindex functions that are passed arguments in registers on the 386
3708 On the Intel 386, the @code{regparm} attribute causes the compiler to
3709 pass arguments number one to @var{number} if they are of integral type
3710 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3711 take a variable number of arguments continue to be passed all of their
3712 arguments on the stack.
3714 Beware that on some ELF systems this attribute is unsuitable for
3715 global functions in shared libraries with lazy binding (which is the
3716 default).  Lazy binding sends the first call via resolving code in
3717 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3718 per the standard calling conventions.  Solaris 8 is affected by this.
3719 Systems with the GNU C Library version 2.1 or higher
3720 and FreeBSD are believed to be
3721 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3722 disabled with the linker or the loader if desired, to avoid the
3723 problem.)
3725 @item reset
3726 @cindex reset handler functions
3727 Use this attribute on the NDS32 target to indicate that the specified function
3728 is a reset handler.  The compiler will generate corresponding sections
3729 for use in a reset handler.  You can use the following attributes
3730 to provide extra exception handling:
3731 @table @code
3732 @item nmi
3733 @cindex @code{nmi} attribute
3734 Provide a user-defined function to handle NMI exception.
3735 @item warm
3736 @cindex @code{warm} attribute
3737 Provide a user-defined function to handle warm reset exception.
3738 @end table
3740 @item sseregparm
3741 @cindex @code{sseregparm} attribute
3742 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3743 causes the compiler to pass up to 3 floating-point arguments in
3744 SSE registers instead of on the stack.  Functions that take a
3745 variable number of arguments continue to pass all of their
3746 floating-point arguments on the stack.
3748 @item force_align_arg_pointer
3749 @cindex @code{force_align_arg_pointer} attribute
3750 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3751 applied to individual function definitions, generating an alternate
3752 prologue and epilogue that realigns the run-time stack if necessary.
3753 This supports mixing legacy codes that run with a 4-byte aligned stack
3754 with modern codes that keep a 16-byte stack for SSE compatibility.
3756 @item renesas
3757 @cindex @code{renesas} attribute
3758 On SH targets this attribute specifies that the function or struct follows the
3759 Renesas ABI.
3761 @item resbank
3762 @cindex @code{resbank} attribute
3763 On the SH2A target, this attribute enables the high-speed register
3764 saving and restoration using a register bank for @code{interrupt_handler}
3765 routines.  Saving to the bank is performed automatically after the CPU
3766 accepts an interrupt that uses a register bank.
3768 The nineteen 32-bit registers comprising general register R0 to R14,
3769 control register GBR, and system registers MACH, MACL, and PR and the
3770 vector table address offset are saved into a register bank.  Register
3771 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3772 from the bank is executed by issuing a RESBANK instruction.
3774 @item returns_twice
3775 @cindex @code{returns_twice} attribute
3776 The @code{returns_twice} attribute tells the compiler that a function may
3777 return more than one time.  The compiler ensures that all registers
3778 are dead before calling such a function and emits a warning about
3779 the variables that may be clobbered after the second return from the
3780 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3781 The @code{longjmp}-like counterpart of such function, if any, might need
3782 to be marked with the @code{noreturn} attribute.
3784 @item saveall
3785 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3786 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3787 all registers except the stack pointer should be saved in the prologue
3788 regardless of whether they are used or not.
3790 @item save_volatiles
3791 @cindex save volatile registers on the MicroBlaze
3792 Use this attribute on the MicroBlaze to indicate that the function is
3793 an interrupt handler.  All volatile registers (in addition to non-volatile
3794 registers) are saved in the function prologue.  If the function is a leaf
3795 function, only volatiles used by the function are saved.  A normal function
3796 return is generated instead of a return from interrupt.
3798 @item break_handler
3799 @cindex break handler functions
3800 Use this attribute on the MicroBlaze ports to indicate that
3801 the specified function is an break handler.  The compiler generates function
3802 entry and exit sequences suitable for use in an break handler when this
3803 attribute is present. The return from @code{break_handler} is done through
3804 the @code{rtbd} instead of @code{rtsd}.
3806 @smallexample
3807 void f () __attribute__ ((break_handler));
3808 @end smallexample
3810 @item section ("@var{section-name}")
3811 @cindex @code{section} function attribute
3812 Normally, the compiler places the code it generates in the @code{text} section.
3813 Sometimes, however, you need additional sections, or you need certain
3814 particular functions to appear in special sections.  The @code{section}
3815 attribute specifies that a function lives in a particular section.
3816 For example, the declaration:
3818 @smallexample
3819 extern void foobar (void) __attribute__ ((section ("bar")));
3820 @end smallexample
3822 @noindent
3823 puts the function @code{foobar} in the @code{bar} section.
3825 Some file formats do not support arbitrary sections so the @code{section}
3826 attribute is not available on all platforms.
3827 If you need to map the entire contents of a module to a particular
3828 section, consider using the facilities of the linker instead.
3830 @item sentinel
3831 @cindex @code{sentinel} function attribute
3832 This function attribute ensures that a parameter in a function call is
3833 an explicit @code{NULL}.  The attribute is only valid on variadic
3834 functions.  By default, the sentinel is located at position zero, the
3835 last parameter of the function call.  If an optional integer position
3836 argument P is supplied to the attribute, the sentinel must be located at
3837 position P counting backwards from the end of the argument list.
3839 @smallexample
3840 __attribute__ ((sentinel))
3841 is equivalent to
3842 __attribute__ ((sentinel(0)))
3843 @end smallexample
3845 The attribute is automatically set with a position of 0 for the built-in
3846 functions @code{execl} and @code{execlp}.  The built-in function
3847 @code{execle} has the attribute set with a position of 1.
3849 A valid @code{NULL} in this context is defined as zero with any pointer
3850 type.  If your system defines the @code{NULL} macro with an integer type
3851 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3852 with a copy that redefines NULL appropriately.
3854 The warnings for missing or incorrect sentinels are enabled with
3855 @option{-Wformat}.
3857 @item short_call
3858 See @code{long_call/short_call}.
3860 @item shortcall
3861 See @code{longcall/shortcall}.
3863 @item signal
3864 @cindex interrupt handler functions on the AVR processors
3865 Use this attribute on the AVR to indicate that the specified
3866 function is an interrupt handler.  The compiler generates function
3867 entry and exit sequences suitable for use in an interrupt handler when this
3868 attribute is present.
3870 See also the @code{interrupt} function attribute. 
3872 The AVR hardware globally disables interrupts when an interrupt is executed.
3873 Interrupt handler functions defined with the @code{signal} attribute
3874 do not re-enable interrupts.  It is save to enable interrupts in a
3875 @code{signal} handler.  This ``save'' only applies to the code
3876 generated by the compiler and not to the IRQ layout of the
3877 application which is responsibility of the application.
3879 If both @code{signal} and @code{interrupt} are specified for the same
3880 function, @code{signal} is silently ignored.
3882 @item sp_switch
3883 @cindex @code{sp_switch} attribute
3884 Use this attribute on the SH to indicate an @code{interrupt_handler}
3885 function should switch to an alternate stack.  It expects a string
3886 argument that names a global variable holding the address of the
3887 alternate stack.
3889 @smallexample
3890 void *alt_stack;
3891 void f () __attribute__ ((interrupt_handler,
3892                           sp_switch ("alt_stack")));
3893 @end smallexample
3895 @item stdcall
3896 @cindex functions that pop the argument stack on the 386
3897 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3898 assume that the called function pops off the stack space used to
3899 pass arguments, unless it takes a variable number of arguments.
3901 @item syscall_linkage
3902 @cindex @code{syscall_linkage} attribute
3903 This attribute is used to modify the IA-64 calling convention by marking
3904 all input registers as live at all function exits.  This makes it possible
3905 to restart a system call after an interrupt without having to save/restore
3906 the input registers.  This also prevents kernel data from leaking into
3907 application code.
3909 @item target
3910 @cindex @code{target} function attribute
3911 The @code{target} attribute is used to specify that a function is to
3912 be compiled with different target options than specified on the
3913 command line.  This can be used for instance to have functions
3914 compiled with a different ISA (instruction set architecture) than the
3915 default.  You can also use the @samp{#pragma GCC target} pragma to set
3916 more than one function to be compiled with specific target options.
3917 @xref{Function Specific Option Pragmas}, for details about the
3918 @samp{#pragma GCC target} pragma.
3920 For instance on a 386, you could compile one function with
3921 @code{target("sse4.1,arch=core2")} and another with
3922 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3923 compiling the first function with @option{-msse4.1} and
3924 @option{-march=core2} options, and the second function with
3925 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3926 user to make sure that a function is only invoked on a machine that
3927 supports the particular ISA it is compiled for (for example by using
3928 @code{cpuid} on 386 to determine what feature bits and architecture
3929 family are used).
3931 @smallexample
3932 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3933 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3934 @end smallexample
3936 You can either use multiple
3937 strings to specify multiple options, or separate the options
3938 with a comma (@samp{,}).
3940 The @code{target} attribute is presently implemented for
3941 i386/x86_64, PowerPC, and Nios II targets only.
3942 The options supported are specific to each target.
3944 On the 386, the following options are allowed:
3946 @table @samp
3947 @item abm
3948 @itemx no-abm
3949 @cindex @code{target("abm")} attribute
3950 Enable/disable the generation of the advanced bit instructions.
3952 @item aes
3953 @itemx no-aes
3954 @cindex @code{target("aes")} attribute
3955 Enable/disable the generation of the AES instructions.
3957 @item default
3958 @cindex @code{target("default")} attribute
3959 @xref{Function Multiversioning}, where it is used to specify the
3960 default function version.
3962 @item mmx
3963 @itemx no-mmx
3964 @cindex @code{target("mmx")} attribute
3965 Enable/disable the generation of the MMX instructions.
3967 @item pclmul
3968 @itemx no-pclmul
3969 @cindex @code{target("pclmul")} attribute
3970 Enable/disable the generation of the PCLMUL instructions.
3972 @item popcnt
3973 @itemx no-popcnt
3974 @cindex @code{target("popcnt")} attribute
3975 Enable/disable the generation of the POPCNT instruction.
3977 @item sse
3978 @itemx no-sse
3979 @cindex @code{target("sse")} attribute
3980 Enable/disable the generation of the SSE instructions.
3982 @item sse2
3983 @itemx no-sse2
3984 @cindex @code{target("sse2")} attribute
3985 Enable/disable the generation of the SSE2 instructions.
3987 @item sse3
3988 @itemx no-sse3
3989 @cindex @code{target("sse3")} attribute
3990 Enable/disable the generation of the SSE3 instructions.
3992 @item sse4
3993 @itemx no-sse4
3994 @cindex @code{target("sse4")} attribute
3995 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3996 and SSE4.2).
3998 @item sse4.1
3999 @itemx no-sse4.1
4000 @cindex @code{target("sse4.1")} attribute
4001 Enable/disable the generation of the sse4.1 instructions.
4003 @item sse4.2
4004 @itemx no-sse4.2
4005 @cindex @code{target("sse4.2")} attribute
4006 Enable/disable the generation of the sse4.2 instructions.
4008 @item sse4a
4009 @itemx no-sse4a
4010 @cindex @code{target("sse4a")} attribute
4011 Enable/disable the generation of the SSE4A instructions.
4013 @item fma4
4014 @itemx no-fma4
4015 @cindex @code{target("fma4")} attribute
4016 Enable/disable the generation of the FMA4 instructions.
4018 @item xop
4019 @itemx no-xop
4020 @cindex @code{target("xop")} attribute
4021 Enable/disable the generation of the XOP instructions.
4023 @item lwp
4024 @itemx no-lwp
4025 @cindex @code{target("lwp")} attribute
4026 Enable/disable the generation of the LWP instructions.
4028 @item ssse3
4029 @itemx no-ssse3
4030 @cindex @code{target("ssse3")} attribute
4031 Enable/disable the generation of the SSSE3 instructions.
4033 @item cld
4034 @itemx no-cld
4035 @cindex @code{target("cld")} attribute
4036 Enable/disable the generation of the CLD before string moves.
4038 @item fancy-math-387
4039 @itemx no-fancy-math-387
4040 @cindex @code{target("fancy-math-387")} attribute
4041 Enable/disable the generation of the @code{sin}, @code{cos}, and
4042 @code{sqrt} instructions on the 387 floating-point unit.
4044 @item fused-madd
4045 @itemx no-fused-madd
4046 @cindex @code{target("fused-madd")} attribute
4047 Enable/disable the generation of the fused multiply/add instructions.
4049 @item ieee-fp
4050 @itemx no-ieee-fp
4051 @cindex @code{target("ieee-fp")} attribute
4052 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4054 @item inline-all-stringops
4055 @itemx no-inline-all-stringops
4056 @cindex @code{target("inline-all-stringops")} attribute
4057 Enable/disable inlining of string operations.
4059 @item inline-stringops-dynamically
4060 @itemx no-inline-stringops-dynamically
4061 @cindex @code{target("inline-stringops-dynamically")} attribute
4062 Enable/disable the generation of the inline code to do small string
4063 operations and calling the library routines for large operations.
4065 @item align-stringops
4066 @itemx no-align-stringops
4067 @cindex @code{target("align-stringops")} attribute
4068 Do/do not align destination of inlined string operations.
4070 @item recip
4071 @itemx no-recip
4072 @cindex @code{target("recip")} attribute
4073 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4074 instructions followed an additional Newton-Raphson step instead of
4075 doing a floating-point division.
4077 @item arch=@var{ARCH}
4078 @cindex @code{target("arch=@var{ARCH}")} attribute
4079 Specify the architecture to generate code for in compiling the function.
4081 @item tune=@var{TUNE}
4082 @cindex @code{target("tune=@var{TUNE}")} attribute
4083 Specify the architecture to tune for in compiling the function.
4085 @item fpmath=@var{FPMATH}
4086 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4087 Specify which floating-point unit to use.  The
4088 @code{target("fpmath=sse,387")} option must be specified as
4089 @code{target("fpmath=sse+387")} because the comma would separate
4090 different options.
4091 @end table
4093 On the PowerPC, the following options are allowed:
4095 @table @samp
4096 @item altivec
4097 @itemx no-altivec
4098 @cindex @code{target("altivec")} attribute
4099 Generate code that uses (does not use) AltiVec instructions.  In
4100 32-bit code, you cannot enable AltiVec instructions unless
4101 @option{-mabi=altivec} is used on the command line.
4103 @item cmpb
4104 @itemx no-cmpb
4105 @cindex @code{target("cmpb")} attribute
4106 Generate code that uses (does not use) the compare bytes instruction
4107 implemented on the POWER6 processor and other processors that support
4108 the PowerPC V2.05 architecture.
4110 @item dlmzb
4111 @itemx no-dlmzb
4112 @cindex @code{target("dlmzb")} attribute
4113 Generate code that uses (does not use) the string-search @samp{dlmzb}
4114 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4115 generated by default when targeting those processors.
4117 @item fprnd
4118 @itemx no-fprnd
4119 @cindex @code{target("fprnd")} attribute
4120 Generate code that uses (does not use) the FP round to integer
4121 instructions implemented on the POWER5+ processor and other processors
4122 that support the PowerPC V2.03 architecture.
4124 @item hard-dfp
4125 @itemx no-hard-dfp
4126 @cindex @code{target("hard-dfp")} attribute
4127 Generate code that uses (does not use) the decimal floating-point
4128 instructions implemented on some POWER processors.
4130 @item isel
4131 @itemx no-isel
4132 @cindex @code{target("isel")} attribute
4133 Generate code that uses (does not use) ISEL instruction.
4135 @item mfcrf
4136 @itemx no-mfcrf
4137 @cindex @code{target("mfcrf")} attribute
4138 Generate code that uses (does not use) the move from condition
4139 register field instruction implemented on the POWER4 processor and
4140 other processors that support the PowerPC V2.01 architecture.
4142 @item mfpgpr
4143 @itemx no-mfpgpr
4144 @cindex @code{target("mfpgpr")} attribute
4145 Generate code that uses (does not use) the FP move to/from general
4146 purpose register instructions implemented on the POWER6X processor and
4147 other processors that support the extended PowerPC V2.05 architecture.
4149 @item mulhw
4150 @itemx no-mulhw
4151 @cindex @code{target("mulhw")} attribute
4152 Generate code that uses (does not use) the half-word multiply and
4153 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4154 These instructions are generated by default when targeting those
4155 processors.
4157 @item multiple
4158 @itemx no-multiple
4159 @cindex @code{target("multiple")} attribute
4160 Generate code that uses (does not use) the load multiple word
4161 instructions and the store multiple word instructions.
4163 @item update
4164 @itemx no-update
4165 @cindex @code{target("update")} attribute
4166 Generate code that uses (does not use) the load or store instructions
4167 that update the base register to the address of the calculated memory
4168 location.
4170 @item popcntb
4171 @itemx no-popcntb
4172 @cindex @code{target("popcntb")} attribute
4173 Generate code that uses (does not use) the popcount and double-precision
4174 FP reciprocal estimate instruction implemented on the POWER5
4175 processor and other processors that support the PowerPC V2.02
4176 architecture.
4178 @item popcntd
4179 @itemx no-popcntd
4180 @cindex @code{target("popcntd")} attribute
4181 Generate code that uses (does not use) the popcount instruction
4182 implemented on the POWER7 processor and other processors that support
4183 the PowerPC V2.06 architecture.
4185 @item powerpc-gfxopt
4186 @itemx no-powerpc-gfxopt
4187 @cindex @code{target("powerpc-gfxopt")} attribute
4188 Generate code that uses (does not use) the optional PowerPC
4189 architecture instructions in the Graphics group, including
4190 floating-point select.
4192 @item powerpc-gpopt
4193 @itemx no-powerpc-gpopt
4194 @cindex @code{target("powerpc-gpopt")} attribute
4195 Generate code that uses (does not use) the optional PowerPC
4196 architecture instructions in the General Purpose group, including
4197 floating-point square root.
4199 @item recip-precision
4200 @itemx no-recip-precision
4201 @cindex @code{target("recip-precision")} attribute
4202 Assume (do not assume) that the reciprocal estimate instructions
4203 provide higher-precision estimates than is mandated by the powerpc
4204 ABI.
4206 @item string
4207 @itemx no-string
4208 @cindex @code{target("string")} attribute
4209 Generate code that uses (does not use) the load string instructions
4210 and the store string word instructions to save multiple registers and
4211 do small block moves.
4213 @item vsx
4214 @itemx no-vsx
4215 @cindex @code{target("vsx")} attribute
4216 Generate code that uses (does not use) vector/scalar (VSX)
4217 instructions, and also enable the use of built-in functions that allow
4218 more direct access to the VSX instruction set.  In 32-bit code, you
4219 cannot enable VSX or AltiVec instructions unless
4220 @option{-mabi=altivec} is used on the command line.
4222 @item friz
4223 @itemx no-friz
4224 @cindex @code{target("friz")} attribute
4225 Generate (do not generate) the @code{friz} instruction when the
4226 @option{-funsafe-math-optimizations} option is used to optimize
4227 rounding a floating-point value to 64-bit integer and back to floating
4228 point.  The @code{friz} instruction does not return the same value if
4229 the floating-point number is too large to fit in an integer.
4231 @item avoid-indexed-addresses
4232 @itemx no-avoid-indexed-addresses
4233 @cindex @code{target("avoid-indexed-addresses")} attribute
4234 Generate code that tries to avoid (not avoid) the use of indexed load
4235 or store instructions.
4237 @item paired
4238 @itemx no-paired
4239 @cindex @code{target("paired")} attribute
4240 Generate code that uses (does not use) the generation of PAIRED simd
4241 instructions.
4243 @item longcall
4244 @itemx no-longcall
4245 @cindex @code{target("longcall")} attribute
4246 Generate code that assumes (does not assume) that all calls are far
4247 away so that a longer more expensive calling sequence is required.
4249 @item cpu=@var{CPU}
4250 @cindex @code{target("cpu=@var{CPU}")} attribute
4251 Specify the architecture to generate code for when compiling the
4252 function.  If you select the @code{target("cpu=power7")} attribute when
4253 generating 32-bit code, VSX and AltiVec instructions are not generated
4254 unless you use the @option{-mabi=altivec} option on the command line.
4256 @item tune=@var{TUNE}
4257 @cindex @code{target("tune=@var{TUNE}")} attribute
4258 Specify the architecture to tune for when compiling the function.  If
4259 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4260 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4261 compilation tunes for the @var{CPU} architecture, and not the
4262 default tuning specified on the command line.
4263 @end table
4265 When compiling for Nios II, the following options are allowed:
4267 @table @samp
4268 @item custom-@var{insn}=@var{N}
4269 @itemx no-custom-@var{insn}
4270 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4271 @cindex @code{target("no-custom-@var{insn}")} attribute
4272 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4273 custom instruction with encoding @var{N} when generating code that uses 
4274 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4275 the custom instruction @var{insn}.
4276 These target attributes correspond to the
4277 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4278 command-line options, and support the same set of @var{insn} keywords.
4279 @xref{Nios II Options}, for more information.
4281 @item custom-fpu-cfg=@var{name}
4282 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4283 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4284 command-line option, to select a predefined set of custom instructions
4285 named @var{name}.
4286 @xref{Nios II Options}, for more information.
4287 @end table
4289 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4290 function that has different target options than the caller, unless the
4291 callee has a subset of the target options of the caller.  For example
4292 a function declared with @code{target("sse3")} can inline a function
4293 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4295 @item tiny_data
4296 @cindex tiny data section on the H8/300H and H8S
4297 Use this attribute on the H8/300H and H8S to indicate that the specified
4298 variable should be placed into the tiny data section.
4299 The compiler generates more efficient code for loads and stores
4300 on data in the tiny data section.  Note the tiny data area is limited to
4301 slightly under 32KB of data.
4303 @item trap_exit
4304 @cindex @code{trap_exit} attribute
4305 Use this attribute on the SH for an @code{interrupt_handler} to return using
4306 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4307 argument specifying the trap number to be used.
4309 @item trapa_handler
4310 @cindex @code{trapa_handler} attribute
4311 On SH targets this function attribute is similar to @code{interrupt_handler}
4312 but it does not save and restore all registers.
4314 @item unused
4315 @cindex @code{unused} attribute.
4316 This attribute, attached to a function, means that the function is meant
4317 to be possibly unused.  GCC does not produce a warning for this
4318 function.
4320 @item used
4321 @cindex @code{used} attribute.
4322 This attribute, attached to a function, means that code must be emitted
4323 for the function even if it appears that the function is not referenced.
4324 This is useful, for example, when the function is referenced only in
4325 inline assembly.
4327 When applied to a member function of a C++ class template, the
4328 attribute also means that the function is instantiated if the
4329 class itself is instantiated.
4331 @item vector
4332 @cindex @code{vector} attribute
4333 This RX attribute is similar to the @code{interrupt} attribute, including its
4334 parameters, but does not make the function an interrupt-handler type
4335 function (i.e. it retains the normal C function calling ABI).  See the
4336 @code{interrupt} attribute for a description of its arguments.
4338 @item version_id
4339 @cindex @code{version_id} attribute
4340 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4341 symbol to contain a version string, thus allowing for function level
4342 versioning.  HP-UX system header files may use function level versioning
4343 for some system calls.
4345 @smallexample
4346 extern int foo () __attribute__((version_id ("20040821")));
4347 @end smallexample
4349 @noindent
4350 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4352 @item visibility ("@var{visibility_type}")
4353 @cindex @code{visibility} attribute
4354 This attribute affects the linkage of the declaration to which it is attached.
4355 There are four supported @var{visibility_type} values: default,
4356 hidden, protected or internal visibility.
4358 @smallexample
4359 void __attribute__ ((visibility ("protected")))
4360 f () @{ /* @r{Do something.} */; @}
4361 int i __attribute__ ((visibility ("hidden")));
4362 @end smallexample
4364 The possible values of @var{visibility_type} correspond to the
4365 visibility settings in the ELF gABI.
4367 @table @dfn
4368 @c keep this list of visibilities in alphabetical order.
4370 @item default
4371 Default visibility is the normal case for the object file format.
4372 This value is available for the visibility attribute to override other
4373 options that may change the assumed visibility of entities.
4375 On ELF, default visibility means that the declaration is visible to other
4376 modules and, in shared libraries, means that the declared entity may be
4377 overridden.
4379 On Darwin, default visibility means that the declaration is visible to
4380 other modules.
4382 Default visibility corresponds to ``external linkage'' in the language.
4384 @item hidden
4385 Hidden visibility indicates that the entity declared has a new
4386 form of linkage, which we call ``hidden linkage''.  Two
4387 declarations of an object with hidden linkage refer to the same object
4388 if they are in the same shared object.
4390 @item internal
4391 Internal visibility is like hidden visibility, but with additional
4392 processor specific semantics.  Unless otherwise specified by the
4393 psABI, GCC defines internal visibility to mean that a function is
4394 @emph{never} called from another module.  Compare this with hidden
4395 functions which, while they cannot be referenced directly by other
4396 modules, can be referenced indirectly via function pointers.  By
4397 indicating that a function cannot be called from outside the module,
4398 GCC may for instance omit the load of a PIC register since it is known
4399 that the calling function loaded the correct value.
4401 @item protected
4402 Protected visibility is like default visibility except that it
4403 indicates that references within the defining module bind to the
4404 definition in that module.  That is, the declared entity cannot be
4405 overridden by another module.
4407 @end table
4409 All visibilities are supported on many, but not all, ELF targets
4410 (supported when the assembler supports the @samp{.visibility}
4411 pseudo-op).  Default visibility is supported everywhere.  Hidden
4412 visibility is supported on Darwin targets.
4414 The visibility attribute should be applied only to declarations that
4415 would otherwise have external linkage.  The attribute should be applied
4416 consistently, so that the same entity should not be declared with
4417 different settings of the attribute.
4419 In C++, the visibility attribute applies to types as well as functions
4420 and objects, because in C++ types have linkage.  A class must not have
4421 greater visibility than its non-static data member types and bases,
4422 and class members default to the visibility of their class.  Also, a
4423 declaration without explicit visibility is limited to the visibility
4424 of its type.
4426 In C++, you can mark member functions and static member variables of a
4427 class with the visibility attribute.  This is useful if you know a
4428 particular method or static member variable should only be used from
4429 one shared object; then you can mark it hidden while the rest of the
4430 class has default visibility.  Care must be taken to avoid breaking
4431 the One Definition Rule; for example, it is usually not useful to mark
4432 an inline method as hidden without marking the whole class as hidden.
4434 A C++ namespace declaration can also have the visibility attribute.
4436 @smallexample
4437 namespace nspace1 __attribute__ ((visibility ("protected")))
4438 @{ /* @r{Do something.} */; @}
4439 @end smallexample
4441 This attribute applies only to the particular namespace body, not to
4442 other definitions of the same namespace; it is equivalent to using
4443 @samp{#pragma GCC visibility} before and after the namespace
4444 definition (@pxref{Visibility Pragmas}).
4446 In C++, if a template argument has limited visibility, this
4447 restriction is implicitly propagated to the template instantiation.
4448 Otherwise, template instantiations and specializations default to the
4449 visibility of their template.
4451 If both the template and enclosing class have explicit visibility, the
4452 visibility from the template is used.
4454 @item vliw
4455 @cindex @code{vliw} attribute
4456 On MeP, the @code{vliw} attribute tells the compiler to emit
4457 instructions in VLIW mode instead of core mode.  Note that this
4458 attribute is not allowed unless a VLIW coprocessor has been configured
4459 and enabled through command-line options.
4461 @item warn_unused_result
4462 @cindex @code{warn_unused_result} attribute
4463 The @code{warn_unused_result} attribute causes a warning to be emitted
4464 if a caller of the function with this attribute does not use its
4465 return value.  This is useful for functions where not checking
4466 the result is either a security problem or always a bug, such as
4467 @code{realloc}.
4469 @smallexample
4470 int fn () __attribute__ ((warn_unused_result));
4471 int foo ()
4473   if (fn () < 0) return -1;
4474   fn ();
4475   return 0;
4477 @end smallexample
4479 @noindent
4480 results in warning on line 5.
4482 @item weak
4483 @cindex @code{weak} attribute
4484 The @code{weak} attribute causes the declaration to be emitted as a weak
4485 symbol rather than a global.  This is primarily useful in defining
4486 library functions that can be overridden in user code, though it can
4487 also be used with non-function declarations.  Weak symbols are supported
4488 for ELF targets, and also for a.out targets when using the GNU assembler
4489 and linker.
4491 @item weakref
4492 @itemx weakref ("@var{target}")
4493 @cindex @code{weakref} attribute
4494 The @code{weakref} attribute marks a declaration as a weak reference.
4495 Without arguments, it should be accompanied by an @code{alias} attribute
4496 naming the target symbol.  Optionally, the @var{target} may be given as
4497 an argument to @code{weakref} itself.  In either case, @code{weakref}
4498 implicitly marks the declaration as @code{weak}.  Without a
4499 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4500 @code{weakref} is equivalent to @code{weak}.
4502 @smallexample
4503 static int x() __attribute__ ((weakref ("y")));
4504 /* is equivalent to... */
4505 static int x() __attribute__ ((weak, weakref, alias ("y")));
4506 /* and to... */
4507 static int x() __attribute__ ((weakref));
4508 static int x() __attribute__ ((alias ("y")));
4509 @end smallexample
4511 A weak reference is an alias that does not by itself require a
4512 definition to be given for the target symbol.  If the target symbol is
4513 only referenced through weak references, then it becomes a @code{weak}
4514 undefined symbol.  If it is directly referenced, however, then such
4515 strong references prevail, and a definition is required for the
4516 symbol, not necessarily in the same translation unit.
4518 The effect is equivalent to moving all references to the alias to a
4519 separate translation unit, renaming the alias to the aliased symbol,
4520 declaring it as weak, compiling the two separate translation units and
4521 performing a reloadable link on them.
4523 At present, a declaration to which @code{weakref} is attached can
4524 only be @code{static}.
4526 @end table
4528 You can specify multiple attributes in a declaration by separating them
4529 by commas within the double parentheses or by immediately following an
4530 attribute declaration with another attribute declaration.
4532 @cindex @code{#pragma}, reason for not using
4533 @cindex pragma, reason for not using
4534 Some people object to the @code{__attribute__} feature, suggesting that
4535 ISO C's @code{#pragma} should be used instead.  At the time
4536 @code{__attribute__} was designed, there were two reasons for not doing
4537 this.
4539 @enumerate
4540 @item
4541 It is impossible to generate @code{#pragma} commands from a macro.
4543 @item
4544 There is no telling what the same @code{#pragma} might mean in another
4545 compiler.
4546 @end enumerate
4548 These two reasons applied to almost any application that might have been
4549 proposed for @code{#pragma}.  It was basically a mistake to use
4550 @code{#pragma} for @emph{anything}.
4552 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4553 to be generated from macros.  In addition, a @code{#pragma GCC}
4554 namespace is now in use for GCC-specific pragmas.  However, it has been
4555 found convenient to use @code{__attribute__} to achieve a natural
4556 attachment of attributes to their corresponding declarations, whereas
4557 @code{#pragma GCC} is of use for constructs that do not naturally form
4558 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4560 @node Label Attributes
4561 @section Label Attributes
4562 @cindex Label Attributes
4564 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
4565 details of the exact syntax for using attributes.  Other attributes are 
4566 available for functions (@pxref{Function Attributes}), variables 
4567 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4569 This example uses the @code{cold} label attribute to indicate the 
4570 @code{ErrorHandling} branch is unlikely to be taken and that the
4571 @code{ErrorHandling} label is unused:
4573 @smallexample
4575    asm goto ("some asm" : : : : NoError);
4577 /* This branch (the fallthru from the asm) is less commonly used */
4578 ErrorHandling: 
4579    __attribute__((cold, unused)); /* Semi-colon is required here */
4580    printf("error\n");
4581    return 0;
4583 NoError:
4584    printf("no error\n");
4585    return 1;
4586 @end smallexample
4588 @table @code
4589 @item unused
4590 @cindex @code{unused} label attribute
4591 This feature is intended for program-generated code that may contain 
4592 unused labels, but which is compiled with @option{-Wall}.  It is
4593 not normally appropriate to use in it human-written code, though it
4594 could be useful in cases where the code that jumps to the label is
4595 contained within an @code{#ifdef} conditional.
4597 @item hot
4598 @cindex @code{hot} label attribute
4599 The @code{hot} attribute on a label is used to inform the compiler that
4600 the path following the label is more likely than paths that are not so
4601 annotated.  This attribute is used in cases where @code{__builtin_expect}
4602 cannot be used, for instance with computed goto or @code{asm goto}.
4604 The @code{hot} attribute on labels is not implemented in GCC versions
4605 earlier than 4.8.
4607 @item cold
4608 @cindex @code{cold} label attribute
4609 The @code{cold} attribute on labels is used to inform the compiler that
4610 the path following the label is unlikely to be executed.  This attribute
4611 is used in cases where @code{__builtin_expect} cannot be used, for instance
4612 with computed goto or @code{asm goto}.
4614 The @code{cold} attribute on labels is not implemented in GCC versions
4615 earlier than 4.8.
4617 @end table
4619 @node Attribute Syntax
4620 @section Attribute Syntax
4621 @cindex attribute syntax
4623 This section describes the syntax with which @code{__attribute__} may be
4624 used, and the constructs to which attribute specifiers bind, for the C
4625 language.  Some details may vary for C++ and Objective-C@.  Because of
4626 infelicities in the grammar for attributes, some forms described here
4627 may not be successfully parsed in all cases.
4629 There are some problems with the semantics of attributes in C++.  For
4630 example, there are no manglings for attributes, although they may affect
4631 code generation, so problems may arise when attributed types are used in
4632 conjunction with templates or overloading.  Similarly, @code{typeid}
4633 does not distinguish between types with different attributes.  Support
4634 for attributes in C++ may be restricted in future to attributes on
4635 declarations only, but not on nested declarators.
4637 @xref{Function Attributes}, for details of the semantics of attributes
4638 applying to functions.  @xref{Variable Attributes}, for details of the
4639 semantics of attributes applying to variables.  @xref{Type Attributes},
4640 for details of the semantics of attributes applying to structure, union
4641 and enumerated types.
4642 @xref{Label Attributes}, for details of the semantics of attributes 
4643 applying to labels.
4645 An @dfn{attribute specifier} is of the form
4646 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4647 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4648 each attribute is one of the following:
4650 @itemize @bullet
4651 @item
4652 Empty.  Empty attributes are ignored.
4654 @item
4655 A word (which may be an identifier such as @code{unused}, or a reserved
4656 word such as @code{const}).
4658 @item
4659 A word, followed by, in parentheses, parameters for the attribute.
4660 These parameters take one of the following forms:
4662 @itemize @bullet
4663 @item
4664 An identifier.  For example, @code{mode} attributes use this form.
4666 @item
4667 An identifier followed by a comma and a non-empty comma-separated list
4668 of expressions.  For example, @code{format} attributes use this form.
4670 @item
4671 A possibly empty comma-separated list of expressions.  For example,
4672 @code{format_arg} attributes use this form with the list being a single
4673 integer constant expression, and @code{alias} attributes use this form
4674 with the list being a single string constant.
4675 @end itemize
4676 @end itemize
4678 An @dfn{attribute specifier list} is a sequence of one or more attribute
4679 specifiers, not separated by any other tokens.
4681 @subsubheading Label Attributes
4683 In GNU C, an attribute specifier list may appear after the colon following a
4684 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
4685 attributes on labels if the attribute specifier is immediately
4686 followed by a semicolon (i.e., the label applies to an empty
4687 statement).  If the semicolon is missing, C++ label attributes are
4688 ambiguous, as it is permissible for a declaration, which could begin
4689 with an attribute list, to be labelled in C++.  Declarations cannot be
4690 labelled in C90 or C99, so the ambiguity does not arise there.
4692 @subsubheading Type Attributes
4694 An attribute specifier list may appear as part of a @code{struct},
4695 @code{union} or @code{enum} specifier.  It may go either immediately
4696 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4697 the closing brace.  The former syntax is preferred.
4698 Where attribute specifiers follow the closing brace, they are considered
4699 to relate to the structure, union or enumerated type defined, not to any
4700 enclosing declaration the type specifier appears in, and the type
4701 defined is not complete until after the attribute specifiers.
4702 @c Otherwise, there would be the following problems: a shift/reduce
4703 @c conflict between attributes binding the struct/union/enum and
4704 @c binding to the list of specifiers/qualifiers; and "aligned"
4705 @c attributes could use sizeof for the structure, but the size could be
4706 @c changed later by "packed" attributes.
4709 @subsubheading All other attributes
4711 Otherwise, an attribute specifier appears as part of a declaration,
4712 counting declarations of unnamed parameters and type names, and relates
4713 to that declaration (which may be nested in another declaration, for
4714 example in the case of a parameter declaration), or to a particular declarator
4715 within a declaration.  Where an
4716 attribute specifier is applied to a parameter declared as a function or
4717 an array, it should apply to the function or array rather than the
4718 pointer to which the parameter is implicitly converted, but this is not
4719 yet correctly implemented.
4721 Any list of specifiers and qualifiers at the start of a declaration may
4722 contain attribute specifiers, whether or not such a list may in that
4723 context contain storage class specifiers.  (Some attributes, however,
4724 are essentially in the nature of storage class specifiers, and only make
4725 sense where storage class specifiers may be used; for example,
4726 @code{section}.)  There is one necessary limitation to this syntax: the
4727 first old-style parameter declaration in a function definition cannot
4728 begin with an attribute specifier, because such an attribute applies to
4729 the function instead by syntax described below (which, however, is not
4730 yet implemented in this case).  In some other cases, attribute
4731 specifiers are permitted by this grammar but not yet supported by the
4732 compiler.  All attribute specifiers in this place relate to the
4733 declaration as a whole.  In the obsolescent usage where a type of
4734 @code{int} is implied by the absence of type specifiers, such a list of
4735 specifiers and qualifiers may be an attribute specifier list with no
4736 other specifiers or qualifiers.
4738 At present, the first parameter in a function prototype must have some
4739 type specifier that is not an attribute specifier; this resolves an
4740 ambiguity in the interpretation of @code{void f(int
4741 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4742 the parentheses of a function declarator contain only attributes then
4743 those attributes are ignored, rather than yielding an error or warning
4744 or implying a single parameter of type int, but this is subject to
4745 change.
4747 An attribute specifier list may appear immediately before a declarator
4748 (other than the first) in a comma-separated list of declarators in a
4749 declaration of more than one identifier using a single list of
4750 specifiers and qualifiers.  Such attribute specifiers apply
4751 only to the identifier before whose declarator they appear.  For
4752 example, in
4754 @smallexample
4755 __attribute__((noreturn)) void d0 (void),
4756     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4757      d2 (void)
4758 @end smallexample
4760 @noindent
4761 the @code{noreturn} attribute applies to all the functions
4762 declared; the @code{format} attribute only applies to @code{d1}.
4764 An attribute specifier list may appear immediately before the comma,
4765 @code{=} or semicolon terminating the declaration of an identifier other
4766 than a function definition.  Such attribute specifiers apply
4767 to the declared object or function.  Where an
4768 assembler name for an object or function is specified (@pxref{Asm
4769 Labels}), the attribute must follow the @code{asm}
4770 specification.
4772 An attribute specifier list may, in future, be permitted to appear after
4773 the declarator in a function definition (before any old-style parameter
4774 declarations or the function body).
4776 Attribute specifiers may be mixed with type qualifiers appearing inside
4777 the @code{[]} of a parameter array declarator, in the C99 construct by
4778 which such qualifiers are applied to the pointer to which the array is
4779 implicitly converted.  Such attribute specifiers apply to the pointer,
4780 not to the array, but at present this is not implemented and they are
4781 ignored.
4783 An attribute specifier list may appear at the start of a nested
4784 declarator.  At present, there are some limitations in this usage: the
4785 attributes correctly apply to the declarator, but for most individual
4786 attributes the semantics this implies are not implemented.
4787 When attribute specifiers follow the @code{*} of a pointer
4788 declarator, they may be mixed with any type qualifiers present.
4789 The following describes the formal semantics of this syntax.  It makes the
4790 most sense if you are familiar with the formal specification of
4791 declarators in the ISO C standard.
4793 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4794 D1}, where @code{T} contains declaration specifiers that specify a type
4795 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4796 contains an identifier @var{ident}.  The type specified for @var{ident}
4797 for derived declarators whose type does not include an attribute
4798 specifier is as in the ISO C standard.
4800 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4801 and the declaration @code{T D} specifies the type
4802 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4803 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4804 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4806 If @code{D1} has the form @code{*
4807 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4808 declaration @code{T D} specifies the type
4809 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4810 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4811 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4812 @var{ident}.
4814 For example,
4816 @smallexample
4817 void (__attribute__((noreturn)) ****f) (void);
4818 @end smallexample
4820 @noindent
4821 specifies the type ``pointer to pointer to pointer to pointer to
4822 non-returning function returning @code{void}''.  As another example,
4824 @smallexample
4825 char *__attribute__((aligned(8))) *f;
4826 @end smallexample
4828 @noindent
4829 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4830 Note again that this does not work with most attributes; for example,
4831 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4832 is not yet supported.
4834 For compatibility with existing code written for compiler versions that
4835 did not implement attributes on nested declarators, some laxity is
4836 allowed in the placing of attributes.  If an attribute that only applies
4837 to types is applied to a declaration, it is treated as applying to
4838 the type of that declaration.  If an attribute that only applies to
4839 declarations is applied to the type of a declaration, it is treated
4840 as applying to that declaration; and, for compatibility with code
4841 placing the attributes immediately before the identifier declared, such
4842 an attribute applied to a function return type is treated as
4843 applying to the function type, and such an attribute applied to an array
4844 element type is treated as applying to the array type.  If an
4845 attribute that only applies to function types is applied to a
4846 pointer-to-function type, it is treated as applying to the pointer
4847 target type; if such an attribute is applied to a function return type
4848 that is not a pointer-to-function type, it is treated as applying
4849 to the function type.
4851 @node Function Prototypes
4852 @section Prototypes and Old-Style Function Definitions
4853 @cindex function prototype declarations
4854 @cindex old-style function definitions
4855 @cindex promotion of formal parameters
4857 GNU C extends ISO C to allow a function prototype to override a later
4858 old-style non-prototype definition.  Consider the following example:
4860 @smallexample
4861 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4862 #ifdef __STDC__
4863 #define P(x) x
4864 #else
4865 #define P(x) ()
4866 #endif
4868 /* @r{Prototype function declaration.}  */
4869 int isroot P((uid_t));
4871 /* @r{Old-style function definition.}  */
4873 isroot (x)   /* @r{??? lossage here ???} */
4874      uid_t x;
4876   return x == 0;
4878 @end smallexample
4880 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4881 not allow this example, because subword arguments in old-style
4882 non-prototype definitions are promoted.  Therefore in this example the
4883 function definition's argument is really an @code{int}, which does not
4884 match the prototype argument type of @code{short}.
4886 This restriction of ISO C makes it hard to write code that is portable
4887 to traditional C compilers, because the programmer does not know
4888 whether the @code{uid_t} type is @code{short}, @code{int}, or
4889 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4890 to override a later old-style definition.  More precisely, in GNU C, a
4891 function prototype argument type overrides the argument type specified
4892 by a later old-style definition if the former type is the same as the
4893 latter type before promotion.  Thus in GNU C the above example is
4894 equivalent to the following:
4896 @smallexample
4897 int isroot (uid_t);
4900 isroot (uid_t x)
4902   return x == 0;
4904 @end smallexample
4906 @noindent
4907 GNU C++ does not support old-style function definitions, so this
4908 extension is irrelevant.
4910 @node C++ Comments
4911 @section C++ Style Comments
4912 @cindex @code{//}
4913 @cindex C++ comments
4914 @cindex comments, C++ style
4916 In GNU C, you may use C++ style comments, which start with @samp{//} and
4917 continue until the end of the line.  Many other C implementations allow
4918 such comments, and they are included in the 1999 C standard.  However,
4919 C++ style comments are not recognized if you specify an @option{-std}
4920 option specifying a version of ISO C before C99, or @option{-ansi}
4921 (equivalent to @option{-std=c90}).
4923 @node Dollar Signs
4924 @section Dollar Signs in Identifier Names
4925 @cindex $
4926 @cindex dollar signs in identifier names
4927 @cindex identifier names, dollar signs in
4929 In GNU C, you may normally use dollar signs in identifier names.
4930 This is because many traditional C implementations allow such identifiers.
4931 However, dollar signs in identifiers are not supported on a few target
4932 machines, typically because the target assembler does not allow them.
4934 @node Character Escapes
4935 @section The Character @key{ESC} in Constants
4937 You can use the sequence @samp{\e} in a string or character constant to
4938 stand for the ASCII character @key{ESC}.
4940 @node Variable Attributes
4941 @section Specifying Attributes of Variables
4942 @cindex attribute of variables
4943 @cindex variable attributes
4945 The keyword @code{__attribute__} allows you to specify special
4946 attributes of variables or structure fields.  This keyword is followed
4947 by an attribute specification inside double parentheses.  Some
4948 attributes are currently defined generically for variables.
4949 Other attributes are defined for variables on particular target
4950 systems.  Other attributes are available for functions
4951 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
4952 types (@pxref{Type Attributes}).
4953 Other front ends might define more attributes
4954 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4956 You may also specify attributes with @samp{__} preceding and following
4957 each keyword.  This allows you to use them in header files without
4958 being concerned about a possible macro of the same name.  For example,
4959 you may use @code{__aligned__} instead of @code{aligned}.
4961 @xref{Attribute Syntax}, for details of the exact syntax for using
4962 attributes.
4964 @table @code
4965 @cindex @code{aligned} attribute
4966 @item aligned (@var{alignment})
4967 This attribute specifies a minimum alignment for the variable or
4968 structure field, measured in bytes.  For example, the declaration:
4970 @smallexample
4971 int x __attribute__ ((aligned (16))) = 0;
4972 @end smallexample
4974 @noindent
4975 causes the compiler to allocate the global variable @code{x} on a
4976 16-byte boundary.  On a 68040, this could be used in conjunction with
4977 an @code{asm} expression to access the @code{move16} instruction which
4978 requires 16-byte aligned operands.
4980 You can also specify the alignment of structure fields.  For example, to
4981 create a double-word aligned @code{int} pair, you could write:
4983 @smallexample
4984 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4985 @end smallexample
4987 @noindent
4988 This is an alternative to creating a union with a @code{double} member,
4989 which forces the union to be double-word aligned.
4991 As in the preceding examples, you can explicitly specify the alignment
4992 (in bytes) that you wish the compiler to use for a given variable or
4993 structure field.  Alternatively, you can leave out the alignment factor
4994 and just ask the compiler to align a variable or field to the
4995 default alignment for the target architecture you are compiling for.
4996 The default alignment is sufficient for all scalar types, but may not be
4997 enough for all vector types on a target that supports vector operations.
4998 The default alignment is fixed for a particular target ABI.
5000 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5001 which is the largest alignment ever used for any data type on the
5002 target machine you are compiling for.  For example, you could write:
5004 @smallexample
5005 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5006 @end smallexample
5008 The compiler automatically sets the alignment for the declared
5009 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5010 often make copy operations more efficient, because the compiler can
5011 use whatever instructions copy the biggest chunks of memory when
5012 performing copies to or from the variables or fields that you have
5013 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5014 may change depending on command-line options.
5016 When used on a struct, or struct member, the @code{aligned} attribute can
5017 only increase the alignment; in order to decrease it, the @code{packed}
5018 attribute must be specified as well.  When used as part of a typedef, the
5019 @code{aligned} attribute can both increase and decrease alignment, and
5020 specifying the @code{packed} attribute generates a warning.
5022 Note that the effectiveness of @code{aligned} attributes may be limited
5023 by inherent limitations in your linker.  On many systems, the linker is
5024 only able to arrange for variables to be aligned up to a certain maximum
5025 alignment.  (For some linkers, the maximum supported alignment may
5026 be very very small.)  If your linker is only able to align variables
5027 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5028 in an @code{__attribute__} still only provides you with 8-byte
5029 alignment.  See your linker documentation for further information.
5031 The @code{aligned} attribute can also be used for functions
5032 (@pxref{Function Attributes}.)
5034 @item cleanup (@var{cleanup_function})
5035 @cindex @code{cleanup} attribute
5036 The @code{cleanup} attribute runs a function when the variable goes
5037 out of scope.  This attribute can only be applied to auto function
5038 scope variables; it may not be applied to parameters or variables
5039 with static storage duration.  The function must take one parameter,
5040 a pointer to a type compatible with the variable.  The return value
5041 of the function (if any) is ignored.
5043 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5044 is run during the stack unwinding that happens during the
5045 processing of the exception.  Note that the @code{cleanup} attribute
5046 does not allow the exception to be caught, only to perform an action.
5047 It is undefined what happens if @var{cleanup_function} does not
5048 return normally.
5050 @item common
5051 @itemx nocommon
5052 @cindex @code{common} attribute
5053 @cindex @code{nocommon} attribute
5054 @opindex fcommon
5055 @opindex fno-common
5056 The @code{common} attribute requests GCC to place a variable in
5057 ``common'' storage.  The @code{nocommon} attribute requests the
5058 opposite---to allocate space for it directly.
5060 These attributes override the default chosen by the
5061 @option{-fno-common} and @option{-fcommon} flags respectively.
5063 @item deprecated
5064 @itemx deprecated (@var{msg})
5065 @cindex @code{deprecated} attribute
5066 The @code{deprecated} attribute results in a warning if the variable
5067 is used anywhere in the source file.  This is useful when identifying
5068 variables that are expected to be removed in a future version of a
5069 program.  The warning also includes the location of the declaration
5070 of the deprecated variable, to enable users to easily find further
5071 information about why the variable is deprecated, or what they should
5072 do instead.  Note that the warning only occurs for uses:
5074 @smallexample
5075 extern int old_var __attribute__ ((deprecated));
5076 extern int old_var;
5077 int new_fn () @{ return old_var; @}
5078 @end smallexample
5080 @noindent
5081 results in a warning on line 3 but not line 2.  The optional @var{msg}
5082 argument, which must be a string, is printed in the warning if
5083 present.
5085 The @code{deprecated} attribute can also be used for functions and
5086 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5088 @item mode (@var{mode})
5089 @cindex @code{mode} attribute
5090 This attribute specifies the data type for the declaration---whichever
5091 type corresponds to the mode @var{mode}.  This in effect lets you
5092 request an integer or floating-point type according to its width.
5094 You may also specify a mode of @code{byte} or @code{__byte__} to
5095 indicate the mode corresponding to a one-byte integer, @code{word} or
5096 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5097 or @code{__pointer__} for the mode used to represent pointers.
5099 @item packed
5100 @cindex @code{packed} attribute
5101 The @code{packed} attribute specifies that a variable or structure field
5102 should have the smallest possible alignment---one byte for a variable,
5103 and one bit for a field, unless you specify a larger value with the
5104 @code{aligned} attribute.
5106 Here is a structure in which the field @code{x} is packed, so that it
5107 immediately follows @code{a}:
5109 @smallexample
5110 struct foo
5112   char a;
5113   int x[2] __attribute__ ((packed));
5115 @end smallexample
5117 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5118 @code{packed} attribute on bit-fields of type @code{char}.  This has
5119 been fixed in GCC 4.4 but the change can lead to differences in the
5120 structure layout.  See the documentation of
5121 @option{-Wpacked-bitfield-compat} for more information.
5123 @item section ("@var{section-name}")
5124 @cindex @code{section} variable attribute
5125 Normally, the compiler places the objects it generates in sections like
5126 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5127 or you need certain particular variables to appear in special sections,
5128 for example to map to special hardware.  The @code{section}
5129 attribute specifies that a variable (or function) lives in a particular
5130 section.  For example, this small program uses several specific section names:
5132 @smallexample
5133 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5134 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5135 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5136 int init_data __attribute__ ((section ("INITDATA")));
5138 main()
5140   /* @r{Initialize stack pointer} */
5141   init_sp (stack + sizeof (stack));
5143   /* @r{Initialize initialized data} */
5144   memcpy (&init_data, &data, &edata - &data);
5146   /* @r{Turn on the serial ports} */
5147   init_duart (&a);
5148   init_duart (&b);
5150 @end smallexample
5152 @noindent
5153 Use the @code{section} attribute with
5154 @emph{global} variables and not @emph{local} variables,
5155 as shown in the example.
5157 You may use the @code{section} attribute with initialized or
5158 uninitialized global variables but the linker requires
5159 each object be defined once, with the exception that uninitialized
5160 variables tentatively go in the @code{common} (or @code{bss}) section
5161 and can be multiply ``defined''.  Using the @code{section} attribute
5162 changes what section the variable goes into and may cause the
5163 linker to issue an error if an uninitialized variable has multiple
5164 definitions.  You can force a variable to be initialized with the
5165 @option{-fno-common} flag or the @code{nocommon} attribute.
5167 Some file formats do not support arbitrary sections so the @code{section}
5168 attribute is not available on all platforms.
5169 If you need to map the entire contents of a module to a particular
5170 section, consider using the facilities of the linker instead.
5172 @item shared
5173 @cindex @code{shared} variable attribute
5174 On Microsoft Windows, in addition to putting variable definitions in a named
5175 section, the section can also be shared among all running copies of an
5176 executable or DLL@.  For example, this small program defines shared data
5177 by putting it in a named section @code{shared} and marking the section
5178 shareable:
5180 @smallexample
5181 int foo __attribute__((section ("shared"), shared)) = 0;
5184 main()
5186   /* @r{Read and write foo.  All running
5187      copies see the same value.}  */
5188   return 0;
5190 @end smallexample
5192 @noindent
5193 You may only use the @code{shared} attribute along with @code{section}
5194 attribute with a fully-initialized global definition because of the way
5195 linkers work.  See @code{section} attribute for more information.
5197 The @code{shared} attribute is only available on Microsoft Windows@.
5199 @item tls_model ("@var{tls_model}")
5200 @cindex @code{tls_model} attribute
5201 The @code{tls_model} attribute sets thread-local storage model
5202 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5203 overriding @option{-ftls-model=} command-line switch on a per-variable
5204 basis.
5205 The @var{tls_model} argument should be one of @code{global-dynamic},
5206 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5208 Not all targets support this attribute.
5210 @item unused
5211 This attribute, attached to a variable, means that the variable is meant
5212 to be possibly unused.  GCC does not produce a warning for this
5213 variable.
5215 @item used
5216 This attribute, attached to a variable with the static storage, means that
5217 the variable must be emitted even if it appears that the variable is not
5218 referenced.
5220 When applied to a static data member of a C++ class template, the
5221 attribute also means that the member is instantiated if the
5222 class itself is instantiated.
5224 @item vector_size (@var{bytes})
5225 This attribute specifies the vector size for the variable, measured in
5226 bytes.  For example, the declaration:
5228 @smallexample
5229 int foo __attribute__ ((vector_size (16)));
5230 @end smallexample
5232 @noindent
5233 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5234 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5235 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5237 This attribute is only applicable to integral and float scalars,
5238 although arrays, pointers, and function return values are allowed in
5239 conjunction with this construct.
5241 Aggregates with this attribute are invalid, even if they are of the same
5242 size as a corresponding scalar.  For example, the declaration:
5244 @smallexample
5245 struct S @{ int a; @};
5246 struct S  __attribute__ ((vector_size (16))) foo;
5247 @end smallexample
5249 @noindent
5250 is invalid even if the size of the structure is the same as the size of
5251 the @code{int}.
5253 @item selectany
5254 The @code{selectany} attribute causes an initialized global variable to
5255 have link-once semantics.  When multiple definitions of the variable are
5256 encountered by the linker, the first is selected and the remainder are
5257 discarded.  Following usage by the Microsoft compiler, the linker is told
5258 @emph{not} to warn about size or content differences of the multiple
5259 definitions.
5261 Although the primary usage of this attribute is for POD types, the
5262 attribute can also be applied to global C++ objects that are initialized
5263 by a constructor.  In this case, the static initialization and destruction
5264 code for the object is emitted in each translation defining the object,
5265 but the calls to the constructor and destructor are protected by a
5266 link-once guard variable.
5268 The @code{selectany} attribute is only available on Microsoft Windows
5269 targets.  You can use @code{__declspec (selectany)} as a synonym for
5270 @code{__attribute__ ((selectany))} for compatibility with other
5271 compilers.
5273 @item weak
5274 The @code{weak} attribute is described in @ref{Function Attributes}.
5276 @item dllimport
5277 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5279 @item dllexport
5280 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5282 @end table
5284 @anchor{AVR Variable Attributes}
5285 @subsection AVR Variable Attributes
5287 @table @code
5288 @item progmem
5289 @cindex @code{progmem} AVR variable attribute
5290 The @code{progmem} attribute is used on the AVR to place read-only
5291 data in the non-volatile program memory (flash). The @code{progmem}
5292 attribute accomplishes this by putting respective variables into a
5293 section whose name starts with @code{.progmem}.
5295 This attribute works similar to the @code{section} attribute
5296 but adds additional checking. Notice that just like the
5297 @code{section} attribute, @code{progmem} affects the location
5298 of the data but not how this data is accessed.
5300 In order to read data located with the @code{progmem} attribute
5301 (inline) assembler must be used.
5302 @smallexample
5303 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5304 #include <avr/pgmspace.h> 
5306 /* Locate var in flash memory */
5307 const int var[2] PROGMEM = @{ 1, 2 @};
5309 int read_var (int i)
5311     /* Access var[] by accessor macro from avr/pgmspace.h */
5312     return (int) pgm_read_word (& var[i]);
5314 @end smallexample
5316 AVR is a Harvard architecture processor and data and read-only data
5317 normally resides in the data memory (RAM).
5319 See also the @ref{AVR Named Address Spaces} section for
5320 an alternate way to locate and access data in flash memory.
5322 @item io
5323 @itemx io (@var{addr})
5324 Variables with the @code{io} attribute are used to address
5325 memory-mapped peripherals in the io address range.
5326 If an address is specified, the variable
5327 is assigned that address, and the value is interpreted as an
5328 address in the data address space.
5329 Example:
5331 @smallexample
5332 volatile int porta __attribute__((io (0x22)));
5333 @end smallexample
5335 The address specified in the address in the data address range.
5337 Otherwise, the variable it is not assigned an address, but the
5338 compiler will still use in/out instructions where applicable,
5339 assuming some other module assigns an address in the io address range.
5340 Example:
5342 @smallexample
5343 extern volatile int porta __attribute__((io));
5344 @end smallexample
5346 @item io_low
5347 @itemx io_low (@var{addr})
5348 This is like the @code{io} attribute, but additionally it informs the
5349 compiler that the object lies in the lower half of the I/O area,
5350 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5351 instructions.
5353 @item address
5354 @itemx address (@var{addr})
5355 Variables with the @code{address} attribute are used to address
5356 memory-mapped peripherals that may lie outside the io address range.
5358 @smallexample
5359 volatile int porta __attribute__((address (0x600)));
5360 @end smallexample
5362 @end table
5364 @subsection Blackfin Variable Attributes
5366 Three attributes are currently defined for the Blackfin.
5368 @table @code
5369 @item l1_data
5370 @itemx l1_data_A
5371 @itemx l1_data_B
5372 @cindex @code{l1_data} variable attribute
5373 @cindex @code{l1_data_A} variable attribute
5374 @cindex @code{l1_data_B} variable attribute
5375 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5376 Variables with @code{l1_data} attribute are put into the specific section
5377 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5378 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5379 attribute are put into the specific section named @code{.l1.data.B}.
5381 @item l2
5382 @cindex @code{l2} variable attribute
5383 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5384 Variables with @code{l2} attribute are put into the specific section
5385 named @code{.l2.data}.
5386 @end table
5388 @subsection M32R/D Variable Attributes
5390 One attribute is currently defined for the M32R/D@.
5392 @table @code
5393 @item model (@var{model-name})
5394 @cindex variable addressability on the M32R/D
5395 Use this attribute on the M32R/D to set the addressability of an object.
5396 The identifier @var{model-name} is one of @code{small}, @code{medium},
5397 or @code{large}, representing each of the code models.
5399 Small model objects live in the lower 16MB of memory (so that their
5400 addresses can be loaded with the @code{ld24} instruction).
5402 Medium and large model objects may live anywhere in the 32-bit address space
5403 (the compiler generates @code{seth/add3} instructions to load their
5404 addresses).
5405 @end table
5407 @anchor{MeP Variable Attributes}
5408 @subsection MeP Variable Attributes
5410 The MeP target has a number of addressing modes and busses.  The
5411 @code{near} space spans the standard memory space's first 16 megabytes
5412 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5413 The @code{based} space is a 128-byte region in the memory space that
5414 is addressed relative to the @code{$tp} register.  The @code{tiny}
5415 space is a 65536-byte region relative to the @code{$gp} register.  In
5416 addition to these memory regions, the MeP target has a separate 16-bit
5417 control bus which is specified with @code{cb} attributes.
5419 @table @code
5421 @item based
5422 Any variable with the @code{based} attribute is assigned to the
5423 @code{.based} section, and is accessed with relative to the
5424 @code{$tp} register.
5426 @item tiny
5427 Likewise, the @code{tiny} attribute assigned variables to the
5428 @code{.tiny} section, relative to the @code{$gp} register.
5430 @item near
5431 Variables with the @code{near} attribute are assumed to have addresses
5432 that fit in a 24-bit addressing mode.  This is the default for large
5433 variables (@code{-mtiny=4} is the default) but this attribute can
5434 override @code{-mtiny=} for small variables, or override @code{-ml}.
5436 @item far
5437 Variables with the @code{far} attribute are addressed using a full
5438 32-bit address.  Since this covers the entire memory space, this
5439 allows modules to make no assumptions about where variables might be
5440 stored.
5442 @item io
5443 @itemx io (@var{addr})
5444 Variables with the @code{io} attribute are used to address
5445 memory-mapped peripherals.  If an address is specified, the variable
5446 is assigned that address, else it is not assigned an address (it is
5447 assumed some other module assigns an address).  Example:
5449 @smallexample
5450 int timer_count __attribute__((io(0x123)));
5451 @end smallexample
5453 @item cb
5454 @itemx cb (@var{addr})
5455 Variables with the @code{cb} attribute are used to access the control
5456 bus, using special instructions.  @code{addr} indicates the control bus
5457 address.  Example:
5459 @smallexample
5460 int cpu_clock __attribute__((cb(0x123)));
5461 @end smallexample
5463 @end table
5465 @anchor{i386 Variable Attributes}
5466 @subsection i386 Variable Attributes
5468 Two attributes are currently defined for i386 configurations:
5469 @code{ms_struct} and @code{gcc_struct}
5471 @table @code
5472 @item ms_struct
5473 @itemx gcc_struct
5474 @cindex @code{ms_struct} attribute
5475 @cindex @code{gcc_struct} attribute
5477 If @code{packed} is used on a structure, or if bit-fields are used,
5478 it may be that the Microsoft ABI lays out the structure differently
5479 than the way GCC normally does.  Particularly when moving packed
5480 data between functions compiled with GCC and the native Microsoft compiler
5481 (either via function call or as data in a file), it may be necessary to access
5482 either format.
5484 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5485 compilers to match the native Microsoft compiler.
5487 The Microsoft structure layout algorithm is fairly simple with the exception
5488 of the bit-field packing.  
5489 The padding and alignment of members of structures and whether a bit-field 
5490 can straddle a storage-unit boundary are determine by these rules:
5492 @enumerate
5493 @item Structure members are stored sequentially in the order in which they are
5494 declared: the first member has the lowest memory address and the last member
5495 the highest.
5497 @item Every data object has an alignment requirement.  The alignment requirement
5498 for all data except structures, unions, and arrays is either the size of the
5499 object or the current packing size (specified with either the
5500 @code{aligned} attribute or the @code{pack} pragma),
5501 whichever is less.  For structures, unions, and arrays,
5502 the alignment requirement is the largest alignment requirement of its members.
5503 Every object is allocated an offset so that:
5505 @smallexample
5506 offset % alignment_requirement == 0
5507 @end smallexample
5509 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5510 unit if the integral types are the same size and if the next bit-field fits
5511 into the current allocation unit without crossing the boundary imposed by the
5512 common alignment requirements of the bit-fields.
5513 @end enumerate
5515 MSVC interprets zero-length bit-fields in the following ways:
5517 @enumerate
5518 @item If a zero-length bit-field is inserted between two bit-fields that
5519 are normally coalesced, the bit-fields are not coalesced.
5521 For example:
5523 @smallexample
5524 struct
5525  @{
5526    unsigned long bf_1 : 12;
5527    unsigned long : 0;
5528    unsigned long bf_2 : 12;
5529  @} t1;
5530 @end smallexample
5532 @noindent
5533 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5534 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5536 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5537 alignment of the zero-length bit-field is greater than the member that follows it,
5538 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5540 For example:
5542 @smallexample
5543 struct
5544  @{
5545    char foo : 4;
5546    short : 0;
5547    char bar;
5548  @} t2;
5550 struct
5551  @{
5552    char foo : 4;
5553    short : 0;
5554    double bar;
5555  @} t3;
5556 @end smallexample
5558 @noindent
5559 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5560 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5561 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5562 of the structure.
5564 Taking this into account, it is important to note the following:
5566 @enumerate
5567 @item If a zero-length bit-field follows a normal bit-field, the type of the
5568 zero-length bit-field may affect the alignment of the structure as whole. For
5569 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5570 normal bit-field, and is of type short.
5572 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5573 still affect the alignment of the structure:
5575 @smallexample
5576 struct
5577  @{
5578    char foo : 6;
5579    long : 0;
5580  @} t4;
5581 @end smallexample
5583 @noindent
5584 Here, @code{t4} takes up 4 bytes.
5585 @end enumerate
5587 @item Zero-length bit-fields following non-bit-field members are ignored:
5589 @smallexample
5590 struct
5591  @{
5592    char foo;
5593    long : 0;
5594    char bar;
5595  @} t5;
5596 @end smallexample
5598 @noindent
5599 Here, @code{t5} takes up 2 bytes.
5600 @end enumerate
5601 @end table
5603 @subsection PowerPC Variable Attributes
5605 Three attributes currently are defined for PowerPC configurations:
5606 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5608 For full documentation of the struct attributes please see the
5609 documentation in @ref{i386 Variable Attributes}.
5611 For documentation of @code{altivec} attribute please see the
5612 documentation in @ref{PowerPC Type Attributes}.
5614 @subsection SPU Variable Attributes
5616 The SPU supports the @code{spu_vector} attribute for variables.  For
5617 documentation of this attribute please see the documentation in
5618 @ref{SPU Type Attributes}.
5620 @subsection Xstormy16 Variable Attributes
5622 One attribute is currently defined for xstormy16 configurations:
5623 @code{below100}.
5625 @table @code
5626 @item below100
5627 @cindex @code{below100} attribute
5629 If a variable has the @code{below100} attribute (@code{BELOW100} is
5630 allowed also), GCC places the variable in the first 0x100 bytes of
5631 memory and use special opcodes to access it.  Such variables are
5632 placed in either the @code{.bss_below100} section or the
5633 @code{.data_below100} section.
5635 @end table
5637 @node Type Attributes
5638 @section Specifying Attributes of Types
5639 @cindex attribute of types
5640 @cindex type attributes
5642 The keyword @code{__attribute__} allows you to specify special
5643 attributes of @code{struct} and @code{union} types when you define
5644 such types.  This keyword is followed by an attribute specification
5645 inside double parentheses.  Seven attributes are currently defined for
5646 types: @code{aligned}, @code{packed}, @code{transparent_union},
5647 @code{unused}, @code{deprecated}, @code{visibility}, and
5648 @code{may_alias}.  Other attributes are defined for functions
5649 (@pxref{Function Attributes}), labels (@pxref{Label 
5650 Attributes}) and for variables (@pxref{Variable Attributes}).
5652 You may also specify any one of these attributes with @samp{__}
5653 preceding and following its keyword.  This allows you to use these
5654 attributes in header files without being concerned about a possible
5655 macro of the same name.  For example, you may use @code{__aligned__}
5656 instead of @code{aligned}.
5658 You may specify type attributes in an enum, struct or union type
5659 declaration or definition, or for other types in a @code{typedef}
5660 declaration.
5662 For an enum, struct or union type, you may specify attributes either
5663 between the enum, struct or union tag and the name of the type, or
5664 just past the closing curly brace of the @emph{definition}.  The
5665 former syntax is preferred.
5667 @xref{Attribute Syntax}, for details of the exact syntax for using
5668 attributes.
5670 @table @code
5671 @cindex @code{aligned} attribute
5672 @item aligned (@var{alignment})
5673 This attribute specifies a minimum alignment (in bytes) for variables
5674 of the specified type.  For example, the declarations:
5676 @smallexample
5677 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5678 typedef int more_aligned_int __attribute__ ((aligned (8)));
5679 @end smallexample
5681 @noindent
5682 force the compiler to ensure (as far as it can) that each variable whose
5683 type is @code{struct S} or @code{more_aligned_int} is allocated and
5684 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5685 variables of type @code{struct S} aligned to 8-byte boundaries allows
5686 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5687 store) instructions when copying one variable of type @code{struct S} to
5688 another, thus improving run-time efficiency.
5690 Note that the alignment of any given @code{struct} or @code{union} type
5691 is required by the ISO C standard to be at least a perfect multiple of
5692 the lowest common multiple of the alignments of all of the members of
5693 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5694 effectively adjust the alignment of a @code{struct} or @code{union}
5695 type by attaching an @code{aligned} attribute to any one of the members
5696 of such a type, but the notation illustrated in the example above is a
5697 more obvious, intuitive, and readable way to request the compiler to
5698 adjust the alignment of an entire @code{struct} or @code{union} type.
5700 As in the preceding example, you can explicitly specify the alignment
5701 (in bytes) that you wish the compiler to use for a given @code{struct}
5702 or @code{union} type.  Alternatively, you can leave out the alignment factor
5703 and just ask the compiler to align a type to the maximum
5704 useful alignment for the target machine you are compiling for.  For
5705 example, you could write:
5707 @smallexample
5708 struct S @{ short f[3]; @} __attribute__ ((aligned));
5709 @end smallexample
5711 Whenever you leave out the alignment factor in an @code{aligned}
5712 attribute specification, the compiler automatically sets the alignment
5713 for the type to the largest alignment that is ever used for any data
5714 type on the target machine you are compiling for.  Doing this can often
5715 make copy operations more efficient, because the compiler can use
5716 whatever instructions copy the biggest chunks of memory when performing
5717 copies to or from the variables that have types that you have aligned
5718 this way.
5720 In the example above, if the size of each @code{short} is 2 bytes, then
5721 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5722 power of two that is greater than or equal to that is 8, so the
5723 compiler sets the alignment for the entire @code{struct S} type to 8
5724 bytes.
5726 Note that although you can ask the compiler to select a time-efficient
5727 alignment for a given type and then declare only individual stand-alone
5728 objects of that type, the compiler's ability to select a time-efficient
5729 alignment is primarily useful only when you plan to create arrays of
5730 variables having the relevant (efficiently aligned) type.  If you
5731 declare or use arrays of variables of an efficiently-aligned type, then
5732 it is likely that your program also does pointer arithmetic (or
5733 subscripting, which amounts to the same thing) on pointers to the
5734 relevant type, and the code that the compiler generates for these
5735 pointer arithmetic operations is often more efficient for
5736 efficiently-aligned types than for other types.
5738 The @code{aligned} attribute can only increase the alignment; but you
5739 can decrease it by specifying @code{packed} as well.  See below.
5741 Note that the effectiveness of @code{aligned} attributes may be limited
5742 by inherent limitations in your linker.  On many systems, the linker is
5743 only able to arrange for variables to be aligned up to a certain maximum
5744 alignment.  (For some linkers, the maximum supported alignment may
5745 be very very small.)  If your linker is only able to align variables
5746 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5747 in an @code{__attribute__} still only provides you with 8-byte
5748 alignment.  See your linker documentation for further information.
5750 @item packed
5751 This attribute, attached to @code{struct} or @code{union} type
5752 definition, specifies that each member (other than zero-width bit-fields)
5753 of the structure or union is placed to minimize the memory required.  When
5754 attached to an @code{enum} definition, it indicates that the smallest
5755 integral type should be used.
5757 @opindex fshort-enums
5758 Specifying this attribute for @code{struct} and @code{union} types is
5759 equivalent to specifying the @code{packed} attribute on each of the
5760 structure or union members.  Specifying the @option{-fshort-enums}
5761 flag on the line is equivalent to specifying the @code{packed}
5762 attribute on all @code{enum} definitions.
5764 In the following example @code{struct my_packed_struct}'s members are
5765 packed closely together, but the internal layout of its @code{s} member
5766 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5767 be packed too.
5769 @smallexample
5770 struct my_unpacked_struct
5771  @{
5772     char c;
5773     int i;
5774  @};
5776 struct __attribute__ ((__packed__)) my_packed_struct
5777   @{
5778      char c;
5779      int  i;
5780      struct my_unpacked_struct s;
5781   @};
5782 @end smallexample
5784 You may only specify this attribute on the definition of an @code{enum},
5785 @code{struct} or @code{union}, not on a @code{typedef} that does not
5786 also define the enumerated type, structure or union.
5788 @item transparent_union
5789 @cindex @code{transparent_union} attribute
5791 This attribute, attached to a @code{union} type definition, indicates
5792 that any function parameter having that union type causes calls to that
5793 function to be treated in a special way.
5795 First, the argument corresponding to a transparent union type can be of
5796 any type in the union; no cast is required.  Also, if the union contains
5797 a pointer type, the corresponding argument can be a null pointer
5798 constant or a void pointer expression; and if the union contains a void
5799 pointer type, the corresponding argument can be any pointer expression.
5800 If the union member type is a pointer, qualifiers like @code{const} on
5801 the referenced type must be respected, just as with normal pointer
5802 conversions.
5804 Second, the argument is passed to the function using the calling
5805 conventions of the first member of the transparent union, not the calling
5806 conventions of the union itself.  All members of the union must have the
5807 same machine representation; this is necessary for this argument passing
5808 to work properly.
5810 Transparent unions are designed for library functions that have multiple
5811 interfaces for compatibility reasons.  For example, suppose the
5812 @code{wait} function must accept either a value of type @code{int *} to
5813 comply with POSIX, or a value of type @code{union wait *} to comply with
5814 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5815 @code{wait} would accept both kinds of arguments, but it would also
5816 accept any other pointer type and this would make argument type checking
5817 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5818 as follows:
5820 @smallexample
5821 typedef union __attribute__ ((__transparent_union__))
5822   @{
5823     int *__ip;
5824     union wait *__up;
5825   @} wait_status_ptr_t;
5827 pid_t wait (wait_status_ptr_t);
5828 @end smallexample
5830 @noindent
5831 This interface allows either @code{int *} or @code{union wait *}
5832 arguments to be passed, using the @code{int *} calling convention.
5833 The program can call @code{wait} with arguments of either type:
5835 @smallexample
5836 int w1 () @{ int w; return wait (&w); @}
5837 int w2 () @{ union wait w; return wait (&w); @}
5838 @end smallexample
5840 @noindent
5841 With this interface, @code{wait}'s implementation might look like this:
5843 @smallexample
5844 pid_t wait (wait_status_ptr_t p)
5846   return waitpid (-1, p.__ip, 0);
5848 @end smallexample
5850 @item unused
5851 When attached to a type (including a @code{union} or a @code{struct}),
5852 this attribute means that variables of that type are meant to appear
5853 possibly unused.  GCC does not produce a warning for any variables of
5854 that type, even if the variable appears to do nothing.  This is often
5855 the case with lock or thread classes, which are usually defined and then
5856 not referenced, but contain constructors and destructors that have
5857 nontrivial bookkeeping functions.
5859 @item deprecated
5860 @itemx deprecated (@var{msg})
5861 The @code{deprecated} attribute results in a warning if the type
5862 is used anywhere in the source file.  This is useful when identifying
5863 types that are expected to be removed in a future version of a program.
5864 If possible, the warning also includes the location of the declaration
5865 of the deprecated type, to enable users to easily find further
5866 information about why the type is deprecated, or what they should do
5867 instead.  Note that the warnings only occur for uses and then only
5868 if the type is being applied to an identifier that itself is not being
5869 declared as deprecated.
5871 @smallexample
5872 typedef int T1 __attribute__ ((deprecated));
5873 T1 x;
5874 typedef T1 T2;
5875 T2 y;
5876 typedef T1 T3 __attribute__ ((deprecated));
5877 T3 z __attribute__ ((deprecated));
5878 @end smallexample
5880 @noindent
5881 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5882 warning is issued for line 4 because T2 is not explicitly
5883 deprecated.  Line 5 has no warning because T3 is explicitly
5884 deprecated.  Similarly for line 6.  The optional @var{msg}
5885 argument, which must be a string, is printed in the warning if
5886 present.
5888 The @code{deprecated} attribute can also be used for functions and
5889 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5891 @item may_alias
5892 Accesses through pointers to types with this attribute are not subject
5893 to type-based alias analysis, but are instead assumed to be able to alias
5894 any other type of objects.
5895 In the context of section 6.5 paragraph 7 of the C99 standard,
5896 an lvalue expression
5897 dereferencing such a pointer is treated like having a character type.
5898 See @option{-fstrict-aliasing} for more information on aliasing issues.
5899 This extension exists to support some vector APIs, in which pointers to
5900 one vector type are permitted to alias pointers to a different vector type.
5902 Note that an object of a type with this attribute does not have any
5903 special semantics.
5905 Example of use:
5907 @smallexample
5908 typedef short __attribute__((__may_alias__)) short_a;
5911 main (void)
5913   int a = 0x12345678;
5914   short_a *b = (short_a *) &a;
5916   b[1] = 0;
5918   if (a == 0x12345678)
5919     abort();
5921   exit(0);
5923 @end smallexample
5925 @noindent
5926 If you replaced @code{short_a} with @code{short} in the variable
5927 declaration, the above program would abort when compiled with
5928 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5929 above in recent GCC versions.
5931 @item visibility
5932 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5933 applied to class, struct, union and enum types.  Unlike other type
5934 attributes, the attribute must appear between the initial keyword and
5935 the name of the type; it cannot appear after the body of the type.
5937 Note that the type visibility is applied to vague linkage entities
5938 associated with the class (vtable, typeinfo node, etc.).  In
5939 particular, if a class is thrown as an exception in one shared object
5940 and caught in another, the class must have default visibility.
5941 Otherwise the two shared objects are unable to use the same
5942 typeinfo node and exception handling will break.
5944 @item designated_init
5945 This attribute may only be applied to structure types.  It indicates
5946 that any initialization of an object of this type must use designated
5947 initializers rather than positional initializers.  The intent of this
5948 attribute is to allow the programmer to indicate that a structure's
5949 layout may change, and that therefore relying on positional
5950 initialization will result in future breakage.
5952 GCC emits warnings based on this attribute by default; use
5953 @option{-Wno-designated-init} to suppress them.
5955 @end table
5957 To specify multiple attributes, separate them by commas within the
5958 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5959 packed))}.
5961 @subsection ARM Type Attributes
5963 On those ARM targets that support @code{dllimport} (such as Symbian
5964 OS), you can use the @code{notshared} attribute to indicate that the
5965 virtual table and other similar data for a class should not be
5966 exported from a DLL@.  For example:
5968 @smallexample
5969 class __declspec(notshared) C @{
5970 public:
5971   __declspec(dllimport) C();
5972   virtual void f();
5975 __declspec(dllexport)
5976 C::C() @{@}
5977 @end smallexample
5979 @noindent
5980 In this code, @code{C::C} is exported from the current DLL, but the
5981 virtual table for @code{C} is not exported.  (You can use
5982 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5983 most Symbian OS code uses @code{__declspec}.)
5985 @anchor{MeP Type Attributes}
5986 @subsection MeP Type Attributes
5988 Many of the MeP variable attributes may be applied to types as well.
5989 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5990 @code{far} attributes may be applied to either.  The @code{io} and
5991 @code{cb} attributes may not be applied to types.
5993 @anchor{i386 Type Attributes}
5994 @subsection i386 Type Attributes
5996 Two attributes are currently defined for i386 configurations:
5997 @code{ms_struct} and @code{gcc_struct}.
5999 @table @code
6001 @item ms_struct
6002 @itemx gcc_struct
6003 @cindex @code{ms_struct}
6004 @cindex @code{gcc_struct}
6006 If @code{packed} is used on a structure, or if bit-fields are used
6007 it may be that the Microsoft ABI packs them differently
6008 than GCC normally packs them.  Particularly when moving packed
6009 data between functions compiled with GCC and the native Microsoft compiler
6010 (either via function call or as data in a file), it may be necessary to access
6011 either format.
6013 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
6014 compilers to match the native Microsoft compiler.
6015 @end table
6017 @anchor{PowerPC Type Attributes}
6018 @subsection PowerPC Type Attributes
6020 Three attributes currently are defined for PowerPC configurations:
6021 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6023 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6024 attributes please see the documentation in @ref{i386 Type Attributes}.
6026 The @code{altivec} attribute allows one to declare AltiVec vector data
6027 types supported by the AltiVec Programming Interface Manual.  The
6028 attribute requires an argument to specify one of three vector types:
6029 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6030 and @code{bool__} (always followed by unsigned).
6032 @smallexample
6033 __attribute__((altivec(vector__)))
6034 __attribute__((altivec(pixel__))) unsigned short
6035 __attribute__((altivec(bool__))) unsigned
6036 @end smallexample
6038 These attributes mainly are intended to support the @code{__vector},
6039 @code{__pixel}, and @code{__bool} AltiVec keywords.
6041 @anchor{SPU Type Attributes}
6042 @subsection SPU Type Attributes
6044 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6045 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6046 Language Extensions Specification.  It is intended to support the
6047 @code{__vector} keyword.
6049 @node Alignment
6050 @section Inquiring on Alignment of Types or Variables
6051 @cindex alignment
6052 @cindex type alignment
6053 @cindex variable alignment
6055 The keyword @code{__alignof__} allows you to inquire about how an object
6056 is aligned, or the minimum alignment usually required by a type.  Its
6057 syntax is just like @code{sizeof}.
6059 For example, if the target machine requires a @code{double} value to be
6060 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6061 This is true on many RISC machines.  On more traditional machine
6062 designs, @code{__alignof__ (double)} is 4 or even 2.
6064 Some machines never actually require alignment; they allow reference to any
6065 data type even at an odd address.  For these machines, @code{__alignof__}
6066 reports the smallest alignment that GCC gives the data type, usually as
6067 mandated by the target ABI.
6069 If the operand of @code{__alignof__} is an lvalue rather than a type,
6070 its value is the required alignment for its type, taking into account
6071 any minimum alignment specified with GCC's @code{__attribute__}
6072 extension (@pxref{Variable Attributes}).  For example, after this
6073 declaration:
6075 @smallexample
6076 struct foo @{ int x; char y; @} foo1;
6077 @end smallexample
6079 @noindent
6080 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6081 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6083 It is an error to ask for the alignment of an incomplete type.
6086 @node Inline
6087 @section An Inline Function is As Fast As a Macro
6088 @cindex inline functions
6089 @cindex integrating function code
6090 @cindex open coding
6091 @cindex macros, inline alternative
6093 By declaring a function inline, you can direct GCC to make
6094 calls to that function faster.  One way GCC can achieve this is to
6095 integrate that function's code into the code for its callers.  This
6096 makes execution faster by eliminating the function-call overhead; in
6097 addition, if any of the actual argument values are constant, their
6098 known values may permit simplifications at compile time so that not
6099 all of the inline function's code needs to be included.  The effect on
6100 code size is less predictable; object code may be larger or smaller
6101 with function inlining, depending on the particular case.  You can
6102 also direct GCC to try to integrate all ``simple enough'' functions
6103 into their callers with the option @option{-finline-functions}.
6105 GCC implements three different semantics of declaring a function
6106 inline.  One is available with @option{-std=gnu89} or
6107 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6108 on all inline declarations, another when
6109 @option{-std=c99}, @option{-std=c11},
6110 @option{-std=gnu99} or @option{-std=gnu11}
6111 (without @option{-fgnu89-inline}), and the third
6112 is used when compiling C++.
6114 To declare a function inline, use the @code{inline} keyword in its
6115 declaration, like this:
6117 @smallexample
6118 static inline int
6119 inc (int *a)
6121   return (*a)++;
6123 @end smallexample
6125 If you are writing a header file to be included in ISO C90 programs, write
6126 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6128 The three types of inlining behave similarly in two important cases:
6129 when the @code{inline} keyword is used on a @code{static} function,
6130 like the example above, and when a function is first declared without
6131 using the @code{inline} keyword and then is defined with
6132 @code{inline}, like this:
6134 @smallexample
6135 extern int inc (int *a);
6136 inline int
6137 inc (int *a)
6139   return (*a)++;
6141 @end smallexample
6143 In both of these common cases, the program behaves the same as if you
6144 had not used the @code{inline} keyword, except for its speed.
6146 @cindex inline functions, omission of
6147 @opindex fkeep-inline-functions
6148 When a function is both inline and @code{static}, if all calls to the
6149 function are integrated into the caller, and the function's address is
6150 never used, then the function's own assembler code is never referenced.
6151 In this case, GCC does not actually output assembler code for the
6152 function, unless you specify the option @option{-fkeep-inline-functions}.
6153 Some calls cannot be integrated for various reasons (in particular,
6154 calls that precede the function's definition cannot be integrated, and
6155 neither can recursive calls within the definition).  If there is a
6156 nonintegrated call, then the function is compiled to assembler code as
6157 usual.  The function must also be compiled as usual if the program
6158 refers to its address, because that can't be inlined.
6160 @opindex Winline
6161 Note that certain usages in a function definition can make it unsuitable
6162 for inline substitution.  Among these usages are: variadic functions, use of
6163 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6164 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6165 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6166 warns when a function marked @code{inline} could not be substituted,
6167 and gives the reason for the failure.
6169 @cindex automatic @code{inline} for C++ member fns
6170 @cindex @code{inline} automatic for C++ member fns
6171 @cindex member fns, automatically @code{inline}
6172 @cindex C++ member fns, automatically @code{inline}
6173 @opindex fno-default-inline
6174 As required by ISO C++, GCC considers member functions defined within
6175 the body of a class to be marked inline even if they are
6176 not explicitly declared with the @code{inline} keyword.  You can
6177 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6178 Options,,Options Controlling C++ Dialect}.
6180 GCC does not inline any functions when not optimizing unless you specify
6181 the @samp{always_inline} attribute for the function, like this:
6183 @smallexample
6184 /* @r{Prototype.}  */
6185 inline void foo (const char) __attribute__((always_inline));
6186 @end smallexample
6188 The remainder of this section is specific to GNU C90 inlining.
6190 @cindex non-static inline function
6191 When an inline function is not @code{static}, then the compiler must assume
6192 that there may be calls from other source files; since a global symbol can
6193 be defined only once in any program, the function must not be defined in
6194 the other source files, so the calls therein cannot be integrated.
6195 Therefore, a non-@code{static} inline function is always compiled on its
6196 own in the usual fashion.
6198 If you specify both @code{inline} and @code{extern} in the function
6199 definition, then the definition is used only for inlining.  In no case
6200 is the function compiled on its own, not even if you refer to its
6201 address explicitly.  Such an address becomes an external reference, as
6202 if you had only declared the function, and had not defined it.
6204 This combination of @code{inline} and @code{extern} has almost the
6205 effect of a macro.  The way to use it is to put a function definition in
6206 a header file with these keywords, and put another copy of the
6207 definition (lacking @code{inline} and @code{extern}) in a library file.
6208 The definition in the header file causes most calls to the function
6209 to be inlined.  If any uses of the function remain, they refer to
6210 the single copy in the library.
6212 @node Volatiles
6213 @section When is a Volatile Object Accessed?
6214 @cindex accessing volatiles
6215 @cindex volatile read
6216 @cindex volatile write
6217 @cindex volatile access
6219 C has the concept of volatile objects.  These are normally accessed by
6220 pointers and used for accessing hardware or inter-thread
6221 communication.  The standard encourages compilers to refrain from
6222 optimizations concerning accesses to volatile objects, but leaves it
6223 implementation defined as to what constitutes a volatile access.  The
6224 minimum requirement is that at a sequence point all previous accesses
6225 to volatile objects have stabilized and no subsequent accesses have
6226 occurred.  Thus an implementation is free to reorder and combine
6227 volatile accesses that occur between sequence points, but cannot do
6228 so for accesses across a sequence point.  The use of volatile does
6229 not allow you to violate the restriction on updating objects multiple
6230 times between two sequence points.
6232 Accesses to non-volatile objects are not ordered with respect to
6233 volatile accesses.  You cannot use a volatile object as a memory
6234 barrier to order a sequence of writes to non-volatile memory.  For
6235 instance:
6237 @smallexample
6238 int *ptr = @var{something};
6239 volatile int vobj;
6240 *ptr = @var{something};
6241 vobj = 1;
6242 @end smallexample
6244 @noindent
6245 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6246 that the write to @var{*ptr} occurs by the time the update
6247 of @var{vobj} happens.  If you need this guarantee, you must use
6248 a stronger memory barrier such as:
6250 @smallexample
6251 int *ptr = @var{something};
6252 volatile int vobj;
6253 *ptr = @var{something};
6254 asm volatile ("" : : : "memory");
6255 vobj = 1;
6256 @end smallexample
6258 A scalar volatile object is read when it is accessed in a void context:
6260 @smallexample
6261 volatile int *src = @var{somevalue};
6262 *src;
6263 @end smallexample
6265 Such expressions are rvalues, and GCC implements this as a
6266 read of the volatile object being pointed to.
6268 Assignments are also expressions and have an rvalue.  However when
6269 assigning to a scalar volatile, the volatile object is not reread,
6270 regardless of whether the assignment expression's rvalue is used or
6271 not.  If the assignment's rvalue is used, the value is that assigned
6272 to the volatile object.  For instance, there is no read of @var{vobj}
6273 in all the following cases:
6275 @smallexample
6276 int obj;
6277 volatile int vobj;
6278 vobj = @var{something};
6279 obj = vobj = @var{something};
6280 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6281 obj = (@var{something}, vobj = @var{anotherthing});
6282 @end smallexample
6284 If you need to read the volatile object after an assignment has
6285 occurred, you must use a separate expression with an intervening
6286 sequence point.
6288 As bit-fields are not individually addressable, volatile bit-fields may
6289 be implicitly read when written to, or when adjacent bit-fields are
6290 accessed.  Bit-field operations may be optimized such that adjacent
6291 bit-fields are only partially accessed, if they straddle a storage unit
6292 boundary.  For these reasons it is unwise to use volatile bit-fields to
6293 access hardware.
6295 @node Using Assembly Language with C
6296 @section How to Use Inline Assembly Language in C Code
6298 GCC provides various extensions that allow you to embed assembler within 
6299 C code.
6301 @menu
6302 * Basic Asm::          Inline assembler with no operands.
6303 * Extended Asm::       Inline assembler with operands.
6304 * Constraints::        Constraints for @code{asm} operands
6305 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6306 * Explicit Reg Vars::  Defining variables residing in specified registers.
6307 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6308 @end menu
6310 @node Basic Asm
6311 @subsection Basic Asm --- Assembler Instructions with No Operands
6312 @cindex basic @code{asm}
6314 The @code{asm} keyword allows you to embed assembler instructions within 
6315 C code.
6317 @example
6318 asm [ volatile ] ( AssemblerInstructions )
6319 @end example
6321 To create headers compatible with ISO C, write @code{__asm__} instead of 
6322 @code{asm} (@pxref{Alternate Keywords}).
6324 By definition, a Basic @code{asm} statement is one with no operands. 
6325 @code{asm} statements that contain one or more colons (used to delineate 
6326 operands) are considered to be Extended (for example, @code{asm("int $3")} 
6327 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6329 @subsubheading Qualifiers
6330 @emph{volatile}
6332 This optional qualifier has no effect. All Basic @code{asm} blocks are 
6333 implicitly volatile.
6335 @subsubheading Parameters
6336 @emph{AssemblerInstructions}
6338 This is a literal string that specifies the assembler code. The string can 
6339 contain any instructions recognized by the assembler, including directives. 
6340 GCC does not parse the assembler instructions themselves and 
6341 does not know what they mean or even whether they are valid assembler input. 
6342 The compiler copies it verbatim to the assembly language output file, without 
6343 processing dialects or any of the "%" operators that are available with
6344 Extended @code{asm}. This results in minor differences between Basic 
6345 @code{asm} strings and Extended @code{asm} templates. For example, to refer to 
6346 registers you might use %%eax in Extended @code{asm} and %eax in Basic 
6347 @code{asm}.
6349 You may place multiple assembler instructions together in a single @code{asm} 
6350 string, separated by the characters normally used in assembly code for the 
6351 system. A combination that works in most places is a newline to break the 
6352 line, plus a tab character (written as "\n\t").
6353 Some assemblers allow semicolons as a line separator. However, 
6354 note that some assembler dialects use semicolons to start a comment. 
6356 Do not expect a sequence of @code{asm} statements to remain perfectly 
6357 consecutive after compilation. If certain instructions need to remain 
6358 consecutive in the output, put them in a single multi-instruction asm 
6359 statement. Note that GCC's optimizers can move @code{asm} statements 
6360 relative to other code, including across jumps.
6362 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6363 GCC does not know about these jumps, and therefore cannot take 
6364 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6365 labels are only supported in Extended @code{asm}.
6367 @subsubheading Remarks
6368 Using Extended @code{asm} will typically produce smaller, safer, and more 
6369 efficient code, and in most cases it is a better solution. When writing 
6370 inline assembly language outside of C functions, however, you must use Basic 
6371 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6372 Functions declared with the @code{naked} attribute also require Basic 
6373 @code{asm} (@pxref{Function Attributes}).
6375 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6376 assembly code when optimizing. This can lead to unexpected duplicate 
6377 symbol errors during compilation if your assembly code defines symbols or 
6378 labels.
6380 Safely accessing C data and calling functions from Basic @code{asm} is more 
6381 complex than it may appear. To access C data, it is better to use Extended 
6382 @code{asm}.
6384 Since GCC does not parse the AssemblerInstructions, it has no 
6385 visibility of any symbols it references. This may result in GCC discarding 
6386 those symbols as unreferenced.
6388 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly 
6389 volatile. @xref{Volatile}.  Similarly, Basic @code{asm} blocks are not treated 
6390 as though they used a "memory" clobber (@pxref{Clobbers}).
6392 All Basic @code{asm} blocks use the assembler dialect specified by the 
6393 @option{-masm} command-line option. Basic @code{asm} provides no
6394 mechanism to provide different assembler strings for different dialects.
6396 Here is an example of Basic @code{asm} for i386:
6398 @example
6399 /* Note that this code will not compile with -masm=intel */
6400 #define DebugBreak() asm("int $3")
6401 @end example
6403 @node Extended Asm
6404 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6405 @cindex @code{asm} keyword
6406 @cindex extended @code{asm}
6407 @cindex assembler instructions
6409 The @code{asm} keyword allows you to embed assembler instructions within C 
6410 code. With Extended @code{asm} you can read and write C variables from 
6411 assembler and perform jumps from assembler code to C labels.
6413 @example
6414 @ifhtml
6415 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6417 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6418 @end ifhtml
6419 @ifnothtml
6420 asm [volatile] ( AssemblerTemplate 
6421                  : [OutputOperands] 
6422                  [ : [InputOperands] 
6423                  [ : [Clobbers] ] ])
6425 asm [volatile] goto ( AssemblerTemplate 
6426                       : 
6427                       : [InputOperands] 
6428                       : [Clobbers] 
6429                       : GotoLabels)
6430 @end ifnothtml
6431 @end example
6433 To create headers compatible with ISO C, write @code{__asm__} instead of 
6434 @code{asm} and @code{__volatile__} instead of @code{volatile} 
6435 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6437 By definition, Extended @code{asm} is an @code{asm} statement that contains 
6438 operands. To separate the classes of operands, you use colons. Basic 
6439 @code{asm} statements contain no colons. (So, for example, 
6440 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is 
6441 Extended @code{asm}. @pxref{Basic Asm}.)
6443 @subsubheading Qualifiers
6444 @emph{volatile}
6446 The typical use of Extended @code{asm} statements is to manipulate input 
6447 values to produce output values. However, your @code{asm} statements may 
6448 also produce side effects. If so, you may need to use the @code{volatile} 
6449 qualifier to disable certain optimizations. @xref{Volatile}.
6451 @emph{goto}
6453 This qualifier informs the compiler that the @code{asm} statement may 
6454 perform a jump to one of the labels listed in the GotoLabels section. 
6455 @xref{GotoLabels}.
6457 @subsubheading Parameters
6458 @emph{AssemblerTemplate}
6460 This is a literal string that contains the assembler code. It is a 
6461 combination of fixed text and tokens that refer to the input, output, 
6462 and goto parameters. @xref{AssemblerTemplate}.
6464 @emph{OutputOperands}
6466 A comma-separated list of the C variables modified by the instructions in the 
6467 AssemblerTemplate. @xref{OutputOperands}.
6469 @emph{InputOperands}
6471 A comma-separated list of C expressions read by the instructions in the 
6472 AssemblerTemplate. @xref{InputOperands}.
6474 @emph{Clobbers}
6476 A comma-separated list of registers or other values changed by the 
6477 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6479 @emph{GotoLabels}
6481 When you are using the @code{goto} form of @code{asm}, this section contains 
6482 the list of all C labels to which the AssemblerTemplate may jump. 
6483 @xref{GotoLabels}.
6485 @subsubheading Remarks
6486 The @code{asm} statement allows you to include assembly instructions directly 
6487 within C code. This may help you to maximize performance in time-sensitive 
6488 code or to access assembly instructions that are not readily available to C 
6489 programs.
6491 Note that Extended @code{asm} statements must be inside a function. Only 
6492 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6493 Functions declared with the @code{naked} attribute also require Basic 
6494 @code{asm} (@pxref{Function Attributes}).
6496 While the uses of @code{asm} are many and varied, it may help to think of an 
6497 @code{asm} statement as a series of low-level instructions that convert input 
6498 parameters to output parameters. So a simple (if not particularly useful) 
6499 example for i386 using @code{asm} might look like this:
6501 @example
6502 int src = 1;
6503 int dst;   
6505 asm ("mov %1, %0\n\t"
6506     "add $1, %0"
6507     : "=r" (dst) 
6508     : "r" (src));
6510 printf("%d\n", dst);
6511 @end example
6513 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6515 @anchor{Volatile}
6516 @subsubsection Volatile
6517 @cindex volatile @code{asm}
6518 @cindex @code{asm} volatile
6520 GCC's optimizers sometimes discard @code{asm} statements if they determine 
6521 there is no need for the output variables. Also, the optimizers may move 
6522 code out of loops if they believe that the code will always return the same 
6523 result (i.e. none of its input values change between calls). Using the 
6524 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
6525 that have no output operands are implicitly volatile.
6527 Examples:
6529 This i386 code demonstrates a case that does not use (or require) the 
6530 @code{volatile} qualifier. If it is performing assertion checking, this code 
6531 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is 
6532 unreferenced by any code. As a result, the optimizers can discard the 
6533 @code{asm} statement, which in turn removes the need for the entire 
6534 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
6535 isn't needed you allow the optimizers to produce the most efficient code 
6536 possible.
6538 @example
6539 void DoCheck(uint32_t dwSomeValue)
6541    uint32_t dwRes;
6543    // Assumes dwSomeValue is not zero.
6544    asm ("bsfl %1,%0"
6545      : "=r" (dwRes)
6546      : "r" (dwSomeValue)
6547      : "cc");
6549    assert(dwRes > 3);
6551 @end example
6553 The next example shows a case where the optimizers can recognize that the input 
6554 (@var{dwSomeValue}) never changes during the execution of the function and can 
6555 therefore move the @code{asm} outside the loop to produce more efficient code. 
6556 Again, using @code{volatile} disables this type of optimization.
6558 @example
6559 void do_print(uint32_t dwSomeValue)
6561    uint32_t dwRes;
6563    for (uint32_t x=0; x < 5; x++)
6564    @{
6565       // Assumes dwSomeValue is not zero.
6566       asm ("bsfl %1,%0"
6567         : "=r" (dwRes)
6568         : "r" (dwSomeValue)
6569         : "cc");
6571       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6572    @}
6574 @end example
6576 The following example demonstrates a case where you need to use the 
6577 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads 
6578 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
6579 the optimizers might assume that the @code{asm} block will always return the 
6580 same value and therefore optimize away the second call.
6582 @example
6583 uint64_t msr;
6585 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6586         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6587         "or %%rdx, %0"        // 'Or' in the lower bits.
6588         : "=a" (msr)
6589         : 
6590         : "rdx");
6592 printf("msr: %llx\n", msr);
6594 // Do other work...
6596 // Reprint the timestamp
6597 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6598         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6599         "or %%rdx, %0"        // 'Or' in the lower bits.
6600         : "=a" (msr)
6601         : 
6602         : "rdx");
6604 printf("msr: %llx\n", msr);
6605 @end example
6607 GCC's optimizers will not treat this code like the non-volatile code in the 
6608 earlier examples. They do not move it out of loops or omit it on the 
6609 assumption that the result from a previous call is still valid.
6611 Note that the compiler can move even volatile @code{asm} instructions relative 
6612 to other code, including across jump instructions. For example, on many 
6613 targets there is a system register that controls the rounding mode of 
6614 floating-point operations. Setting it with a volatile @code{asm}, as in the 
6615 following PowerPC example, will not work reliably.
6617 @example
6618 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6619 sum = x + y;
6620 @end example
6622 The compiler may move the addition back before the volatile @code{asm}. To 
6623 make it work as expected, add an artificial dependency to the @code{asm} by 
6624 referencing a variable in the subsequent code, for example: 
6626 @example
6627 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6628 sum = x + y;
6629 @end example
6631 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6632 assembly code when optimizing. This can lead to unexpected duplicate symbol 
6633 errors during compilation if your asm code defines symbols or labels. Using %= 
6634 (@pxref{AssemblerTemplate}) may help resolve this problem.
6636 @anchor{AssemblerTemplate}
6637 @subsubsection Assembler Template
6638 @cindex @code{asm} assembler template
6640 An assembler template is a literal string containing assembler instructions. 
6641 The compiler will replace any references to inputs, outputs, and goto labels 
6642 in the template, and then output the resulting string to the assembler. The 
6643 string can contain any instructions recognized by the assembler, including 
6644 directives. GCC does not parse the assembler instructions 
6645 themselves and does not know what they mean or even whether they are valid 
6646 assembler input. However, it does count the statements 
6647 (@pxref{Size of an asm}).
6649 You may place multiple assembler instructions together in a single @code{asm} 
6650 string, separated by the characters normally used in assembly code for the 
6651 system. A combination that works in most places is a newline to break the 
6652 line, plus a tab character to move to the instruction field (written as 
6653 "\n\t"). Some assemblers allow semicolons as a line separator. However, note 
6654 that some assembler dialects use semicolons to start a comment. 
6656 Do not expect a sequence of @code{asm} statements to remain perfectly 
6657 consecutive after compilation, even when you are using the @code{volatile} 
6658 qualifier. If certain instructions need to remain consecutive in the output, 
6659 put them in a single multi-instruction asm statement.
6661 Accessing data from C programs without using input/output operands (such as 
6662 by using global symbols directly from the assembler template) may not work as 
6663 expected. Similarly, calling functions directly from an assembler template 
6664 requires a detailed understanding of the target assembler and ABI.
6666 Since GCC does not parse the AssemblerTemplate, it has no visibility of any 
6667 symbols it references. This may result in GCC discarding those symbols as 
6668 unreferenced unless they are also listed as input, output, or goto operands.
6670 GCC can support multiple assembler dialects (for example, GCC for i386 
6671 supports "att" and "intel" dialects) for inline assembler. In builds that 
6672 support this capability, the @option{-masm} option controls which dialect 
6673 GCC uses as its default. The hardware-specific documentation for the 
6674 @option{-masm} option contains the list of supported dialects, as well as the 
6675 default dialect if the option is not specified. This information may be 
6676 important to understand, since assembler code that works correctly when 
6677 compiled using one dialect will likely fail if compiled using another.
6679 @subsubheading Using braces in @code{asm} templates
6681 If your code needs to support multiple assembler dialects (for example, if 
6682 you are writing public headers that need to support a variety of compilation 
6683 options), use constructs of this form:
6685 @example
6686 @{ dialect0 | dialect1 | dialect2... @}
6687 @end example
6689 This construct outputs 'dialect0' when using dialect #0 to compile the code, 
6690 'dialect1' for dialect #1, etc. If there are fewer alternatives within the 
6691 braces than the number of dialects the compiler supports, the construct 
6692 outputs nothing.
6694 For example, if an i386 compiler supports two dialects (att, intel), an 
6695 assembler template such as this:
6697 @example
6698 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6699 @end example
6701 would produce the output:
6703 @example
6704 For att: "btl %[Offset],%[Base] ; jc %l2"
6705 For intel: "bt %[Base],%[Offset]; jc %l2"
6706 @end example
6708 Using that same compiler, this code:
6710 @example
6711 "xchg@{l@}\t@{%%@}ebx, %1"
6712 @end example
6714 would produce 
6716 @example
6717 For att: "xchgl\t%%ebx, %1"
6718 For intel: "xchg\tebx, %1"
6719 @end example
6721 There is no support for nesting dialect alternatives. Also, there is no 
6722 ``escape'' for an open brace (@{), so do not use open braces in an Extended 
6723 @code{asm} template other than as a dialect indicator.
6725 @subsubheading Other format strings
6727 In addition to the tokens described by the input, output, and goto operands, 
6728 there are a few special cases:
6730 @itemize
6731 @item
6732 "%%" outputs a single "%" into the assembler code.
6734 @item
6735 "%=" outputs a number that is unique to each instance of the @code{asm} 
6736 statement in the entire compilation. This option is useful when creating local 
6737 labels and referring to them multiple times in a single template that 
6738 generates multiple assembler instructions. 
6740 @end itemize
6742 @anchor{OutputOperands}
6743 @subsubsection Output Operands
6744 @cindex @code{asm} output operands
6746 An @code{asm} statement has zero or more output operands indicating the names
6747 of C variables modified by the assembler code.
6749 In this i386 example, @var{old} (referred to in the template string as 
6750 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset} 
6751 (@code{%2}) is an input:
6753 @example
6754 bool old;
6756 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6757          "sbb %0,%0"      // Use the CF to calculate old.
6758    : "=r" (old), "+rm" (*Base)
6759    : "Ir" (Offset)
6760    : "cc");
6762 return old;
6763 @end example
6765 Operands use this format:
6767 @example
6768 [ [asmSymbolicName] ] "constraint" (cvariablename)
6769 @end example
6771 @emph{asmSymbolicName}
6774 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6775 in the list of operands in the assembler template. For example if there are 
6776 three output operands, use @code{%0} in the template to refer to the first, 
6777 @code{%1} for the second, and @code{%2} for the third. When using an 
6778 asmSymbolicName, reference it by enclosing the name in square brackets 
6779 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement 
6780 that contains the definition. Any valid C variable name is acceptable, 
6781 including names already defined in the surrounding code. No two operands 
6782 within the same @code{asm} statement can use the same symbolic name.
6784 @emph{constraint}
6786 Output constraints must begin with either @code{"="} (a variable overwriting an 
6787 existing value) or @code{"+"} (when reading and writing). When using 
6788 @code{"="}, do not assume the location will contain the existing value (except 
6789 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6791 After the prefix, there must be one or more additional constraints 
6792 (@pxref{Constraints}) that describe where the value resides. Common 
6793 constraints include @code{"r"} for register and @code{"m"} for memory. 
6794 When you list more than one possible location (for example @code{"=rm"}), the 
6795 compiler chooses the most efficient one based on the current context. If you 
6796 list as many alternates as the @code{asm} statement allows, you will permit 
6797 the optimizers to produce the best possible code. If you must use a specific
6798 register, but your Machine Constraints do not provide sufficient 
6799 control to select the specific register you want, Local Reg Vars may provide 
6800 a solution (@pxref{Local Reg Vars}).
6802 @emph{cvariablename}
6804 Specifies the C variable name of the output (enclosed by parentheses). Accepts 
6805 any (non-constant) variable within scope.
6807 Remarks:
6809 The total number of input + output + goto operands has a limit of 30. Commas 
6810 separate the operands. When the compiler selects the registers to use to 
6811 represent the output operands, it will not use any of the clobbered registers 
6812 (@pxref{Clobbers}).
6814 Output operand expressions must be lvalues. The compiler cannot check whether 
6815 the operands have data types that are reasonable for the instruction being 
6816 executed. For output expressions that are not directly addressable (for 
6817 example a bit-field), the constraint must allow a register. In that case, GCC 
6818 uses the register as the output of the @code{asm}, and then stores that 
6819 register into the output. 
6821 Unless an output operand has the '@code{&}' constraint modifier 
6822 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated 
6823 input operand, on the assumption that the assembler code will consume its 
6824 inputs before producing outputs. This assumption may be false if the assembler 
6825 code actually consists of more than one instruction. In this case, use 
6826 '@code{&}' on each output operand that must not overlap an input.
6828 The same problem can occur if one output parameter (@var{a}) allows a register 
6829 constraint and another output parameter (@var{b}) allows a memory constraint.
6830 The code generated by GCC to access the memory address in @var{b} can contain
6831 registers which @emph{might} be shared by @var{a}, and GCC considers those 
6832 registers to be inputs to the asm. As above, GCC assumes that such input
6833 registers are consumed before any outputs are written. This assumption may 
6834 result in incorrect behavior if the asm writes to @var{a} before using 
6835 @var{b}. Combining the `@code{&}' constraint with the register constraint 
6836 ensures that modifying @var{a} will not affect what address is referenced by 
6837 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b} 
6838 will be undefined if @var{a} is modified before using @var{b}.
6840 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6841 instead of simply @code{%2}). Typically these qualifiers are hardware 
6842 dependent. The list of supported modifiers for i386 is found at 
6843 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6845 If the C code that follows the @code{asm} makes no use of any of the output 
6846 operands, use @code{volatile} for the @code{asm} statement to prevent the 
6847 optimizers from discarding the @code{asm} statement as unneeded 
6848 (see @ref{Volatile}).
6850 Examples:
6852 This code makes no use of the optional asmSymbolicName. Therefore it 
6853 references the first output operand as @code{%0} (were there a second, it 
6854 would be @code{%1}, etc). The number of the first input operand is one greater 
6855 than that of the last output operand. In this i386 example, that makes 
6856 @var{Mask} @code{%1}:
6858 @example
6859 uint32_t Mask = 1234;
6860 uint32_t Index;
6862   asm ("bsfl %1, %0"
6863      : "=r" (Index)
6864      : "r" (Mask)
6865      : "cc");
6866 @end example
6868 That code overwrites the variable Index ("="), placing the value in a register 
6869 ("r"). The generic "r" constraint instead of a constraint for a specific 
6870 register allows the compiler to pick the register to use, which can result 
6871 in more efficient code. This may not be possible if an assembler instruction 
6872 requires a specific register.
6874 The following i386 example uses the asmSymbolicName operand. It produces the 
6875 same result as the code above, but some may consider it more readable or more 
6876 maintainable since reordering index numbers is not necessary when adding or 
6877 removing operands. The names aIndex and aMask are only used to emphasize which 
6878 names get used where. It is acceptable to reuse the names Index and Mask.
6880 @example
6881 uint32_t Mask = 1234;
6882 uint32_t Index;
6884   asm ("bsfl %[aMask], %[aIndex]"
6885      : [aIndex] "=r" (Index)
6886      : [aMask] "r" (Mask)
6887      : "cc");
6888 @end example
6890 Here are some more examples of output operands.
6892 @example
6893 uint32_t c = 1;
6894 uint32_t d;
6895 uint32_t *e = &c;
6897 asm ("mov %[e], %[d]"
6898    : [d] "=rm" (d)
6899    : [e] "rm" (*e));
6900 @end example
6902 Here, @var{d} may either be in a register or in memory. Since the compiler 
6903 might already have the current value of the uint32_t pointed to by @var{e} 
6904 in a register, you can enable it to choose the best location
6905 for @var{d} by specifying both constraints.
6907 @anchor{InputOperands}
6908 @subsubsection Input Operands
6909 @cindex @code{asm} input operands
6910 @cindex @code{asm} expressions
6912 Input operands make inputs from C variables and expressions available to the 
6913 assembly code.
6915 Specify input operands by using the format:
6917 @example
6918 [ [asmSymbolicName] ] "constraint" (cexpression)
6919 @end example
6921 @emph{asmSymbolicName}
6923 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6924 in the list of operands, including outputs, in the assembler template. For 
6925 example, if there are two output parameters and three inputs, @code{%2} refers 
6926 to the first input, @code{%3} to the second, and @code{%4} to the third.
6927 When using an asmSymbolicName, reference it by enclosing the name in square 
6928 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm} 
6929 statement that contains the definition. Any valid C variable name is 
6930 acceptable, including names already defined in the surrounding code. No two 
6931 operands within the same @code{asm} statement can use the same symbolic name.
6933 @emph{constraint}
6935 Input constraints must be a string containing one or more constraints 
6936 (@pxref{Constraints}). When you give more than one possible constraint 
6937 (for example, @code{"irm"}), the compiler will choose the most efficient 
6938 method based on the current context. Input constraints may not begin with 
6939 either "=" or "+". If you must use a specific register, but your Machine
6940 Constraints do not provide sufficient control to select the specific 
6941 register you want, Local Reg Vars may provide a solution 
6942 (@pxref{Local Reg Vars}).
6944 Input constraints can also be digits (for example, @code{"0"}). This indicates 
6945 that the specified input will be in the same place as the output constraint 
6946 at the (zero-based) index in the output constraint list. When using 
6947 asmSymbolicNames for the output operands, you may use these names (enclosed 
6948 in brackets []) instead of digits.
6950 @emph{cexpression}
6952 This is the C variable or expression being passed to the @code{asm} statement 
6953 as input.
6955 When the compiler selects the registers to use to represent the input 
6956 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
6958 If there are no output operands but there are input operands, place two 
6959 consecutive colons where the output operands would go:
6961 @example
6962 __asm__ ("some instructions"
6963    : /* No outputs. */
6964    : "r" (Offset / 8);
6965 @end example
6967 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
6968 (except for inputs tied to outputs). The compiler assumes that on exit from 
6969 the @code{asm} statement these operands will contain the same values as they 
6970 had before executing the assembler. It is @emph{not} possible to use Clobbers 
6971 to inform the compiler that the values in these inputs are changing. One 
6972 common work-around is to tie the changing input variable to an output variable 
6973 that never gets used. Note, however, that if the code that follows the 
6974 @code{asm} statement makes no use of any of the output operands, the GCC 
6975 optimizers may discard the @code{asm} statement as unneeded 
6976 (see @ref{Volatile}).
6978 Remarks:
6980 The total number of input + output + goto operands has a limit of 30.
6982 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6983 instead of simply @code{%2}). Typically these qualifiers are hardware 
6984 dependent. The list of supported modifiers for i386 is found at 
6985 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6987 Examples:
6989 In this example using the fictitious @code{combine} instruction, the 
6990 constraint @code{"0"} for input operand 1 says that it must occupy the same 
6991 location as output operand 0. Only input operands may use numbers in 
6992 constraints, and they must each refer to an output operand. Only a number (or 
6993 the symbolic assembler name) in the constraint can guarantee that one operand 
6994 is in the same place as another. The mere fact that @var{foo} is the value of 
6995 both operands is not enough to guarantee that they are in the same place in 
6996 the generated assembler code.
6998 @example
6999 asm ("combine %2, %0" 
7000    : "=r" (foo) 
7001    : "0" (foo), "g" (bar));
7002 @end example
7004 Here is an example using symbolic names.
7006 @example
7007 asm ("cmoveq %1, %2, %[result]" 
7008    : [result] "=r"(result) 
7009    : "r" (test), "r" (new), "[result]" (old));
7010 @end example
7012 @anchor{Clobbers}
7013 @subsubsection Clobbers
7014 @cindex @code{asm} clobbers
7016 While the compiler is aware of changes to entries listed in the output 
7017 operands, the assembler code may modify more than just the outputs. For 
7018 example, calculations may require additional registers, or the processor may 
7019 overwrite a register as a side effect of a particular assembler instruction. 
7020 In order to inform the compiler of these changes, list them in the clobber 
7021 list. Clobber list items are either register names or the special clobbers 
7022 (listed below). Each clobber list item is enclosed in double quotes and 
7023 separated by commas.
7025 Clobber descriptions may not in any way overlap with an input or output 
7026 operand. For example, you may not have an operand describing a register class 
7027 with one member when listing that register in the clobber list. Variables 
7028 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used 
7029 as @code{asm} input or output operands, must have no part mentioned in the 
7030 clobber description. In particular, there is no way to specify that input 
7031 operands get modified without also specifying them as output operands.
7033 When the compiler selects which registers to use to represent input and output 
7034 operands, it will not use any of the clobbered registers. As a result, 
7035 clobbered registers are available for any use in the assembler code.
7037 Here is a realistic example for the VAX showing the use of clobbered 
7038 registers: 
7040 @example
7041 asm volatile ("movc3 %0, %1, %2"
7042                    : /* No outputs. */
7043                    : "g" (from), "g" (to), "g" (count)
7044                    : "r0", "r1", "r2", "r3", "r4", "r5");
7045 @end example
7047 Also, there are two special clobber arguments:
7049 @enumerate
7050 @item
7051 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7052 register. On some machines, GCC represents the condition codes as a specific 
7053 hardware register; "cc" serves to name this register. On other machines, 
7054 condition code handling is different, and specifying "cc" has no effect. But 
7055 it is valid no matter what the machine.
7057 @item
7058 The "memory" clobber tells the compiler that the assembly code performs memory 
7059 reads or writes to items other than those listed in the input and output 
7060 operands (for example accessing the memory pointed to by one of the input 
7061 parameters). To ensure memory contains correct values, GCC may need to flush 
7062 specific register values to memory before executing the @code{asm}. Further, 
7063 the compiler will not assume that any values read from memory before an 
7064 @code{asm} will remain unchanged after that @code{asm}; it will reload them as 
7065 needed. This effectively forms a read/write memory barrier for the compiler.
7067 Note that this clobber does not prevent the @emph{processor} from doing 
7068 speculative reads past the @code{asm} statement. To prevent that, you need 
7069 processor-specific fence instructions.
7071 Flushing registers to memory has performance implications and may be an issue 
7072 for time-sensitive code. One trick to avoid this is available if the size of 
7073 the memory being accessed is known at compile time. For example, if accessing 
7074 ten bytes of a string, use a memory input like: 
7076 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7078 @end enumerate
7080 @anchor{GotoLabels}
7081 @subsubsection Goto Labels
7082 @cindex @code{asm} goto labels
7084 @code{asm goto} allows assembly code to jump to one or more C labels. The 
7085 GotoLabels section in an @code{asm goto} statement contains a comma-separated 
7086 list of all C labels to which the assembler code may jump. GCC assumes that 
7087 @code{asm} execution falls through to the next statement (if this is not the 
7088 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7089 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7090 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7091 Attributes}). The total number of input + output + goto operands has 
7092 a limit of 30.
7094 An @code{asm goto} statement can not have outputs (which means that the 
7095 statement is implicitly volatile). This is due to an internal restriction of 
7096 the compiler: control transfer instructions cannot have outputs. If the 
7097 assembler code does modify anything, use the "memory" clobber to force the 
7098 optimizers to flush all register values to memory, and reload them if 
7099 necessary, after the @code{asm} statement.
7101 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed 
7102 by its (zero-based) position in GotoLabels plus the number of input 
7103 arguments.  For example, if the @code{asm} has three inputs and references two 
7104 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7106 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7107 GCC's optimizers do not know about these jumps; therefore they cannot take 
7108 account of them when deciding how to optimize.
7110 Example code for i386 might look like:
7112 @example
7113 asm goto (
7114     "btl %1, %0\n\t"
7115     "jc %l2"
7116     : /* No outputs. */
7117     : "r" (p1), "r" (p2) 
7118     : "cc" 
7119     : carry);
7121 return 0;
7123 carry:
7124 return 1;
7125 @end example
7127 The following example shows an @code{asm goto} that uses the memory clobber.
7129 @example
7130 int frob(int x)
7132   int y;
7133   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7134             : /* No outputs. */
7135             : "r"(x), "r"(&y)
7136             : "r5", "memory" 
7137             : error);
7138   return y;
7139 error:
7140   return -1;
7142 @end example
7144 @anchor{i386Operandmodifiers}
7145 @subsubsection i386 Operand modifiers
7147 Input, output, and goto operands for extended @code{asm} statements can use 
7148 modifiers to affect the code output to the assembler. For example, the 
7149 following code uses the "h" and "b" modifiers for i386:
7151 @example
7152 uint16_t  num;
7153 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7154 @end example
7156 These modifiers generate this assembler code:
7158 @example
7159 xchg %ah, %al
7160 @end example
7162 The rest of this discussion uses the following code for illustrative purposes.
7164 @example
7165 int main()
7167    int iInt = 1;
7169 top:
7171    asm volatile goto ("some assembler instructions here"
7172    : /* No outputs. */
7173    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7174    : /* No clobbers. */
7175    : top);
7177 @end example
7179 With no modifiers, this is what the output from the operands would be for the 
7180 att and intel dialects of assembler:
7182 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7183 @headitem Operand @tab masm=att @tab masm=intel
7184 @item @code{%0}
7185 @tab @code{%eax}
7186 @tab @code{eax}
7187 @item @code{%1}
7188 @tab @code{$2}
7189 @tab @code{2}
7190 @item @code{%2}
7191 @tab @code{$.L2}
7192 @tab @code{OFFSET FLAT:.L2}
7193 @end multitable
7195 The table below shows the list of supported modifiers and their effects.
7197 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7198 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7199 @item @code{z}
7200 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7201 @tab @code{%z0}
7202 @tab @code{l}
7203 @tab 
7204 @item @code{b}
7205 @tab Print the QImode name of the register.
7206 @tab @code{%b0}
7207 @tab @code{%al}
7208 @tab @code{al}
7209 @item @code{h}
7210 @tab Print the QImode name for a ``high'' register.
7211 @tab @code{%h0}
7212 @tab @code{%ah}
7213 @tab @code{ah}
7214 @item @code{w}
7215 @tab Print the HImode name of the register.
7216 @tab @code{%w0}
7217 @tab @code{%ax}
7218 @tab @code{ax}
7219 @item @code{k}
7220 @tab Print the SImode name of the register.
7221 @tab @code{%k0}
7222 @tab @code{%eax}
7223 @tab @code{eax}
7224 @item @code{q}
7225 @tab Print the DImode name of the register.
7226 @tab @code{%q0}
7227 @tab @code{%rax}
7228 @tab @code{rax}
7229 @item @code{l}
7230 @tab Print the label name with no punctuation.
7231 @tab @code{%l2}
7232 @tab @code{.L2}
7233 @tab @code{.L2}
7234 @item @code{c}
7235 @tab Require a constant operand and print the constant expression with no punctuation.
7236 @tab @code{%c1}
7237 @tab @code{2}
7238 @tab @code{2}
7239 @end multitable
7241 @anchor{i386floatingpointasmoperands}
7242 @subsubsection i386 floating-point asm operands
7244 On i386 targets, there are several rules on the usage of stack-like registers
7245 in the operands of an @code{asm}.  These rules apply only to the operands
7246 that are stack-like registers:
7248 @enumerate
7249 @item
7250 Given a set of input registers that die in an @code{asm}, it is
7251 necessary to know which are implicitly popped by the @code{asm}, and
7252 which must be explicitly popped by GCC@.
7254 An input register that is implicitly popped by the @code{asm} must be
7255 explicitly clobbered, unless it is constrained to match an
7256 output operand.
7258 @item
7259 For any input register that is implicitly popped by an @code{asm}, it is
7260 necessary to know how to adjust the stack to compensate for the pop.
7261 If any non-popped input is closer to the top of the reg-stack than
7262 the implicitly popped register, it would not be possible to know what the
7263 stack looked like---it's not clear how the rest of the stack ``slides
7264 up''.
7266 All implicitly popped input registers must be closer to the top of
7267 the reg-stack than any input that is not implicitly popped.
7269 It is possible that if an input dies in an @code{asm}, the compiler might
7270 use the input register for an output reload.  Consider this example:
7272 @smallexample
7273 asm ("foo" : "=t" (a) : "f" (b));
7274 @end smallexample
7276 @noindent
7277 This code says that input @code{b} is not popped by the @code{asm}, and that
7278 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7279 deeper after the @code{asm} than it was before.  But, it is possible that
7280 reload may think that it can use the same register for both the input and
7281 the output.
7283 To prevent this from happening,
7284 if any input operand uses the @code{f} constraint, all output register
7285 constraints must use the @code{&} early-clobber modifier.
7287 The example above would be correctly written as:
7289 @smallexample
7290 asm ("foo" : "=&t" (a) : "f" (b));
7291 @end smallexample
7293 @item
7294 Some operands need to be in particular places on the stack.  All
7295 output operands fall in this category---GCC has no other way to
7296 know which registers the outputs appear in unless you indicate
7297 this in the constraints.
7299 Output operands must specifically indicate which register an output
7300 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
7301 constraints must select a class with a single register.
7303 @item
7304 Output operands may not be ``inserted'' between existing stack registers.
7305 Since no 387 opcode uses a read/write operand, all output operands
7306 are dead before the @code{asm}, and are pushed by the @code{asm}.
7307 It makes no sense to push anywhere but the top of the reg-stack.
7309 Output operands must start at the top of the reg-stack: output
7310 operands may not ``skip'' a register.
7312 @item
7313 Some @code{asm} statements may need extra stack space for internal
7314 calculations.  This can be guaranteed by clobbering stack registers
7315 unrelated to the inputs and outputs.
7317 @end enumerate
7319 Here are a couple of reasonable @code{asm}s to want to write.  This
7320 @code{asm}
7321 takes one input, which is internally popped, and produces two outputs.
7323 @smallexample
7324 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7325 @end smallexample
7327 @noindent
7328 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7329 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7330 for the compiler to know that @code{fyl2xp1} pops both inputs.
7332 @smallexample
7333 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7334 @end smallexample
7336 @lowersections
7337 @include md.texi
7338 @raisesections
7340 @node Asm Labels
7341 @subsection Controlling Names Used in Assembler Code
7342 @cindex assembler names for identifiers
7343 @cindex names used in assembler code
7344 @cindex identifiers, names in assembler code
7346 You can specify the name to be used in the assembler code for a C
7347 function or variable by writing the @code{asm} (or @code{__asm__})
7348 keyword after the declarator as follows:
7350 @smallexample
7351 int foo asm ("myfoo") = 2;
7352 @end smallexample
7354 @noindent
7355 This specifies that the name to be used for the variable @code{foo} in
7356 the assembler code should be @samp{myfoo} rather than the usual
7357 @samp{_foo}.
7359 On systems where an underscore is normally prepended to the name of a C
7360 function or variable, this feature allows you to define names for the
7361 linker that do not start with an underscore.
7363 It does not make sense to use this feature with a non-static local
7364 variable since such variables do not have assembler names.  If you are
7365 trying to put the variable in a particular register, see @ref{Explicit
7366 Reg Vars}.  GCC presently accepts such code with a warning, but will
7367 probably be changed to issue an error, rather than a warning, in the
7368 future.
7370 You cannot use @code{asm} in this way in a function @emph{definition}; but
7371 you can get the same effect by writing a declaration for the function
7372 before its definition and putting @code{asm} there, like this:
7374 @smallexample
7375 extern func () asm ("FUNC");
7377 func (x, y)
7378      int x, y;
7379 /* @r{@dots{}} */
7380 @end smallexample
7382 It is up to you to make sure that the assembler names you choose do not
7383 conflict with any other assembler symbols.  Also, you must not use a
7384 register name; that would produce completely invalid assembler code.  GCC
7385 does not as yet have the ability to store static variables in registers.
7386 Perhaps that will be added.
7388 @node Explicit Reg Vars
7389 @subsection Variables in Specified Registers
7390 @cindex explicit register variables
7391 @cindex variables in specified registers
7392 @cindex specified registers
7393 @cindex registers, global allocation
7395 GNU C allows you to put a few global variables into specified hardware
7396 registers.  You can also specify the register in which an ordinary
7397 register variable should be allocated.
7399 @itemize @bullet
7400 @item
7401 Global register variables reserve registers throughout the program.
7402 This may be useful in programs such as programming language
7403 interpreters that have a couple of global variables that are accessed
7404 very often.
7406 @item
7407 Local register variables in specific registers do not reserve the
7408 registers, except at the point where they are used as input or output
7409 operands in an @code{asm} statement and the @code{asm} statement itself is
7410 not deleted.  The compiler's data flow analysis is capable of determining
7411 where the specified registers contain live values, and where they are
7412 available for other uses.  Stores into local register variables may be deleted
7413 when they appear to be dead according to dataflow analysis.  References
7414 to local register variables may be deleted or moved or simplified.
7416 These local variables are sometimes convenient for use with the extended
7417 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7418 output of the assembler instruction directly into a particular register.
7419 (This works provided the register you specify fits the constraints
7420 specified for that operand in the @code{asm}.)
7421 @end itemize
7423 @menu
7424 * Global Reg Vars::
7425 * Local Reg Vars::
7426 @end menu
7428 @node Global Reg Vars
7429 @subsubsection Defining Global Register Variables
7430 @cindex global register variables
7431 @cindex registers, global variables in
7433 You can define a global register variable in GNU C like this:
7435 @smallexample
7436 register int *foo asm ("a5");
7437 @end smallexample
7439 @noindent
7440 Here @code{a5} is the name of the register that should be used.  Choose a
7441 register that is normally saved and restored by function calls on your
7442 machine, so that library routines will not clobber it.
7444 Naturally the register name is cpu-dependent, so you need to
7445 conditionalize your program according to cpu type.  The register
7446 @code{a5} is a good choice on a 68000 for a variable of pointer
7447 type.  On machines with register windows, be sure to choose a ``global''
7448 register that is not affected magically by the function call mechanism.
7450 In addition, different operating systems on the same CPU may differ in how they
7451 name the registers; then you need additional conditionals.  For
7452 example, some 68000 operating systems call this register @code{%a5}.
7454 Eventually there may be a way of asking the compiler to choose a register
7455 automatically, but first we need to figure out how it should choose and
7456 how to enable you to guide the choice.  No solution is evident.
7458 Defining a global register variable in a certain register reserves that
7459 register entirely for this use, at least within the current compilation.
7460 The register is not allocated for any other purpose in the functions
7461 in the current compilation, and is not saved and restored by
7462 these functions.  Stores into this register are never deleted even if they
7463 appear to be dead, but references may be deleted or moved or
7464 simplified.
7466 It is not safe to access the global register variables from signal
7467 handlers, or from more than one thread of control, because the system
7468 library routines may temporarily use the register for other things (unless
7469 you recompile them specially for the task at hand).
7471 @cindex @code{qsort}, and global register variables
7472 It is not safe for one function that uses a global register variable to
7473 call another such function @code{foo} by way of a third function
7474 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7475 different source file in which the variable isn't declared).  This is
7476 because @code{lose} might save the register and put some other value there.
7477 For example, you can't expect a global register variable to be available in
7478 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7479 might have put something else in that register.  (If you are prepared to
7480 recompile @code{qsort} with the same global register variable, you can
7481 solve this problem.)
7483 If you want to recompile @code{qsort} or other source files that do not
7484 actually use your global register variable, so that they do not use that
7485 register for any other purpose, then it suffices to specify the compiler
7486 option @option{-ffixed-@var{reg}}.  You need not actually add a global
7487 register declaration to their source code.
7489 A function that can alter the value of a global register variable cannot
7490 safely be called from a function compiled without this variable, because it
7491 could clobber the value the caller expects to find there on return.
7492 Therefore, the function that is the entry point into the part of the
7493 program that uses the global register variable must explicitly save and
7494 restore the value that belongs to its caller.
7496 @cindex register variable after @code{longjmp}
7497 @cindex global register after @code{longjmp}
7498 @cindex value after @code{longjmp}
7499 @findex longjmp
7500 @findex setjmp
7501 On most machines, @code{longjmp} restores to each global register
7502 variable the value it had at the time of the @code{setjmp}.  On some
7503 machines, however, @code{longjmp} does not change the value of global
7504 register variables.  To be portable, the function that called @code{setjmp}
7505 should make other arrangements to save the values of the global register
7506 variables, and to restore them in a @code{longjmp}.  This way, the same
7507 thing happens regardless of what @code{longjmp} does.
7509 All global register variable declarations must precede all function
7510 definitions.  If such a declaration could appear after function
7511 definitions, the declaration would be too late to prevent the register from
7512 being used for other purposes in the preceding functions.
7514 Global register variables may not have initial values, because an
7515 executable file has no means to supply initial contents for a register.
7517 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7518 registers, but certain library functions, such as @code{getwd}, as well
7519 as the subroutines for division and remainder, modify g3 and g4.  g1 and
7520 g2 are local temporaries.
7522 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7523 Of course, it does not do to use more than a few of those.
7525 @node Local Reg Vars
7526 @subsubsection Specifying Registers for Local Variables
7527 @cindex local variables, specifying registers
7528 @cindex specifying registers for local variables
7529 @cindex registers for local variables
7531 You can define a local register variable with a specified register
7532 like this:
7534 @smallexample
7535 register int *foo asm ("a5");
7536 @end smallexample
7538 @noindent
7539 Here @code{a5} is the name of the register that should be used.  Note
7540 that this is the same syntax used for defining global register
7541 variables, but for a local variable it appears within a function.
7543 Naturally the register name is cpu-dependent, but this is not a
7544 problem, since specific registers are most often useful with explicit
7545 assembler instructions (@pxref{Extended Asm}).  Both of these things
7546 generally require that you conditionalize your program according to
7547 cpu type.
7549 In addition, operating systems on one type of cpu may differ in how they
7550 name the registers; then you need additional conditionals.  For
7551 example, some 68000 operating systems call this register @code{%a5}.
7553 Defining such a register variable does not reserve the register; it
7554 remains available for other uses in places where flow control determines
7555 the variable's value is not live.
7557 This option does not guarantee that GCC generates code that has
7558 this variable in the register you specify at all times.  You may not
7559 code an explicit reference to this register in the @emph{assembler
7560 instruction template} part of an @code{asm} statement and assume it
7561 always refers to this variable.  However, using the variable as an
7562 @code{asm} @emph{operand} guarantees that the specified register is used
7563 for the operand.
7565 Stores into local register variables may be deleted when they appear to be dead
7566 according to dataflow analysis.  References to local register variables may
7567 be deleted or moved or simplified.
7569 As with global register variables, it is recommended that you choose a
7570 register that is normally saved and restored by function calls on
7571 your machine, so that library routines will not clobber it.  
7573 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
7574 specific register, but there's no matching constraint letter for that 
7575 register. To force the operand into that register, create a local variable 
7576 and specify the register in the variable's declaration. Then use the local 
7577 variable for the asm operand and specify any constraint letter that matches 
7578 the register:
7580 @smallexample
7581 register int *p1 asm ("r0") = @dots{};
7582 register int *p2 asm ("r1") = @dots{};
7583 register int *result asm ("r0");
7584 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7585 @end smallexample
7587 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
7588 call-clobbered by subsequent code, including function calls and library calls 
7589 for arithmetic operators on other variables (for example the initialization 
7590 of p2). In this case, use temporary variables for expressions between the 
7591 register assignments:
7593 @smallexample
7594 int t1 = @dots{};
7595 register int *p1 asm ("r0") = @dots{};
7596 register int *p2 asm ("r1") = t1;
7597 register int *result asm ("r0");
7598 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7599 @end smallexample
7601 @node Size of an asm
7602 @subsection Size of an @code{asm}
7604 Some targets require that GCC track the size of each instruction used
7605 in order to generate correct code.  Because the final length of the
7606 code produced by an @code{asm} statement is only known by the
7607 assembler, GCC must make an estimate as to how big it will be.  It
7608 does this by counting the number of instructions in the pattern of the
7609 @code{asm} and multiplying that by the length of the longest
7610 instruction supported by that processor.  (When working out the number
7611 of instructions, it assumes that any occurrence of a newline or of
7612 whatever statement separator character is supported by the assembler --
7613 typically @samp{;} --- indicates the end of an instruction.)
7615 Normally, GCC's estimate is adequate to ensure that correct
7616 code is generated, but it is possible to confuse the compiler if you use
7617 pseudo instructions or assembler macros that expand into multiple real
7618 instructions, or if you use assembler directives that expand to more
7619 space in the object file than is needed for a single instruction.
7620 If this happens then the assembler may produce a diagnostic saying that
7621 a label is unreachable.
7623 @node Alternate Keywords
7624 @section Alternate Keywords
7625 @cindex alternate keywords
7626 @cindex keywords, alternate
7628 @option{-ansi} and the various @option{-std} options disable certain
7629 keywords.  This causes trouble when you want to use GNU C extensions, or
7630 a general-purpose header file that should be usable by all programs,
7631 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
7632 @code{inline} are not available in programs compiled with
7633 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7634 program compiled with @option{-std=c99} or @option{-std=c11}).  The
7635 ISO C99 keyword
7636 @code{restrict} is only available when @option{-std=gnu99} (which will
7637 eventually be the default) or @option{-std=c99} (or the equivalent
7638 @option{-std=iso9899:1999}), or an option for a later standard
7639 version, is used.
7641 The way to solve these problems is to put @samp{__} at the beginning and
7642 end of each problematical keyword.  For example, use @code{__asm__}
7643 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7645 Other C compilers won't accept these alternative keywords; if you want to
7646 compile with another compiler, you can define the alternate keywords as
7647 macros to replace them with the customary keywords.  It looks like this:
7649 @smallexample
7650 #ifndef __GNUC__
7651 #define __asm__ asm
7652 #endif
7653 @end smallexample
7655 @findex __extension__
7656 @opindex pedantic
7657 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7658 You can
7659 prevent such warnings within one expression by writing
7660 @code{__extension__} before the expression.  @code{__extension__} has no
7661 effect aside from this.
7663 @node Incomplete Enums
7664 @section Incomplete @code{enum} Types
7666 You can define an @code{enum} tag without specifying its possible values.
7667 This results in an incomplete type, much like what you get if you write
7668 @code{struct foo} without describing the elements.  A later declaration
7669 that does specify the possible values completes the type.
7671 You can't allocate variables or storage using the type while it is
7672 incomplete.  However, you can work with pointers to that type.
7674 This extension may not be very useful, but it makes the handling of
7675 @code{enum} more consistent with the way @code{struct} and @code{union}
7676 are handled.
7678 This extension is not supported by GNU C++.
7680 @node Function Names
7681 @section Function Names as Strings
7682 @cindex @code{__func__} identifier
7683 @cindex @code{__FUNCTION__} identifier
7684 @cindex @code{__PRETTY_FUNCTION__} identifier
7686 GCC provides three magic variables that hold the name of the current
7687 function, as a string.  The first of these is @code{__func__}, which
7688 is part of the C99 standard:
7690 The identifier @code{__func__} is implicitly declared by the translator
7691 as if, immediately following the opening brace of each function
7692 definition, the declaration
7694 @smallexample
7695 static const char __func__[] = "function-name";
7696 @end smallexample
7698 @noindent
7699 appeared, where function-name is the name of the lexically-enclosing
7700 function.  This name is the unadorned name of the function.
7702 @code{__FUNCTION__} is another name for @code{__func__}.  Older
7703 versions of GCC recognize only this name.  However, it is not
7704 standardized.  For maximum portability, we recommend you use
7705 @code{__func__}, but provide a fallback definition with the
7706 preprocessor:
7708 @smallexample
7709 #if __STDC_VERSION__ < 199901L
7710 # if __GNUC__ >= 2
7711 #  define __func__ __FUNCTION__
7712 # else
7713 #  define __func__ "<unknown>"
7714 # endif
7715 #endif
7716 @end smallexample
7718 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7719 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
7720 the type signature of the function as well as its bare name.  For
7721 example, this program:
7723 @smallexample
7724 extern "C" @{
7725 extern int printf (char *, ...);
7728 class a @{
7729  public:
7730   void sub (int i)
7731     @{
7732       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7733       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7734     @}
7738 main (void)
7740   a ax;
7741   ax.sub (0);
7742   return 0;
7744 @end smallexample
7746 @noindent
7747 gives this output:
7749 @smallexample
7750 __FUNCTION__ = sub
7751 __PRETTY_FUNCTION__ = void a::sub(int)
7752 @end smallexample
7754 These identifiers are not preprocessor macros.  In GCC 3.3 and
7755 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7756 were treated as string literals; they could be used to initialize
7757 @code{char} arrays, and they could be concatenated with other string
7758 literals.  GCC 3.4 and later treat them as variables, like
7759 @code{__func__}.  In C++, @code{__FUNCTION__} and
7760 @code{__PRETTY_FUNCTION__} have always been variables.
7762 @node Return Address
7763 @section Getting the Return or Frame Address of a Function
7765 These functions may be used to get information about the callers of a
7766 function.
7768 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7769 This function returns the return address of the current function, or of
7770 one of its callers.  The @var{level} argument is number of frames to
7771 scan up the call stack.  A value of @code{0} yields the return address
7772 of the current function, a value of @code{1} yields the return address
7773 of the caller of the current function, and so forth.  When inlining
7774 the expected behavior is that the function returns the address of
7775 the function that is returned to.  To work around this behavior use
7776 the @code{noinline} function attribute.
7778 The @var{level} argument must be a constant integer.
7780 On some machines it may be impossible to determine the return address of
7781 any function other than the current one; in such cases, or when the top
7782 of the stack has been reached, this function returns @code{0} or a
7783 random value.  In addition, @code{__builtin_frame_address} may be used
7784 to determine if the top of the stack has been reached.
7786 Additional post-processing of the returned value may be needed, see
7787 @code{__builtin_extract_return_addr}.
7789 This function should only be used with a nonzero argument for debugging
7790 purposes.
7791 @end deftypefn
7793 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7794 The address as returned by @code{__builtin_return_address} may have to be fed
7795 through this function to get the actual encoded address.  For example, on the
7796 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7797 platforms an offset has to be added for the true next instruction to be
7798 executed.
7800 If no fixup is needed, this function simply passes through @var{addr}.
7801 @end deftypefn
7803 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7804 This function does the reverse of @code{__builtin_extract_return_addr}.
7805 @end deftypefn
7807 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7808 This function is similar to @code{__builtin_return_address}, but it
7809 returns the address of the function frame rather than the return address
7810 of the function.  Calling @code{__builtin_frame_address} with a value of
7811 @code{0} yields the frame address of the current function, a value of
7812 @code{1} yields the frame address of the caller of the current function,
7813 and so forth.
7815 The frame is the area on the stack that holds local variables and saved
7816 registers.  The frame address is normally the address of the first word
7817 pushed on to the stack by the function.  However, the exact definition
7818 depends upon the processor and the calling convention.  If the processor
7819 has a dedicated frame pointer register, and the function has a frame,
7820 then @code{__builtin_frame_address} returns the value of the frame
7821 pointer register.
7823 On some machines it may be impossible to determine the frame address of
7824 any function other than the current one; in such cases, or when the top
7825 of the stack has been reached, this function returns @code{0} if
7826 the first frame pointer is properly initialized by the startup code.
7828 This function should only be used with a nonzero argument for debugging
7829 purposes.
7830 @end deftypefn
7832 @node Vector Extensions
7833 @section Using Vector Instructions through Built-in Functions
7835 On some targets, the instruction set contains SIMD vector instructions which
7836 operate on multiple values contained in one large register at the same time.
7837 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7838 this way.
7840 The first step in using these extensions is to provide the necessary data
7841 types.  This should be done using an appropriate @code{typedef}:
7843 @smallexample
7844 typedef int v4si __attribute__ ((vector_size (16)));
7845 @end smallexample
7847 @noindent
7848 The @code{int} type specifies the base type, while the attribute specifies
7849 the vector size for the variable, measured in bytes.  For example, the
7850 declaration above causes the compiler to set the mode for the @code{v4si}
7851 type to be 16 bytes wide and divided into @code{int} sized units.  For
7852 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7853 corresponding mode of @code{foo} is @acronym{V4SI}.
7855 The @code{vector_size} attribute is only applicable to integral and
7856 float scalars, although arrays, pointers, and function return values
7857 are allowed in conjunction with this construct. Only sizes that are
7858 a power of two are currently allowed.
7860 All the basic integer types can be used as base types, both as signed
7861 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7862 @code{long long}.  In addition, @code{float} and @code{double} can be
7863 used to build floating-point vector types.
7865 Specifying a combination that is not valid for the current architecture
7866 causes GCC to synthesize the instructions using a narrower mode.
7867 For example, if you specify a variable of type @code{V4SI} and your
7868 architecture does not allow for this specific SIMD type, GCC
7869 produces code that uses 4 @code{SIs}.
7871 The types defined in this manner can be used with a subset of normal C
7872 operations.  Currently, GCC allows using the following operators
7873 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7875 The operations behave like C++ @code{valarrays}.  Addition is defined as
7876 the addition of the corresponding elements of the operands.  For
7877 example, in the code below, each of the 4 elements in @var{a} is
7878 added to the corresponding 4 elements in @var{b} and the resulting
7879 vector is stored in @var{c}.
7881 @smallexample
7882 typedef int v4si __attribute__ ((vector_size (16)));
7884 v4si a, b, c;
7886 c = a + b;
7887 @end smallexample
7889 Subtraction, multiplication, division, and the logical operations
7890 operate in a similar manner.  Likewise, the result of using the unary
7891 minus or complement operators on a vector type is a vector whose
7892 elements are the negative or complemented values of the corresponding
7893 elements in the operand.
7895 It is possible to use shifting operators @code{<<}, @code{>>} on
7896 integer-type vectors. The operation is defined as following: @code{@{a0,
7897 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7898 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7899 elements. 
7901 For convenience, it is allowed to use a binary vector operation
7902 where one operand is a scalar. In that case the compiler transforms
7903 the scalar operand into a vector where each element is the scalar from
7904 the operation. The transformation happens only if the scalar could be
7905 safely converted to the vector-element type.
7906 Consider the following code.
7908 @smallexample
7909 typedef int v4si __attribute__ ((vector_size (16)));
7911 v4si a, b, c;
7912 long l;
7914 a = b + 1;    /* a = b + @{1,1,1,1@}; */
7915 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
7917 a = l + a;    /* Error, cannot convert long to int. */
7918 @end smallexample
7920 Vectors can be subscripted as if the vector were an array with
7921 the same number of elements and base type.  Out of bound accesses
7922 invoke undefined behavior at run time.  Warnings for out of bound
7923 accesses for vector subscription can be enabled with
7924 @option{-Warray-bounds}.
7926 Vector comparison is supported with standard comparison
7927 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7928 vector expressions of integer-type or real-type. Comparison between
7929 integer-type vectors and real-type vectors are not supported.  The
7930 result of the comparison is a vector of the same width and number of
7931 elements as the comparison operands with a signed integral element
7932 type.
7934 Vectors are compared element-wise producing 0 when comparison is false
7935 and -1 (constant of the appropriate type where all bits are set)
7936 otherwise. Consider the following example.
7938 @smallexample
7939 typedef int v4si __attribute__ ((vector_size (16)));
7941 v4si a = @{1,2,3,4@};
7942 v4si b = @{3,2,1,4@};
7943 v4si c;
7945 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
7946 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
7947 @end smallexample
7949 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
7950 @code{b} and @code{c} are vectors of the same type and @code{a} is an
7951 integer vector with the same number of elements of the same size as @code{b}
7952 and @code{c}, computes all three arguments and creates a vector
7953 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
7954 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
7955 As in the case of binary operations, this syntax is also accepted when
7956 one of @code{b} or @code{c} is a scalar that is then transformed into a
7957 vector. If both @code{b} and @code{c} are scalars and the type of
7958 @code{true?b:c} has the same size as the element type of @code{a}, then
7959 @code{b} and @code{c} are converted to a vector type whose elements have
7960 this type and with the same number of elements as @code{a}.
7962 In C++, the logic operators @code{!, &&, ||} are available for vectors.
7963 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
7964 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
7965 For mixed operations between a scalar @code{s} and a vector @code{v},
7966 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
7967 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
7969 Vector shuffling is available using functions
7970 @code{__builtin_shuffle (vec, mask)} and
7971 @code{__builtin_shuffle (vec0, vec1, mask)}.
7972 Both functions construct a permutation of elements from one or two
7973 vectors and return a vector of the same type as the input vector(s).
7974 The @var{mask} is an integral vector with the same width (@var{W})
7975 and element count (@var{N}) as the output vector.
7977 The elements of the input vectors are numbered in memory ordering of
7978 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
7979 elements of @var{mask} are considered modulo @var{N} in the single-operand
7980 case and modulo @math{2*@var{N}} in the two-operand case.
7982 Consider the following example,
7984 @smallexample
7985 typedef int v4si __attribute__ ((vector_size (16)));
7987 v4si a = @{1,2,3,4@};
7988 v4si b = @{5,6,7,8@};
7989 v4si mask1 = @{0,1,1,3@};
7990 v4si mask2 = @{0,4,2,5@};
7991 v4si res;
7993 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
7994 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
7995 @end smallexample
7997 Note that @code{__builtin_shuffle} is intentionally semantically
7998 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8000 You can declare variables and use them in function calls and returns, as
8001 well as in assignments and some casts.  You can specify a vector type as
8002 a return type for a function.  Vector types can also be used as function
8003 arguments.  It is possible to cast from one vector type to another,
8004 provided they are of the same size (in fact, you can also cast vectors
8005 to and from other datatypes of the same size).
8007 You cannot operate between vectors of different lengths or different
8008 signedness without a cast.
8010 @node Offsetof
8011 @section Offsetof
8012 @findex __builtin_offsetof
8014 GCC implements for both C and C++ a syntactic extension to implement
8015 the @code{offsetof} macro.
8017 @smallexample
8018 primary:
8019         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8021 offsetof_member_designator:
8022           @code{identifier}
8023         | offsetof_member_designator "." @code{identifier}
8024         | offsetof_member_designator "[" @code{expr} "]"
8025 @end smallexample
8027 This extension is sufficient such that
8029 @smallexample
8030 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8031 @end smallexample
8033 @noindent
8034 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8035 may be dependent.  In either case, @var{member} may consist of a single
8036 identifier, or a sequence of member accesses and array references.
8038 @node __sync Builtins
8039 @section Legacy __sync Built-in Functions for Atomic Memory Access
8041 The following built-in functions
8042 are intended to be compatible with those described
8043 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8044 section 7.4.  As such, they depart from the normal GCC practice of using
8045 the @samp{__builtin_} prefix, and further that they are overloaded such that
8046 they work on multiple types.
8048 The definition given in the Intel documentation allows only for the use of
8049 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
8050 counterparts.  GCC allows any integral scalar or pointer type that is
8051 1, 2, 4 or 8 bytes in length.
8053 Not all operations are supported by all target processors.  If a particular
8054 operation cannot be implemented on the target processor, a warning is
8055 generated and a call an external function is generated.  The external
8056 function carries the same name as the built-in version,
8057 with an additional suffix
8058 @samp{_@var{n}} where @var{n} is the size of the data type.
8060 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8061 @c useful for implementing the operation under the control of an external
8062 @c mutex.
8064 In most cases, these built-in functions are considered a @dfn{full barrier}.
8065 That is,
8066 no memory operand is moved across the operation, either forward or
8067 backward.  Further, instructions are issued as necessary to prevent the
8068 processor from speculating loads across the operation and from queuing stores
8069 after the operation.
8071 All of the routines are described in the Intel documentation to take
8072 ``an optional list of variables protected by the memory barrier''.  It's
8073 not clear what is meant by that; it could mean that @emph{only} the
8074 following variables are protected, or it could mean that these variables
8075 should in addition be protected.  At present GCC ignores this list and
8076 protects all variables that are globally accessible.  If in the future
8077 we make some use of this list, an empty list will continue to mean all
8078 globally accessible variables.
8080 @table @code
8081 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8082 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8083 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8084 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8085 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8086 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8087 @findex __sync_fetch_and_add
8088 @findex __sync_fetch_and_sub
8089 @findex __sync_fetch_and_or
8090 @findex __sync_fetch_and_and
8091 @findex __sync_fetch_and_xor
8092 @findex __sync_fetch_and_nand
8093 These built-in functions perform the operation suggested by the name, and
8094 returns the value that had previously been in memory.  That is,
8096 @smallexample
8097 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8098 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8099 @end smallexample
8101 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8102 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8104 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8105 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8106 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8107 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8108 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8109 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8110 @findex __sync_add_and_fetch
8111 @findex __sync_sub_and_fetch
8112 @findex __sync_or_and_fetch
8113 @findex __sync_and_and_fetch
8114 @findex __sync_xor_and_fetch
8115 @findex __sync_nand_and_fetch
8116 These built-in functions perform the operation suggested by the name, and
8117 return the new value.  That is,
8119 @smallexample
8120 @{ *ptr @var{op}= value; return *ptr; @}
8121 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8122 @end smallexample
8124 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8125 as @code{*ptr = ~(*ptr & value)} instead of
8126 @code{*ptr = ~*ptr & value}.
8128 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8129 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8130 @findex __sync_bool_compare_and_swap
8131 @findex __sync_val_compare_and_swap
8132 These built-in functions perform an atomic compare and swap.
8133 That is, if the current
8134 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8135 @code{*@var{ptr}}.
8137 The ``bool'' version returns true if the comparison is successful and
8138 @var{newval} is written.  The ``val'' version returns the contents
8139 of @code{*@var{ptr}} before the operation.
8141 @item __sync_synchronize (...)
8142 @findex __sync_synchronize
8143 This built-in function issues a full memory barrier.
8145 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8146 @findex __sync_lock_test_and_set
8147 This built-in function, as described by Intel, is not a traditional test-and-set
8148 operation, but rather an atomic exchange operation.  It writes @var{value}
8149 into @code{*@var{ptr}}, and returns the previous contents of
8150 @code{*@var{ptr}}.
8152 Many targets have only minimal support for such locks, and do not support
8153 a full exchange operation.  In this case, a target may support reduced
8154 functionality here by which the @emph{only} valid value to store is the
8155 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8156 is implementation defined.
8158 This built-in function is not a full barrier,
8159 but rather an @dfn{acquire barrier}.
8160 This means that references after the operation cannot move to (or be
8161 speculated to) before the operation, but previous memory stores may not
8162 be globally visible yet, and previous memory loads may not yet be
8163 satisfied.
8165 @item void __sync_lock_release (@var{type} *ptr, ...)
8166 @findex __sync_lock_release
8167 This built-in function releases the lock acquired by
8168 @code{__sync_lock_test_and_set}.
8169 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8171 This built-in function is not a full barrier,
8172 but rather a @dfn{release barrier}.
8173 This means that all previous memory stores are globally visible, and all
8174 previous memory loads have been satisfied, but following memory reads
8175 are not prevented from being speculated to before the barrier.
8176 @end table
8178 @node __atomic Builtins
8179 @section Built-in functions for memory model aware atomic operations
8181 The following built-in functions approximately match the requirements for
8182 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8183 functions, but all also have a memory model parameter.  These are all
8184 identified by being prefixed with @samp{__atomic}, and most are overloaded
8185 such that they work with multiple types.
8187 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8188 bytes in length. 16-byte integral types are also allowed if
8189 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8191 Target architectures are encouraged to provide their own patterns for
8192 each of these built-in functions.  If no target is provided, the original 
8193 non-memory model set of @samp{__sync} atomic built-in functions are
8194 utilized, along with any required synchronization fences surrounding it in
8195 order to achieve the proper behavior.  Execution in this case is subject
8196 to the same restrictions as those built-in functions.
8198 If there is no pattern or mechanism to provide a lock free instruction
8199 sequence, a call is made to an external routine with the same parameters
8200 to be resolved at run time.
8202 The four non-arithmetic functions (load, store, exchange, and 
8203 compare_exchange) all have a generic version as well.  This generic
8204 version works on any data type.  If the data type size maps to one
8205 of the integral sizes that may have lock free support, the generic
8206 version utilizes the lock free built-in function.  Otherwise an
8207 external call is left to be resolved at run time.  This external call is
8208 the same format with the addition of a @samp{size_t} parameter inserted
8209 as the first parameter indicating the size of the object being pointed to.
8210 All objects must be the same size.
8212 There are 6 different memory models that can be specified.  These map
8213 to the same names in the C++11 standard.  Refer there or to the
8214 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8215 atomic synchronization} for more detailed definitions.  These memory
8216 models integrate both barriers to code motion as well as synchronization
8217 requirements with other threads. These are listed in approximately
8218 ascending order of strength. It is also possible to use target specific
8219 flags for memory model flags, like Hardware Lock Elision.
8221 @table  @code
8222 @item __ATOMIC_RELAXED
8223 No barriers or synchronization.
8224 @item __ATOMIC_CONSUME
8225 Data dependency only for both barrier and synchronization with another
8226 thread.
8227 @item __ATOMIC_ACQUIRE
8228 Barrier to hoisting of code and synchronizes with release (or stronger)
8229 semantic stores from another thread.
8230 @item __ATOMIC_RELEASE
8231 Barrier to sinking of code and synchronizes with acquire (or stronger)
8232 semantic loads from another thread.
8233 @item __ATOMIC_ACQ_REL
8234 Full barrier in both directions and synchronizes with acquire loads and
8235 release stores in another thread.
8236 @item __ATOMIC_SEQ_CST
8237 Full barrier in both directions and synchronizes with acquire loads and
8238 release stores in all threads.
8239 @end table
8241 When implementing patterns for these built-in functions, the memory model
8242 parameter can be ignored as long as the pattern implements the most
8243 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8244 execute correctly with this memory model but they may not execute as
8245 efficiently as they could with a more appropriate implementation of the
8246 relaxed requirements.
8248 Note that the C++11 standard allows for the memory model parameter to be
8249 determined at run time rather than at compile time.  These built-in
8250 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8251 than invoke a runtime library call or inline a switch statement.  This is
8252 standard compliant, safe, and the simplest approach for now.
8254 The memory model parameter is a signed int, but only the lower 8 bits are
8255 reserved for the memory model.  The remainder of the signed int is reserved
8256 for future use and should be 0.  Use of the predefined atomic values
8257 ensures proper usage.
8259 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8260 This built-in function implements an atomic load operation.  It returns the
8261 contents of @code{*@var{ptr}}.
8263 The valid memory model variants are
8264 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8265 and @code{__ATOMIC_CONSUME}.
8267 @end deftypefn
8269 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8270 This is the generic version of an atomic load.  It returns the
8271 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8273 @end deftypefn
8275 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8276 This built-in function implements an atomic store operation.  It writes 
8277 @code{@var{val}} into @code{*@var{ptr}}.  
8279 The valid memory model variants are
8280 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8282 @end deftypefn
8284 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8285 This is the generic version of an atomic store.  It stores the value
8286 of @code{*@var{val}} into @code{*@var{ptr}}.
8288 @end deftypefn
8290 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8291 This built-in function implements an atomic exchange operation.  It writes
8292 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8293 @code{*@var{ptr}}.
8295 The valid memory model variants are
8296 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8297 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8299 @end deftypefn
8301 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8302 This is the generic version of an atomic exchange.  It stores the
8303 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8304 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8306 @end deftypefn
8308 @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)
8309 This built-in function implements an atomic compare and exchange operation.
8310 This compares the contents of @code{*@var{ptr}} with the contents of
8311 @code{*@var{expected}} and if equal, writes @var{desired} into
8312 @code{*@var{ptr}}.  If they are not equal, the current contents of
8313 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8314 for weak compare_exchange, and false for the strong variation.  Many targets 
8315 only offer the strong variation and ignore the parameter.  When in doubt, use
8316 the strong variation.
8318 True is returned if @var{desired} is written into
8319 @code{*@var{ptr}} and the execution is considered to conform to the
8320 memory model specified by @var{success_memmodel}.  There are no
8321 restrictions on what memory model can be used here.
8323 False is returned otherwise, and the execution is considered to conform
8324 to @var{failure_memmodel}. This memory model cannot be
8325 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8326 stronger model than that specified by @var{success_memmodel}.
8328 @end deftypefn
8330 @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)
8331 This built-in function implements the generic version of
8332 @code{__atomic_compare_exchange}.  The function is virtually identical to
8333 @code{__atomic_compare_exchange_n}, except the desired value is also a
8334 pointer.
8336 @end deftypefn
8338 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8339 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8340 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8341 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8342 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8343 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8344 These built-in functions perform the operation suggested by the name, and
8345 return the result of the operation. That is,
8347 @smallexample
8348 @{ *ptr @var{op}= val; return *ptr; @}
8349 @end smallexample
8351 All memory models are valid.
8353 @end deftypefn
8355 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8356 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8357 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8358 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8359 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8360 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8361 These built-in functions perform the operation suggested by the name, and
8362 return the value that had previously been in @code{*@var{ptr}}.  That is,
8364 @smallexample
8365 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8366 @end smallexample
8368 All memory models are valid.
8370 @end deftypefn
8372 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8374 This built-in function performs an atomic test-and-set operation on
8375 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
8376 defined nonzero ``set'' value and the return value is @code{true} if and only
8377 if the previous contents were ``set''.
8378 It should be only used for operands of type @code{bool} or @code{char}. For 
8379 other types only part of the value may be set.
8381 All memory models are valid.
8383 @end deftypefn
8385 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8387 This built-in function performs an atomic clear operation on
8388 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
8389 It should be only used for operands of type @code{bool} or @code{char} and 
8390 in conjunction with @code{__atomic_test_and_set}.
8391 For other types it may only clear partially. If the type is not @code{bool}
8392 prefer using @code{__atomic_store}.
8394 The valid memory model variants are
8395 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8396 @code{__ATOMIC_RELEASE}.
8398 @end deftypefn
8400 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8402 This built-in function acts as a synchronization fence between threads
8403 based on the specified memory model.
8405 All memory orders are valid.
8407 @end deftypefn
8409 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8411 This built-in function acts as a synchronization fence between a thread
8412 and signal handlers based in the same thread.
8414 All memory orders are valid.
8416 @end deftypefn
8418 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
8420 This built-in function returns true if objects of @var{size} bytes always
8421 generate lock free atomic instructions for the target architecture.  
8422 @var{size} must resolve to a compile-time constant and the result also
8423 resolves to a compile-time constant.
8425 @var{ptr} is an optional pointer to the object that may be used to determine
8426 alignment.  A value of 0 indicates typical alignment should be used.  The 
8427 compiler may also ignore this parameter.
8429 @smallexample
8430 if (_atomic_always_lock_free (sizeof (long long), 0))
8431 @end smallexample
8433 @end deftypefn
8435 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8437 This built-in function returns true if objects of @var{size} bytes always
8438 generate lock free atomic instructions for the target architecture.  If
8439 it is not known to be lock free a call is made to a runtime routine named
8440 @code{__atomic_is_lock_free}.
8442 @var{ptr} is an optional pointer to the object that may be used to determine
8443 alignment.  A value of 0 indicates typical alignment should be used.  The 
8444 compiler may also ignore this parameter.
8445 @end deftypefn
8447 @node x86 specific memory model extensions for transactional memory
8448 @section x86 specific memory model extensions for transactional memory
8450 The i386 architecture supports additional memory ordering flags
8451 to mark lock critical sections for hardware lock elision. 
8452 These must be specified in addition to an existing memory model to 
8453 atomic intrinsics.
8455 @table @code
8456 @item __ATOMIC_HLE_ACQUIRE
8457 Start lock elision on a lock variable.
8458 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8459 @item __ATOMIC_HLE_RELEASE
8460 End lock elision on a lock variable.
8461 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8462 @end table
8464 When a lock acquire fails it is required for good performance to abort
8465 the transaction quickly. This can be done with a @code{_mm_pause}
8467 @smallexample
8468 #include <immintrin.h> // For _mm_pause
8470 int lockvar;
8472 /* Acquire lock with lock elision */
8473 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8474     _mm_pause(); /* Abort failed transaction */
8476 /* Free lock with lock elision */
8477 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8478 @end smallexample
8480 @node Object Size Checking
8481 @section Object Size Checking Built-in Functions
8482 @findex __builtin_object_size
8483 @findex __builtin___memcpy_chk
8484 @findex __builtin___mempcpy_chk
8485 @findex __builtin___memmove_chk
8486 @findex __builtin___memset_chk
8487 @findex __builtin___strcpy_chk
8488 @findex __builtin___stpcpy_chk
8489 @findex __builtin___strncpy_chk
8490 @findex __builtin___strcat_chk
8491 @findex __builtin___strncat_chk
8492 @findex __builtin___sprintf_chk
8493 @findex __builtin___snprintf_chk
8494 @findex __builtin___vsprintf_chk
8495 @findex __builtin___vsnprintf_chk
8496 @findex __builtin___printf_chk
8497 @findex __builtin___vprintf_chk
8498 @findex __builtin___fprintf_chk
8499 @findex __builtin___vfprintf_chk
8501 GCC implements a limited buffer overflow protection mechanism
8502 that can prevent some buffer overflow attacks.
8504 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8505 is a built-in construct that returns a constant number of bytes from
8506 @var{ptr} to the end of the object @var{ptr} pointer points to
8507 (if known at compile time).  @code{__builtin_object_size} never evaluates
8508 its arguments for side-effects.  If there are any side-effects in them, it
8509 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8510 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
8511 point to and all of them are known at compile time, the returned number
8512 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8513 0 and minimum if nonzero.  If it is not possible to determine which objects
8514 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8515 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8516 for @var{type} 2 or 3.
8518 @var{type} is an integer constant from 0 to 3.  If the least significant
8519 bit is clear, objects are whole variables, if it is set, a closest
8520 surrounding subobject is considered the object a pointer points to.
8521 The second bit determines if maximum or minimum of remaining bytes
8522 is computed.
8524 @smallexample
8525 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8526 char *p = &var.buf1[1], *q = &var.b;
8528 /* Here the object p points to is var.  */
8529 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8530 /* The subobject p points to is var.buf1.  */
8531 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8532 /* The object q points to is var.  */
8533 assert (__builtin_object_size (q, 0)
8534         == (char *) (&var + 1) - (char *) &var.b);
8535 /* The subobject q points to is var.b.  */
8536 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8537 @end smallexample
8538 @end deftypefn
8540 There are built-in functions added for many common string operation
8541 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8542 built-in is provided.  This built-in has an additional last argument,
8543 which is the number of bytes remaining in object the @var{dest}
8544 argument points to or @code{(size_t) -1} if the size is not known.
8546 The built-in functions are optimized into the normal string functions
8547 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8548 it is known at compile time that the destination object will not
8549 be overflown.  If the compiler can determine at compile time the
8550 object will be always overflown, it issues a warning.
8552 The intended use can be e.g.@:
8554 @smallexample
8555 #undef memcpy
8556 #define bos0(dest) __builtin_object_size (dest, 0)
8557 #define memcpy(dest, src, n) \
8558   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8560 char *volatile p;
8561 char buf[10];
8562 /* It is unknown what object p points to, so this is optimized
8563    into plain memcpy - no checking is possible.  */
8564 memcpy (p, "abcde", n);
8565 /* Destination is known and length too.  It is known at compile
8566    time there will be no overflow.  */
8567 memcpy (&buf[5], "abcde", 5);
8568 /* Destination is known, but the length is not known at compile time.
8569    This will result in __memcpy_chk call that can check for overflow
8570    at run time.  */
8571 memcpy (&buf[5], "abcde", n);
8572 /* Destination is known and it is known at compile time there will
8573    be overflow.  There will be a warning and __memcpy_chk call that
8574    will abort the program at run time.  */
8575 memcpy (&buf[6], "abcde", 5);
8576 @end smallexample
8578 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8579 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8580 @code{strcat} and @code{strncat}.
8582 There are also checking built-in functions for formatted output functions.
8583 @smallexample
8584 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8585 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8586                               const char *fmt, ...);
8587 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8588                               va_list ap);
8589 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8590                                const char *fmt, va_list ap);
8591 @end smallexample
8593 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8594 etc.@: functions and can contain implementation specific flags on what
8595 additional security measures the checking function might take, such as
8596 handling @code{%n} differently.
8598 The @var{os} argument is the object size @var{s} points to, like in the
8599 other built-in functions.  There is a small difference in the behavior
8600 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8601 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8602 the checking function is called with @var{os} argument set to
8603 @code{(size_t) -1}.
8605 In addition to this, there are checking built-in functions
8606 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8607 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8608 These have just one additional argument, @var{flag}, right before
8609 format string @var{fmt}.  If the compiler is able to optimize them to
8610 @code{fputc} etc.@: functions, it does, otherwise the checking function
8611 is called and the @var{flag} argument passed to it.
8613 @node Cilk Plus Builtins
8614 @section Cilk Plus C/C++ language extension Built-in Functions.
8616 GCC provides support for the following built-in reduction funtions if Cilk Plus
8617 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8619 @itemize @bullet
8620 @item __sec_implicit_index
8621 @item __sec_reduce
8622 @item __sec_reduce_add
8623 @item __sec_reduce_all_nonzero
8624 @item __sec_reduce_all_zero
8625 @item __sec_reduce_any_nonzero
8626 @item __sec_reduce_any_zero
8627 @item __sec_reduce_max
8628 @item __sec_reduce_min
8629 @item __sec_reduce_max_ind
8630 @item __sec_reduce_min_ind
8631 @item __sec_reduce_mul
8632 @item __sec_reduce_mutating
8633 @end itemize
8635 Further details and examples about these built-in functions are described 
8636 in the Cilk Plus language manual which can be found at 
8637 @uref{http://www.cilkplus.org}.
8639 @node Other Builtins
8640 @section Other Built-in Functions Provided by GCC
8641 @cindex built-in functions
8642 @findex __builtin_fpclassify
8643 @findex __builtin_isfinite
8644 @findex __builtin_isnormal
8645 @findex __builtin_isgreater
8646 @findex __builtin_isgreaterequal
8647 @findex __builtin_isinf_sign
8648 @findex __builtin_isless
8649 @findex __builtin_islessequal
8650 @findex __builtin_islessgreater
8651 @findex __builtin_isunordered
8652 @findex __builtin_powi
8653 @findex __builtin_powif
8654 @findex __builtin_powil
8655 @findex _Exit
8656 @findex _exit
8657 @findex abort
8658 @findex abs
8659 @findex acos
8660 @findex acosf
8661 @findex acosh
8662 @findex acoshf
8663 @findex acoshl
8664 @findex acosl
8665 @findex alloca
8666 @findex asin
8667 @findex asinf
8668 @findex asinh
8669 @findex asinhf
8670 @findex asinhl
8671 @findex asinl
8672 @findex atan
8673 @findex atan2
8674 @findex atan2f
8675 @findex atan2l
8676 @findex atanf
8677 @findex atanh
8678 @findex atanhf
8679 @findex atanhl
8680 @findex atanl
8681 @findex bcmp
8682 @findex bzero
8683 @findex cabs
8684 @findex cabsf
8685 @findex cabsl
8686 @findex cacos
8687 @findex cacosf
8688 @findex cacosh
8689 @findex cacoshf
8690 @findex cacoshl
8691 @findex cacosl
8692 @findex calloc
8693 @findex carg
8694 @findex cargf
8695 @findex cargl
8696 @findex casin
8697 @findex casinf
8698 @findex casinh
8699 @findex casinhf
8700 @findex casinhl
8701 @findex casinl
8702 @findex catan
8703 @findex catanf
8704 @findex catanh
8705 @findex catanhf
8706 @findex catanhl
8707 @findex catanl
8708 @findex cbrt
8709 @findex cbrtf
8710 @findex cbrtl
8711 @findex ccos
8712 @findex ccosf
8713 @findex ccosh
8714 @findex ccoshf
8715 @findex ccoshl
8716 @findex ccosl
8717 @findex ceil
8718 @findex ceilf
8719 @findex ceill
8720 @findex cexp
8721 @findex cexpf
8722 @findex cexpl
8723 @findex cimag
8724 @findex cimagf
8725 @findex cimagl
8726 @findex clog
8727 @findex clogf
8728 @findex clogl
8729 @findex conj
8730 @findex conjf
8731 @findex conjl
8732 @findex copysign
8733 @findex copysignf
8734 @findex copysignl
8735 @findex cos
8736 @findex cosf
8737 @findex cosh
8738 @findex coshf
8739 @findex coshl
8740 @findex cosl
8741 @findex cpow
8742 @findex cpowf
8743 @findex cpowl
8744 @findex cproj
8745 @findex cprojf
8746 @findex cprojl
8747 @findex creal
8748 @findex crealf
8749 @findex creall
8750 @findex csin
8751 @findex csinf
8752 @findex csinh
8753 @findex csinhf
8754 @findex csinhl
8755 @findex csinl
8756 @findex csqrt
8757 @findex csqrtf
8758 @findex csqrtl
8759 @findex ctan
8760 @findex ctanf
8761 @findex ctanh
8762 @findex ctanhf
8763 @findex ctanhl
8764 @findex ctanl
8765 @findex dcgettext
8766 @findex dgettext
8767 @findex drem
8768 @findex dremf
8769 @findex dreml
8770 @findex erf
8771 @findex erfc
8772 @findex erfcf
8773 @findex erfcl
8774 @findex erff
8775 @findex erfl
8776 @findex exit
8777 @findex exp
8778 @findex exp10
8779 @findex exp10f
8780 @findex exp10l
8781 @findex exp2
8782 @findex exp2f
8783 @findex exp2l
8784 @findex expf
8785 @findex expl
8786 @findex expm1
8787 @findex expm1f
8788 @findex expm1l
8789 @findex fabs
8790 @findex fabsf
8791 @findex fabsl
8792 @findex fdim
8793 @findex fdimf
8794 @findex fdiml
8795 @findex ffs
8796 @findex floor
8797 @findex floorf
8798 @findex floorl
8799 @findex fma
8800 @findex fmaf
8801 @findex fmal
8802 @findex fmax
8803 @findex fmaxf
8804 @findex fmaxl
8805 @findex fmin
8806 @findex fminf
8807 @findex fminl
8808 @findex fmod
8809 @findex fmodf
8810 @findex fmodl
8811 @findex fprintf
8812 @findex fprintf_unlocked
8813 @findex fputs
8814 @findex fputs_unlocked
8815 @findex frexp
8816 @findex frexpf
8817 @findex frexpl
8818 @findex fscanf
8819 @findex gamma
8820 @findex gammaf
8821 @findex gammal
8822 @findex gamma_r
8823 @findex gammaf_r
8824 @findex gammal_r
8825 @findex gettext
8826 @findex hypot
8827 @findex hypotf
8828 @findex hypotl
8829 @findex ilogb
8830 @findex ilogbf
8831 @findex ilogbl
8832 @findex imaxabs
8833 @findex index
8834 @findex isalnum
8835 @findex isalpha
8836 @findex isascii
8837 @findex isblank
8838 @findex iscntrl
8839 @findex isdigit
8840 @findex isgraph
8841 @findex islower
8842 @findex isprint
8843 @findex ispunct
8844 @findex isspace
8845 @findex isupper
8846 @findex iswalnum
8847 @findex iswalpha
8848 @findex iswblank
8849 @findex iswcntrl
8850 @findex iswdigit
8851 @findex iswgraph
8852 @findex iswlower
8853 @findex iswprint
8854 @findex iswpunct
8855 @findex iswspace
8856 @findex iswupper
8857 @findex iswxdigit
8858 @findex isxdigit
8859 @findex j0
8860 @findex j0f
8861 @findex j0l
8862 @findex j1
8863 @findex j1f
8864 @findex j1l
8865 @findex jn
8866 @findex jnf
8867 @findex jnl
8868 @findex labs
8869 @findex ldexp
8870 @findex ldexpf
8871 @findex ldexpl
8872 @findex lgamma
8873 @findex lgammaf
8874 @findex lgammal
8875 @findex lgamma_r
8876 @findex lgammaf_r
8877 @findex lgammal_r
8878 @findex llabs
8879 @findex llrint
8880 @findex llrintf
8881 @findex llrintl
8882 @findex llround
8883 @findex llroundf
8884 @findex llroundl
8885 @findex log
8886 @findex log10
8887 @findex log10f
8888 @findex log10l
8889 @findex log1p
8890 @findex log1pf
8891 @findex log1pl
8892 @findex log2
8893 @findex log2f
8894 @findex log2l
8895 @findex logb
8896 @findex logbf
8897 @findex logbl
8898 @findex logf
8899 @findex logl
8900 @findex lrint
8901 @findex lrintf
8902 @findex lrintl
8903 @findex lround
8904 @findex lroundf
8905 @findex lroundl
8906 @findex malloc
8907 @findex memchr
8908 @findex memcmp
8909 @findex memcpy
8910 @findex mempcpy
8911 @findex memset
8912 @findex modf
8913 @findex modff
8914 @findex modfl
8915 @findex nearbyint
8916 @findex nearbyintf
8917 @findex nearbyintl
8918 @findex nextafter
8919 @findex nextafterf
8920 @findex nextafterl
8921 @findex nexttoward
8922 @findex nexttowardf
8923 @findex nexttowardl
8924 @findex pow
8925 @findex pow10
8926 @findex pow10f
8927 @findex pow10l
8928 @findex powf
8929 @findex powl
8930 @findex printf
8931 @findex printf_unlocked
8932 @findex putchar
8933 @findex puts
8934 @findex remainder
8935 @findex remainderf
8936 @findex remainderl
8937 @findex remquo
8938 @findex remquof
8939 @findex remquol
8940 @findex rindex
8941 @findex rint
8942 @findex rintf
8943 @findex rintl
8944 @findex round
8945 @findex roundf
8946 @findex roundl
8947 @findex scalb
8948 @findex scalbf
8949 @findex scalbl
8950 @findex scalbln
8951 @findex scalblnf
8952 @findex scalblnf
8953 @findex scalbn
8954 @findex scalbnf
8955 @findex scanfnl
8956 @findex signbit
8957 @findex signbitf
8958 @findex signbitl
8959 @findex signbitd32
8960 @findex signbitd64
8961 @findex signbitd128
8962 @findex significand
8963 @findex significandf
8964 @findex significandl
8965 @findex sin
8966 @findex sincos
8967 @findex sincosf
8968 @findex sincosl
8969 @findex sinf
8970 @findex sinh
8971 @findex sinhf
8972 @findex sinhl
8973 @findex sinl
8974 @findex snprintf
8975 @findex sprintf
8976 @findex sqrt
8977 @findex sqrtf
8978 @findex sqrtl
8979 @findex sscanf
8980 @findex stpcpy
8981 @findex stpncpy
8982 @findex strcasecmp
8983 @findex strcat
8984 @findex strchr
8985 @findex strcmp
8986 @findex strcpy
8987 @findex strcspn
8988 @findex strdup
8989 @findex strfmon
8990 @findex strftime
8991 @findex strlen
8992 @findex strncasecmp
8993 @findex strncat
8994 @findex strncmp
8995 @findex strncpy
8996 @findex strndup
8997 @findex strpbrk
8998 @findex strrchr
8999 @findex strspn
9000 @findex strstr
9001 @findex tan
9002 @findex tanf
9003 @findex tanh
9004 @findex tanhf
9005 @findex tanhl
9006 @findex tanl
9007 @findex tgamma
9008 @findex tgammaf
9009 @findex tgammal
9010 @findex toascii
9011 @findex tolower
9012 @findex toupper
9013 @findex towlower
9014 @findex towupper
9015 @findex trunc
9016 @findex truncf
9017 @findex truncl
9018 @findex vfprintf
9019 @findex vfscanf
9020 @findex vprintf
9021 @findex vscanf
9022 @findex vsnprintf
9023 @findex vsprintf
9024 @findex vsscanf
9025 @findex y0
9026 @findex y0f
9027 @findex y0l
9028 @findex y1
9029 @findex y1f
9030 @findex y1l
9031 @findex yn
9032 @findex ynf
9033 @findex ynl
9035 GCC provides a large number of built-in functions other than the ones
9036 mentioned above.  Some of these are for internal use in the processing
9037 of exceptions or variable-length argument lists and are not
9038 documented here because they may change from time to time; we do not
9039 recommend general use of these functions.
9041 The remaining functions are provided for optimization purposes.
9043 @opindex fno-builtin
9044 GCC includes built-in versions of many of the functions in the standard
9045 C library.  The versions prefixed with @code{__builtin_} are always
9046 treated as having the same meaning as the C library function even if you
9047 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
9048 Many of these functions are only optimized in certain cases; if they are
9049 not optimized in a particular case, a call to the library function is
9050 emitted.
9052 @opindex ansi
9053 @opindex std
9054 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9055 @option{-std=c99} or @option{-std=c11}), the functions
9056 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9057 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9058 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9059 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9060 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9061 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9062 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9063 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9064 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9065 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9066 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9067 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9068 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9069 @code{significandl}, @code{significand}, @code{sincosf},
9070 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9071 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9072 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9073 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9074 @code{yn}
9075 may be handled as built-in functions.
9076 All these functions have corresponding versions
9077 prefixed with @code{__builtin_}, which may be used even in strict C90
9078 mode.
9080 The ISO C99 functions
9081 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9082 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9083 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9084 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9085 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9086 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9087 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9088 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9089 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9090 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9091 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9092 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9093 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9094 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9095 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9096 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9097 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9098 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9099 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9100 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9101 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9102 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9103 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9104 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9105 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9106 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9107 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9108 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9109 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9110 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9111 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9112 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9113 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9114 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9115 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9116 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9117 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9118 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9119 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9120 are handled as built-in functions
9121 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9123 There are also built-in versions of the ISO C99 functions
9124 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9125 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9126 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9127 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9128 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9129 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9130 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9131 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9132 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9133 that are recognized in any mode since ISO C90 reserves these names for
9134 the purpose to which ISO C99 puts them.  All these functions have
9135 corresponding versions prefixed with @code{__builtin_}.
9137 The ISO C94 functions
9138 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9139 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9140 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9141 @code{towupper}
9142 are handled as built-in functions
9143 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9145 The ISO C90 functions
9146 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9147 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9148 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9149 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9150 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9151 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9152 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9153 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9154 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9155 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9156 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9157 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9158 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9159 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9160 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9161 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9162 are all recognized as built-in functions unless
9163 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9164 is specified for an individual function).  All of these functions have
9165 corresponding versions prefixed with @code{__builtin_}.
9167 GCC provides built-in versions of the ISO C99 floating-point comparison
9168 macros that avoid raising exceptions for unordered operands.  They have
9169 the same names as the standard macros ( @code{isgreater},
9170 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9171 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9172 prefixed.  We intend for a library implementor to be able to simply
9173 @code{#define} each standard macro to its built-in equivalent.
9174 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9175 @code{isinf_sign} and @code{isnormal} built-ins used with
9176 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
9177 built-in functions appear both with and without the @code{__builtin_} prefix.
9179 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9181 You can use the built-in function @code{__builtin_types_compatible_p} to
9182 determine whether two types are the same.
9184 This built-in function returns 1 if the unqualified versions of the
9185 types @var{type1} and @var{type2} (which are types, not expressions) are
9186 compatible, 0 otherwise.  The result of this built-in function can be
9187 used in integer constant expressions.
9189 This built-in function ignores top level qualifiers (e.g., @code{const},
9190 @code{volatile}).  For example, @code{int} is equivalent to @code{const
9191 int}.
9193 The type @code{int[]} and @code{int[5]} are compatible.  On the other
9194 hand, @code{int} and @code{char *} are not compatible, even if the size
9195 of their types, on the particular architecture are the same.  Also, the
9196 amount of pointer indirection is taken into account when determining
9197 similarity.  Consequently, @code{short *} is not similar to
9198 @code{short **}.  Furthermore, two types that are typedefed are
9199 considered compatible if their underlying types are compatible.
9201 An @code{enum} type is not considered to be compatible with another
9202 @code{enum} type even if both are compatible with the same integer
9203 type; this is what the C standard specifies.
9204 For example, @code{enum @{foo, bar@}} is not similar to
9205 @code{enum @{hot, dog@}}.
9207 You typically use this function in code whose execution varies
9208 depending on the arguments' types.  For example:
9210 @smallexample
9211 #define foo(x)                                                  \
9212   (@{                                                           \
9213     typeof (x) tmp = (x);                                       \
9214     if (__builtin_types_compatible_p (typeof (x), long double)) \
9215       tmp = foo_long_double (tmp);                              \
9216     else if (__builtin_types_compatible_p (typeof (x), double)) \
9217       tmp = foo_double (tmp);                                   \
9218     else if (__builtin_types_compatible_p (typeof (x), float))  \
9219       tmp = foo_float (tmp);                                    \
9220     else                                                        \
9221       abort ();                                                 \
9222     tmp;                                                        \
9223   @})
9224 @end smallexample
9226 @emph{Note:} This construct is only available for C@.
9228 @end deftypefn
9230 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9232 You can use the built-in function @code{__builtin_choose_expr} to
9233 evaluate code depending on the value of a constant expression.  This
9234 built-in function returns @var{exp1} if @var{const_exp}, which is an
9235 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
9237 This built-in function is analogous to the @samp{? :} operator in C,
9238 except that the expression returned has its type unaltered by promotion
9239 rules.  Also, the built-in function does not evaluate the expression
9240 that is not chosen.  For example, if @var{const_exp} evaluates to true,
9241 @var{exp2} is not evaluated even if it has side-effects.
9243 This built-in function can return an lvalue if the chosen argument is an
9244 lvalue.
9246 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9247 type.  Similarly, if @var{exp2} is returned, its return type is the same
9248 as @var{exp2}.
9250 Example:
9252 @smallexample
9253 #define foo(x)                                                    \
9254   __builtin_choose_expr (                                         \
9255     __builtin_types_compatible_p (typeof (x), double),            \
9256     foo_double (x),                                               \
9257     __builtin_choose_expr (                                       \
9258       __builtin_types_compatible_p (typeof (x), float),           \
9259       foo_float (x),                                              \
9260       /* @r{The void expression results in a compile-time error}  \
9261          @r{when assigning the result to something.}  */          \
9262       (void)0))
9263 @end smallexample
9265 @emph{Note:} This construct is only available for C@.  Furthermore, the
9266 unused expression (@var{exp1} or @var{exp2} depending on the value of
9267 @var{const_exp}) may still generate syntax errors.  This may change in
9268 future revisions.
9270 @end deftypefn
9272 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9274 The built-in function @code{__builtin_complex} is provided for use in
9275 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9276 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
9277 real binary floating-point type, and the result has the corresponding
9278 complex type with real and imaginary parts @var{real} and @var{imag}.
9279 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9280 infinities, NaNs and negative zeros are involved.
9282 @end deftypefn
9284 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9285 You can use the built-in function @code{__builtin_constant_p} to
9286 determine if a value is known to be constant at compile time and hence
9287 that GCC can perform constant-folding on expressions involving that
9288 value.  The argument of the function is the value to test.  The function
9289 returns the integer 1 if the argument is known to be a compile-time
9290 constant and 0 if it is not known to be a compile-time constant.  A
9291 return of 0 does not indicate that the value is @emph{not} a constant,
9292 but merely that GCC cannot prove it is a constant with the specified
9293 value of the @option{-O} option.
9295 You typically use this function in an embedded application where
9296 memory is a critical resource.  If you have some complex calculation,
9297 you may want it to be folded if it involves constants, but need to call
9298 a function if it does not.  For example:
9300 @smallexample
9301 #define Scale_Value(X)      \
9302   (__builtin_constant_p (X) \
9303   ? ((X) * SCALE + OFFSET) : Scale (X))
9304 @end smallexample
9306 You may use this built-in function in either a macro or an inline
9307 function.  However, if you use it in an inlined function and pass an
9308 argument of the function as the argument to the built-in, GCC 
9309 never returns 1 when you call the inline function with a string constant
9310 or compound literal (@pxref{Compound Literals}) and does not return 1
9311 when you pass a constant numeric value to the inline function unless you
9312 specify the @option{-O} option.
9314 You may also use @code{__builtin_constant_p} in initializers for static
9315 data.  For instance, you can write
9317 @smallexample
9318 static const int table[] = @{
9319    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9320    /* @r{@dots{}} */
9322 @end smallexample
9324 @noindent
9325 This is an acceptable initializer even if @var{EXPRESSION} is not a
9326 constant expression, including the case where
9327 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9328 folded to a constant but @var{EXPRESSION} contains operands that are
9329 not otherwise permitted in a static initializer (for example,
9330 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
9331 built-in in this case, because it has no opportunity to perform
9332 optimization.
9334 Previous versions of GCC did not accept this built-in in data
9335 initializers.  The earliest version where it is completely safe is
9336 3.0.1.
9337 @end deftypefn
9339 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9340 @opindex fprofile-arcs
9341 You may use @code{__builtin_expect} to provide the compiler with
9342 branch prediction information.  In general, you should prefer to
9343 use actual profile feedback for this (@option{-fprofile-arcs}), as
9344 programmers are notoriously bad at predicting how their programs
9345 actually perform.  However, there are applications in which this
9346 data is hard to collect.
9348 The return value is the value of @var{exp}, which should be an integral
9349 expression.  The semantics of the built-in are that it is expected that
9350 @var{exp} == @var{c}.  For example:
9352 @smallexample
9353 if (__builtin_expect (x, 0))
9354   foo ();
9355 @end smallexample
9357 @noindent
9358 indicates that we do not expect to call @code{foo}, since
9359 we expect @code{x} to be zero.  Since you are limited to integral
9360 expressions for @var{exp}, you should use constructions such as
9362 @smallexample
9363 if (__builtin_expect (ptr != NULL, 1))
9364   foo (*ptr);
9365 @end smallexample
9367 @noindent
9368 when testing pointer or floating-point values.
9369 @end deftypefn
9371 @deftypefn {Built-in Function} void __builtin_trap (void)
9372 This function causes the program to exit abnormally.  GCC implements
9373 this function by using a target-dependent mechanism (such as
9374 intentionally executing an illegal instruction) or by calling
9375 @code{abort}.  The mechanism used may vary from release to release so
9376 you should not rely on any particular implementation.
9377 @end deftypefn
9379 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9380 If control flow reaches the point of the @code{__builtin_unreachable},
9381 the program is undefined.  It is useful in situations where the
9382 compiler cannot deduce the unreachability of the code.
9384 One such case is immediately following an @code{asm} statement that
9385 either never terminates, or one that transfers control elsewhere
9386 and never returns.  In this example, without the
9387 @code{__builtin_unreachable}, GCC issues a warning that control
9388 reaches the end of a non-void function.  It also generates code
9389 to return after the @code{asm}.
9391 @smallexample
9392 int f (int c, int v)
9394   if (c)
9395     @{
9396       return v;
9397     @}
9398   else
9399     @{
9400       asm("jmp error_handler");
9401       __builtin_unreachable ();
9402     @}
9404 @end smallexample
9406 @noindent
9407 Because the @code{asm} statement unconditionally transfers control out
9408 of the function, control never reaches the end of the function
9409 body.  The @code{__builtin_unreachable} is in fact unreachable and
9410 communicates this fact to the compiler.
9412 Another use for @code{__builtin_unreachable} is following a call a
9413 function that never returns but that is not declared
9414 @code{__attribute__((noreturn))}, as in this example:
9416 @smallexample
9417 void function_that_never_returns (void);
9419 int g (int c)
9421   if (c)
9422     @{
9423       return 1;
9424     @}
9425   else
9426     @{
9427       function_that_never_returns ();
9428       __builtin_unreachable ();
9429     @}
9431 @end smallexample
9433 @end deftypefn
9435 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9436 This function returns its first argument, and allows the compiler
9437 to assume that the returned pointer is at least @var{align} bytes
9438 aligned.  This built-in can have either two or three arguments,
9439 if it has three, the third argument should have integer type, and
9440 if it is nonzero means misalignment offset.  For example:
9442 @smallexample
9443 void *x = __builtin_assume_aligned (arg, 16);
9444 @end smallexample
9446 @noindent
9447 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9448 16-byte aligned, while:
9450 @smallexample
9451 void *x = __builtin_assume_aligned (arg, 32, 8);
9452 @end smallexample
9454 @noindent
9455 means that the compiler can assume for @code{x}, set to @code{arg}, that
9456 @code{(char *) x - 8} is 32-byte aligned.
9457 @end deftypefn
9459 @deftypefn {Built-in Function} int __builtin_LINE ()
9460 This function is the equivalent to the preprocessor @code{__LINE__}
9461 macro and returns the line number of the invocation of the built-in.
9462 In a C++ default argument for a function @var{F}, it gets the line number of
9463 the call to @var{F}.
9464 @end deftypefn
9466 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9467 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9468 macro and returns the function name the invocation of the built-in is in.
9469 @end deftypefn
9471 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9472 This function is the equivalent to the preprocessor @code{__FILE__}
9473 macro and returns the file name the invocation of the built-in is in.
9474 In a C++ default argument for a function @var{F}, it gets the file name of
9475 the call to @var{F}.
9476 @end deftypefn
9478 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9479 This function is used to flush the processor's instruction cache for
9480 the region of memory between @var{begin} inclusive and @var{end}
9481 exclusive.  Some targets require that the instruction cache be
9482 flushed, after modifying memory containing code, in order to obtain
9483 deterministic behavior.
9485 If the target does not require instruction cache flushes,
9486 @code{__builtin___clear_cache} has no effect.  Otherwise either
9487 instructions are emitted in-line to clear the instruction cache or a
9488 call to the @code{__clear_cache} function in libgcc is made.
9489 @end deftypefn
9491 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9492 This function is used to minimize cache-miss latency by moving data into
9493 a cache before it is accessed.
9494 You can insert calls to @code{__builtin_prefetch} into code for which
9495 you know addresses of data in memory that is likely to be accessed soon.
9496 If the target supports them, data prefetch instructions are generated.
9497 If the prefetch is done early enough before the access then the data will
9498 be in the cache by the time it is accessed.
9500 The value of @var{addr} is the address of the memory to prefetch.
9501 There are two optional arguments, @var{rw} and @var{locality}.
9502 The value of @var{rw} is a compile-time constant one or zero; one
9503 means that the prefetch is preparing for a write to the memory address
9504 and zero, the default, means that the prefetch is preparing for a read.
9505 The value @var{locality} must be a compile-time constant integer between
9506 zero and three.  A value of zero means that the data has no temporal
9507 locality, so it need not be left in the cache after the access.  A value
9508 of three means that the data has a high degree of temporal locality and
9509 should be left in all levels of cache possible.  Values of one and two
9510 mean, respectively, a low or moderate degree of temporal locality.  The
9511 default is three.
9513 @smallexample
9514 for (i = 0; i < n; i++)
9515   @{
9516     a[i] = a[i] + b[i];
9517     __builtin_prefetch (&a[i+j], 1, 1);
9518     __builtin_prefetch (&b[i+j], 0, 1);
9519     /* @r{@dots{}} */
9520   @}
9521 @end smallexample
9523 Data prefetch does not generate faults if @var{addr} is invalid, but
9524 the address expression itself must be valid.  For example, a prefetch
9525 of @code{p->next} does not fault if @code{p->next} is not a valid
9526 address, but evaluation faults if @code{p} is not a valid address.
9528 If the target does not support data prefetch, the address expression
9529 is evaluated if it includes side effects but no other code is generated
9530 and GCC does not issue a warning.
9531 @end deftypefn
9533 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9534 Returns a positive infinity, if supported by the floating-point format,
9535 else @code{DBL_MAX}.  This function is suitable for implementing the
9536 ISO C macro @code{HUGE_VAL}.
9537 @end deftypefn
9539 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9540 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9541 @end deftypefn
9543 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9544 Similar to @code{__builtin_huge_val}, except the return
9545 type is @code{long double}.
9546 @end deftypefn
9548 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9549 This built-in implements the C99 fpclassify functionality.  The first
9550 five int arguments should be the target library's notion of the
9551 possible FP classes and are used for return values.  They must be
9552 constant values and they must appear in this order: @code{FP_NAN},
9553 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9554 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
9555 to classify.  GCC treats the last argument as type-generic, which
9556 means it does not do default promotion from float to double.
9557 @end deftypefn
9559 @deftypefn {Built-in Function} double __builtin_inf (void)
9560 Similar to @code{__builtin_huge_val}, except a warning is generated
9561 if the target floating-point format does not support infinities.
9562 @end deftypefn
9564 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9565 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9566 @end deftypefn
9568 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9569 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9570 @end deftypefn
9572 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9573 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9574 @end deftypefn
9576 @deftypefn {Built-in Function} float __builtin_inff (void)
9577 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9578 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9579 @end deftypefn
9581 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9582 Similar to @code{__builtin_inf}, except the return
9583 type is @code{long double}.
9584 @end deftypefn
9586 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9587 Similar to @code{isinf}, except the return value is -1 for
9588 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9589 Note while the parameter list is an
9590 ellipsis, this function only accepts exactly one floating-point
9591 argument.  GCC treats this parameter as type-generic, which means it
9592 does not do default promotion from float to double.
9593 @end deftypefn
9595 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9596 This is an implementation of the ISO C99 function @code{nan}.
9598 Since ISO C99 defines this function in terms of @code{strtod}, which we
9599 do not implement, a description of the parsing is in order.  The string
9600 is parsed as by @code{strtol}; that is, the base is recognized by
9601 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
9602 in the significand such that the least significant bit of the number
9603 is at the least significant bit of the significand.  The number is
9604 truncated to fit the significand field provided.  The significand is
9605 forced to be a quiet NaN@.
9607 This function, if given a string literal all of which would have been
9608 consumed by @code{strtol}, is evaluated early enough that it is considered a
9609 compile-time constant.
9610 @end deftypefn
9612 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9613 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9614 @end deftypefn
9616 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9617 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9618 @end deftypefn
9620 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9621 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9622 @end deftypefn
9624 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9625 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9626 @end deftypefn
9628 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9629 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9630 @end deftypefn
9632 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9633 Similar to @code{__builtin_nan}, except the significand is forced
9634 to be a signaling NaN@.  The @code{nans} function is proposed by
9635 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9636 @end deftypefn
9638 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9639 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9640 @end deftypefn
9642 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9643 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9644 @end deftypefn
9646 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9647 Returns one plus the index of the least significant 1-bit of @var{x}, or
9648 if @var{x} is zero, returns zero.
9649 @end deftypefn
9651 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9652 Returns the number of leading 0-bits in @var{x}, starting at the most
9653 significant bit position.  If @var{x} is 0, the result is undefined.
9654 @end deftypefn
9656 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9657 Returns the number of trailing 0-bits in @var{x}, starting at the least
9658 significant bit position.  If @var{x} is 0, the result is undefined.
9659 @end deftypefn
9661 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9662 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9663 number of bits following the most significant bit that are identical
9664 to it.  There are no special cases for 0 or other values. 
9665 @end deftypefn
9667 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9668 Returns the number of 1-bits in @var{x}.
9669 @end deftypefn
9671 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9672 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9673 modulo 2.
9674 @end deftypefn
9676 @deftypefn {Built-in Function} int __builtin_ffsl (long)
9677 Similar to @code{__builtin_ffs}, except the argument type is
9678 @code{long}.
9679 @end deftypefn
9681 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9682 Similar to @code{__builtin_clz}, except the argument type is
9683 @code{unsigned long}.
9684 @end deftypefn
9686 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9687 Similar to @code{__builtin_ctz}, except the argument type is
9688 @code{unsigned long}.
9689 @end deftypefn
9691 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
9692 Similar to @code{__builtin_clrsb}, except the argument type is
9693 @code{long}.
9694 @end deftypefn
9696 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
9697 Similar to @code{__builtin_popcount}, except the argument type is
9698 @code{unsigned long}.
9699 @end deftypefn
9701 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
9702 Similar to @code{__builtin_parity}, except the argument type is
9703 @code{unsigned long}.
9704 @end deftypefn
9706 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
9707 Similar to @code{__builtin_ffs}, except the argument type is
9708 @code{long long}.
9709 @end deftypefn
9711 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
9712 Similar to @code{__builtin_clz}, except the argument type is
9713 @code{unsigned long long}.
9714 @end deftypefn
9716 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
9717 Similar to @code{__builtin_ctz}, except the argument type is
9718 @code{unsigned long long}.
9719 @end deftypefn
9721 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
9722 Similar to @code{__builtin_clrsb}, except the argument type is
9723 @code{long long}.
9724 @end deftypefn
9726 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
9727 Similar to @code{__builtin_popcount}, except the argument type is
9728 @code{unsigned long long}.
9729 @end deftypefn
9731 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
9732 Similar to @code{__builtin_parity}, except the argument type is
9733 @code{unsigned long long}.
9734 @end deftypefn
9736 @deftypefn {Built-in Function} double __builtin_powi (double, int)
9737 Returns the first argument raised to the power of the second.  Unlike the
9738 @code{pow} function no guarantees about precision and rounding are made.
9739 @end deftypefn
9741 @deftypefn {Built-in Function} float __builtin_powif (float, int)
9742 Similar to @code{__builtin_powi}, except the argument and return types
9743 are @code{float}.
9744 @end deftypefn
9746 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
9747 Similar to @code{__builtin_powi}, except the argument and return types
9748 are @code{long double}.
9749 @end deftypefn
9751 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
9752 Returns @var{x} with the order of the bytes reversed; for example,
9753 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
9754 exactly 8 bits.
9755 @end deftypefn
9757 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
9758 Similar to @code{__builtin_bswap16}, except the argument and return types
9759 are 32 bit.
9760 @end deftypefn
9762 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
9763 Similar to @code{__builtin_bswap32}, except the argument and return types
9764 are 64 bit.
9765 @end deftypefn
9767 @node Target Builtins
9768 @section Built-in Functions Specific to Particular Target Machines
9770 On some target machines, GCC supports many built-in functions specific
9771 to those machines.  Generally these generate calls to specific machine
9772 instructions, but allow the compiler to schedule those calls.
9774 @menu
9775 * AArch64 Built-in Functions::
9776 * AArch64 intrinsics::
9777 * Alpha Built-in Functions::
9778 * Altera Nios II Built-in Functions::
9779 * ARC Built-in Functions::
9780 * ARC SIMD Built-in Functions::
9781 * ARM iWMMXt Built-in Functions::
9782 * ARM NEON Intrinsics::
9783 * ARM ACLE Intrinsics::
9784 * ARM Floating Point Status and Control Intrinsics::
9785 * AVR Built-in Functions::
9786 * Blackfin Built-in Functions::
9787 * FR-V Built-in Functions::
9788 * X86 Built-in Functions::
9789 * X86 transactional memory intrinsics::
9790 * MIPS DSP Built-in Functions::
9791 * MIPS Paired-Single Support::
9792 * MIPS Loongson Built-in Functions::
9793 * Other MIPS Built-in Functions::
9794 * MSP430 Built-in Functions::
9795 * NDS32 Built-in Functions::
9796 * picoChip Built-in Functions::
9797 * PowerPC Built-in Functions::
9798 * PowerPC AltiVec/VSX Built-in Functions::
9799 * PowerPC Hardware Transactional Memory Built-in Functions::
9800 * RX Built-in Functions::
9801 * S/390 System z Built-in Functions::
9802 * SH Built-in Functions::
9803 * SPARC VIS Built-in Functions::
9804 * SPU Built-in Functions::
9805 * TI C6X Built-in Functions::
9806 * TILE-Gx Built-in Functions::
9807 * TILEPro Built-in Functions::
9808 @end menu
9810 @node AArch64 Built-in Functions
9811 @subsection AArch64 Built-in Functions
9813 These built-in functions are available for the AArch64 family of
9814 processors.
9815 @smallexample
9816 unsigned int __builtin_aarch64_get_fpcr ()
9817 void __builtin_aarch64_set_fpcr (unsigned int)
9818 unsigned int __builtin_aarch64_get_fpsr ()
9819 void __builtin_aarch64_set_fpsr (unsigned int)
9820 @end smallexample
9822 @node AArch64 intrinsics
9823 @subsection ACLE Intrinsics for AArch64
9825 @include aarch64-acle-intrinsics.texi
9827 @node Alpha Built-in Functions
9828 @subsection Alpha Built-in Functions
9830 These built-in functions are available for the Alpha family of
9831 processors, depending on the command-line switches used.
9833 The following built-in functions are always available.  They
9834 all generate the machine instruction that is part of the name.
9836 @smallexample
9837 long __builtin_alpha_implver (void)
9838 long __builtin_alpha_rpcc (void)
9839 long __builtin_alpha_amask (long)
9840 long __builtin_alpha_cmpbge (long, long)
9841 long __builtin_alpha_extbl (long, long)
9842 long __builtin_alpha_extwl (long, long)
9843 long __builtin_alpha_extll (long, long)
9844 long __builtin_alpha_extql (long, long)
9845 long __builtin_alpha_extwh (long, long)
9846 long __builtin_alpha_extlh (long, long)
9847 long __builtin_alpha_extqh (long, long)
9848 long __builtin_alpha_insbl (long, long)
9849 long __builtin_alpha_inswl (long, long)
9850 long __builtin_alpha_insll (long, long)
9851 long __builtin_alpha_insql (long, long)
9852 long __builtin_alpha_inswh (long, long)
9853 long __builtin_alpha_inslh (long, long)
9854 long __builtin_alpha_insqh (long, long)
9855 long __builtin_alpha_mskbl (long, long)
9856 long __builtin_alpha_mskwl (long, long)
9857 long __builtin_alpha_mskll (long, long)
9858 long __builtin_alpha_mskql (long, long)
9859 long __builtin_alpha_mskwh (long, long)
9860 long __builtin_alpha_msklh (long, long)
9861 long __builtin_alpha_mskqh (long, long)
9862 long __builtin_alpha_umulh (long, long)
9863 long __builtin_alpha_zap (long, long)
9864 long __builtin_alpha_zapnot (long, long)
9865 @end smallexample
9867 The following built-in functions are always with @option{-mmax}
9868 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
9869 later.  They all generate the machine instruction that is part
9870 of the name.
9872 @smallexample
9873 long __builtin_alpha_pklb (long)
9874 long __builtin_alpha_pkwb (long)
9875 long __builtin_alpha_unpkbl (long)
9876 long __builtin_alpha_unpkbw (long)
9877 long __builtin_alpha_minub8 (long, long)
9878 long __builtin_alpha_minsb8 (long, long)
9879 long __builtin_alpha_minuw4 (long, long)
9880 long __builtin_alpha_minsw4 (long, long)
9881 long __builtin_alpha_maxub8 (long, long)
9882 long __builtin_alpha_maxsb8 (long, long)
9883 long __builtin_alpha_maxuw4 (long, long)
9884 long __builtin_alpha_maxsw4 (long, long)
9885 long __builtin_alpha_perr (long, long)
9886 @end smallexample
9888 The following built-in functions are always with @option{-mcix}
9889 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
9890 later.  They all generate the machine instruction that is part
9891 of the name.
9893 @smallexample
9894 long __builtin_alpha_cttz (long)
9895 long __builtin_alpha_ctlz (long)
9896 long __builtin_alpha_ctpop (long)
9897 @end smallexample
9899 The following built-in functions are available on systems that use the OSF/1
9900 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
9901 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
9902 @code{rdval} and @code{wrval}.
9904 @smallexample
9905 void *__builtin_thread_pointer (void)
9906 void __builtin_set_thread_pointer (void *)
9907 @end smallexample
9909 @node Altera Nios II Built-in Functions
9910 @subsection Altera Nios II Built-in Functions
9912 These built-in functions are available for the Altera Nios II
9913 family of processors.
9915 The following built-in functions are always available.  They
9916 all generate the machine instruction that is part of the name.
9918 @example
9919 int __builtin_ldbio (volatile const void *)
9920 int __builtin_ldbuio (volatile const void *)
9921 int __builtin_ldhio (volatile const void *)
9922 int __builtin_ldhuio (volatile const void *)
9923 int __builtin_ldwio (volatile const void *)
9924 void __builtin_stbio (volatile void *, int)
9925 void __builtin_sthio (volatile void *, int)
9926 void __builtin_stwio (volatile void *, int)
9927 void __builtin_sync (void)
9928 int __builtin_rdctl (int) 
9929 void __builtin_wrctl (int, int)
9930 @end example
9932 The following built-in functions are always available.  They
9933 all generate a Nios II Custom Instruction. The name of the
9934 function represents the types that the function takes and
9935 returns. The letter before the @code{n} is the return type
9936 or void if absent. The @code{n} represents the first parameter
9937 to all the custom instructions, the custom instruction number.
9938 The two letters after the @code{n} represent the up to two
9939 parameters to the function.
9941 The letters represent the following data types:
9942 @table @code
9943 @item <no letter>
9944 @code{void} for return type and no parameter for parameter types.
9946 @item i
9947 @code{int} for return type and parameter type
9949 @item f
9950 @code{float} for return type and parameter type
9952 @item p
9953 @code{void *} for return type and parameter type
9955 @end table
9957 And the function names are:
9958 @example
9959 void __builtin_custom_n (void)
9960 void __builtin_custom_ni (int)
9961 void __builtin_custom_nf (float)
9962 void __builtin_custom_np (void *)
9963 void __builtin_custom_nii (int, int)
9964 void __builtin_custom_nif (int, float)
9965 void __builtin_custom_nip (int, void *)
9966 void __builtin_custom_nfi (float, int)
9967 void __builtin_custom_nff (float, float)
9968 void __builtin_custom_nfp (float, void *)
9969 void __builtin_custom_npi (void *, int)
9970 void __builtin_custom_npf (void *, float)
9971 void __builtin_custom_npp (void *, void *)
9972 int __builtin_custom_in (void)
9973 int __builtin_custom_ini (int)
9974 int __builtin_custom_inf (float)
9975 int __builtin_custom_inp (void *)
9976 int __builtin_custom_inii (int, int)
9977 int __builtin_custom_inif (int, float)
9978 int __builtin_custom_inip (int, void *)
9979 int __builtin_custom_infi (float, int)
9980 int __builtin_custom_inff (float, float)
9981 int __builtin_custom_infp (float, void *)
9982 int __builtin_custom_inpi (void *, int)
9983 int __builtin_custom_inpf (void *, float)
9984 int __builtin_custom_inpp (void *, void *)
9985 float __builtin_custom_fn (void)
9986 float __builtin_custom_fni (int)
9987 float __builtin_custom_fnf (float)
9988 float __builtin_custom_fnp (void *)
9989 float __builtin_custom_fnii (int, int)
9990 float __builtin_custom_fnif (int, float)
9991 float __builtin_custom_fnip (int, void *)
9992 float __builtin_custom_fnfi (float, int)
9993 float __builtin_custom_fnff (float, float)
9994 float __builtin_custom_fnfp (float, void *)
9995 float __builtin_custom_fnpi (void *, int)
9996 float __builtin_custom_fnpf (void *, float)
9997 float __builtin_custom_fnpp (void *, void *)
9998 void * __builtin_custom_pn (void)
9999 void * __builtin_custom_pni (int)
10000 void * __builtin_custom_pnf (float)
10001 void * __builtin_custom_pnp (void *)
10002 void * __builtin_custom_pnii (int, int)
10003 void * __builtin_custom_pnif (int, float)
10004 void * __builtin_custom_pnip (int, void *)
10005 void * __builtin_custom_pnfi (float, int)
10006 void * __builtin_custom_pnff (float, float)
10007 void * __builtin_custom_pnfp (float, void *)
10008 void * __builtin_custom_pnpi (void *, int)
10009 void * __builtin_custom_pnpf (void *, float)
10010 void * __builtin_custom_pnpp (void *, void *)
10011 @end example
10013 @node ARC Built-in Functions
10014 @subsection ARC Built-in Functions
10016 The following built-in functions are provided for ARC targets.  The
10017 built-ins generate the corresponding assembly instructions.  In the
10018 examples given below, the generated code often requires an operand or
10019 result to be in a register.  Where necessary further code will be
10020 generated to ensure this is true, but for brevity this is not
10021 described in each case.
10023 @emph{Note:} Using a built-in to generate an instruction not supported
10024 by a target may cause problems. At present the compiler is not
10025 guaranteed to detect such misuse, and as a result an internal compiler
10026 error may be generated.
10028 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10029 Return 1 if @var{val} is known to have the byte alignment given
10030 by @var{alignval}, otherwise return 0.
10031 Note that this is different from
10032 @smallexample
10033 __alignof__(*(char *)@var{val}) >= alignval
10034 @end smallexample
10035 because __alignof__ sees only the type of the dereference, whereas
10036 __builtin_arc_align uses alignment information from the pointer
10037 as well as from the pointed-to type.
10038 The information available will depend on optimization level.
10039 @end deftypefn
10041 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10042 Generates
10043 @example
10045 @end example
10046 @end deftypefn
10048 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10049 The operand is the number of a register to be read.  Generates:
10050 @example
10051 mov  @var{dest}, r@var{regno}
10052 @end example
10053 where the value in @var{dest} will be the result returned from the
10054 built-in.
10055 @end deftypefn
10057 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10058 The first operand is the number of a register to be written, the
10059 second operand is a compile time constant to write into that
10060 register.  Generates:
10061 @example
10062 mov  r@var{regno}, @var{val}
10063 @end example
10064 @end deftypefn
10066 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10067 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10068 Generates:
10069 @example
10070 divaw  @var{dest}, @var{a}, @var{b}
10071 @end example
10072 where the value in @var{dest} will be the result returned from the
10073 built-in.
10074 @end deftypefn
10076 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10077 Generates
10078 @example
10079 flag  @var{a}
10080 @end example
10081 @end deftypefn
10083 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10084 The operand, @var{auxv}, is the address of an auxiliary register and
10085 must be a compile time constant.  Generates:
10086 @example
10087 lr  @var{dest}, [@var{auxr}]
10088 @end example
10089 Where the value in @var{dest} will be the result returned from the
10090 built-in.
10091 @end deftypefn
10093 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10094 Only available with @option{-mmul64}.  Generates:
10095 @example
10096 mul64  @var{a}, @var{b}
10097 @end example
10098 @end deftypefn
10100 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10101 Only available with @option{-mmul64}.  Generates:
10102 @example
10103 mulu64  @var{a}, @var{b}
10104 @end example
10105 @end deftypefn
10107 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10108 Generates:
10109 @example
10111 @end example
10112 @end deftypefn
10114 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10115 Only valid if the @samp{norm} instruction is available through the
10116 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10117 Generates:
10118 @example
10119 norm  @var{dest}, @var{src}
10120 @end example
10121 Where the value in @var{dest} will be the result returned from the
10122 built-in.
10123 @end deftypefn
10125 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
10126 Only valid if the @samp{normw} instruction is available through the
10127 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10128 Generates:
10129 @example
10130 normw  @var{dest}, @var{src}
10131 @end example
10132 Where the value in @var{dest} will be the result returned from the
10133 built-in.
10134 @end deftypefn
10136 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
10137 Generates:
10138 @example
10139 rtie
10140 @end example
10141 @end deftypefn
10143 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
10144 Generates:
10145 @example
10146 sleep  @var{a}
10147 @end example
10148 @end deftypefn
10150 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10151 The first argument, @var{auxv}, is the address of an auxiliary
10152 register, the second argument, @var{val}, is a compile time constant
10153 to be written to the register.  Generates:
10154 @example
10155 sr  @var{auxr}, [@var{val}]
10156 @end example
10157 @end deftypefn
10159 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
10160 Only valid with @option{-mswap}.  Generates:
10161 @example
10162 swap  @var{dest}, @var{src}
10163 @end example
10164 Where the value in @var{dest} will be the result returned from the
10165 built-in.
10166 @end deftypefn
10168 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
10169 Generates:
10170 @example
10172 @end example
10173 @end deftypefn
10175 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
10176 Only available with @option{-mcpu=ARC700}.  Generates:
10177 @example
10178 sync
10179 @end example
10180 @end deftypefn
10182 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
10183 Only available with @option{-mcpu=ARC700}.  Generates:
10184 @example
10185 trap_s  @var{c}
10186 @end example
10187 @end deftypefn
10189 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
10190 Only available with @option{-mcpu=ARC700}.  Generates:
10191 @example
10192 unimp_s
10193 @end example
10194 @end deftypefn
10196 The instructions generated by the following builtins are not
10197 considered as candidates for scheduling.  They are not moved around by
10198 the compiler during scheduling, and thus can be expected to appear
10199 where they are put in the C code:
10200 @example
10201 __builtin_arc_brk()
10202 __builtin_arc_core_read()
10203 __builtin_arc_core_write()
10204 __builtin_arc_flag()
10205 __builtin_arc_lr()
10206 __builtin_arc_sleep()
10207 __builtin_arc_sr()
10208 __builtin_arc_swi()
10209 @end example
10211 @node ARC SIMD Built-in Functions
10212 @subsection ARC SIMD Built-in Functions
10214 SIMD builtins provided by the compiler can be used to generate the
10215 vector instructions.  This section describes the available builtins
10216 and their usage in programs.  With the @option{-msimd} option, the
10217 compiler provides 128-bit vector types, which can be specified using
10218 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
10219 can be included to use the following predefined types:
10220 @example
10221 typedef int __v4si   __attribute__((vector_size(16)));
10222 typedef short __v8hi __attribute__((vector_size(16)));
10223 @end example
10225 These types can be used to define 128-bit variables.  The built-in
10226 functions listed in the following section can be used on these
10227 variables to generate the vector operations.
10229 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10230 @file{arc-simd.h} also provides equivalent macros called
10231 @code{_@var{someinsn}} that can be used for programming ease and
10232 improved readability.  The following macros for DMA control are also
10233 provided:
10234 @example
10235 #define _setup_dma_in_channel_reg _vdiwr
10236 #define _setup_dma_out_channel_reg _vdowr
10237 @end example
10239 The following is a complete list of all the SIMD built-ins provided
10240 for ARC, grouped by calling signature.
10242 The following take two @code{__v8hi} arguments and return a
10243 @code{__v8hi} result:
10244 @example
10245 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10246 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10247 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10248 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10249 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10250 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10251 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10252 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10253 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10254 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10255 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10256 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10257 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10258 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10259 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10260 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10261 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10262 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10263 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10264 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10265 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10266 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10267 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10268 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10269 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10270 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10271 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10272 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10273 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10274 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10275 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10276 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10277 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10278 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10279 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10280 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10281 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10282 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10283 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10284 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10285 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10286 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10287 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10288 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10289 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10290 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10291 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10292 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10293 @end example
10295 The following take one @code{__v8hi} and one @code{int} argument and return a
10296 @code{__v8hi} result:
10298 @example
10299 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10300 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10301 __v8hi __builtin_arc_vbminw (__v8hi, int)
10302 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10303 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10304 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10305 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10306 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10307 @end example
10309 The following take one @code{__v8hi} argument and one @code{int} argument which
10310 must be a 3-bit compile time constant indicating a register number
10311 I0-I7.  They return a @code{__v8hi} result.
10312 @example
10313 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10314 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10315 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10316 @end example
10318 The following take one @code{__v8hi} argument and one @code{int}
10319 argument which must be a 6-bit compile time constant.  They return a
10320 @code{__v8hi} result.
10321 @example
10322 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10323 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10324 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10325 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10326 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10327 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10328 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10329 @end example
10331 The following take one @code{__v8hi} argument and one @code{int} argument which
10332 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10333 result.
10334 @example
10335 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10336 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10337 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10338 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10339 @end example
10341 The following take two @code{int} arguments, the second of which which
10342 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10343 result:
10344 @example
10345 __v8hi __builtin_arc_vmovaw (int, const int)
10346 __v8hi __builtin_arc_vmovw (int, const int)
10347 __v8hi __builtin_arc_vmovzw (int, const int)
10348 @end example
10350 The following take a single @code{__v8hi} argument and return a
10351 @code{__v8hi} result:
10352 @example
10353 __v8hi __builtin_arc_vabsaw (__v8hi)
10354 __v8hi __builtin_arc_vabsw (__v8hi)
10355 __v8hi __builtin_arc_vaddsuw (__v8hi)
10356 __v8hi __builtin_arc_vexch1 (__v8hi)
10357 __v8hi __builtin_arc_vexch2 (__v8hi)
10358 __v8hi __builtin_arc_vexch4 (__v8hi)
10359 __v8hi __builtin_arc_vsignw (__v8hi)
10360 __v8hi __builtin_arc_vupbaw (__v8hi)
10361 __v8hi __builtin_arc_vupbw (__v8hi)
10362 __v8hi __builtin_arc_vupsbaw (__v8hi)
10363 __v8hi __builtin_arc_vupsbw (__v8hi)
10364 @end example
10366 The followign take two @code{int} arguments and return no result:
10367 @example
10368 void __builtin_arc_vdirun (int, int)
10369 void __builtin_arc_vdorun (int, int)
10370 @end example
10372 The following take two @code{int} arguments and return no result.  The
10373 first argument must a 3-bit compile time constant indicating one of
10374 the DR0-DR7 DMA setup channels:
10375 @example
10376 void __builtin_arc_vdiwr (const int, int)
10377 void __builtin_arc_vdowr (const int, int)
10378 @end example
10380 The following take an @code{int} argument and return no result:
10381 @example
10382 void __builtin_arc_vendrec (int)
10383 void __builtin_arc_vrec (int)
10384 void __builtin_arc_vrecrun (int)
10385 void __builtin_arc_vrun (int)
10386 @end example
10388 The following take a @code{__v8hi} argument and two @code{int}
10389 arguments and return a @code{__v8hi} result.  The second argument must
10390 be a 3-bit compile time constants, indicating one the registers I0-I7,
10391 and the third argument must be an 8-bit compile time constant.
10393 @emph{Note:} Although the equivalent hardware instructions do not take
10394 an SIMD register as an operand, these builtins overwrite the relevant
10395 bits of the @code{__v8hi} register provided as the first argument with
10396 the value loaded from the @code{[Ib, u8]} location in the SDM.
10398 @example
10399 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10400 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10401 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10402 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10403 @end example
10405 The following take two @code{int} arguments and return a @code{__v8hi}
10406 result.  The first argument must be a 3-bit compile time constants,
10407 indicating one the registers I0-I7, and the second argument must be an
10408 8-bit compile time constant.
10410 @example
10411 __v8hi __builtin_arc_vld128 (const int, const int)
10412 __v8hi __builtin_arc_vld64w (const int, const int)
10413 @end example
10415 The following take a @code{__v8hi} argument and two @code{int}
10416 arguments and return no result.  The second argument must be a 3-bit
10417 compile time constants, indicating one the registers I0-I7, and the
10418 third argument must be an 8-bit compile time constant.
10420 @example
10421 void __builtin_arc_vst128 (__v8hi, const int, const int)
10422 void __builtin_arc_vst64 (__v8hi, const int, const int)
10423 @end example
10425 The following take a @code{__v8hi} argument and three @code{int}
10426 arguments and return no result.  The second argument must be a 3-bit
10427 compile-time constant, identifying the 16-bit sub-register to be
10428 stored, the third argument must be a 3-bit compile time constants,
10429 indicating one the registers I0-I7, and the fourth argument must be an
10430 8-bit compile time constant.
10432 @example
10433 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10434 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10435 @end example
10437 @node ARM iWMMXt Built-in Functions
10438 @subsection ARM iWMMXt Built-in Functions
10440 These built-in functions are available for the ARM family of
10441 processors when the @option{-mcpu=iwmmxt} switch is used:
10443 @smallexample
10444 typedef int v2si __attribute__ ((vector_size (8)));
10445 typedef short v4hi __attribute__ ((vector_size (8)));
10446 typedef char v8qi __attribute__ ((vector_size (8)));
10448 int __builtin_arm_getwcgr0 (void)
10449 void __builtin_arm_setwcgr0 (int)
10450 int __builtin_arm_getwcgr1 (void)
10451 void __builtin_arm_setwcgr1 (int)
10452 int __builtin_arm_getwcgr2 (void)
10453 void __builtin_arm_setwcgr2 (int)
10454 int __builtin_arm_getwcgr3 (void)
10455 void __builtin_arm_setwcgr3 (int)
10456 int __builtin_arm_textrmsb (v8qi, int)
10457 int __builtin_arm_textrmsh (v4hi, int)
10458 int __builtin_arm_textrmsw (v2si, int)
10459 int __builtin_arm_textrmub (v8qi, int)
10460 int __builtin_arm_textrmuh (v4hi, int)
10461 int __builtin_arm_textrmuw (v2si, int)
10462 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10463 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10464 v2si __builtin_arm_tinsrw (v2si, int, int)
10465 long long __builtin_arm_tmia (long long, int, int)
10466 long long __builtin_arm_tmiabb (long long, int, int)
10467 long long __builtin_arm_tmiabt (long long, int, int)
10468 long long __builtin_arm_tmiaph (long long, int, int)
10469 long long __builtin_arm_tmiatb (long long, int, int)
10470 long long __builtin_arm_tmiatt (long long, int, int)
10471 int __builtin_arm_tmovmskb (v8qi)
10472 int __builtin_arm_tmovmskh (v4hi)
10473 int __builtin_arm_tmovmskw (v2si)
10474 long long __builtin_arm_waccb (v8qi)
10475 long long __builtin_arm_wacch (v4hi)
10476 long long __builtin_arm_waccw (v2si)
10477 v8qi __builtin_arm_waddb (v8qi, v8qi)
10478 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10479 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10480 v4hi __builtin_arm_waddh (v4hi, v4hi)
10481 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10482 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10483 v2si __builtin_arm_waddw (v2si, v2si)
10484 v2si __builtin_arm_waddwss (v2si, v2si)
10485 v2si __builtin_arm_waddwus (v2si, v2si)
10486 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10487 long long __builtin_arm_wand(long long, long long)
10488 long long __builtin_arm_wandn (long long, long long)
10489 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10490 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10491 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10492 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10493 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10494 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10495 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10496 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10497 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10498 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10499 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10500 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10501 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10502 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10503 long long __builtin_arm_wmacsz (v4hi, v4hi)
10504 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10505 long long __builtin_arm_wmacuz (v4hi, v4hi)
10506 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10507 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10508 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10509 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10510 v2si __builtin_arm_wmaxsw (v2si, v2si)
10511 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10512 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10513 v2si __builtin_arm_wmaxuw (v2si, v2si)
10514 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10515 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10516 v2si __builtin_arm_wminsw (v2si, v2si)
10517 v8qi __builtin_arm_wminub (v8qi, v8qi)
10518 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10519 v2si __builtin_arm_wminuw (v2si, v2si)
10520 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10521 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10522 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10523 long long __builtin_arm_wor (long long, long long)
10524 v2si __builtin_arm_wpackdss (long long, long long)
10525 v2si __builtin_arm_wpackdus (long long, long long)
10526 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10527 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10528 v4hi __builtin_arm_wpackwss (v2si, v2si)
10529 v4hi __builtin_arm_wpackwus (v2si, v2si)
10530 long long __builtin_arm_wrord (long long, long long)
10531 long long __builtin_arm_wrordi (long long, int)
10532 v4hi __builtin_arm_wrorh (v4hi, long long)
10533 v4hi __builtin_arm_wrorhi (v4hi, int)
10534 v2si __builtin_arm_wrorw (v2si, long long)
10535 v2si __builtin_arm_wrorwi (v2si, int)
10536 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10537 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10538 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10539 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10540 v4hi __builtin_arm_wshufh (v4hi, int)
10541 long long __builtin_arm_wslld (long long, long long)
10542 long long __builtin_arm_wslldi (long long, int)
10543 v4hi __builtin_arm_wsllh (v4hi, long long)
10544 v4hi __builtin_arm_wsllhi (v4hi, int)
10545 v2si __builtin_arm_wsllw (v2si, long long)
10546 v2si __builtin_arm_wsllwi (v2si, int)
10547 long long __builtin_arm_wsrad (long long, long long)
10548 long long __builtin_arm_wsradi (long long, int)
10549 v4hi __builtin_arm_wsrah (v4hi, long long)
10550 v4hi __builtin_arm_wsrahi (v4hi, int)
10551 v2si __builtin_arm_wsraw (v2si, long long)
10552 v2si __builtin_arm_wsrawi (v2si, int)
10553 long long __builtin_arm_wsrld (long long, long long)
10554 long long __builtin_arm_wsrldi (long long, int)
10555 v4hi __builtin_arm_wsrlh (v4hi, long long)
10556 v4hi __builtin_arm_wsrlhi (v4hi, int)
10557 v2si __builtin_arm_wsrlw (v2si, long long)
10558 v2si __builtin_arm_wsrlwi (v2si, int)
10559 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10560 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10561 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10562 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10563 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10564 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10565 v2si __builtin_arm_wsubw (v2si, v2si)
10566 v2si __builtin_arm_wsubwss (v2si, v2si)
10567 v2si __builtin_arm_wsubwus (v2si, v2si)
10568 v4hi __builtin_arm_wunpckehsb (v8qi)
10569 v2si __builtin_arm_wunpckehsh (v4hi)
10570 long long __builtin_arm_wunpckehsw (v2si)
10571 v4hi __builtin_arm_wunpckehub (v8qi)
10572 v2si __builtin_arm_wunpckehuh (v4hi)
10573 long long __builtin_arm_wunpckehuw (v2si)
10574 v4hi __builtin_arm_wunpckelsb (v8qi)
10575 v2si __builtin_arm_wunpckelsh (v4hi)
10576 long long __builtin_arm_wunpckelsw (v2si)
10577 v4hi __builtin_arm_wunpckelub (v8qi)
10578 v2si __builtin_arm_wunpckeluh (v4hi)
10579 long long __builtin_arm_wunpckeluw (v2si)
10580 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10581 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10582 v2si __builtin_arm_wunpckihw (v2si, v2si)
10583 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10584 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10585 v2si __builtin_arm_wunpckilw (v2si, v2si)
10586 long long __builtin_arm_wxor (long long, long long)
10587 long long __builtin_arm_wzero ()
10588 @end smallexample
10590 @node ARM NEON Intrinsics
10591 @subsection ARM NEON Intrinsics
10593 These built-in intrinsics for the ARM Advanced SIMD extension are available
10594 when the @option{-mfpu=neon} switch is used:
10596 @include arm-neon-intrinsics.texi
10598 @node ARM ACLE Intrinsics
10599 @subsection ARM ACLE Intrinsics
10601 @include arm-acle-intrinsics.texi
10603 @node ARM Floating Point Status and Control Intrinsics
10604 @subsection ARM Floating Point Status and Control Intrinsics
10606 These built-in functions are available for the ARM family of
10607 processors with floating-point unit.
10609 @smallexample
10610 unsigned int __builtin_arm_get_fpscr ()
10611 void __builtin_arm_set_fpscr (unsigned int)
10612 @end smallexample
10614 @node AVR Built-in Functions
10615 @subsection AVR Built-in Functions
10617 For each built-in function for AVR, there is an equally named,
10618 uppercase built-in macro defined. That way users can easily query if
10619 or if not a specific built-in is implemented or not. For example, if
10620 @code{__builtin_avr_nop} is available the macro
10621 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10623 The following built-in functions map to the respective machine
10624 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10625 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10626 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10627 as library call if no hardware multiplier is available.
10629 @smallexample
10630 void __builtin_avr_nop (void)
10631 void __builtin_avr_sei (void)
10632 void __builtin_avr_cli (void)
10633 void __builtin_avr_sleep (void)
10634 void __builtin_avr_wdr (void)
10635 unsigned char __builtin_avr_swap (unsigned char)
10636 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10637 int __builtin_avr_fmuls (char, char)
10638 int __builtin_avr_fmulsu (char, unsigned char)
10639 @end smallexample
10641 In order to delay execution for a specific number of cycles, GCC
10642 implements
10643 @smallexample
10644 void __builtin_avr_delay_cycles (unsigned long ticks)
10645 @end smallexample
10647 @noindent
10648 @code{ticks} is the number of ticks to delay execution. Note that this
10649 built-in does not take into account the effect of interrupts that
10650 might increase delay time. @code{ticks} must be a compile-time
10651 integer constant; delays with a variable number of cycles are not supported.
10653 @smallexample
10654 char __builtin_avr_flash_segment (const __memx void*)
10655 @end smallexample
10657 @noindent
10658 This built-in takes a byte address to the 24-bit
10659 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10660 the number of the flash segment (the 64 KiB chunk) where the address
10661 points to.  Counting starts at @code{0}.
10662 If the address does not point to flash memory, return @code{-1}.
10664 @smallexample
10665 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10666 @end smallexample
10668 @noindent
10669 Insert bits from @var{bits} into @var{val} and return the resulting
10670 value. The nibbles of @var{map} determine how the insertion is
10671 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
10672 @enumerate
10673 @item If @var{X} is @code{0xf},
10674 then the @var{n}-th bit of @var{val} is returned unaltered.
10676 @item If X is in the range 0@dots{}7,
10677 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
10679 @item If X is in the range 8@dots{}@code{0xe},
10680 then the @var{n}-th result bit is undefined.
10681 @end enumerate
10683 @noindent
10684 One typical use case for this built-in is adjusting input and
10685 output values to non-contiguous port layouts. Some examples:
10687 @smallexample
10688 // same as val, bits is unused
10689 __builtin_avr_insert_bits (0xffffffff, bits, val)
10690 @end smallexample
10692 @smallexample
10693 // same as bits, val is unused
10694 __builtin_avr_insert_bits (0x76543210, bits, val)
10695 @end smallexample
10697 @smallexample
10698 // same as rotating bits by 4
10699 __builtin_avr_insert_bits (0x32107654, bits, 0)
10700 @end smallexample
10702 @smallexample
10703 // high nibble of result is the high nibble of val
10704 // low nibble of result is the low nibble of bits
10705 __builtin_avr_insert_bits (0xffff3210, bits, val)
10706 @end smallexample
10708 @smallexample
10709 // reverse the bit order of bits
10710 __builtin_avr_insert_bits (0x01234567, bits, 0)
10711 @end smallexample
10713 @node Blackfin Built-in Functions
10714 @subsection Blackfin Built-in Functions
10716 Currently, there are two Blackfin-specific built-in functions.  These are
10717 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
10718 using inline assembly; by using these built-in functions the compiler can
10719 automatically add workarounds for hardware errata involving these
10720 instructions.  These functions are named as follows:
10722 @smallexample
10723 void __builtin_bfin_csync (void)
10724 void __builtin_bfin_ssync (void)
10725 @end smallexample
10727 @node FR-V Built-in Functions
10728 @subsection FR-V Built-in Functions
10730 GCC provides many FR-V-specific built-in functions.  In general,
10731 these functions are intended to be compatible with those described
10732 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
10733 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
10734 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
10735 pointer rather than by value.
10737 Most of the functions are named after specific FR-V instructions.
10738 Such functions are said to be ``directly mapped'' and are summarized
10739 here in tabular form.
10741 @menu
10742 * Argument Types::
10743 * Directly-mapped Integer Functions::
10744 * Directly-mapped Media Functions::
10745 * Raw read/write Functions::
10746 * Other Built-in Functions::
10747 @end menu
10749 @node Argument Types
10750 @subsubsection Argument Types
10752 The arguments to the built-in functions can be divided into three groups:
10753 register numbers, compile-time constants and run-time values.  In order
10754 to make this classification clear at a glance, the arguments and return
10755 values are given the following pseudo types:
10757 @multitable @columnfractions .20 .30 .15 .35
10758 @item Pseudo type @tab Real C type @tab Constant? @tab Description
10759 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
10760 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
10761 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
10762 @item @code{uw2} @tab @code{unsigned long long} @tab No
10763 @tab an unsigned doubleword
10764 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
10765 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
10766 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
10767 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
10768 @end multitable
10770 These pseudo types are not defined by GCC, they are simply a notational
10771 convenience used in this manual.
10773 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
10774 and @code{sw2} are evaluated at run time.  They correspond to
10775 register operands in the underlying FR-V instructions.
10777 @code{const} arguments represent immediate operands in the underlying
10778 FR-V instructions.  They must be compile-time constants.
10780 @code{acc} arguments are evaluated at compile time and specify the number
10781 of an accumulator register.  For example, an @code{acc} argument of 2
10782 selects the ACC2 register.
10784 @code{iacc} arguments are similar to @code{acc} arguments but specify the
10785 number of an IACC register.  See @pxref{Other Built-in Functions}
10786 for more details.
10788 @node Directly-mapped Integer Functions
10789 @subsubsection Directly-mapped Integer Functions
10791 The functions listed below map directly to FR-V I-type instructions.
10793 @multitable @columnfractions .45 .32 .23
10794 @item Function prototype @tab Example usage @tab Assembly output
10795 @item @code{sw1 __ADDSS (sw1, sw1)}
10796 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
10797 @tab @code{ADDSS @var{a},@var{b},@var{c}}
10798 @item @code{sw1 __SCAN (sw1, sw1)}
10799 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
10800 @tab @code{SCAN @var{a},@var{b},@var{c}}
10801 @item @code{sw1 __SCUTSS (sw1)}
10802 @tab @code{@var{b} = __SCUTSS (@var{a})}
10803 @tab @code{SCUTSS @var{a},@var{b}}
10804 @item @code{sw1 __SLASS (sw1, sw1)}
10805 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
10806 @tab @code{SLASS @var{a},@var{b},@var{c}}
10807 @item @code{void __SMASS (sw1, sw1)}
10808 @tab @code{__SMASS (@var{a}, @var{b})}
10809 @tab @code{SMASS @var{a},@var{b}}
10810 @item @code{void __SMSSS (sw1, sw1)}
10811 @tab @code{__SMSSS (@var{a}, @var{b})}
10812 @tab @code{SMSSS @var{a},@var{b}}
10813 @item @code{void __SMU (sw1, sw1)}
10814 @tab @code{__SMU (@var{a}, @var{b})}
10815 @tab @code{SMU @var{a},@var{b}}
10816 @item @code{sw2 __SMUL (sw1, sw1)}
10817 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
10818 @tab @code{SMUL @var{a},@var{b},@var{c}}
10819 @item @code{sw1 __SUBSS (sw1, sw1)}
10820 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
10821 @tab @code{SUBSS @var{a},@var{b},@var{c}}
10822 @item @code{uw2 __UMUL (uw1, uw1)}
10823 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
10824 @tab @code{UMUL @var{a},@var{b},@var{c}}
10825 @end multitable
10827 @node Directly-mapped Media Functions
10828 @subsubsection Directly-mapped Media Functions
10830 The functions listed below map directly to FR-V M-type instructions.
10832 @multitable @columnfractions .45 .32 .23
10833 @item Function prototype @tab Example usage @tab Assembly output
10834 @item @code{uw1 __MABSHS (sw1)}
10835 @tab @code{@var{b} = __MABSHS (@var{a})}
10836 @tab @code{MABSHS @var{a},@var{b}}
10837 @item @code{void __MADDACCS (acc, acc)}
10838 @tab @code{__MADDACCS (@var{b}, @var{a})}
10839 @tab @code{MADDACCS @var{a},@var{b}}
10840 @item @code{sw1 __MADDHSS (sw1, sw1)}
10841 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
10842 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
10843 @item @code{uw1 __MADDHUS (uw1, uw1)}
10844 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
10845 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
10846 @item @code{uw1 __MAND (uw1, uw1)}
10847 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
10848 @tab @code{MAND @var{a},@var{b},@var{c}}
10849 @item @code{void __MASACCS (acc, acc)}
10850 @tab @code{__MASACCS (@var{b}, @var{a})}
10851 @tab @code{MASACCS @var{a},@var{b}}
10852 @item @code{uw1 __MAVEH (uw1, uw1)}
10853 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
10854 @tab @code{MAVEH @var{a},@var{b},@var{c}}
10855 @item @code{uw2 __MBTOH (uw1)}
10856 @tab @code{@var{b} = __MBTOH (@var{a})}
10857 @tab @code{MBTOH @var{a},@var{b}}
10858 @item @code{void __MBTOHE (uw1 *, uw1)}
10859 @tab @code{__MBTOHE (&@var{b}, @var{a})}
10860 @tab @code{MBTOHE @var{a},@var{b}}
10861 @item @code{void __MCLRACC (acc)}
10862 @tab @code{__MCLRACC (@var{a})}
10863 @tab @code{MCLRACC @var{a}}
10864 @item @code{void __MCLRACCA (void)}
10865 @tab @code{__MCLRACCA ()}
10866 @tab @code{MCLRACCA}
10867 @item @code{uw1 __Mcop1 (uw1, uw1)}
10868 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
10869 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
10870 @item @code{uw1 __Mcop2 (uw1, uw1)}
10871 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
10872 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
10873 @item @code{uw1 __MCPLHI (uw2, const)}
10874 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
10875 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
10876 @item @code{uw1 __MCPLI (uw2, const)}
10877 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
10878 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
10879 @item @code{void __MCPXIS (acc, sw1, sw1)}
10880 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
10881 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
10882 @item @code{void __MCPXIU (acc, uw1, uw1)}
10883 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
10884 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
10885 @item @code{void __MCPXRS (acc, sw1, sw1)}
10886 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
10887 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
10888 @item @code{void __MCPXRU (acc, uw1, uw1)}
10889 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
10890 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
10891 @item @code{uw1 __MCUT (acc, uw1)}
10892 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
10893 @tab @code{MCUT @var{a},@var{b},@var{c}}
10894 @item @code{uw1 __MCUTSS (acc, sw1)}
10895 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
10896 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
10897 @item @code{void __MDADDACCS (acc, acc)}
10898 @tab @code{__MDADDACCS (@var{b}, @var{a})}
10899 @tab @code{MDADDACCS @var{a},@var{b}}
10900 @item @code{void __MDASACCS (acc, acc)}
10901 @tab @code{__MDASACCS (@var{b}, @var{a})}
10902 @tab @code{MDASACCS @var{a},@var{b}}
10903 @item @code{uw2 __MDCUTSSI (acc, const)}
10904 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
10905 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
10906 @item @code{uw2 __MDPACKH (uw2, uw2)}
10907 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
10908 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
10909 @item @code{uw2 __MDROTLI (uw2, const)}
10910 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
10911 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
10912 @item @code{void __MDSUBACCS (acc, acc)}
10913 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
10914 @tab @code{MDSUBACCS @var{a},@var{b}}
10915 @item @code{void __MDUNPACKH (uw1 *, uw2)}
10916 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
10917 @tab @code{MDUNPACKH @var{a},@var{b}}
10918 @item @code{uw2 __MEXPDHD (uw1, const)}
10919 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
10920 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
10921 @item @code{uw1 __MEXPDHW (uw1, const)}
10922 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
10923 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
10924 @item @code{uw1 __MHDSETH (uw1, const)}
10925 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
10926 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
10927 @item @code{sw1 __MHDSETS (const)}
10928 @tab @code{@var{b} = __MHDSETS (@var{a})}
10929 @tab @code{MHDSETS #@var{a},@var{b}}
10930 @item @code{uw1 __MHSETHIH (uw1, const)}
10931 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
10932 @tab @code{MHSETHIH #@var{a},@var{b}}
10933 @item @code{sw1 __MHSETHIS (sw1, const)}
10934 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
10935 @tab @code{MHSETHIS #@var{a},@var{b}}
10936 @item @code{uw1 __MHSETLOH (uw1, const)}
10937 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
10938 @tab @code{MHSETLOH #@var{a},@var{b}}
10939 @item @code{sw1 __MHSETLOS (sw1, const)}
10940 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
10941 @tab @code{MHSETLOS #@var{a},@var{b}}
10942 @item @code{uw1 __MHTOB (uw2)}
10943 @tab @code{@var{b} = __MHTOB (@var{a})}
10944 @tab @code{MHTOB @var{a},@var{b}}
10945 @item @code{void __MMACHS (acc, sw1, sw1)}
10946 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
10947 @tab @code{MMACHS @var{a},@var{b},@var{c}}
10948 @item @code{void __MMACHU (acc, uw1, uw1)}
10949 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
10950 @tab @code{MMACHU @var{a},@var{b},@var{c}}
10951 @item @code{void __MMRDHS (acc, sw1, sw1)}
10952 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
10953 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
10954 @item @code{void __MMRDHU (acc, uw1, uw1)}
10955 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
10956 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
10957 @item @code{void __MMULHS (acc, sw1, sw1)}
10958 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
10959 @tab @code{MMULHS @var{a},@var{b},@var{c}}
10960 @item @code{void __MMULHU (acc, uw1, uw1)}
10961 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
10962 @tab @code{MMULHU @var{a},@var{b},@var{c}}
10963 @item @code{void __MMULXHS (acc, sw1, sw1)}
10964 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
10965 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
10966 @item @code{void __MMULXHU (acc, uw1, uw1)}
10967 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
10968 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
10969 @item @code{uw1 __MNOT (uw1)}
10970 @tab @code{@var{b} = __MNOT (@var{a})}
10971 @tab @code{MNOT @var{a},@var{b}}
10972 @item @code{uw1 __MOR (uw1, uw1)}
10973 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
10974 @tab @code{MOR @var{a},@var{b},@var{c}}
10975 @item @code{uw1 __MPACKH (uh, uh)}
10976 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
10977 @tab @code{MPACKH @var{a},@var{b},@var{c}}
10978 @item @code{sw2 __MQADDHSS (sw2, sw2)}
10979 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
10980 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
10981 @item @code{uw2 __MQADDHUS (uw2, uw2)}
10982 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
10983 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
10984 @item @code{void __MQCPXIS (acc, sw2, sw2)}
10985 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
10986 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
10987 @item @code{void __MQCPXIU (acc, uw2, uw2)}
10988 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
10989 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
10990 @item @code{void __MQCPXRS (acc, sw2, sw2)}
10991 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
10992 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
10993 @item @code{void __MQCPXRU (acc, uw2, uw2)}
10994 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
10995 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
10996 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
10997 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
10998 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
10999 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11000 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11001 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11002 @item @code{void __MQMACHS (acc, sw2, sw2)}
11003 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11004 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11005 @item @code{void __MQMACHU (acc, uw2, uw2)}
11006 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11007 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11008 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11009 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11010 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11011 @item @code{void __MQMULHS (acc, sw2, sw2)}
11012 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11013 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11014 @item @code{void __MQMULHU (acc, uw2, uw2)}
11015 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11016 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11017 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11018 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11019 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11020 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11021 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11022 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11023 @item @code{sw2 __MQSATHS (sw2, sw2)}
11024 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11025 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11026 @item @code{uw2 __MQSLLHI (uw2, int)}
11027 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11028 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11029 @item @code{sw2 __MQSRAHI (sw2, int)}
11030 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11031 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11032 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11033 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11034 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11035 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11036 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11037 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11038 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11039 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11040 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11041 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11042 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11043 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11044 @item @code{uw1 __MRDACC (acc)}
11045 @tab @code{@var{b} = __MRDACC (@var{a})}
11046 @tab @code{MRDACC @var{a},@var{b}}
11047 @item @code{uw1 __MRDACCG (acc)}
11048 @tab @code{@var{b} = __MRDACCG (@var{a})}
11049 @tab @code{MRDACCG @var{a},@var{b}}
11050 @item @code{uw1 __MROTLI (uw1, const)}
11051 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11052 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11053 @item @code{uw1 __MROTRI (uw1, const)}
11054 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11055 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11056 @item @code{sw1 __MSATHS (sw1, sw1)}
11057 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11058 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11059 @item @code{uw1 __MSATHU (uw1, uw1)}
11060 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11061 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11062 @item @code{uw1 __MSLLHI (uw1, const)}
11063 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11064 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11065 @item @code{sw1 __MSRAHI (sw1, const)}
11066 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11067 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11068 @item @code{uw1 __MSRLHI (uw1, const)}
11069 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11070 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11071 @item @code{void __MSUBACCS (acc, acc)}
11072 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11073 @tab @code{MSUBACCS @var{a},@var{b}}
11074 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11075 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11076 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11077 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11078 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11079 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11080 @item @code{void __MTRAP (void)}
11081 @tab @code{__MTRAP ()}
11082 @tab @code{MTRAP}
11083 @item @code{uw2 __MUNPACKH (uw1)}
11084 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11085 @tab @code{MUNPACKH @var{a},@var{b}}
11086 @item @code{uw1 __MWCUT (uw2, uw1)}
11087 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11088 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11089 @item @code{void __MWTACC (acc, uw1)}
11090 @tab @code{__MWTACC (@var{b}, @var{a})}
11091 @tab @code{MWTACC @var{a},@var{b}}
11092 @item @code{void __MWTACCG (acc, uw1)}
11093 @tab @code{__MWTACCG (@var{b}, @var{a})}
11094 @tab @code{MWTACCG @var{a},@var{b}}
11095 @item @code{uw1 __MXOR (uw1, uw1)}
11096 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11097 @tab @code{MXOR @var{a},@var{b},@var{c}}
11098 @end multitable
11100 @node Raw read/write Functions
11101 @subsubsection Raw read/write Functions
11103 This sections describes built-in functions related to read and write
11104 instructions to access memory.  These functions generate
11105 @code{membar} instructions to flush the I/O load and stores where
11106 appropriate, as described in Fujitsu's manual described above.
11108 @table @code
11110 @item unsigned char __builtin_read8 (void *@var{data})
11111 @item unsigned short __builtin_read16 (void *@var{data})
11112 @item unsigned long __builtin_read32 (void *@var{data})
11113 @item unsigned long long __builtin_read64 (void *@var{data})
11115 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11116 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11117 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11118 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11119 @end table
11121 @node Other Built-in Functions
11122 @subsubsection Other Built-in Functions
11124 This section describes built-in functions that are not named after
11125 a specific FR-V instruction.
11127 @table @code
11128 @item sw2 __IACCreadll (iacc @var{reg})
11129 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
11130 for future expansion and must be 0.
11132 @item sw1 __IACCreadl (iacc @var{reg})
11133 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11134 Other values of @var{reg} are rejected as invalid.
11136 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11137 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
11138 is reserved for future expansion and must be 0.
11140 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11141 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11142 is 1.  Other values of @var{reg} are rejected as invalid.
11144 @item void __data_prefetch0 (const void *@var{x})
11145 Use the @code{dcpl} instruction to load the contents of address @var{x}
11146 into the data cache.
11148 @item void __data_prefetch (const void *@var{x})
11149 Use the @code{nldub} instruction to load the contents of address @var{x}
11150 into the data cache.  The instruction is issued in slot I1@.
11151 @end table
11153 @node X86 Built-in Functions
11154 @subsection X86 Built-in Functions
11156 These built-in functions are available for the i386 and x86-64 family
11157 of computers, depending on the command-line switches used.
11159 If you specify command-line switches such as @option{-msse},
11160 the compiler could use the extended instruction sets even if the built-ins
11161 are not used explicitly in the program.  For this reason, applications
11162 that perform run-time CPU detection must compile separate files for each
11163 supported architecture, using the appropriate flags.  In particular,
11164 the file containing the CPU detection code should be compiled without
11165 these options.
11167 The following machine modes are available for use with MMX built-in functions
11168 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11169 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11170 vector of eight 8-bit integers.  Some of the built-in functions operate on
11171 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11173 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11174 of two 32-bit floating-point values.
11176 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11177 floating-point values.  Some instructions use a vector of four 32-bit
11178 integers, these use @code{V4SI}.  Finally, some instructions operate on an
11179 entire vector register, interpreting it as a 128-bit integer, these use mode
11180 @code{TI}.
11182 In 64-bit mode, the x86-64 family of processors uses additional built-in
11183 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11184 floating point and @code{TC} 128-bit complex floating-point values.
11186 The following floating-point built-in functions are available in 64-bit
11187 mode.  All of them implement the function that is part of the name.
11189 @smallexample
11190 __float128 __builtin_fabsq (__float128)
11191 __float128 __builtin_copysignq (__float128, __float128)
11192 @end smallexample
11194 The following built-in function is always available.
11196 @table @code
11197 @item void __builtin_ia32_pause (void)
11198 Generates the @code{pause} machine instruction with a compiler memory
11199 barrier.
11200 @end table
11202 The following floating-point built-in functions are made available in the
11203 64-bit mode.
11205 @table @code
11206 @item __float128 __builtin_infq (void)
11207 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11208 @findex __builtin_infq
11210 @item __float128 __builtin_huge_valq (void)
11211 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11212 @findex __builtin_huge_valq
11213 @end table
11215 The following built-in functions are always available and can be used to
11216 check the target platform type.
11218 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11219 This function runs the CPU detection code to check the type of CPU and the
11220 features supported.  This built-in function needs to be invoked along with the built-in functions
11221 to check CPU type and features, @code{__builtin_cpu_is} and
11222 @code{__builtin_cpu_supports}, only when used in a function that is
11223 executed before any constructors are called.  The CPU detection code is
11224 automatically executed in a very high priority constructor.
11226 For example, this function has to be used in @code{ifunc} resolvers that
11227 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11228 and @code{__builtin_cpu_supports}, or in constructors on targets that
11229 don't support constructor priority.
11230 @smallexample
11232 static void (*resolve_memcpy (void)) (void)
11234   // ifunc resolvers fire before constructors, explicitly call the init
11235   // function.
11236   __builtin_cpu_init ();
11237   if (__builtin_cpu_supports ("ssse3"))
11238     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11239   else
11240     return default_memcpy;
11243 void *memcpy (void *, const void *, size_t)
11244      __attribute__ ((ifunc ("resolve_memcpy")));
11245 @end smallexample
11247 @end deftypefn
11249 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11250 This function returns a positive integer if the run-time CPU
11251 is of type @var{cpuname}
11252 and returns @code{0} otherwise. The following CPU names can be detected:
11254 @table @samp
11255 @item intel
11256 Intel CPU.
11258 @item atom
11259 Intel Atom CPU.
11261 @item core2
11262 Intel Core 2 CPU.
11264 @item corei7
11265 Intel Core i7 CPU.
11267 @item nehalem
11268 Intel Core i7 Nehalem CPU.
11270 @item westmere
11271 Intel Core i7 Westmere CPU.
11273 @item sandybridge
11274 Intel Core i7 Sandy Bridge CPU.
11276 @item amd
11277 AMD CPU.
11279 @item amdfam10h
11280 AMD Family 10h CPU.
11282 @item barcelona
11283 AMD Family 10h Barcelona CPU.
11285 @item shanghai
11286 AMD Family 10h Shanghai CPU.
11288 @item istanbul
11289 AMD Family 10h Istanbul CPU.
11291 @item btver1
11292 AMD Family 14h CPU.
11294 @item amdfam15h
11295 AMD Family 15h CPU.
11297 @item bdver1
11298 AMD Family 15h Bulldozer version 1.
11300 @item bdver2
11301 AMD Family 15h Bulldozer version 2.
11303 @item bdver3
11304 AMD Family 15h Bulldozer version 3.
11306 @item bdver4
11307 AMD Family 15h Bulldozer version 4.
11309 @item btver2
11310 AMD Family 16h CPU.
11311 @end table
11313 Here is an example:
11314 @smallexample
11315 if (__builtin_cpu_is ("corei7"))
11316   @{
11317      do_corei7 (); // Core i7 specific implementation.
11318   @}
11319 else
11320   @{
11321      do_generic (); // Generic implementation.
11322   @}
11323 @end smallexample
11324 @end deftypefn
11326 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11327 This function returns a positive integer if the run-time CPU
11328 supports @var{feature}
11329 and returns @code{0} otherwise. The following features can be detected:
11331 @table @samp
11332 @item cmov
11333 CMOV instruction.
11334 @item mmx
11335 MMX instructions.
11336 @item popcnt
11337 POPCNT instruction.
11338 @item sse
11339 SSE instructions.
11340 @item sse2
11341 SSE2 instructions.
11342 @item sse3
11343 SSE3 instructions.
11344 @item ssse3
11345 SSSE3 instructions.
11346 @item sse4.1
11347 SSE4.1 instructions.
11348 @item sse4.2
11349 SSE4.2 instructions.
11350 @item avx
11351 AVX instructions.
11352 @item avx2
11353 AVX2 instructions.
11354 @end table
11356 Here is an example:
11357 @smallexample
11358 if (__builtin_cpu_supports ("popcnt"))
11359   @{
11360      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11361   @}
11362 else
11363   @{
11364      count = generic_countbits (n); //generic implementation.
11365   @}
11366 @end smallexample
11367 @end deftypefn
11370 The following built-in functions are made available by @option{-mmmx}.
11371 All of them generate the machine instruction that is part of the name.
11373 @smallexample
11374 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11375 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11376 v2si __builtin_ia32_paddd (v2si, v2si)
11377 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11378 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11379 v2si __builtin_ia32_psubd (v2si, v2si)
11380 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11381 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11382 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11383 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11384 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11385 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11386 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11387 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11388 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11389 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11390 di __builtin_ia32_pand (di, di)
11391 di __builtin_ia32_pandn (di,di)
11392 di __builtin_ia32_por (di, di)
11393 di __builtin_ia32_pxor (di, di)
11394 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11395 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11396 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11397 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11398 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11399 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11400 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11401 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11402 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11403 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11404 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11405 v2si __builtin_ia32_punpckldq (v2si, v2si)
11406 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11407 v4hi __builtin_ia32_packssdw (v2si, v2si)
11408 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11410 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11411 v2si __builtin_ia32_pslld (v2si, v2si)
11412 v1di __builtin_ia32_psllq (v1di, v1di)
11413 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11414 v2si __builtin_ia32_psrld (v2si, v2si)
11415 v1di __builtin_ia32_psrlq (v1di, v1di)
11416 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11417 v2si __builtin_ia32_psrad (v2si, v2si)
11418 v4hi __builtin_ia32_psllwi (v4hi, int)
11419 v2si __builtin_ia32_pslldi (v2si, int)
11420 v1di __builtin_ia32_psllqi (v1di, int)
11421 v4hi __builtin_ia32_psrlwi (v4hi, int)
11422 v2si __builtin_ia32_psrldi (v2si, int)
11423 v1di __builtin_ia32_psrlqi (v1di, int)
11424 v4hi __builtin_ia32_psrawi (v4hi, int)
11425 v2si __builtin_ia32_psradi (v2si, int)
11427 @end smallexample
11429 The following built-in functions are made available either with
11430 @option{-msse}, or with a combination of @option{-m3dnow} and
11431 @option{-march=athlon}.  All of them generate the machine
11432 instruction that is part of the name.
11434 @smallexample
11435 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11436 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11437 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11438 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11439 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11440 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11441 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11442 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11443 int __builtin_ia32_pmovmskb (v8qi)
11444 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11445 void __builtin_ia32_movntq (di *, di)
11446 void __builtin_ia32_sfence (void)
11447 @end smallexample
11449 The following built-in functions are available when @option{-msse} is used.
11450 All of them generate the machine instruction that is part of the name.
11452 @smallexample
11453 int __builtin_ia32_comieq (v4sf, v4sf)
11454 int __builtin_ia32_comineq (v4sf, v4sf)
11455 int __builtin_ia32_comilt (v4sf, v4sf)
11456 int __builtin_ia32_comile (v4sf, v4sf)
11457 int __builtin_ia32_comigt (v4sf, v4sf)
11458 int __builtin_ia32_comige (v4sf, v4sf)
11459 int __builtin_ia32_ucomieq (v4sf, v4sf)
11460 int __builtin_ia32_ucomineq (v4sf, v4sf)
11461 int __builtin_ia32_ucomilt (v4sf, v4sf)
11462 int __builtin_ia32_ucomile (v4sf, v4sf)
11463 int __builtin_ia32_ucomigt (v4sf, v4sf)
11464 int __builtin_ia32_ucomige (v4sf, v4sf)
11465 v4sf __builtin_ia32_addps (v4sf, v4sf)
11466 v4sf __builtin_ia32_subps (v4sf, v4sf)
11467 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11468 v4sf __builtin_ia32_divps (v4sf, v4sf)
11469 v4sf __builtin_ia32_addss (v4sf, v4sf)
11470 v4sf __builtin_ia32_subss (v4sf, v4sf)
11471 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11472 v4sf __builtin_ia32_divss (v4sf, v4sf)
11473 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11474 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11475 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11476 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11477 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11478 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11479 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11480 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11481 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11482 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11483 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11484 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11485 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11486 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11487 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11488 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11489 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11490 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11491 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11492 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11493 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11494 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11495 v4sf __builtin_ia32_minps (v4sf, v4sf)
11496 v4sf __builtin_ia32_minss (v4sf, v4sf)
11497 v4sf __builtin_ia32_andps (v4sf, v4sf)
11498 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11499 v4sf __builtin_ia32_orps (v4sf, v4sf)
11500 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11501 v4sf __builtin_ia32_movss (v4sf, v4sf)
11502 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11503 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11504 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11505 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11506 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11507 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11508 v2si __builtin_ia32_cvtps2pi (v4sf)
11509 int __builtin_ia32_cvtss2si (v4sf)
11510 v2si __builtin_ia32_cvttps2pi (v4sf)
11511 int __builtin_ia32_cvttss2si (v4sf)
11512 v4sf __builtin_ia32_rcpps (v4sf)
11513 v4sf __builtin_ia32_rsqrtps (v4sf)
11514 v4sf __builtin_ia32_sqrtps (v4sf)
11515 v4sf __builtin_ia32_rcpss (v4sf)
11516 v4sf __builtin_ia32_rsqrtss (v4sf)
11517 v4sf __builtin_ia32_sqrtss (v4sf)
11518 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11519 void __builtin_ia32_movntps (float *, v4sf)
11520 int __builtin_ia32_movmskps (v4sf)
11521 @end smallexample
11523 The following built-in functions are available when @option{-msse} is used.
11525 @table @code
11526 @item v4sf __builtin_ia32_loadups (float *)
11527 Generates the @code{movups} machine instruction as a load from memory.
11528 @item void __builtin_ia32_storeups (float *, v4sf)
11529 Generates the @code{movups} machine instruction as a store to memory.
11530 @item v4sf __builtin_ia32_loadss (float *)
11531 Generates the @code{movss} machine instruction as a load from memory.
11532 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11533 Generates the @code{movhps} machine instruction as a load from memory.
11534 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11535 Generates the @code{movlps} machine instruction as a load from memory
11536 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11537 Generates the @code{movhps} machine instruction as a store to memory.
11538 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11539 Generates the @code{movlps} machine instruction as a store to memory.
11540 @end table
11542 The following built-in functions are available when @option{-msse2} is used.
11543 All of them generate the machine instruction that is part of the name.
11545 @smallexample
11546 int __builtin_ia32_comisdeq (v2df, v2df)
11547 int __builtin_ia32_comisdlt (v2df, v2df)
11548 int __builtin_ia32_comisdle (v2df, v2df)
11549 int __builtin_ia32_comisdgt (v2df, v2df)
11550 int __builtin_ia32_comisdge (v2df, v2df)
11551 int __builtin_ia32_comisdneq (v2df, v2df)
11552 int __builtin_ia32_ucomisdeq (v2df, v2df)
11553 int __builtin_ia32_ucomisdlt (v2df, v2df)
11554 int __builtin_ia32_ucomisdle (v2df, v2df)
11555 int __builtin_ia32_ucomisdgt (v2df, v2df)
11556 int __builtin_ia32_ucomisdge (v2df, v2df)
11557 int __builtin_ia32_ucomisdneq (v2df, v2df)
11558 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11559 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11560 v2df __builtin_ia32_cmplepd (v2df, v2df)
11561 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11562 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11563 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11564 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11565 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11566 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11567 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11568 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11569 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11570 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11571 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11572 v2df __builtin_ia32_cmplesd (v2df, v2df)
11573 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11574 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11575 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11576 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11577 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11578 v2di __builtin_ia32_paddq (v2di, v2di)
11579 v2di __builtin_ia32_psubq (v2di, v2di)
11580 v2df __builtin_ia32_addpd (v2df, v2df)
11581 v2df __builtin_ia32_subpd (v2df, v2df)
11582 v2df __builtin_ia32_mulpd (v2df, v2df)
11583 v2df __builtin_ia32_divpd (v2df, v2df)
11584 v2df __builtin_ia32_addsd (v2df, v2df)
11585 v2df __builtin_ia32_subsd (v2df, v2df)
11586 v2df __builtin_ia32_mulsd (v2df, v2df)
11587 v2df __builtin_ia32_divsd (v2df, v2df)
11588 v2df __builtin_ia32_minpd (v2df, v2df)
11589 v2df __builtin_ia32_maxpd (v2df, v2df)
11590 v2df __builtin_ia32_minsd (v2df, v2df)
11591 v2df __builtin_ia32_maxsd (v2df, v2df)
11592 v2df __builtin_ia32_andpd (v2df, v2df)
11593 v2df __builtin_ia32_andnpd (v2df, v2df)
11594 v2df __builtin_ia32_orpd (v2df, v2df)
11595 v2df __builtin_ia32_xorpd (v2df, v2df)
11596 v2df __builtin_ia32_movsd (v2df, v2df)
11597 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11598 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11599 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11600 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11601 v4si __builtin_ia32_paddd128 (v4si, v4si)
11602 v2di __builtin_ia32_paddq128 (v2di, v2di)
11603 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11604 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11605 v4si __builtin_ia32_psubd128 (v4si, v4si)
11606 v2di __builtin_ia32_psubq128 (v2di, v2di)
11607 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11608 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11609 v2di __builtin_ia32_pand128 (v2di, v2di)
11610 v2di __builtin_ia32_pandn128 (v2di, v2di)
11611 v2di __builtin_ia32_por128 (v2di, v2di)
11612 v2di __builtin_ia32_pxor128 (v2di, v2di)
11613 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11614 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11615 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11616 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11617 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11618 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11619 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11620 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11621 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11622 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11623 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11624 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11625 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11626 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11627 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11628 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11629 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11630 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11631 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11632 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11633 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11634 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11635 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11636 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11637 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11638 v2df __builtin_ia32_loadupd (double *)
11639 void __builtin_ia32_storeupd (double *, v2df)
11640 v2df __builtin_ia32_loadhpd (v2df, double const *)
11641 v2df __builtin_ia32_loadlpd (v2df, double const *)
11642 int __builtin_ia32_movmskpd (v2df)
11643 int __builtin_ia32_pmovmskb128 (v16qi)
11644 void __builtin_ia32_movnti (int *, int)
11645 void __builtin_ia32_movnti64 (long long int *, long long int)
11646 void __builtin_ia32_movntpd (double *, v2df)
11647 void __builtin_ia32_movntdq (v2df *, v2df)
11648 v4si __builtin_ia32_pshufd (v4si, int)
11649 v8hi __builtin_ia32_pshuflw (v8hi, int)
11650 v8hi __builtin_ia32_pshufhw (v8hi, int)
11651 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11652 v2df __builtin_ia32_sqrtpd (v2df)
11653 v2df __builtin_ia32_sqrtsd (v2df)
11654 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11655 v2df __builtin_ia32_cvtdq2pd (v4si)
11656 v4sf __builtin_ia32_cvtdq2ps (v4si)
11657 v4si __builtin_ia32_cvtpd2dq (v2df)
11658 v2si __builtin_ia32_cvtpd2pi (v2df)
11659 v4sf __builtin_ia32_cvtpd2ps (v2df)
11660 v4si __builtin_ia32_cvttpd2dq (v2df)
11661 v2si __builtin_ia32_cvttpd2pi (v2df)
11662 v2df __builtin_ia32_cvtpi2pd (v2si)
11663 int __builtin_ia32_cvtsd2si (v2df)
11664 int __builtin_ia32_cvttsd2si (v2df)
11665 long long __builtin_ia32_cvtsd2si64 (v2df)
11666 long long __builtin_ia32_cvttsd2si64 (v2df)
11667 v4si __builtin_ia32_cvtps2dq (v4sf)
11668 v2df __builtin_ia32_cvtps2pd (v4sf)
11669 v4si __builtin_ia32_cvttps2dq (v4sf)
11670 v2df __builtin_ia32_cvtsi2sd (v2df, int)
11671 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
11672 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
11673 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
11674 void __builtin_ia32_clflush (const void *)
11675 void __builtin_ia32_lfence (void)
11676 void __builtin_ia32_mfence (void)
11677 v16qi __builtin_ia32_loaddqu (const char *)
11678 void __builtin_ia32_storedqu (char *, v16qi)
11679 v1di __builtin_ia32_pmuludq (v2si, v2si)
11680 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
11681 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
11682 v4si __builtin_ia32_pslld128 (v4si, v4si)
11683 v2di __builtin_ia32_psllq128 (v2di, v2di)
11684 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
11685 v4si __builtin_ia32_psrld128 (v4si, v4si)
11686 v2di __builtin_ia32_psrlq128 (v2di, v2di)
11687 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
11688 v4si __builtin_ia32_psrad128 (v4si, v4si)
11689 v2di __builtin_ia32_pslldqi128 (v2di, int)
11690 v8hi __builtin_ia32_psllwi128 (v8hi, int)
11691 v4si __builtin_ia32_pslldi128 (v4si, int)
11692 v2di __builtin_ia32_psllqi128 (v2di, int)
11693 v2di __builtin_ia32_psrldqi128 (v2di, int)
11694 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
11695 v4si __builtin_ia32_psrldi128 (v4si, int)
11696 v2di __builtin_ia32_psrlqi128 (v2di, int)
11697 v8hi __builtin_ia32_psrawi128 (v8hi, int)
11698 v4si __builtin_ia32_psradi128 (v4si, int)
11699 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
11700 v2di __builtin_ia32_movq128 (v2di)
11701 @end smallexample
11703 The following built-in functions are available when @option{-msse3} is used.
11704 All of them generate the machine instruction that is part of the name.
11706 @smallexample
11707 v2df __builtin_ia32_addsubpd (v2df, v2df)
11708 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
11709 v2df __builtin_ia32_haddpd (v2df, v2df)
11710 v4sf __builtin_ia32_haddps (v4sf, v4sf)
11711 v2df __builtin_ia32_hsubpd (v2df, v2df)
11712 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
11713 v16qi __builtin_ia32_lddqu (char const *)
11714 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
11715 v4sf __builtin_ia32_movshdup (v4sf)
11716 v4sf __builtin_ia32_movsldup (v4sf)
11717 void __builtin_ia32_mwait (unsigned int, unsigned int)
11718 @end smallexample
11720 The following built-in functions are available when @option{-mssse3} is used.
11721 All of them generate the machine instruction that is part of the name.
11723 @smallexample
11724 v2si __builtin_ia32_phaddd (v2si, v2si)
11725 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
11726 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
11727 v2si __builtin_ia32_phsubd (v2si, v2si)
11728 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
11729 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
11730 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
11731 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
11732 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
11733 v8qi __builtin_ia32_psignb (v8qi, v8qi)
11734 v2si __builtin_ia32_psignd (v2si, v2si)
11735 v4hi __builtin_ia32_psignw (v4hi, v4hi)
11736 v1di __builtin_ia32_palignr (v1di, v1di, int)
11737 v8qi __builtin_ia32_pabsb (v8qi)
11738 v2si __builtin_ia32_pabsd (v2si)
11739 v4hi __builtin_ia32_pabsw (v4hi)
11740 @end smallexample
11742 The following built-in functions are available when @option{-mssse3} is used.
11743 All of them generate the machine instruction that is part of the name.
11745 @smallexample
11746 v4si __builtin_ia32_phaddd128 (v4si, v4si)
11747 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
11748 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
11749 v4si __builtin_ia32_phsubd128 (v4si, v4si)
11750 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
11751 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
11752 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
11753 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
11754 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
11755 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
11756 v4si __builtin_ia32_psignd128 (v4si, v4si)
11757 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
11758 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
11759 v16qi __builtin_ia32_pabsb128 (v16qi)
11760 v4si __builtin_ia32_pabsd128 (v4si)
11761 v8hi __builtin_ia32_pabsw128 (v8hi)
11762 @end smallexample
11764 The following built-in functions are available when @option{-msse4.1} is
11765 used.  All of them generate the machine instruction that is part of the
11766 name.
11768 @smallexample
11769 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
11770 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
11771 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
11772 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
11773 v2df __builtin_ia32_dppd (v2df, v2df, const int)
11774 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
11775 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
11776 v2di __builtin_ia32_movntdqa (v2di *);
11777 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
11778 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
11779 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
11780 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
11781 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
11782 v8hi __builtin_ia32_phminposuw128 (v8hi)
11783 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
11784 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
11785 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
11786 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
11787 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
11788 v4si __builtin_ia32_pminsd128 (v4si, v4si)
11789 v4si __builtin_ia32_pminud128 (v4si, v4si)
11790 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
11791 v4si __builtin_ia32_pmovsxbd128 (v16qi)
11792 v2di __builtin_ia32_pmovsxbq128 (v16qi)
11793 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
11794 v2di __builtin_ia32_pmovsxdq128 (v4si)
11795 v4si __builtin_ia32_pmovsxwd128 (v8hi)
11796 v2di __builtin_ia32_pmovsxwq128 (v8hi)
11797 v4si __builtin_ia32_pmovzxbd128 (v16qi)
11798 v2di __builtin_ia32_pmovzxbq128 (v16qi)
11799 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
11800 v2di __builtin_ia32_pmovzxdq128 (v4si)
11801 v4si __builtin_ia32_pmovzxwd128 (v8hi)
11802 v2di __builtin_ia32_pmovzxwq128 (v8hi)
11803 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
11804 v4si __builtin_ia32_pmulld128 (v4si, v4si)
11805 int __builtin_ia32_ptestc128 (v2di, v2di)
11806 int __builtin_ia32_ptestnzc128 (v2di, v2di)
11807 int __builtin_ia32_ptestz128 (v2di, v2di)
11808 v2df __builtin_ia32_roundpd (v2df, const int)
11809 v4sf __builtin_ia32_roundps (v4sf, const int)
11810 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
11811 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
11812 @end smallexample
11814 The following built-in functions are available when @option{-msse4.1} is
11815 used.
11817 @table @code
11818 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
11819 Generates the @code{insertps} machine instruction.
11820 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
11821 Generates the @code{pextrb} machine instruction.
11822 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
11823 Generates the @code{pinsrb} machine instruction.
11824 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
11825 Generates the @code{pinsrd} machine instruction.
11826 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
11827 Generates the @code{pinsrq} machine instruction in 64bit mode.
11828 @end table
11830 The following built-in functions are changed to generate new SSE4.1
11831 instructions when @option{-msse4.1} is used.
11833 @table @code
11834 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
11835 Generates the @code{extractps} machine instruction.
11836 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
11837 Generates the @code{pextrd} machine instruction.
11838 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
11839 Generates the @code{pextrq} machine instruction in 64bit mode.
11840 @end table
11842 The following built-in functions are available when @option{-msse4.2} is
11843 used.  All of them generate the machine instruction that is part of the
11844 name.
11846 @smallexample
11847 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
11848 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
11849 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
11850 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
11851 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
11852 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
11853 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
11854 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
11855 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
11856 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
11857 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
11858 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
11859 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
11860 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
11861 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
11862 @end smallexample
11864 The following built-in functions are available when @option{-msse4.2} is
11865 used.
11867 @table @code
11868 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
11869 Generates the @code{crc32b} machine instruction.
11870 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
11871 Generates the @code{crc32w} machine instruction.
11872 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
11873 Generates the @code{crc32l} machine instruction.
11874 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
11875 Generates the @code{crc32q} machine instruction.
11876 @end table
11878 The following built-in functions are changed to generate new SSE4.2
11879 instructions when @option{-msse4.2} is used.
11881 @table @code
11882 @item int __builtin_popcount (unsigned int)
11883 Generates the @code{popcntl} machine instruction.
11884 @item int __builtin_popcountl (unsigned long)
11885 Generates the @code{popcntl} or @code{popcntq} machine instruction,
11886 depending on the size of @code{unsigned long}.
11887 @item int __builtin_popcountll (unsigned long long)
11888 Generates the @code{popcntq} machine instruction.
11889 @end table
11891 The following built-in functions are available when @option{-mavx} is
11892 used. All of them generate the machine instruction that is part of the
11893 name.
11895 @smallexample
11896 v4df __builtin_ia32_addpd256 (v4df,v4df)
11897 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
11898 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
11899 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
11900 v4df __builtin_ia32_andnpd256 (v4df,v4df)
11901 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
11902 v4df __builtin_ia32_andpd256 (v4df,v4df)
11903 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
11904 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
11905 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
11906 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
11907 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
11908 v2df __builtin_ia32_cmppd (v2df,v2df,int)
11909 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
11910 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
11911 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
11912 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
11913 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
11914 v4df __builtin_ia32_cvtdq2pd256 (v4si)
11915 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
11916 v4si __builtin_ia32_cvtpd2dq256 (v4df)
11917 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
11918 v8si __builtin_ia32_cvtps2dq256 (v8sf)
11919 v4df __builtin_ia32_cvtps2pd256 (v4sf)
11920 v4si __builtin_ia32_cvttpd2dq256 (v4df)
11921 v8si __builtin_ia32_cvttps2dq256 (v8sf)
11922 v4df __builtin_ia32_divpd256 (v4df,v4df)
11923 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
11924 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
11925 v4df __builtin_ia32_haddpd256 (v4df,v4df)
11926 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
11927 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
11928 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
11929 v32qi __builtin_ia32_lddqu256 (pcchar)
11930 v32qi __builtin_ia32_loaddqu256 (pcchar)
11931 v4df __builtin_ia32_loadupd256 (pcdouble)
11932 v8sf __builtin_ia32_loadups256 (pcfloat)
11933 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
11934 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
11935 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
11936 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
11937 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
11938 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
11939 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
11940 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
11941 v4df __builtin_ia32_maxpd256 (v4df,v4df)
11942 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
11943 v4df __builtin_ia32_minpd256 (v4df,v4df)
11944 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
11945 v4df __builtin_ia32_movddup256 (v4df)
11946 int __builtin_ia32_movmskpd256 (v4df)
11947 int __builtin_ia32_movmskps256 (v8sf)
11948 v8sf __builtin_ia32_movshdup256 (v8sf)
11949 v8sf __builtin_ia32_movsldup256 (v8sf)
11950 v4df __builtin_ia32_mulpd256 (v4df,v4df)
11951 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
11952 v4df __builtin_ia32_orpd256 (v4df,v4df)
11953 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
11954 v2df __builtin_ia32_pd_pd256 (v4df)
11955 v4df __builtin_ia32_pd256_pd (v2df)
11956 v4sf __builtin_ia32_ps_ps256 (v8sf)
11957 v8sf __builtin_ia32_ps256_ps (v4sf)
11958 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
11959 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
11960 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
11961 v8sf __builtin_ia32_rcpps256 (v8sf)
11962 v4df __builtin_ia32_roundpd256 (v4df,int)
11963 v8sf __builtin_ia32_roundps256 (v8sf,int)
11964 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
11965 v8sf __builtin_ia32_rsqrtps256 (v8sf)
11966 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
11967 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
11968 v4si __builtin_ia32_si_si256 (v8si)
11969 v8si __builtin_ia32_si256_si (v4si)
11970 v4df __builtin_ia32_sqrtpd256 (v4df)
11971 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
11972 v8sf __builtin_ia32_sqrtps256 (v8sf)
11973 void __builtin_ia32_storedqu256 (pchar,v32qi)
11974 void __builtin_ia32_storeupd256 (pdouble,v4df)
11975 void __builtin_ia32_storeups256 (pfloat,v8sf)
11976 v4df __builtin_ia32_subpd256 (v4df,v4df)
11977 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
11978 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
11979 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
11980 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
11981 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
11982 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
11983 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
11984 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
11985 v4sf __builtin_ia32_vbroadcastss (pcfloat)
11986 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
11987 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
11988 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
11989 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
11990 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
11991 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
11992 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
11993 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
11994 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
11995 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
11996 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
11997 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
11998 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
11999 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
12000 v2df __builtin_ia32_vpermilpd (v2df,int)
12001 v4df __builtin_ia32_vpermilpd256 (v4df,int)
12002 v4sf __builtin_ia32_vpermilps (v4sf,int)
12003 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
12004 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
12005 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
12006 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
12007 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
12008 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
12009 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
12010 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
12011 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
12012 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
12013 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
12014 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
12015 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
12016 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
12017 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
12018 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
12019 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
12020 void __builtin_ia32_vzeroall (void)
12021 void __builtin_ia32_vzeroupper (void)
12022 v4df __builtin_ia32_xorpd256 (v4df,v4df)
12023 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
12024 @end smallexample
12026 The following built-in functions are available when @option{-mavx2} is
12027 used. All of them generate the machine instruction that is part of the
12028 name.
12030 @smallexample
12031 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
12032 v32qi __builtin_ia32_pabsb256 (v32qi)
12033 v16hi __builtin_ia32_pabsw256 (v16hi)
12034 v8si __builtin_ia32_pabsd256 (v8si)
12035 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
12036 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
12037 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
12038 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
12039 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
12040 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
12041 v8si __builtin_ia32_paddd256 (v8si,v8si)
12042 v4di __builtin_ia32_paddq256 (v4di,v4di)
12043 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
12044 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
12045 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
12046 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
12047 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
12048 v4di __builtin_ia32_andsi256 (v4di,v4di)
12049 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
12050 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
12051 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
12052 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
12053 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
12054 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
12055 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
12056 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
12057 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
12058 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
12059 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
12060 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
12061 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
12062 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
12063 v8si __builtin_ia32_phaddd256 (v8si,v8si)
12064 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
12065 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
12066 v8si __builtin_ia32_phsubd256 (v8si,v8si)
12067 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
12068 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
12069 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
12070 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
12071 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
12072 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
12073 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
12074 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
12075 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
12076 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
12077 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
12078 v8si __builtin_ia32_pminsd256 (v8si,v8si)
12079 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
12080 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
12081 v8si __builtin_ia32_pminud256 (v8si,v8si)
12082 int __builtin_ia32_pmovmskb256 (v32qi)
12083 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
12084 v8si __builtin_ia32_pmovsxbd256 (v16qi)
12085 v4di __builtin_ia32_pmovsxbq256 (v16qi)
12086 v8si __builtin_ia32_pmovsxwd256 (v8hi)
12087 v4di __builtin_ia32_pmovsxwq256 (v8hi)
12088 v4di __builtin_ia32_pmovsxdq256 (v4si)
12089 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
12090 v8si __builtin_ia32_pmovzxbd256 (v16qi)
12091 v4di __builtin_ia32_pmovzxbq256 (v16qi)
12092 v8si __builtin_ia32_pmovzxwd256 (v8hi)
12093 v4di __builtin_ia32_pmovzxwq256 (v8hi)
12094 v4di __builtin_ia32_pmovzxdq256 (v4si)
12095 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12096 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12097 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12098 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12099 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12100 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12101 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12102 v4di __builtin_ia32_por256 (v4di,v4di)
12103 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12104 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12105 v8si __builtin_ia32_pshufd256 (v8si,int)
12106 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12107 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12108 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12109 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12110 v8si __builtin_ia32_psignd256 (v8si,v8si)
12111 v4di __builtin_ia32_pslldqi256 (v4di,int)
12112 v16hi __builtin_ia32_psllwi256 (16hi,int)
12113 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12114 v8si __builtin_ia32_pslldi256 (v8si,int)
12115 v8si __builtin_ia32_pslld256(v8si,v4si)
12116 v4di __builtin_ia32_psllqi256 (v4di,int)
12117 v4di __builtin_ia32_psllq256(v4di,v2di)
12118 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12119 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12120 v8si __builtin_ia32_psradi256 (v8si,int)
12121 v8si __builtin_ia32_psrad256 (v8si,v4si)
12122 v4di __builtin_ia32_psrldqi256 (v4di, int)
12123 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12124 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12125 v8si __builtin_ia32_psrldi256 (v8si,int)
12126 v8si __builtin_ia32_psrld256 (v8si,v4si)
12127 v4di __builtin_ia32_psrlqi256 (v4di,int)
12128 v4di __builtin_ia32_psrlq256(v4di,v2di)
12129 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12130 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12131 v8si __builtin_ia32_psubd256 (v8si,v8si)
12132 v4di __builtin_ia32_psubq256 (v4di,v4di)
12133 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12134 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12135 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12136 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12137 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12138 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12139 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12140 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12141 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12142 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12143 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12144 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12145 v4di __builtin_ia32_pxor256 (v4di,v4di)
12146 v4di __builtin_ia32_movntdqa256 (pv4di)
12147 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12148 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12149 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12150 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12151 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12152 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12153 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12154 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12155 v8si __builtin_ia32_pbroadcastd256 (v4si)
12156 v4di __builtin_ia32_pbroadcastq256 (v2di)
12157 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12158 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12159 v4si __builtin_ia32_pbroadcastd128 (v4si)
12160 v2di __builtin_ia32_pbroadcastq128 (v2di)
12161 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12162 v4df __builtin_ia32_permdf256 (v4df,int)
12163 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12164 v4di __builtin_ia32_permdi256 (v4di,int)
12165 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12166 v4di __builtin_ia32_extract128i256 (v4di,int)
12167 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12168 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12169 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12170 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12171 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12172 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12173 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12174 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12175 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12176 v8si __builtin_ia32_psllv8si (v8si,v8si)
12177 v4si __builtin_ia32_psllv4si (v4si,v4si)
12178 v4di __builtin_ia32_psllv4di (v4di,v4di)
12179 v2di __builtin_ia32_psllv2di (v2di,v2di)
12180 v8si __builtin_ia32_psrav8si (v8si,v8si)
12181 v4si __builtin_ia32_psrav4si (v4si,v4si)
12182 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12183 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12184 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12185 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12186 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12187 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12188 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12189 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12190 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12191 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12192 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12193 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12194 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12195 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12196 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12197 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12198 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12199 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12200 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12201 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12202 @end smallexample
12204 The following built-in functions are available when @option{-maes} is
12205 used.  All of them generate the machine instruction that is part of the
12206 name.
12208 @smallexample
12209 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12210 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12211 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12212 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12213 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12214 v2di __builtin_ia32_aesimc128 (v2di)
12215 @end smallexample
12217 The following built-in function is available when @option{-mpclmul} is
12218 used.
12220 @table @code
12221 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12222 Generates the @code{pclmulqdq} machine instruction.
12223 @end table
12225 The following built-in function is available when @option{-mfsgsbase} is
12226 used.  All of them generate the machine instruction that is part of the
12227 name.
12229 @smallexample
12230 unsigned int __builtin_ia32_rdfsbase32 (void)
12231 unsigned long long __builtin_ia32_rdfsbase64 (void)
12232 unsigned int __builtin_ia32_rdgsbase32 (void)
12233 unsigned long long __builtin_ia32_rdgsbase64 (void)
12234 void _writefsbase_u32 (unsigned int)
12235 void _writefsbase_u64 (unsigned long long)
12236 void _writegsbase_u32 (unsigned int)
12237 void _writegsbase_u64 (unsigned long long)
12238 @end smallexample
12240 The following built-in function is available when @option{-mrdrnd} is
12241 used.  All of them generate the machine instruction that is part of the
12242 name.
12244 @smallexample
12245 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12246 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12247 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12248 @end smallexample
12250 The following built-in functions are available when @option{-msse4a} is used.
12251 All of them generate the machine instruction that is part of the name.
12253 @smallexample
12254 void __builtin_ia32_movntsd (double *, v2df)
12255 void __builtin_ia32_movntss (float *, v4sf)
12256 v2di __builtin_ia32_extrq  (v2di, v16qi)
12257 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12258 v2di __builtin_ia32_insertq (v2di, v2di)
12259 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12260 @end smallexample
12262 The following built-in functions are available when @option{-mxop} is used.
12263 @smallexample
12264 v2df __builtin_ia32_vfrczpd (v2df)
12265 v4sf __builtin_ia32_vfrczps (v4sf)
12266 v2df __builtin_ia32_vfrczsd (v2df)
12267 v4sf __builtin_ia32_vfrczss (v4sf)
12268 v4df __builtin_ia32_vfrczpd256 (v4df)
12269 v8sf __builtin_ia32_vfrczps256 (v8sf)
12270 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12271 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12272 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12273 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12274 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12275 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12276 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12277 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12278 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12279 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12280 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12281 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12282 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12283 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12284 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12285 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12286 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12287 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12288 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12289 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12290 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12291 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12292 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12293 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12294 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12295 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12296 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12297 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12298 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12299 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12300 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12301 v4si __builtin_ia32_vpcomged (v4si, v4si)
12302 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12303 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12304 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12305 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12306 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12307 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12308 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12309 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12310 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12311 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12312 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12313 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12314 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12315 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12316 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12317 v4si __builtin_ia32_vpcomled (v4si, v4si)
12318 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12319 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12320 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12321 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12322 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12323 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12324 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12325 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12326 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12327 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12328 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12329 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12330 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12331 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12332 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12333 v4si __builtin_ia32_vpcomned (v4si, v4si)
12334 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12335 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12336 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12337 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12338 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12339 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12340 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12341 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12342 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12343 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12344 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12345 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12346 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12347 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12348 v4si __builtin_ia32_vphaddbd (v16qi)
12349 v2di __builtin_ia32_vphaddbq (v16qi)
12350 v8hi __builtin_ia32_vphaddbw (v16qi)
12351 v2di __builtin_ia32_vphadddq (v4si)
12352 v4si __builtin_ia32_vphaddubd (v16qi)
12353 v2di __builtin_ia32_vphaddubq (v16qi)
12354 v8hi __builtin_ia32_vphaddubw (v16qi)
12355 v2di __builtin_ia32_vphaddudq (v4si)
12356 v4si __builtin_ia32_vphadduwd (v8hi)
12357 v2di __builtin_ia32_vphadduwq (v8hi)
12358 v4si __builtin_ia32_vphaddwd (v8hi)
12359 v2di __builtin_ia32_vphaddwq (v8hi)
12360 v8hi __builtin_ia32_vphsubbw (v16qi)
12361 v2di __builtin_ia32_vphsubdq (v4si)
12362 v4si __builtin_ia32_vphsubwd (v8hi)
12363 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12364 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12365 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12366 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12367 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12368 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12369 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12370 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12371 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12372 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12373 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12374 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12375 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12376 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12377 v4si __builtin_ia32_vprotd (v4si, v4si)
12378 v2di __builtin_ia32_vprotq (v2di, v2di)
12379 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12380 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12381 v4si __builtin_ia32_vpshad (v4si, v4si)
12382 v2di __builtin_ia32_vpshaq (v2di, v2di)
12383 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12384 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12385 v4si __builtin_ia32_vpshld (v4si, v4si)
12386 v2di __builtin_ia32_vpshlq (v2di, v2di)
12387 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12388 @end smallexample
12390 The following built-in functions are available when @option{-mfma4} is used.
12391 All of them generate the machine instruction that is part of the name.
12393 @smallexample
12394 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12395 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12396 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12397 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12398 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12399 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12400 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12401 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12402 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12403 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12404 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12405 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12406 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12407 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12408 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12409 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12410 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
12411 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
12412 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
12413 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
12414 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12415 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12416 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12417 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12418 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12419 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12420 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12421 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12422 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12423 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12424 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12425 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12427 @end smallexample
12429 The following built-in functions are available when @option{-mlwp} is used.
12431 @smallexample
12432 void __builtin_ia32_llwpcb16 (void *);
12433 void __builtin_ia32_llwpcb32 (void *);
12434 void __builtin_ia32_llwpcb64 (void *);
12435 void * __builtin_ia32_llwpcb16 (void);
12436 void * __builtin_ia32_llwpcb32 (void);
12437 void * __builtin_ia32_llwpcb64 (void);
12438 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12439 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12440 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12441 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12442 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12443 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12444 @end smallexample
12446 The following built-in functions are available when @option{-mbmi} is used.
12447 All of them generate the machine instruction that is part of the name.
12448 @smallexample
12449 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12450 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12451 @end smallexample
12453 The following built-in functions are available when @option{-mbmi2} is used.
12454 All of them generate the machine instruction that is part of the name.
12455 @smallexample
12456 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12457 unsigned int _pdep_u32 (unsigned int, unsigned int)
12458 unsigned int _pext_u32 (unsigned int, unsigned int)
12459 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12460 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12461 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12462 @end smallexample
12464 The following built-in functions are available when @option{-mlzcnt} is used.
12465 All of them generate the machine instruction that is part of the name.
12466 @smallexample
12467 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12468 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12469 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12470 @end smallexample
12472 The following built-in functions are available when @option{-mfxsr} is used.
12473 All of them generate the machine instruction that is part of the name.
12474 @smallexample
12475 void __builtin_ia32_fxsave (void *)
12476 void __builtin_ia32_fxrstor (void *)
12477 void __builtin_ia32_fxsave64 (void *)
12478 void __builtin_ia32_fxrstor64 (void *)
12479 @end smallexample
12481 The following built-in functions are available when @option{-mxsave} is used.
12482 All of them generate the machine instruction that is part of the name.
12483 @smallexample
12484 void __builtin_ia32_xsave (void *, long long)
12485 void __builtin_ia32_xrstor (void *, long long)
12486 void __builtin_ia32_xsave64 (void *, long long)
12487 void __builtin_ia32_xrstor64 (void *, long long)
12488 @end smallexample
12490 The following built-in functions are available when @option{-mxsaveopt} is used.
12491 All of them generate the machine instruction that is part of the name.
12492 @smallexample
12493 void __builtin_ia32_xsaveopt (void *, long long)
12494 void __builtin_ia32_xsaveopt64 (void *, long long)
12495 @end smallexample
12497 The following built-in functions are available when @option{-mtbm} is used.
12498 Both of them generate the immediate form of the bextr machine instruction.
12499 @smallexample
12500 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12501 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12502 @end smallexample
12505 The following built-in functions are available when @option{-m3dnow} is used.
12506 All of them generate the machine instruction that is part of the name.
12508 @smallexample
12509 void __builtin_ia32_femms (void)
12510 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12511 v2si __builtin_ia32_pf2id (v2sf)
12512 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12513 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12514 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12515 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12516 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12517 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12518 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12519 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12520 v2sf __builtin_ia32_pfrcp (v2sf)
12521 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12522 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12523 v2sf __builtin_ia32_pfrsqrt (v2sf)
12524 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12525 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12526 v2sf __builtin_ia32_pi2fd (v2si)
12527 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12528 @end smallexample
12530 The following built-in functions are available when both @option{-m3dnow}
12531 and @option{-march=athlon} are used.  All of them generate the machine
12532 instruction that is part of the name.
12534 @smallexample
12535 v2si __builtin_ia32_pf2iw (v2sf)
12536 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12537 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12538 v2sf __builtin_ia32_pi2fw (v2si)
12539 v2sf __builtin_ia32_pswapdsf (v2sf)
12540 v2si __builtin_ia32_pswapdsi (v2si)
12541 @end smallexample
12543 The following built-in functions are available when @option{-mrtm} is used
12544 They are used for restricted transactional memory. These are the internal
12545 low level functions. Normally the functions in 
12546 @ref{X86 transactional memory intrinsics} should be used instead.
12548 @smallexample
12549 int __builtin_ia32_xbegin ()
12550 void __builtin_ia32_xend ()
12551 void __builtin_ia32_xabort (status)
12552 int __builtin_ia32_xtest ()
12553 @end smallexample
12555 @node X86 transactional memory intrinsics
12556 @subsection X86 transaction memory intrinsics
12558 Hardware transactional memory intrinsics for i386. These allow to use
12559 memory transactions with RTM (Restricted Transactional Memory).
12560 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12561 This support is enabled with the @option{-mrtm} option.
12563 A memory transaction commits all changes to memory in an atomic way,
12564 as visible to other threads. If the transaction fails it is rolled back
12565 and all side effects discarded.
12567 Generally there is no guarantee that a memory transaction ever succeeds
12568 and suitable fallback code always needs to be supplied.
12570 @deftypefn {RTM Function} {unsigned} _xbegin ()
12571 Start a RTM (Restricted Transactional Memory) transaction. 
12572 Returns _XBEGIN_STARTED when the transaction
12573 started successfully (note this is not 0, so the constant has to be 
12574 explicitely tested). When the transaction aborts all side effects
12575 are undone and an abort code is returned. There is no guarantee
12576 any transaction ever succeeds, so there always needs to be a valid
12577 tested fallback path.
12578 @end deftypefn
12580 @smallexample
12581 #include <immintrin.h>
12583 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12584     ... transaction code...
12585     _xend ();
12586 @} else @{
12587     ... non transactional fallback path...
12589 @end smallexample
12591 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12593 @table @code
12594 @item _XABORT_EXPLICIT
12595 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12596 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12597 @item _XABORT_RETRY
12598 Transaction retry is possible.
12599 @item _XABORT_CONFLICT
12600 Transaction abort due to a memory conflict with another thread
12601 @item _XABORT_CAPACITY
12602 Transaction abort due to the transaction using too much memory
12603 @item _XABORT_DEBUG
12604 Transaction abort due to a debug trap
12605 @item _XABORT_NESTED
12606 Transaction abort in a inner nested transaction
12607 @end table
12609 @deftypefn {RTM Function} {void} _xend ()
12610 Commit the current transaction. When no transaction is active this will
12611 fault. All memory side effects of the transactions will become visible
12612 to other threads in an atomic matter.
12613 @end deftypefn
12615 @deftypefn {RTM Function} {int} _xtest ()
12616 Return a value not zero when a transaction is currently active, otherwise 0.
12617 @end deftypefn
12619 @deftypefn {RTM Function} {void} _xabort (status)
12620 Abort the current transaction. When no transaction is active this is a no-op.
12621 status must be a 8bit constant, that is included in the status code returned
12622 by @code{_xbegin}
12623 @end deftypefn
12625 @node MIPS DSP Built-in Functions
12626 @subsection MIPS DSP Built-in Functions
12628 The MIPS DSP Application-Specific Extension (ASE) includes new
12629 instructions that are designed to improve the performance of DSP and
12630 media applications.  It provides instructions that operate on packed
12631 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12633 GCC supports MIPS DSP operations using both the generic
12634 vector extensions (@pxref{Vector Extensions}) and a collection of
12635 MIPS-specific built-in functions.  Both kinds of support are
12636 enabled by the @option{-mdsp} command-line option.
12638 Revision 2 of the ASE was introduced in the second half of 2006.
12639 This revision adds extra instructions to the original ASE, but is
12640 otherwise backwards-compatible with it.  You can select revision 2
12641 using the command-line option @option{-mdspr2}; this option implies
12642 @option{-mdsp}.
12644 The SCOUNT and POS bits of the DSP control register are global.  The
12645 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12646 POS bits.  During optimization, the compiler does not delete these
12647 instructions and it does not delete calls to functions containing
12648 these instructions.
12650 At present, GCC only provides support for operations on 32-bit
12651 vectors.  The vector type associated with 8-bit integer data is
12652 usually called @code{v4i8}, the vector type associated with Q7
12653 is usually called @code{v4q7}, the vector type associated with 16-bit
12654 integer data is usually called @code{v2i16}, and the vector type
12655 associated with Q15 is usually called @code{v2q15}.  They can be
12656 defined in C as follows:
12658 @smallexample
12659 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12660 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12661 typedef short v2i16 __attribute__ ((vector_size(4)));
12662 typedef short v2q15 __attribute__ ((vector_size(4)));
12663 @end smallexample
12665 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12666 initialized in the same way as aggregates.  For example:
12668 @smallexample
12669 v4i8 a = @{1, 2, 3, 4@};
12670 v4i8 b;
12671 b = (v4i8) @{5, 6, 7, 8@};
12673 v2q15 c = @{0x0fcb, 0x3a75@};
12674 v2q15 d;
12675 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12676 @end smallexample
12678 @emph{Note:} The CPU's endianness determines the order in which values
12679 are packed.  On little-endian targets, the first value is the least
12680 significant and the last value is the most significant.  The opposite
12681 order applies to big-endian targets.  For example, the code above
12682 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12683 and @code{4} on big-endian targets.
12685 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12686 representation.  As shown in this example, the integer representation
12687 of a Q7 value can be obtained by multiplying the fractional value by
12688 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
12689 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
12690 @code{0x1.0p31}.
12692 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12693 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
12694 and @code{c} and @code{d} are @code{v2q15} values.
12696 @multitable @columnfractions .50 .50
12697 @item C code @tab MIPS instruction
12698 @item @code{a + b} @tab @code{addu.qb}
12699 @item @code{c + d} @tab @code{addq.ph}
12700 @item @code{a - b} @tab @code{subu.qb}
12701 @item @code{c - d} @tab @code{subq.ph}
12702 @end multitable
12704 The table below lists the @code{v2i16} operation for which
12705 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
12706 @code{v2i16} values.
12708 @multitable @columnfractions .50 .50
12709 @item C code @tab MIPS instruction
12710 @item @code{e * f} @tab @code{mul.ph}
12711 @end multitable
12713 It is easier to describe the DSP built-in functions if we first define
12714 the following types:
12716 @smallexample
12717 typedef int q31;
12718 typedef int i32;
12719 typedef unsigned int ui32;
12720 typedef long long a64;
12721 @end smallexample
12723 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12724 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12725 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
12726 @code{long long}, but we use @code{a64} to indicate values that are
12727 placed in one of the four DSP accumulators (@code{$ac0},
12728 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12730 Also, some built-in functions prefer or require immediate numbers as
12731 parameters, because the corresponding DSP instructions accept both immediate
12732 numbers and register operands, or accept immediate numbers only.  The
12733 immediate parameters are listed as follows.
12735 @smallexample
12736 imm0_3: 0 to 3.
12737 imm0_7: 0 to 7.
12738 imm0_15: 0 to 15.
12739 imm0_31: 0 to 31.
12740 imm0_63: 0 to 63.
12741 imm0_255: 0 to 255.
12742 imm_n32_31: -32 to 31.
12743 imm_n512_511: -512 to 511.
12744 @end smallexample
12746 The following built-in functions map directly to a particular MIPS DSP
12747 instruction.  Please refer to the architecture specification
12748 for details on what each instruction does.
12750 @smallexample
12751 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12752 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12753 q31 __builtin_mips_addq_s_w (q31, q31)
12754 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12755 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12756 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12757 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12758 q31 __builtin_mips_subq_s_w (q31, q31)
12759 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12760 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12761 i32 __builtin_mips_addsc (i32, i32)
12762 i32 __builtin_mips_addwc (i32, i32)
12763 i32 __builtin_mips_modsub (i32, i32)
12764 i32 __builtin_mips_raddu_w_qb (v4i8)
12765 v2q15 __builtin_mips_absq_s_ph (v2q15)
12766 q31 __builtin_mips_absq_s_w (q31)
12767 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12768 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12769 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12770 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12771 q31 __builtin_mips_preceq_w_phl (v2q15)
12772 q31 __builtin_mips_preceq_w_phr (v2q15)
12773 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12774 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12775 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12776 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12777 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12778 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12779 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12780 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12781 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12782 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12783 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12784 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12785 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12786 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12787 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12788 q31 __builtin_mips_shll_s_w (q31, i32)
12789 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12790 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12791 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12792 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12793 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12794 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12795 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12796 q31 __builtin_mips_shra_r_w (q31, i32)
12797 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12798 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12799 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12800 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12801 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12802 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12803 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12804 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12805 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12806 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12807 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12808 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12809 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12810 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12811 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12812 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12813 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12814 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12815 i32 __builtin_mips_bitrev (i32)
12816 i32 __builtin_mips_insv (i32, i32)
12817 v4i8 __builtin_mips_repl_qb (imm0_255)
12818 v4i8 __builtin_mips_repl_qb (i32)
12819 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12820 v2q15 __builtin_mips_repl_ph (i32)
12821 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12822 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12823 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12824 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12825 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12826 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12827 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12828 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12829 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12830 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12831 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12832 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12833 i32 __builtin_mips_extr_w (a64, imm0_31)
12834 i32 __builtin_mips_extr_w (a64, i32)
12835 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12836 i32 __builtin_mips_extr_s_h (a64, i32)
12837 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12838 i32 __builtin_mips_extr_rs_w (a64, i32)
12839 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12840 i32 __builtin_mips_extr_r_w (a64, i32)
12841 i32 __builtin_mips_extp (a64, imm0_31)
12842 i32 __builtin_mips_extp (a64, i32)
12843 i32 __builtin_mips_extpdp (a64, imm0_31)
12844 i32 __builtin_mips_extpdp (a64, i32)
12845 a64 __builtin_mips_shilo (a64, imm_n32_31)
12846 a64 __builtin_mips_shilo (a64, i32)
12847 a64 __builtin_mips_mthlip (a64, i32)
12848 void __builtin_mips_wrdsp (i32, imm0_63)
12849 i32 __builtin_mips_rddsp (imm0_63)
12850 i32 __builtin_mips_lbux (void *, i32)
12851 i32 __builtin_mips_lhx (void *, i32)
12852 i32 __builtin_mips_lwx (void *, i32)
12853 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12854 i32 __builtin_mips_bposge32 (void)
12855 a64 __builtin_mips_madd (a64, i32, i32);
12856 a64 __builtin_mips_maddu (a64, ui32, ui32);
12857 a64 __builtin_mips_msub (a64, i32, i32);
12858 a64 __builtin_mips_msubu (a64, ui32, ui32);
12859 a64 __builtin_mips_mult (i32, i32);
12860 a64 __builtin_mips_multu (ui32, ui32);
12861 @end smallexample
12863 The following built-in functions map directly to a particular MIPS DSP REV 2
12864 instruction.  Please refer to the architecture specification
12865 for details on what each instruction does.
12867 @smallexample
12868 v4q7 __builtin_mips_absq_s_qb (v4q7);
12869 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12870 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12871 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12872 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12873 i32 __builtin_mips_append (i32, i32, imm0_31);
12874 i32 __builtin_mips_balign (i32, i32, imm0_3);
12875 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12876 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12877 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12878 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12879 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12880 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12881 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12882 q31 __builtin_mips_mulq_rs_w (q31, q31);
12883 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12884 q31 __builtin_mips_mulq_s_w (q31, q31);
12885 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12886 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12887 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12888 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12889 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12890 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12891 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12892 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12893 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12894 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12895 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12896 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12897 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12898 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12899 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12900 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12901 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12902 q31 __builtin_mips_addqh_w (q31, q31);
12903 q31 __builtin_mips_addqh_r_w (q31, q31);
12904 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12905 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12906 q31 __builtin_mips_subqh_w (q31, q31);
12907 q31 __builtin_mips_subqh_r_w (q31, q31);
12908 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12909 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12910 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12911 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12912 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12913 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12914 @end smallexample
12917 @node MIPS Paired-Single Support
12918 @subsection MIPS Paired-Single Support
12920 The MIPS64 architecture includes a number of instructions that
12921 operate on pairs of single-precision floating-point values.
12922 Each pair is packed into a 64-bit floating-point register,
12923 with one element being designated the ``upper half'' and
12924 the other being designated the ``lower half''.
12926 GCC supports paired-single 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{-mpaired-single} command-line option.
12931 The vector type associated with paired-single values is usually
12932 called @code{v2sf}.  It can be defined in C as follows:
12934 @smallexample
12935 typedef float v2sf __attribute__ ((vector_size (8)));
12936 @end smallexample
12938 @code{v2sf} values are initialized in the same way as aggregates.
12939 For example:
12941 @smallexample
12942 v2sf a = @{1.5, 9.1@};
12943 v2sf b;
12944 float e, f;
12945 b = (v2sf) @{e, f@};
12946 @end smallexample
12948 @emph{Note:} The CPU's endianness determines which value is stored in
12949 the upper half of a register and which value is stored in the lower half.
12950 On little-endian targets, the first value is the lower one and the second
12951 value is the upper one.  The opposite order applies to big-endian targets.
12952 For example, the code above sets the lower half of @code{a} to
12953 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12955 @node MIPS Loongson Built-in Functions
12956 @subsection MIPS Loongson Built-in Functions
12958 GCC provides intrinsics to access the SIMD instructions provided by the
12959 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
12960 available after inclusion of the @code{loongson.h} header file,
12961 operate on the following 64-bit vector types:
12963 @itemize
12964 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12965 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12966 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12967 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12968 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12969 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12970 @end itemize
12972 The intrinsics provided are listed below; each is named after the
12973 machine instruction to which it corresponds, with suffixes added as
12974 appropriate to distinguish intrinsics that expand to the same machine
12975 instruction yet have different argument types.  Refer to the architecture
12976 documentation for a description of the functionality of each
12977 instruction.
12979 @smallexample
12980 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12981 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12982 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12983 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12984 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12985 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12986 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12987 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12988 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12989 uint64_t paddd_u (uint64_t s, uint64_t t);
12990 int64_t paddd_s (int64_t s, int64_t t);
12991 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12992 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12993 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12994 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12995 uint64_t pandn_ud (uint64_t s, uint64_t t);
12996 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12997 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12998 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12999 int64_t pandn_sd (int64_t s, int64_t t);
13000 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13001 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13002 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13003 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13004 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13005 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13006 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13007 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13008 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13009 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13010 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13011 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13012 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13013 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13014 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13015 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13016 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13017 uint16x4_t pextrh_u (uint16x4_t s, int field);
13018 int16x4_t pextrh_s (int16x4_t s, int field);
13019 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13020 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13021 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13022 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13023 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13024 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13025 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13026 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13027 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13028 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13029 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13030 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13031 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13032 uint8x8_t pmovmskb_u (uint8x8_t s);
13033 int8x8_t pmovmskb_s (int8x8_t s);
13034 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13035 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13036 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13037 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13038 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13039 uint16x4_t biadd (uint8x8_t s);
13040 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13041 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13042 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13043 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13044 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13045 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13046 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13047 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13048 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13049 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13050 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13051 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13052 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13053 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13054 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13055 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13056 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13057 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13058 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13059 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13060 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13061 uint64_t psubd_u (uint64_t s, uint64_t t);
13062 int64_t psubd_s (int64_t s, int64_t t);
13063 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13064 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13065 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13066 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13067 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13068 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13069 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13070 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13071 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13072 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13073 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13074 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13075 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13076 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13077 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13078 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13079 @end smallexample
13081 @menu
13082 * Paired-Single Arithmetic::
13083 * Paired-Single Built-in Functions::
13084 * MIPS-3D Built-in Functions::
13085 @end menu
13087 @node Paired-Single Arithmetic
13088 @subsubsection Paired-Single Arithmetic
13090 The table below lists the @code{v2sf} operations for which hardware
13091 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
13092 values and @code{x} is an integral value.
13094 @multitable @columnfractions .50 .50
13095 @item C code @tab MIPS instruction
13096 @item @code{a + b} @tab @code{add.ps}
13097 @item @code{a - b} @tab @code{sub.ps}
13098 @item @code{-a} @tab @code{neg.ps}
13099 @item @code{a * b} @tab @code{mul.ps}
13100 @item @code{a * b + c} @tab @code{madd.ps}
13101 @item @code{a * b - c} @tab @code{msub.ps}
13102 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13103 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13104 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13105 @end multitable
13107 Note that the multiply-accumulate instructions can be disabled
13108 using the command-line option @code{-mno-fused-madd}.
13110 @node Paired-Single Built-in Functions
13111 @subsubsection Paired-Single Built-in Functions
13113 The following paired-single functions map directly to a particular
13114 MIPS instruction.  Please refer to the architecture specification
13115 for details on what each instruction does.
13117 @table @code
13118 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13119 Pair lower lower (@code{pll.ps}).
13121 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13122 Pair upper lower (@code{pul.ps}).
13124 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13125 Pair lower upper (@code{plu.ps}).
13127 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13128 Pair upper upper (@code{puu.ps}).
13130 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13131 Convert pair to paired single (@code{cvt.ps.s}).
13133 @item float __builtin_mips_cvt_s_pl (v2sf)
13134 Convert pair lower to single (@code{cvt.s.pl}).
13136 @item float __builtin_mips_cvt_s_pu (v2sf)
13137 Convert pair upper to single (@code{cvt.s.pu}).
13139 @item v2sf __builtin_mips_abs_ps (v2sf)
13140 Absolute value (@code{abs.ps}).
13142 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13143 Align variable (@code{alnv.ps}).
13145 @emph{Note:} The value of the third parameter must be 0 or 4
13146 modulo 8, otherwise the result is unpredictable.  Please read the
13147 instruction description for details.
13148 @end table
13150 The following multi-instruction functions are also available.
13151 In each case, @var{cond} can be any of the 16 floating-point conditions:
13152 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13153 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13154 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13156 @table @code
13157 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13158 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13159 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13160 @code{movt.ps}/@code{movf.ps}).
13162 The @code{movt} functions return the value @var{x} computed by:
13164 @smallexample
13165 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13166 mov.ps @var{x},@var{c}
13167 movt.ps @var{x},@var{d},@var{cc}
13168 @end smallexample
13170 The @code{movf} functions are similar but use @code{movf.ps} instead
13171 of @code{movt.ps}.
13173 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13174 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13175 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13176 @code{bc1t}/@code{bc1f}).
13178 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13179 and return either the upper or lower half of the result.  For example:
13181 @smallexample
13182 v2sf a, b;
13183 if (__builtin_mips_upper_c_eq_ps (a, b))
13184   upper_halves_are_equal ();
13185 else
13186   upper_halves_are_unequal ();
13188 if (__builtin_mips_lower_c_eq_ps (a, b))
13189   lower_halves_are_equal ();
13190 else
13191   lower_halves_are_unequal ();
13192 @end smallexample
13193 @end table
13195 @node MIPS-3D Built-in Functions
13196 @subsubsection MIPS-3D Built-in Functions
13198 The MIPS-3D Application-Specific Extension (ASE) includes additional
13199 paired-single instructions that are designed to improve the performance
13200 of 3D graphics operations.  Support for these instructions is controlled
13201 by the @option{-mips3d} command-line option.
13203 The functions listed below map directly to a particular MIPS-3D
13204 instruction.  Please refer to the architecture specification for
13205 more details on what each instruction does.
13207 @table @code
13208 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13209 Reduction add (@code{addr.ps}).
13211 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13212 Reduction multiply (@code{mulr.ps}).
13214 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13215 Convert paired single to paired word (@code{cvt.pw.ps}).
13217 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13218 Convert paired word to paired single (@code{cvt.ps.pw}).
13220 @item float __builtin_mips_recip1_s (float)
13221 @itemx double __builtin_mips_recip1_d (double)
13222 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13223 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13225 @item float __builtin_mips_recip2_s (float, float)
13226 @itemx double __builtin_mips_recip2_d (double, double)
13227 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13228 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13230 @item float __builtin_mips_rsqrt1_s (float)
13231 @itemx double __builtin_mips_rsqrt1_d (double)
13232 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13233 Reduced-precision reciprocal square root (sequence step 1)
13234 (@code{rsqrt1.@var{fmt}}).
13236 @item float __builtin_mips_rsqrt2_s (float, float)
13237 @itemx double __builtin_mips_rsqrt2_d (double, double)
13238 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13239 Reduced-precision reciprocal square root (sequence step 2)
13240 (@code{rsqrt2.@var{fmt}}).
13241 @end table
13243 The following multi-instruction functions are also available.
13244 In each case, @var{cond} can be any of the 16 floating-point conditions:
13245 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13246 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13247 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13249 @table @code
13250 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13251 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13252 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13253 @code{bc1t}/@code{bc1f}).
13255 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13256 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13257 For example:
13259 @smallexample
13260 float a, b;
13261 if (__builtin_mips_cabs_eq_s (a, b))
13262   true ();
13263 else
13264   false ();
13265 @end smallexample
13267 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13268 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13269 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13270 @code{bc1t}/@code{bc1f}).
13272 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13273 and return either the upper or lower half of the result.  For example:
13275 @smallexample
13276 v2sf a, b;
13277 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13278   upper_halves_are_equal ();
13279 else
13280   upper_halves_are_unequal ();
13282 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13283   lower_halves_are_equal ();
13284 else
13285   lower_halves_are_unequal ();
13286 @end smallexample
13288 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13289 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13290 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13291 @code{movt.ps}/@code{movf.ps}).
13293 The @code{movt} functions return the value @var{x} computed by:
13295 @smallexample
13296 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13297 mov.ps @var{x},@var{c}
13298 movt.ps @var{x},@var{d},@var{cc}
13299 @end smallexample
13301 The @code{movf} functions are similar but use @code{movf.ps} instead
13302 of @code{movt.ps}.
13304 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13305 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13306 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13307 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13308 Comparison of two paired-single values
13309 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13310 @code{bc1any2t}/@code{bc1any2f}).
13312 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13313 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13314 result is true and the @code{all} forms return true if both results are true.
13315 For example:
13317 @smallexample
13318 v2sf a, b;
13319 if (__builtin_mips_any_c_eq_ps (a, b))
13320   one_is_true ();
13321 else
13322   both_are_false ();
13324 if (__builtin_mips_all_c_eq_ps (a, b))
13325   both_are_true ();
13326 else
13327   one_is_false ();
13328 @end smallexample
13330 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13331 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13332 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13333 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13334 Comparison of four paired-single values
13335 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13336 @code{bc1any4t}/@code{bc1any4f}).
13338 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13339 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13340 The @code{any} forms return true if any of the four results are true
13341 and the @code{all} forms return true if all four results are true.
13342 For example:
13344 @smallexample
13345 v2sf a, b, c, d;
13346 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13347   some_are_true ();
13348 else
13349   all_are_false ();
13351 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13352   all_are_true ();
13353 else
13354   some_are_false ();
13355 @end smallexample
13356 @end table
13358 @node Other MIPS Built-in Functions
13359 @subsection Other MIPS Built-in Functions
13361 GCC provides other MIPS-specific built-in functions:
13363 @table @code
13364 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13365 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13366 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13367 when this function is available.
13369 @item unsigned int __builtin_mips_get_fcsr (void)
13370 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13371 Get and set the contents of the floating-point control and status register
13372 (FPU control register 31).  These functions are only available in hard-float
13373 code but can be called in both MIPS16 and non-MIPS16 contexts.
13375 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13376 register except the condition codes, which GCC assumes are preserved.
13377 @end table
13379 @node MSP430 Built-in Functions
13380 @subsection MSP430 Built-in Functions
13382 GCC provides a couple of special builtin functions to aid in the
13383 writing of interrupt handlers in C.
13385 @table @code
13386 @item __bic_SR_register_on_exit (int @var{mask})
13387 This clears the indicated bits in the saved copy of the status register
13388 currently residing on the stack.  This only works inside interrupt
13389 handlers and the changes to the status register will only take affect
13390 once the handler returns.
13392 @item __bis_SR_register_on_exit (int @var{mask})
13393 This sets the indicated bits in the saved copy of the status register
13394 currently residing on the stack.  This only works inside interrupt
13395 handlers and the changes to the status register will only take affect
13396 once the handler returns.
13398 @item __delay_cycles (long long @var{cycles})
13399 This inserts an instruction sequence that takes exactly @var{cycles}
13400 cycles (between 0 and about 17E9) to complete.  The inserted sequence
13401 may use jumps, loops, or no-ops, and does not interfere with any other
13402 instructions.  Note that @var{cycles} must be a compile-time constant
13403 integer - that is, you must pass a number, not a variable that may be
13404 optimized to a constant later.  The number of cycles delayed by this
13405 builtin is exact.
13406 @end table
13408 @node NDS32 Built-in Functions
13409 @subsection NDS32 Built-in Functions
13411 These built-in functions are available for the NDS32 target:
13413 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13414 Insert an ISYNC instruction into the instruction stream where
13415 @var{addr} is an instruction address for serialization.
13416 @end deftypefn
13418 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13419 Insert an ISB instruction into the instruction stream.
13420 @end deftypefn
13422 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13423 Return the content of a system register which is mapped by @var{sr}.
13424 @end deftypefn
13426 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13427 Return the content of a user space register which is mapped by @var{usr}.
13428 @end deftypefn
13430 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13431 Move the @var{value} to a system register which is mapped by @var{sr}.
13432 @end deftypefn
13434 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13435 Move the @var{value} to a user space register which is mapped by @var{usr}.
13436 @end deftypefn
13438 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13439 Enable global interrupt.
13440 @end deftypefn
13442 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13443 Disable global interrupt.
13444 @end deftypefn
13446 @node picoChip Built-in Functions
13447 @subsection picoChip Built-in Functions
13449 GCC provides an interface to selected machine instructions from the
13450 picoChip instruction set.
13452 @table @code
13453 @item int __builtin_sbc (int @var{value})
13454 Sign bit count.  Return the number of consecutive bits in @var{value}
13455 that have the same value as the sign bit.  The result is the number of
13456 leading sign bits minus one, giving the number of redundant sign bits in
13457 @var{value}.
13459 @item int __builtin_byteswap (int @var{value})
13460 Byte swap.  Return the result of swapping the upper and lower bytes of
13461 @var{value}.
13463 @item int __builtin_brev (int @var{value})
13464 Bit reversal.  Return the result of reversing the bits in
13465 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13466 and so on.
13468 @item int __builtin_adds (int @var{x}, int @var{y})
13469 Saturating addition.  Return the result of adding @var{x} and @var{y},
13470 storing the value 32767 if the result overflows.
13472 @item int __builtin_subs (int @var{x}, int @var{y})
13473 Saturating subtraction.  Return the result of subtracting @var{y} from
13474 @var{x}, storing the value @minus{}32768 if the result overflows.
13476 @item void __builtin_halt (void)
13477 Halt.  The processor stops execution.  This built-in is useful for
13478 implementing assertions.
13480 @end table
13482 @node PowerPC Built-in Functions
13483 @subsection PowerPC Built-in Functions
13485 These built-in functions are available for the PowerPC family of
13486 processors:
13487 @smallexample
13488 float __builtin_recipdivf (float, float);
13489 float __builtin_rsqrtf (float);
13490 double __builtin_recipdiv (double, double);
13491 double __builtin_rsqrt (double);
13492 uint64_t __builtin_ppc_get_timebase ();
13493 unsigned long __builtin_ppc_mftb ();
13494 double __builtin_unpack_longdouble (long double, int);
13495 long double __builtin_pack_longdouble (double, double);
13496 @end smallexample
13498 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13499 @code{__builtin_rsqrtf} functions generate multiple instructions to
13500 implement the reciprocal sqrt functionality using reciprocal sqrt
13501 estimate instructions.
13503 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13504 functions generate multiple instructions to implement division using
13505 the reciprocal estimate instructions.
13507 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13508 functions generate instructions to read the Time Base Register.  The
13509 @code{__builtin_ppc_get_timebase} function may generate multiple
13510 instructions and always returns the 64 bits of the Time Base Register.
13511 The @code{__builtin_ppc_mftb} function always generates one instruction and
13512 returns the Time Base Register value as an unsigned long, throwing away
13513 the most significant word on 32-bit environments.
13515 The following built-in functions are available for the PowerPC family
13516 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13517 or @option{-mpopcntd}):
13518 @smallexample
13519 long __builtin_bpermd (long, long);
13520 int __builtin_divwe (int, int);
13521 int __builtin_divweo (int, int);
13522 unsigned int __builtin_divweu (unsigned int, unsigned int);
13523 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13524 long __builtin_divde (long, long);
13525 long __builtin_divdeo (long, long);
13526 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13527 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13528 unsigned int cdtbcd (unsigned int);
13529 unsigned int cbcdtd (unsigned int);
13530 unsigned int addg6s (unsigned int, unsigned int);
13531 @end smallexample
13533 The @code{__builtin_divde}, @code{__builtin_divdeo},
13534 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13535 64-bit environment support ISA 2.06 or later.
13537 The following built-in functions are available for the PowerPC family
13538 of processors when hardware decimal floating point
13539 (@option{-mhard-dfp}) is available:
13540 @smallexample
13541 _Decimal64 __builtin_dxex (_Decimal64);
13542 _Decimal128 __builtin_dxexq (_Decimal128);
13543 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13544 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13545 _Decimal64 __builtin_denbcd (int, _Decimal64);
13546 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13547 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13548 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13549 _Decimal64 __builtin_dscli (_Decimal64, int);
13550 _Decimal128 __builitn_dscliq (_Decimal128, int);
13551 _Decimal64 __builtin_dscri (_Decimal64, int);
13552 _Decimal128 __builitn_dscriq (_Decimal128, int);
13553 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13554 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13555 @end smallexample
13557 The following built-in functions are available for the PowerPC family
13558 of processors when the Vector Scalar (vsx) instruction set is
13559 available:
13560 @smallexample
13561 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13562 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13563                                                 unsigned long long);
13564 @end smallexample
13566 @node PowerPC AltiVec/VSX Built-in Functions
13567 @subsection PowerPC AltiVec Built-in Functions
13569 GCC provides an interface for the PowerPC family of processors to access
13570 the AltiVec operations described in Motorola's AltiVec Programming
13571 Interface Manual.  The interface is made available by including
13572 @code{<altivec.h>} and using @option{-maltivec} and
13573 @option{-mabi=altivec}.  The interface supports the following vector
13574 types.
13576 @smallexample
13577 vector unsigned char
13578 vector signed char
13579 vector bool char
13581 vector unsigned short
13582 vector signed short
13583 vector bool short
13584 vector pixel
13586 vector unsigned int
13587 vector signed int
13588 vector bool int
13589 vector float
13590 @end smallexample
13592 If @option{-mvsx} is used the following additional vector types are
13593 implemented.
13595 @smallexample
13596 vector unsigned long
13597 vector signed long
13598 vector double
13599 @end smallexample
13601 The long types are only implemented for 64-bit code generation, and
13602 the long type is only used in the floating point/integer conversion
13603 instructions.
13605 GCC's implementation of the high-level language interface available from
13606 C and C++ code differs from Motorola's documentation in several ways.
13608 @itemize @bullet
13610 @item
13611 A vector constant is a list of constant expressions within curly braces.
13613 @item
13614 A vector initializer requires no cast if the vector constant is of the
13615 same type as the variable it is initializing.
13617 @item
13618 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13619 vector type is the default signedness of the base type.  The default
13620 varies depending on the operating system, so a portable program should
13621 always specify the signedness.
13623 @item
13624 Compiling with @option{-maltivec} adds keywords @code{__vector},
13625 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13626 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13627 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13628 disabled.  To use them, you must include @code{<altivec.h>} instead.
13630 @item
13631 GCC allows using a @code{typedef} name as the type specifier for a
13632 vector type.
13634 @item
13635 For C, overloaded functions are implemented with macros so the following
13636 does not work:
13638 @smallexample
13639   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13640 @end smallexample
13642 @noindent
13643 Since @code{vec_add} is a macro, the vector constant in the example
13644 is treated as four separate arguments.  Wrap the entire argument in
13645 parentheses for this to work.
13646 @end itemize
13648 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13649 Internally, GCC uses built-in functions to achieve the functionality in
13650 the aforementioned header file, but they are not supported and are
13651 subject to change without notice.
13653 The following interfaces are supported for the generic and specific
13654 AltiVec operations and the AltiVec predicates.  In cases where there
13655 is a direct mapping between generic and specific operations, only the
13656 generic names are shown here, although the specific operations can also
13657 be used.
13659 Arguments that are documented as @code{const int} require literal
13660 integral values within the range required for that operation.
13662 @smallexample
13663 vector signed char vec_abs (vector signed char);
13664 vector signed short vec_abs (vector signed short);
13665 vector signed int vec_abs (vector signed int);
13666 vector float vec_abs (vector float);
13668 vector signed char vec_abss (vector signed char);
13669 vector signed short vec_abss (vector signed short);
13670 vector signed int vec_abss (vector signed int);
13672 vector signed char vec_add (vector bool char, vector signed char);
13673 vector signed char vec_add (vector signed char, vector bool char);
13674 vector signed char vec_add (vector signed char, vector signed char);
13675 vector unsigned char vec_add (vector bool char, vector unsigned char);
13676 vector unsigned char vec_add (vector unsigned char, vector bool char);
13677 vector unsigned char vec_add (vector unsigned char,
13678                               vector unsigned char);
13679 vector signed short vec_add (vector bool short, vector signed short);
13680 vector signed short vec_add (vector signed short, vector bool short);
13681 vector signed short vec_add (vector signed short, vector signed short);
13682 vector unsigned short vec_add (vector bool short,
13683                                vector unsigned short);
13684 vector unsigned short vec_add (vector unsigned short,
13685                                vector bool short);
13686 vector unsigned short vec_add (vector unsigned short,
13687                                vector unsigned short);
13688 vector signed int vec_add (vector bool int, vector signed int);
13689 vector signed int vec_add (vector signed int, vector bool int);
13690 vector signed int vec_add (vector signed int, vector signed int);
13691 vector unsigned int vec_add (vector bool int, vector unsigned int);
13692 vector unsigned int vec_add (vector unsigned int, vector bool int);
13693 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13694 vector float vec_add (vector float, vector float);
13696 vector float vec_vaddfp (vector float, vector float);
13698 vector signed int vec_vadduwm (vector bool int, vector signed int);
13699 vector signed int vec_vadduwm (vector signed int, vector bool int);
13700 vector signed int vec_vadduwm (vector signed int, vector signed int);
13701 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13702 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13703 vector unsigned int vec_vadduwm (vector unsigned int,
13704                                  vector unsigned int);
13706 vector signed short vec_vadduhm (vector bool short,
13707                                  vector signed short);
13708 vector signed short vec_vadduhm (vector signed short,
13709                                  vector bool short);
13710 vector signed short vec_vadduhm (vector signed short,
13711                                  vector signed short);
13712 vector unsigned short vec_vadduhm (vector bool short,
13713                                    vector unsigned short);
13714 vector unsigned short vec_vadduhm (vector unsigned short,
13715                                    vector bool short);
13716 vector unsigned short vec_vadduhm (vector unsigned short,
13717                                    vector unsigned short);
13719 vector signed char vec_vaddubm (vector bool char, vector signed char);
13720 vector signed char vec_vaddubm (vector signed char, vector bool char);
13721 vector signed char vec_vaddubm (vector signed char, vector signed char);
13722 vector unsigned char vec_vaddubm (vector bool char,
13723                                   vector unsigned char);
13724 vector unsigned char vec_vaddubm (vector unsigned char,
13725                                   vector bool char);
13726 vector unsigned char vec_vaddubm (vector unsigned char,
13727                                   vector unsigned char);
13729 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13731 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13732 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13733 vector unsigned char vec_adds (vector unsigned char,
13734                                vector unsigned char);
13735 vector signed char vec_adds (vector bool char, vector signed char);
13736 vector signed char vec_adds (vector signed char, vector bool char);
13737 vector signed char vec_adds (vector signed char, vector signed char);
13738 vector unsigned short vec_adds (vector bool short,
13739                                 vector unsigned short);
13740 vector unsigned short vec_adds (vector unsigned short,
13741                                 vector bool short);
13742 vector unsigned short vec_adds (vector unsigned short,
13743                                 vector unsigned short);
13744 vector signed short vec_adds (vector bool short, vector signed short);
13745 vector signed short vec_adds (vector signed short, vector bool short);
13746 vector signed short vec_adds (vector signed short, vector signed short);
13747 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13748 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13749 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13750 vector signed int vec_adds (vector bool int, vector signed int);
13751 vector signed int vec_adds (vector signed int, vector bool int);
13752 vector signed int vec_adds (vector signed int, vector signed int);
13754 vector signed int vec_vaddsws (vector bool int, vector signed int);
13755 vector signed int vec_vaddsws (vector signed int, vector bool int);
13756 vector signed int vec_vaddsws (vector signed int, vector signed int);
13758 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13759 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13760 vector unsigned int vec_vadduws (vector unsigned int,
13761                                  vector unsigned int);
13763 vector signed short vec_vaddshs (vector bool short,
13764                                  vector signed short);
13765 vector signed short vec_vaddshs (vector signed short,
13766                                  vector bool short);
13767 vector signed short vec_vaddshs (vector signed short,
13768                                  vector signed short);
13770 vector unsigned short vec_vadduhs (vector bool short,
13771                                    vector unsigned short);
13772 vector unsigned short vec_vadduhs (vector unsigned short,
13773                                    vector bool short);
13774 vector unsigned short vec_vadduhs (vector unsigned short,
13775                                    vector unsigned short);
13777 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13778 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13779 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13781 vector unsigned char vec_vaddubs (vector bool char,
13782                                   vector unsigned char);
13783 vector unsigned char vec_vaddubs (vector unsigned char,
13784                                   vector bool char);
13785 vector unsigned char vec_vaddubs (vector unsigned char,
13786                                   vector unsigned char);
13788 vector float vec_and (vector float, vector float);
13789 vector float vec_and (vector float, vector bool int);
13790 vector float vec_and (vector bool int, vector float);
13791 vector bool int vec_and (vector bool int, vector bool int);
13792 vector signed int vec_and (vector bool int, vector signed int);
13793 vector signed int vec_and (vector signed int, vector bool int);
13794 vector signed int vec_and (vector signed int, vector signed int);
13795 vector unsigned int vec_and (vector bool int, vector unsigned int);
13796 vector unsigned int vec_and (vector unsigned int, vector bool int);
13797 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13798 vector bool short vec_and (vector bool short, vector bool short);
13799 vector signed short vec_and (vector bool short, vector signed short);
13800 vector signed short vec_and (vector signed short, vector bool short);
13801 vector signed short vec_and (vector signed short, vector signed short);
13802 vector unsigned short vec_and (vector bool short,
13803                                vector unsigned short);
13804 vector unsigned short vec_and (vector unsigned short,
13805                                vector bool short);
13806 vector unsigned short vec_and (vector unsigned short,
13807                                vector unsigned short);
13808 vector signed char vec_and (vector bool char, vector signed char);
13809 vector bool char vec_and (vector bool char, vector bool char);
13810 vector signed char vec_and (vector signed char, vector bool char);
13811 vector signed char vec_and (vector signed char, vector signed char);
13812 vector unsigned char vec_and (vector bool char, vector unsigned char);
13813 vector unsigned char vec_and (vector unsigned char, vector bool char);
13814 vector unsigned char vec_and (vector unsigned char,
13815                               vector unsigned char);
13817 vector float vec_andc (vector float, vector float);
13818 vector float vec_andc (vector float, vector bool int);
13819 vector float vec_andc (vector bool int, vector float);
13820 vector bool int vec_andc (vector bool int, vector bool int);
13821 vector signed int vec_andc (vector bool int, vector signed int);
13822 vector signed int vec_andc (vector signed int, vector bool int);
13823 vector signed int vec_andc (vector signed int, vector signed int);
13824 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13825 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13826 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13827 vector bool short vec_andc (vector bool short, vector bool short);
13828 vector signed short vec_andc (vector bool short, vector signed short);
13829 vector signed short vec_andc (vector signed short, vector bool short);
13830 vector signed short vec_andc (vector signed short, vector signed short);
13831 vector unsigned short vec_andc (vector bool short,
13832                                 vector unsigned short);
13833 vector unsigned short vec_andc (vector unsigned short,
13834                                 vector bool short);
13835 vector unsigned short vec_andc (vector unsigned short,
13836                                 vector unsigned short);
13837 vector signed char vec_andc (vector bool char, vector signed char);
13838 vector bool char vec_andc (vector bool char, vector bool char);
13839 vector signed char vec_andc (vector signed char, vector bool char);
13840 vector signed char vec_andc (vector signed char, vector signed char);
13841 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13842 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13843 vector unsigned char vec_andc (vector unsigned char,
13844                                vector unsigned char);
13846 vector unsigned char vec_avg (vector unsigned char,
13847                               vector unsigned char);
13848 vector signed char vec_avg (vector signed char, vector signed char);
13849 vector unsigned short vec_avg (vector unsigned short,
13850                                vector unsigned short);
13851 vector signed short vec_avg (vector signed short, vector signed short);
13852 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13853 vector signed int vec_avg (vector signed int, vector signed int);
13855 vector signed int vec_vavgsw (vector signed int, vector signed int);
13857 vector unsigned int vec_vavguw (vector unsigned int,
13858                                 vector unsigned int);
13860 vector signed short vec_vavgsh (vector signed short,
13861                                 vector signed short);
13863 vector unsigned short vec_vavguh (vector unsigned short,
13864                                   vector unsigned short);
13866 vector signed char vec_vavgsb (vector signed char, vector signed char);
13868 vector unsigned char vec_vavgub (vector unsigned char,
13869                                  vector unsigned char);
13871 vector float vec_copysign (vector float);
13873 vector float vec_ceil (vector float);
13875 vector signed int vec_cmpb (vector float, vector float);
13877 vector bool char vec_cmpeq (vector signed char, vector signed char);
13878 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13879 vector bool short vec_cmpeq (vector signed short, vector signed short);
13880 vector bool short vec_cmpeq (vector unsigned short,
13881                              vector unsigned short);
13882 vector bool int vec_cmpeq (vector signed int, vector signed int);
13883 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13884 vector bool int vec_cmpeq (vector float, vector float);
13886 vector bool int vec_vcmpeqfp (vector float, vector float);
13888 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13889 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13891 vector bool short vec_vcmpequh (vector signed short,
13892                                 vector signed short);
13893 vector bool short vec_vcmpequh (vector unsigned short,
13894                                 vector unsigned short);
13896 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13897 vector bool char vec_vcmpequb (vector unsigned char,
13898                                vector unsigned char);
13900 vector bool int vec_cmpge (vector float, vector float);
13902 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13903 vector bool char vec_cmpgt (vector signed char, vector signed char);
13904 vector bool short vec_cmpgt (vector unsigned short,
13905                              vector unsigned short);
13906 vector bool short vec_cmpgt (vector signed short, vector signed short);
13907 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13908 vector bool int vec_cmpgt (vector signed int, vector signed int);
13909 vector bool int vec_cmpgt (vector float, vector float);
13911 vector bool int vec_vcmpgtfp (vector float, vector float);
13913 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13915 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13917 vector bool short vec_vcmpgtsh (vector signed short,
13918                                 vector signed short);
13920 vector bool short vec_vcmpgtuh (vector unsigned short,
13921                                 vector unsigned short);
13923 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13925 vector bool char vec_vcmpgtub (vector unsigned char,
13926                                vector unsigned char);
13928 vector bool int vec_cmple (vector float, vector float);
13930 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13931 vector bool char vec_cmplt (vector signed char, vector signed char);
13932 vector bool short vec_cmplt (vector unsigned short,
13933                              vector unsigned short);
13934 vector bool short vec_cmplt (vector signed short, vector signed short);
13935 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13936 vector bool int vec_cmplt (vector signed int, vector signed int);
13937 vector bool int vec_cmplt (vector float, vector float);
13939 vector float vec_cpsgn (vector float, vector float);
13941 vector float vec_ctf (vector unsigned int, const int);
13942 vector float vec_ctf (vector signed int, const int);
13943 vector double vec_ctf (vector unsigned long, const int);
13944 vector double vec_ctf (vector signed long, const int);
13946 vector float vec_vcfsx (vector signed int, const int);
13948 vector float vec_vcfux (vector unsigned int, const int);
13950 vector signed int vec_cts (vector float, const int);
13951 vector signed long vec_cts (vector double, const int);
13953 vector unsigned int vec_ctu (vector float, const int);
13954 vector unsigned long vec_ctu (vector double, const int);
13956 void vec_dss (const int);
13958 void vec_dssall (void);
13960 void vec_dst (const vector unsigned char *, int, const int);
13961 void vec_dst (const vector signed char *, int, const int);
13962 void vec_dst (const vector bool char *, int, const int);
13963 void vec_dst (const vector unsigned short *, int, const int);
13964 void vec_dst (const vector signed short *, int, const int);
13965 void vec_dst (const vector bool short *, int, const int);
13966 void vec_dst (const vector pixel *, int, const int);
13967 void vec_dst (const vector unsigned int *, int, const int);
13968 void vec_dst (const vector signed int *, int, const int);
13969 void vec_dst (const vector bool int *, int, const int);
13970 void vec_dst (const vector float *, int, const int);
13971 void vec_dst (const unsigned char *, int, const int);
13972 void vec_dst (const signed char *, int, const int);
13973 void vec_dst (const unsigned short *, int, const int);
13974 void vec_dst (const short *, int, const int);
13975 void vec_dst (const unsigned int *, int, const int);
13976 void vec_dst (const int *, int, const int);
13977 void vec_dst (const unsigned long *, int, const int);
13978 void vec_dst (const long *, int, const int);
13979 void vec_dst (const float *, int, const int);
13981 void vec_dstst (const vector unsigned char *, int, const int);
13982 void vec_dstst (const vector signed char *, int, const int);
13983 void vec_dstst (const vector bool char *, int, const int);
13984 void vec_dstst (const vector unsigned short *, int, const int);
13985 void vec_dstst (const vector signed short *, int, const int);
13986 void vec_dstst (const vector bool short *, int, const int);
13987 void vec_dstst (const vector pixel *, int, const int);
13988 void vec_dstst (const vector unsigned int *, int, const int);
13989 void vec_dstst (const vector signed int *, int, const int);
13990 void vec_dstst (const vector bool int *, int, const int);
13991 void vec_dstst (const vector float *, int, const int);
13992 void vec_dstst (const unsigned char *, int, const int);
13993 void vec_dstst (const signed char *, int, const int);
13994 void vec_dstst (const unsigned short *, int, const int);
13995 void vec_dstst (const short *, int, const int);
13996 void vec_dstst (const unsigned int *, int, const int);
13997 void vec_dstst (const int *, int, const int);
13998 void vec_dstst (const unsigned long *, int, const int);
13999 void vec_dstst (const long *, int, const int);
14000 void vec_dstst (const float *, int, const int);
14002 void vec_dststt (const vector unsigned char *, int, const int);
14003 void vec_dststt (const vector signed char *, int, const int);
14004 void vec_dststt (const vector bool char *, int, const int);
14005 void vec_dststt (const vector unsigned short *, int, const int);
14006 void vec_dststt (const vector signed short *, int, const int);
14007 void vec_dststt (const vector bool short *, int, const int);
14008 void vec_dststt (const vector pixel *, int, const int);
14009 void vec_dststt (const vector unsigned int *, int, const int);
14010 void vec_dststt (const vector signed int *, int, const int);
14011 void vec_dststt (const vector bool int *, int, const int);
14012 void vec_dststt (const vector float *, int, const int);
14013 void vec_dststt (const unsigned char *, int, const int);
14014 void vec_dststt (const signed char *, int, const int);
14015 void vec_dststt (const unsigned short *, int, const int);
14016 void vec_dststt (const short *, int, const int);
14017 void vec_dststt (const unsigned int *, int, const int);
14018 void vec_dststt (const int *, int, const int);
14019 void vec_dststt (const unsigned long *, int, const int);
14020 void vec_dststt (const long *, int, const int);
14021 void vec_dststt (const float *, int, const int);
14023 void vec_dstt (const vector unsigned char *, int, const int);
14024 void vec_dstt (const vector signed char *, int, const int);
14025 void vec_dstt (const vector bool char *, int, const int);
14026 void vec_dstt (const vector unsigned short *, int, const int);
14027 void vec_dstt (const vector signed short *, int, const int);
14028 void vec_dstt (const vector bool short *, int, const int);
14029 void vec_dstt (const vector pixel *, int, const int);
14030 void vec_dstt (const vector unsigned int *, int, const int);
14031 void vec_dstt (const vector signed int *, int, const int);
14032 void vec_dstt (const vector bool int *, int, const int);
14033 void vec_dstt (const vector float *, int, const int);
14034 void vec_dstt (const unsigned char *, int, const int);
14035 void vec_dstt (const signed char *, int, const int);
14036 void vec_dstt (const unsigned short *, int, const int);
14037 void vec_dstt (const short *, int, const int);
14038 void vec_dstt (const unsigned int *, int, const int);
14039 void vec_dstt (const int *, int, const int);
14040 void vec_dstt (const unsigned long *, int, const int);
14041 void vec_dstt (const long *, int, const int);
14042 void vec_dstt (const float *, int, const int);
14044 vector float vec_expte (vector float);
14046 vector float vec_floor (vector float);
14048 vector float vec_ld (int, const vector float *);
14049 vector float vec_ld (int, const float *);
14050 vector bool int vec_ld (int, const vector bool int *);
14051 vector signed int vec_ld (int, const vector signed int *);
14052 vector signed int vec_ld (int, const int *);
14053 vector signed int vec_ld (int, const long *);
14054 vector unsigned int vec_ld (int, const vector unsigned int *);
14055 vector unsigned int vec_ld (int, const unsigned int *);
14056 vector unsigned int vec_ld (int, const unsigned long *);
14057 vector bool short vec_ld (int, const vector bool short *);
14058 vector pixel vec_ld (int, const vector pixel *);
14059 vector signed short vec_ld (int, const vector signed short *);
14060 vector signed short vec_ld (int, const short *);
14061 vector unsigned short vec_ld (int, const vector unsigned short *);
14062 vector unsigned short vec_ld (int, const unsigned short *);
14063 vector bool char vec_ld (int, const vector bool char *);
14064 vector signed char vec_ld (int, const vector signed char *);
14065 vector signed char vec_ld (int, const signed char *);
14066 vector unsigned char vec_ld (int, const vector unsigned char *);
14067 vector unsigned char vec_ld (int, const unsigned char *);
14069 vector signed char vec_lde (int, const signed char *);
14070 vector unsigned char vec_lde (int, const unsigned char *);
14071 vector signed short vec_lde (int, const short *);
14072 vector unsigned short vec_lde (int, const unsigned short *);
14073 vector float vec_lde (int, const float *);
14074 vector signed int vec_lde (int, const int *);
14075 vector unsigned int vec_lde (int, const unsigned int *);
14076 vector signed int vec_lde (int, const long *);
14077 vector unsigned int vec_lde (int, const unsigned long *);
14079 vector float vec_lvewx (int, float *);
14080 vector signed int vec_lvewx (int, int *);
14081 vector unsigned int vec_lvewx (int, unsigned int *);
14082 vector signed int vec_lvewx (int, long *);
14083 vector unsigned int vec_lvewx (int, unsigned long *);
14085 vector signed short vec_lvehx (int, short *);
14086 vector unsigned short vec_lvehx (int, unsigned short *);
14088 vector signed char vec_lvebx (int, char *);
14089 vector unsigned char vec_lvebx (int, unsigned char *);
14091 vector float vec_ldl (int, const vector float *);
14092 vector float vec_ldl (int, const float *);
14093 vector bool int vec_ldl (int, const vector bool int *);
14094 vector signed int vec_ldl (int, const vector signed int *);
14095 vector signed int vec_ldl (int, const int *);
14096 vector signed int vec_ldl (int, const long *);
14097 vector unsigned int vec_ldl (int, const vector unsigned int *);
14098 vector unsigned int vec_ldl (int, const unsigned int *);
14099 vector unsigned int vec_ldl (int, const unsigned long *);
14100 vector bool short vec_ldl (int, const vector bool short *);
14101 vector pixel vec_ldl (int, const vector pixel *);
14102 vector signed short vec_ldl (int, const vector signed short *);
14103 vector signed short vec_ldl (int, const short *);
14104 vector unsigned short vec_ldl (int, const vector unsigned short *);
14105 vector unsigned short vec_ldl (int, const unsigned short *);
14106 vector bool char vec_ldl (int, const vector bool char *);
14107 vector signed char vec_ldl (int, const vector signed char *);
14108 vector signed char vec_ldl (int, const signed char *);
14109 vector unsigned char vec_ldl (int, const vector unsigned char *);
14110 vector unsigned char vec_ldl (int, const unsigned char *);
14112 vector float vec_loge (vector float);
14114 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14115 vector unsigned char vec_lvsl (int, const volatile signed char *);
14116 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14117 vector unsigned char vec_lvsl (int, const volatile short *);
14118 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14119 vector unsigned char vec_lvsl (int, const volatile int *);
14120 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14121 vector unsigned char vec_lvsl (int, const volatile long *);
14122 vector unsigned char vec_lvsl (int, const volatile float *);
14124 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14125 vector unsigned char vec_lvsr (int, const volatile signed char *);
14126 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14127 vector unsigned char vec_lvsr (int, const volatile short *);
14128 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14129 vector unsigned char vec_lvsr (int, const volatile int *);
14130 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14131 vector unsigned char vec_lvsr (int, const volatile long *);
14132 vector unsigned char vec_lvsr (int, const volatile float *);
14134 vector float vec_madd (vector float, vector float, vector float);
14136 vector signed short vec_madds (vector signed short,
14137                                vector signed short,
14138                                vector signed short);
14140 vector unsigned char vec_max (vector bool char, vector unsigned char);
14141 vector unsigned char vec_max (vector unsigned char, vector bool char);
14142 vector unsigned char vec_max (vector unsigned char,
14143                               vector unsigned char);
14144 vector signed char vec_max (vector bool char, vector signed char);
14145 vector signed char vec_max (vector signed char, vector bool char);
14146 vector signed char vec_max (vector signed char, vector signed char);
14147 vector unsigned short vec_max (vector bool short,
14148                                vector unsigned short);
14149 vector unsigned short vec_max (vector unsigned short,
14150                                vector bool short);
14151 vector unsigned short vec_max (vector unsigned short,
14152                                vector unsigned short);
14153 vector signed short vec_max (vector bool short, vector signed short);
14154 vector signed short vec_max (vector signed short, vector bool short);
14155 vector signed short vec_max (vector signed short, vector signed short);
14156 vector unsigned int vec_max (vector bool int, vector unsigned int);
14157 vector unsigned int vec_max (vector unsigned int, vector bool int);
14158 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14159 vector signed int vec_max (vector bool int, vector signed int);
14160 vector signed int vec_max (vector signed int, vector bool int);
14161 vector signed int vec_max (vector signed int, vector signed int);
14162 vector float vec_max (vector float, vector float);
14164 vector float vec_vmaxfp (vector float, vector float);
14166 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14167 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14168 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14170 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14171 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14172 vector unsigned int vec_vmaxuw (vector unsigned int,
14173                                 vector unsigned int);
14175 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14176 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14177 vector signed short vec_vmaxsh (vector signed short,
14178                                 vector signed short);
14180 vector unsigned short vec_vmaxuh (vector bool short,
14181                                   vector unsigned short);
14182 vector unsigned short vec_vmaxuh (vector unsigned short,
14183                                   vector bool short);
14184 vector unsigned short vec_vmaxuh (vector unsigned short,
14185                                   vector unsigned short);
14187 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14188 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14189 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14191 vector unsigned char vec_vmaxub (vector bool char,
14192                                  vector unsigned char);
14193 vector unsigned char vec_vmaxub (vector unsigned char,
14194                                  vector bool char);
14195 vector unsigned char vec_vmaxub (vector unsigned char,
14196                                  vector unsigned char);
14198 vector bool char vec_mergeh (vector bool char, vector bool char);
14199 vector signed char vec_mergeh (vector signed char, vector signed char);
14200 vector unsigned char vec_mergeh (vector unsigned char,
14201                                  vector unsigned char);
14202 vector bool short vec_mergeh (vector bool short, vector bool short);
14203 vector pixel vec_mergeh (vector pixel, vector pixel);
14204 vector signed short vec_mergeh (vector signed short,
14205                                 vector signed short);
14206 vector unsigned short vec_mergeh (vector unsigned short,
14207                                   vector unsigned short);
14208 vector float vec_mergeh (vector float, vector float);
14209 vector bool int vec_mergeh (vector bool int, vector bool int);
14210 vector signed int vec_mergeh (vector signed int, vector signed int);
14211 vector unsigned int vec_mergeh (vector unsigned int,
14212                                 vector unsigned int);
14214 vector float vec_vmrghw (vector float, vector float);
14215 vector bool int vec_vmrghw (vector bool int, vector bool int);
14216 vector signed int vec_vmrghw (vector signed int, vector signed int);
14217 vector unsigned int vec_vmrghw (vector unsigned int,
14218                                 vector unsigned int);
14220 vector bool short vec_vmrghh (vector bool short, vector bool short);
14221 vector signed short vec_vmrghh (vector signed short,
14222                                 vector signed short);
14223 vector unsigned short vec_vmrghh (vector unsigned short,
14224                                   vector unsigned short);
14225 vector pixel vec_vmrghh (vector pixel, vector pixel);
14227 vector bool char vec_vmrghb (vector bool char, vector bool char);
14228 vector signed char vec_vmrghb (vector signed char, vector signed char);
14229 vector unsigned char vec_vmrghb (vector unsigned char,
14230                                  vector unsigned char);
14232 vector bool char vec_mergel (vector bool char, vector bool char);
14233 vector signed char vec_mergel (vector signed char, vector signed char);
14234 vector unsigned char vec_mergel (vector unsigned char,
14235                                  vector unsigned char);
14236 vector bool short vec_mergel (vector bool short, vector bool short);
14237 vector pixel vec_mergel (vector pixel, vector pixel);
14238 vector signed short vec_mergel (vector signed short,
14239                                 vector signed short);
14240 vector unsigned short vec_mergel (vector unsigned short,
14241                                   vector unsigned short);
14242 vector float vec_mergel (vector float, vector float);
14243 vector bool int vec_mergel (vector bool int, vector bool int);
14244 vector signed int vec_mergel (vector signed int, vector signed int);
14245 vector unsigned int vec_mergel (vector unsigned int,
14246                                 vector unsigned int);
14248 vector float vec_vmrglw (vector float, vector float);
14249 vector signed int vec_vmrglw (vector signed int, vector signed int);
14250 vector unsigned int vec_vmrglw (vector unsigned int,
14251                                 vector unsigned int);
14252 vector bool int vec_vmrglw (vector bool int, vector bool int);
14254 vector bool short vec_vmrglh (vector bool short, vector bool short);
14255 vector signed short vec_vmrglh (vector signed short,
14256                                 vector signed short);
14257 vector unsigned short vec_vmrglh (vector unsigned short,
14258                                   vector unsigned short);
14259 vector pixel vec_vmrglh (vector pixel, vector pixel);
14261 vector bool char vec_vmrglb (vector bool char, vector bool char);
14262 vector signed char vec_vmrglb (vector signed char, vector signed char);
14263 vector unsigned char vec_vmrglb (vector unsigned char,
14264                                  vector unsigned char);
14266 vector unsigned short vec_mfvscr (void);
14268 vector unsigned char vec_min (vector bool char, vector unsigned char);
14269 vector unsigned char vec_min (vector unsigned char, vector bool char);
14270 vector unsigned char vec_min (vector unsigned char,
14271                               vector unsigned char);
14272 vector signed char vec_min (vector bool char, vector signed char);
14273 vector signed char vec_min (vector signed char, vector bool char);
14274 vector signed char vec_min (vector signed char, vector signed char);
14275 vector unsigned short vec_min (vector bool short,
14276                                vector unsigned short);
14277 vector unsigned short vec_min (vector unsigned short,
14278                                vector bool short);
14279 vector unsigned short vec_min (vector unsigned short,
14280                                vector unsigned short);
14281 vector signed short vec_min (vector bool short, vector signed short);
14282 vector signed short vec_min (vector signed short, vector bool short);
14283 vector signed short vec_min (vector signed short, vector signed short);
14284 vector unsigned int vec_min (vector bool int, vector unsigned int);
14285 vector unsigned int vec_min (vector unsigned int, vector bool int);
14286 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14287 vector signed int vec_min (vector bool int, vector signed int);
14288 vector signed int vec_min (vector signed int, vector bool int);
14289 vector signed int vec_min (vector signed int, vector signed int);
14290 vector float vec_min (vector float, vector float);
14292 vector float vec_vminfp (vector float, vector float);
14294 vector signed int vec_vminsw (vector bool int, vector signed int);
14295 vector signed int vec_vminsw (vector signed int, vector bool int);
14296 vector signed int vec_vminsw (vector signed int, vector signed int);
14298 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14299 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14300 vector unsigned int vec_vminuw (vector unsigned int,
14301                                 vector unsigned int);
14303 vector signed short vec_vminsh (vector bool short, vector signed short);
14304 vector signed short vec_vminsh (vector signed short, vector bool short);
14305 vector signed short vec_vminsh (vector signed short,
14306                                 vector signed short);
14308 vector unsigned short vec_vminuh (vector bool short,
14309                                   vector unsigned short);
14310 vector unsigned short vec_vminuh (vector unsigned short,
14311                                   vector bool short);
14312 vector unsigned short vec_vminuh (vector unsigned short,
14313                                   vector unsigned short);
14315 vector signed char vec_vminsb (vector bool char, vector signed char);
14316 vector signed char vec_vminsb (vector signed char, vector bool char);
14317 vector signed char vec_vminsb (vector signed char, vector signed char);
14319 vector unsigned char vec_vminub (vector bool char,
14320                                  vector unsigned char);
14321 vector unsigned char vec_vminub (vector unsigned char,
14322                                  vector bool char);
14323 vector unsigned char vec_vminub (vector unsigned char,
14324                                  vector unsigned char);
14326 vector signed short vec_mladd (vector signed short,
14327                                vector signed short,
14328                                vector signed short);
14329 vector signed short vec_mladd (vector signed short,
14330                                vector unsigned short,
14331                                vector unsigned short);
14332 vector signed short vec_mladd (vector unsigned short,
14333                                vector signed short,
14334                                vector signed short);
14335 vector unsigned short vec_mladd (vector unsigned short,
14336                                  vector unsigned short,
14337                                  vector unsigned short);
14339 vector signed short vec_mradds (vector signed short,
14340                                 vector signed short,
14341                                 vector signed short);
14343 vector unsigned int vec_msum (vector unsigned char,
14344                               vector unsigned char,
14345                               vector unsigned int);
14346 vector signed int vec_msum (vector signed char,
14347                             vector unsigned char,
14348                             vector signed int);
14349 vector unsigned int vec_msum (vector unsigned short,
14350                               vector unsigned short,
14351                               vector unsigned int);
14352 vector signed int vec_msum (vector signed short,
14353                             vector signed short,
14354                             vector signed int);
14356 vector signed int vec_vmsumshm (vector signed short,
14357                                 vector signed short,
14358                                 vector signed int);
14360 vector unsigned int vec_vmsumuhm (vector unsigned short,
14361                                   vector unsigned short,
14362                                   vector unsigned int);
14364 vector signed int vec_vmsummbm (vector signed char,
14365                                 vector unsigned char,
14366                                 vector signed int);
14368 vector unsigned int vec_vmsumubm (vector unsigned char,
14369                                   vector unsigned char,
14370                                   vector unsigned int);
14372 vector unsigned int vec_msums (vector unsigned short,
14373                                vector unsigned short,
14374                                vector unsigned int);
14375 vector signed int vec_msums (vector signed short,
14376                              vector signed short,
14377                              vector signed int);
14379 vector signed int vec_vmsumshs (vector signed short,
14380                                 vector signed short,
14381                                 vector signed int);
14383 vector unsigned int vec_vmsumuhs (vector unsigned short,
14384                                   vector unsigned short,
14385                                   vector unsigned int);
14387 void vec_mtvscr (vector signed int);
14388 void vec_mtvscr (vector unsigned int);
14389 void vec_mtvscr (vector bool int);
14390 void vec_mtvscr (vector signed short);
14391 void vec_mtvscr (vector unsigned short);
14392 void vec_mtvscr (vector bool short);
14393 void vec_mtvscr (vector pixel);
14394 void vec_mtvscr (vector signed char);
14395 void vec_mtvscr (vector unsigned char);
14396 void vec_mtvscr (vector bool char);
14398 vector unsigned short vec_mule (vector unsigned char,
14399                                 vector unsigned char);
14400 vector signed short vec_mule (vector signed char,
14401                               vector signed char);
14402 vector unsigned int vec_mule (vector unsigned short,
14403                               vector unsigned short);
14404 vector signed int vec_mule (vector signed short, vector signed short);
14406 vector signed int vec_vmulesh (vector signed short,
14407                                vector signed short);
14409 vector unsigned int vec_vmuleuh (vector unsigned short,
14410                                  vector unsigned short);
14412 vector signed short vec_vmulesb (vector signed char,
14413                                  vector signed char);
14415 vector unsigned short vec_vmuleub (vector unsigned char,
14416                                   vector unsigned char);
14418 vector unsigned short vec_mulo (vector unsigned char,
14419                                 vector unsigned char);
14420 vector signed short vec_mulo (vector signed char, vector signed char);
14421 vector unsigned int vec_mulo (vector unsigned short,
14422                               vector unsigned short);
14423 vector signed int vec_mulo (vector signed short, vector signed short);
14425 vector signed int vec_vmulosh (vector signed short,
14426                                vector signed short);
14428 vector unsigned int vec_vmulouh (vector unsigned short,
14429                                  vector unsigned short);
14431 vector signed short vec_vmulosb (vector signed char,
14432                                  vector signed char);
14434 vector unsigned short vec_vmuloub (vector unsigned char,
14435                                    vector unsigned char);
14437 vector float vec_nmsub (vector float, vector float, vector float);
14439 vector float vec_nor (vector float, vector float);
14440 vector signed int vec_nor (vector signed int, vector signed int);
14441 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14442 vector bool int vec_nor (vector bool int, vector bool int);
14443 vector signed short vec_nor (vector signed short, vector signed short);
14444 vector unsigned short vec_nor (vector unsigned short,
14445                                vector unsigned short);
14446 vector bool short vec_nor (vector bool short, vector bool short);
14447 vector signed char vec_nor (vector signed char, vector signed char);
14448 vector unsigned char vec_nor (vector unsigned char,
14449                               vector unsigned char);
14450 vector bool char vec_nor (vector bool char, vector bool char);
14452 vector float vec_or (vector float, vector float);
14453 vector float vec_or (vector float, vector bool int);
14454 vector float vec_or (vector bool int, vector float);
14455 vector bool int vec_or (vector bool int, vector bool int);
14456 vector signed int vec_or (vector bool int, vector signed int);
14457 vector signed int vec_or (vector signed int, vector bool int);
14458 vector signed int vec_or (vector signed int, vector signed int);
14459 vector unsigned int vec_or (vector bool int, vector unsigned int);
14460 vector unsigned int vec_or (vector unsigned int, vector bool int);
14461 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14462 vector bool short vec_or (vector bool short, vector bool short);
14463 vector signed short vec_or (vector bool short, vector signed short);
14464 vector signed short vec_or (vector signed short, vector bool short);
14465 vector signed short vec_or (vector signed short, vector signed short);
14466 vector unsigned short vec_or (vector bool short, vector unsigned short);
14467 vector unsigned short vec_or (vector unsigned short, vector bool short);
14468 vector unsigned short vec_or (vector unsigned short,
14469                               vector unsigned short);
14470 vector signed char vec_or (vector bool char, vector signed char);
14471 vector bool char vec_or (vector bool char, vector bool char);
14472 vector signed char vec_or (vector signed char, vector bool char);
14473 vector signed char vec_or (vector signed char, vector signed char);
14474 vector unsigned char vec_or (vector bool char, vector unsigned char);
14475 vector unsigned char vec_or (vector unsigned char, vector bool char);
14476 vector unsigned char vec_or (vector unsigned char,
14477                              vector unsigned char);
14479 vector signed char vec_pack (vector signed short, vector signed short);
14480 vector unsigned char vec_pack (vector unsigned short,
14481                                vector unsigned short);
14482 vector bool char vec_pack (vector bool short, vector bool short);
14483 vector signed short vec_pack (vector signed int, vector signed int);
14484 vector unsigned short vec_pack (vector unsigned int,
14485                                 vector unsigned int);
14486 vector bool short vec_pack (vector bool int, vector bool int);
14488 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14489 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14490 vector unsigned short vec_vpkuwum (vector unsigned int,
14491                                    vector unsigned int);
14493 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14494 vector signed char vec_vpkuhum (vector signed short,
14495                                 vector signed short);
14496 vector unsigned char vec_vpkuhum (vector unsigned short,
14497                                   vector unsigned short);
14499 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14501 vector unsigned char vec_packs (vector unsigned short,
14502                                 vector unsigned short);
14503 vector signed char vec_packs (vector signed short, vector signed short);
14504 vector unsigned short vec_packs (vector unsigned int,
14505                                  vector unsigned int);
14506 vector signed short vec_packs (vector signed int, vector signed int);
14508 vector signed short vec_vpkswss (vector signed int, vector signed int);
14510 vector unsigned short vec_vpkuwus (vector unsigned int,
14511                                    vector unsigned int);
14513 vector signed char vec_vpkshss (vector signed short,
14514                                 vector signed short);
14516 vector unsigned char vec_vpkuhus (vector unsigned short,
14517                                   vector unsigned short);
14519 vector unsigned char vec_packsu (vector unsigned short,
14520                                  vector unsigned short);
14521 vector unsigned char vec_packsu (vector signed short,
14522                                  vector signed short);
14523 vector unsigned short vec_packsu (vector unsigned int,
14524                                   vector unsigned int);
14525 vector unsigned short vec_packsu (vector signed int, vector signed int);
14527 vector unsigned short vec_vpkswus (vector signed int,
14528                                    vector signed int);
14530 vector unsigned char vec_vpkshus (vector signed short,
14531                                   vector signed short);
14533 vector float vec_perm (vector float,
14534                        vector float,
14535                        vector unsigned char);
14536 vector signed int vec_perm (vector signed int,
14537                             vector signed int,
14538                             vector unsigned char);
14539 vector unsigned int vec_perm (vector unsigned int,
14540                               vector unsigned int,
14541                               vector unsigned char);
14542 vector bool int vec_perm (vector bool int,
14543                           vector bool int,
14544                           vector unsigned char);
14545 vector signed short vec_perm (vector signed short,
14546                               vector signed short,
14547                               vector unsigned char);
14548 vector unsigned short vec_perm (vector unsigned short,
14549                                 vector unsigned short,
14550                                 vector unsigned char);
14551 vector bool short vec_perm (vector bool short,
14552                             vector bool short,
14553                             vector unsigned char);
14554 vector pixel vec_perm (vector pixel,
14555                        vector pixel,
14556                        vector unsigned char);
14557 vector signed char vec_perm (vector signed char,
14558                              vector signed char,
14559                              vector unsigned char);
14560 vector unsigned char vec_perm (vector unsigned char,
14561                                vector unsigned char,
14562                                vector unsigned char);
14563 vector bool char vec_perm (vector bool char,
14564                            vector bool char,
14565                            vector unsigned char);
14567 vector float vec_re (vector float);
14569 vector signed char vec_rl (vector signed char,
14570                            vector unsigned char);
14571 vector unsigned char vec_rl (vector unsigned char,
14572                              vector unsigned char);
14573 vector signed short vec_rl (vector signed short, vector unsigned short);
14574 vector unsigned short vec_rl (vector unsigned short,
14575                               vector unsigned short);
14576 vector signed int vec_rl (vector signed int, vector unsigned int);
14577 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14579 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14580 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14582 vector signed short vec_vrlh (vector signed short,
14583                               vector unsigned short);
14584 vector unsigned short vec_vrlh (vector unsigned short,
14585                                 vector unsigned short);
14587 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14588 vector unsigned char vec_vrlb (vector unsigned char,
14589                                vector unsigned char);
14591 vector float vec_round (vector float);
14593 vector float vec_recip (vector float, vector float);
14595 vector float vec_rsqrt (vector float);
14597 vector float vec_rsqrte (vector float);
14599 vector float vec_sel (vector float, vector float, vector bool int);
14600 vector float vec_sel (vector float, vector float, vector unsigned int);
14601 vector signed int vec_sel (vector signed int,
14602                            vector signed int,
14603                            vector bool int);
14604 vector signed int vec_sel (vector signed int,
14605                            vector signed int,
14606                            vector unsigned int);
14607 vector unsigned int vec_sel (vector unsigned int,
14608                              vector unsigned int,
14609                              vector bool int);
14610 vector unsigned int vec_sel (vector unsigned int,
14611                              vector unsigned int,
14612                              vector unsigned int);
14613 vector bool int vec_sel (vector bool int,
14614                          vector bool int,
14615                          vector bool int);
14616 vector bool int vec_sel (vector bool int,
14617                          vector bool int,
14618                          vector unsigned int);
14619 vector signed short vec_sel (vector signed short,
14620                              vector signed short,
14621                              vector bool short);
14622 vector signed short vec_sel (vector signed short,
14623                              vector signed short,
14624                              vector unsigned short);
14625 vector unsigned short vec_sel (vector unsigned short,
14626                                vector unsigned short,
14627                                vector bool short);
14628 vector unsigned short vec_sel (vector unsigned short,
14629                                vector unsigned short,
14630                                vector unsigned short);
14631 vector bool short vec_sel (vector bool short,
14632                            vector bool short,
14633                            vector bool short);
14634 vector bool short vec_sel (vector bool short,
14635                            vector bool short,
14636                            vector unsigned short);
14637 vector signed char vec_sel (vector signed char,
14638                             vector signed char,
14639                             vector bool char);
14640 vector signed char vec_sel (vector signed char,
14641                             vector signed char,
14642                             vector unsigned char);
14643 vector unsigned char vec_sel (vector unsigned char,
14644                               vector unsigned char,
14645                               vector bool char);
14646 vector unsigned char vec_sel (vector unsigned char,
14647                               vector unsigned char,
14648                               vector unsigned char);
14649 vector bool char vec_sel (vector bool char,
14650                           vector bool char,
14651                           vector bool char);
14652 vector bool char vec_sel (vector bool char,
14653                           vector bool char,
14654                           vector unsigned char);
14656 vector signed char vec_sl (vector signed char,
14657                            vector unsigned char);
14658 vector unsigned char vec_sl (vector unsigned char,
14659                              vector unsigned char);
14660 vector signed short vec_sl (vector signed short, vector unsigned short);
14661 vector unsigned short vec_sl (vector unsigned short,
14662                               vector unsigned short);
14663 vector signed int vec_sl (vector signed int, vector unsigned int);
14664 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14666 vector signed int vec_vslw (vector signed int, vector unsigned int);
14667 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14669 vector signed short vec_vslh (vector signed short,
14670                               vector unsigned short);
14671 vector unsigned short vec_vslh (vector unsigned short,
14672                                 vector unsigned short);
14674 vector signed char vec_vslb (vector signed char, vector unsigned char);
14675 vector unsigned char vec_vslb (vector unsigned char,
14676                                vector unsigned char);
14678 vector float vec_sld (vector float, vector float, const int);
14679 vector signed int vec_sld (vector signed int,
14680                            vector signed int,
14681                            const int);
14682 vector unsigned int vec_sld (vector unsigned int,
14683                              vector unsigned int,
14684                              const int);
14685 vector bool int vec_sld (vector bool int,
14686                          vector bool int,
14687                          const int);
14688 vector signed short vec_sld (vector signed short,
14689                              vector signed short,
14690                              const int);
14691 vector unsigned short vec_sld (vector unsigned short,
14692                                vector unsigned short,
14693                                const int);
14694 vector bool short vec_sld (vector bool short,
14695                            vector bool short,
14696                            const int);
14697 vector pixel vec_sld (vector pixel,
14698                       vector pixel,
14699                       const int);
14700 vector signed char vec_sld (vector signed char,
14701                             vector signed char,
14702                             const int);
14703 vector unsigned char vec_sld (vector unsigned char,
14704                               vector unsigned char,
14705                               const int);
14706 vector bool char vec_sld (vector bool char,
14707                           vector bool char,
14708                           const int);
14710 vector signed int vec_sll (vector signed int,
14711                            vector unsigned int);
14712 vector signed int vec_sll (vector signed int,
14713                            vector unsigned short);
14714 vector signed int vec_sll (vector signed int,
14715                            vector unsigned char);
14716 vector unsigned int vec_sll (vector unsigned int,
14717                              vector unsigned int);
14718 vector unsigned int vec_sll (vector unsigned int,
14719                              vector unsigned short);
14720 vector unsigned int vec_sll (vector unsigned int,
14721                              vector unsigned char);
14722 vector bool int vec_sll (vector bool int,
14723                          vector unsigned int);
14724 vector bool int vec_sll (vector bool int,
14725                          vector unsigned short);
14726 vector bool int vec_sll (vector bool int,
14727                          vector unsigned char);
14728 vector signed short vec_sll (vector signed short,
14729                              vector unsigned int);
14730 vector signed short vec_sll (vector signed short,
14731                              vector unsigned short);
14732 vector signed short vec_sll (vector signed short,
14733                              vector unsigned char);
14734 vector unsigned short vec_sll (vector unsigned short,
14735                                vector unsigned int);
14736 vector unsigned short vec_sll (vector unsigned short,
14737                                vector unsigned short);
14738 vector unsigned short vec_sll (vector unsigned short,
14739                                vector unsigned char);
14740 vector bool short vec_sll (vector bool short, vector unsigned int);
14741 vector bool short vec_sll (vector bool short, vector unsigned short);
14742 vector bool short vec_sll (vector bool short, vector unsigned char);
14743 vector pixel vec_sll (vector pixel, vector unsigned int);
14744 vector pixel vec_sll (vector pixel, vector unsigned short);
14745 vector pixel vec_sll (vector pixel, vector unsigned char);
14746 vector signed char vec_sll (vector signed char, vector unsigned int);
14747 vector signed char vec_sll (vector signed char, vector unsigned short);
14748 vector signed char vec_sll (vector signed char, vector unsigned char);
14749 vector unsigned char vec_sll (vector unsigned char,
14750                               vector unsigned int);
14751 vector unsigned char vec_sll (vector unsigned char,
14752                               vector unsigned short);
14753 vector unsigned char vec_sll (vector unsigned char,
14754                               vector unsigned char);
14755 vector bool char vec_sll (vector bool char, vector unsigned int);
14756 vector bool char vec_sll (vector bool char, vector unsigned short);
14757 vector bool char vec_sll (vector bool char, vector unsigned char);
14759 vector float vec_slo (vector float, vector signed char);
14760 vector float vec_slo (vector float, vector unsigned char);
14761 vector signed int vec_slo (vector signed int, vector signed char);
14762 vector signed int vec_slo (vector signed int, vector unsigned char);
14763 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14764 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14765 vector signed short vec_slo (vector signed short, vector signed char);
14766 vector signed short vec_slo (vector signed short, vector unsigned char);
14767 vector unsigned short vec_slo (vector unsigned short,
14768                                vector signed char);
14769 vector unsigned short vec_slo (vector unsigned short,
14770                                vector unsigned char);
14771 vector pixel vec_slo (vector pixel, vector signed char);
14772 vector pixel vec_slo (vector pixel, vector unsigned char);
14773 vector signed char vec_slo (vector signed char, vector signed char);
14774 vector signed char vec_slo (vector signed char, vector unsigned char);
14775 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14776 vector unsigned char vec_slo (vector unsigned char,
14777                               vector unsigned char);
14779 vector signed char vec_splat (vector signed char, const int);
14780 vector unsigned char vec_splat (vector unsigned char, const int);
14781 vector bool char vec_splat (vector bool char, const int);
14782 vector signed short vec_splat (vector signed short, const int);
14783 vector unsigned short vec_splat (vector unsigned short, const int);
14784 vector bool short vec_splat (vector bool short, const int);
14785 vector pixel vec_splat (vector pixel, const int);
14786 vector float vec_splat (vector float, const int);
14787 vector signed int vec_splat (vector signed int, const int);
14788 vector unsigned int vec_splat (vector unsigned int, const int);
14789 vector bool int vec_splat (vector bool int, const int);
14790 vector signed long vec_splat (vector signed long, const int);
14791 vector unsigned long vec_splat (vector unsigned long, const int);
14793 vector signed char vec_splats (signed char);
14794 vector unsigned char vec_splats (unsigned char);
14795 vector signed short vec_splats (signed short);
14796 vector unsigned short vec_splats (unsigned short);
14797 vector signed int vec_splats (signed int);
14798 vector unsigned int vec_splats (unsigned int);
14799 vector float vec_splats (float);
14801 vector float vec_vspltw (vector float, const int);
14802 vector signed int vec_vspltw (vector signed int, const int);
14803 vector unsigned int vec_vspltw (vector unsigned int, const int);
14804 vector bool int vec_vspltw (vector bool int, const int);
14806 vector bool short vec_vsplth (vector bool short, const int);
14807 vector signed short vec_vsplth (vector signed short, const int);
14808 vector unsigned short vec_vsplth (vector unsigned short, const int);
14809 vector pixel vec_vsplth (vector pixel, const int);
14811 vector signed char vec_vspltb (vector signed char, const int);
14812 vector unsigned char vec_vspltb (vector unsigned char, const int);
14813 vector bool char vec_vspltb (vector bool char, const int);
14815 vector signed char vec_splat_s8 (const int);
14817 vector signed short vec_splat_s16 (const int);
14819 vector signed int vec_splat_s32 (const int);
14821 vector unsigned char vec_splat_u8 (const int);
14823 vector unsigned short vec_splat_u16 (const int);
14825 vector unsigned int vec_splat_u32 (const int);
14827 vector signed char vec_sr (vector signed char, vector unsigned char);
14828 vector unsigned char vec_sr (vector unsigned char,
14829                              vector unsigned char);
14830 vector signed short vec_sr (vector signed short,
14831                             vector unsigned short);
14832 vector unsigned short vec_sr (vector unsigned short,
14833                               vector unsigned short);
14834 vector signed int vec_sr (vector signed int, vector unsigned int);
14835 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14837 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14838 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14840 vector signed short vec_vsrh (vector signed short,
14841                               vector unsigned short);
14842 vector unsigned short vec_vsrh (vector unsigned short,
14843                                 vector unsigned short);
14845 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14846 vector unsigned char vec_vsrb (vector unsigned char,
14847                                vector unsigned char);
14849 vector signed char vec_sra (vector signed char, vector unsigned char);
14850 vector unsigned char vec_sra (vector unsigned char,
14851                               vector unsigned char);
14852 vector signed short vec_sra (vector signed short,
14853                              vector unsigned short);
14854 vector unsigned short vec_sra (vector unsigned short,
14855                                vector unsigned short);
14856 vector signed int vec_sra (vector signed int, vector unsigned int);
14857 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14859 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14860 vector unsigned int vec_vsraw (vector unsigned int,
14861                                vector unsigned int);
14863 vector signed short vec_vsrah (vector signed short,
14864                                vector unsigned short);
14865 vector unsigned short vec_vsrah (vector unsigned short,
14866                                  vector unsigned short);
14868 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14869 vector unsigned char vec_vsrab (vector unsigned char,
14870                                 vector unsigned char);
14872 vector signed int vec_srl (vector signed int, vector unsigned int);
14873 vector signed int vec_srl (vector signed int, vector unsigned short);
14874 vector signed int vec_srl (vector signed int, vector unsigned char);
14875 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14876 vector unsigned int vec_srl (vector unsigned int,
14877                              vector unsigned short);
14878 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14879 vector bool int vec_srl (vector bool int, vector unsigned int);
14880 vector bool int vec_srl (vector bool int, vector unsigned short);
14881 vector bool int vec_srl (vector bool int, vector unsigned char);
14882 vector signed short vec_srl (vector signed short, vector unsigned int);
14883 vector signed short vec_srl (vector signed short,
14884                              vector unsigned short);
14885 vector signed short vec_srl (vector signed short, vector unsigned char);
14886 vector unsigned short vec_srl (vector unsigned short,
14887                                vector unsigned int);
14888 vector unsigned short vec_srl (vector unsigned short,
14889                                vector unsigned short);
14890 vector unsigned short vec_srl (vector unsigned short,
14891                                vector unsigned char);
14892 vector bool short vec_srl (vector bool short, vector unsigned int);
14893 vector bool short vec_srl (vector bool short, vector unsigned short);
14894 vector bool short vec_srl (vector bool short, vector unsigned char);
14895 vector pixel vec_srl (vector pixel, vector unsigned int);
14896 vector pixel vec_srl (vector pixel, vector unsigned short);
14897 vector pixel vec_srl (vector pixel, vector unsigned char);
14898 vector signed char vec_srl (vector signed char, vector unsigned int);
14899 vector signed char vec_srl (vector signed char, vector unsigned short);
14900 vector signed char vec_srl (vector signed char, vector unsigned char);
14901 vector unsigned char vec_srl (vector unsigned char,
14902                               vector unsigned int);
14903 vector unsigned char vec_srl (vector unsigned char,
14904                               vector unsigned short);
14905 vector unsigned char vec_srl (vector unsigned char,
14906                               vector unsigned char);
14907 vector bool char vec_srl (vector bool char, vector unsigned int);
14908 vector bool char vec_srl (vector bool char, vector unsigned short);
14909 vector bool char vec_srl (vector bool char, vector unsigned char);
14911 vector float vec_sro (vector float, vector signed char);
14912 vector float vec_sro (vector float, vector unsigned char);
14913 vector signed int vec_sro (vector signed int, vector signed char);
14914 vector signed int vec_sro (vector signed int, vector unsigned char);
14915 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14916 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14917 vector signed short vec_sro (vector signed short, vector signed char);
14918 vector signed short vec_sro (vector signed short, vector unsigned char);
14919 vector unsigned short vec_sro (vector unsigned short,
14920                                vector signed char);
14921 vector unsigned short vec_sro (vector unsigned short,
14922                                vector unsigned char);
14923 vector pixel vec_sro (vector pixel, vector signed char);
14924 vector pixel vec_sro (vector pixel, vector unsigned char);
14925 vector signed char vec_sro (vector signed char, vector signed char);
14926 vector signed char vec_sro (vector signed char, vector unsigned char);
14927 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14928 vector unsigned char vec_sro (vector unsigned char,
14929                               vector unsigned char);
14931 void vec_st (vector float, int, vector float *);
14932 void vec_st (vector float, int, float *);
14933 void vec_st (vector signed int, int, vector signed int *);
14934 void vec_st (vector signed int, int, int *);
14935 void vec_st (vector unsigned int, int, vector unsigned int *);
14936 void vec_st (vector unsigned int, int, unsigned int *);
14937 void vec_st (vector bool int, int, vector bool int *);
14938 void vec_st (vector bool int, int, unsigned int *);
14939 void vec_st (vector bool int, int, int *);
14940 void vec_st (vector signed short, int, vector signed short *);
14941 void vec_st (vector signed short, int, short *);
14942 void vec_st (vector unsigned short, int, vector unsigned short *);
14943 void vec_st (vector unsigned short, int, unsigned short *);
14944 void vec_st (vector bool short, int, vector bool short *);
14945 void vec_st (vector bool short, int, unsigned short *);
14946 void vec_st (vector pixel, int, vector pixel *);
14947 void vec_st (vector pixel, int, unsigned short *);
14948 void vec_st (vector pixel, int, short *);
14949 void vec_st (vector bool short, int, short *);
14950 void vec_st (vector signed char, int, vector signed char *);
14951 void vec_st (vector signed char, int, signed char *);
14952 void vec_st (vector unsigned char, int, vector unsigned char *);
14953 void vec_st (vector unsigned char, int, unsigned char *);
14954 void vec_st (vector bool char, int, vector bool char *);
14955 void vec_st (vector bool char, int, unsigned char *);
14956 void vec_st (vector bool char, int, signed char *);
14958 void vec_ste (vector signed char, int, signed char *);
14959 void vec_ste (vector unsigned char, int, unsigned char *);
14960 void vec_ste (vector bool char, int, signed char *);
14961 void vec_ste (vector bool char, int, unsigned char *);
14962 void vec_ste (vector signed short, int, short *);
14963 void vec_ste (vector unsigned short, int, unsigned short *);
14964 void vec_ste (vector bool short, int, short *);
14965 void vec_ste (vector bool short, int, unsigned short *);
14966 void vec_ste (vector pixel, int, short *);
14967 void vec_ste (vector pixel, int, unsigned short *);
14968 void vec_ste (vector float, int, float *);
14969 void vec_ste (vector signed int, int, int *);
14970 void vec_ste (vector unsigned int, int, unsigned int *);
14971 void vec_ste (vector bool int, int, int *);
14972 void vec_ste (vector bool int, int, unsigned int *);
14974 void vec_stvewx (vector float, int, float *);
14975 void vec_stvewx (vector signed int, int, int *);
14976 void vec_stvewx (vector unsigned int, int, unsigned int *);
14977 void vec_stvewx (vector bool int, int, int *);
14978 void vec_stvewx (vector bool int, int, unsigned int *);
14980 void vec_stvehx (vector signed short, int, short *);
14981 void vec_stvehx (vector unsigned short, int, unsigned short *);
14982 void vec_stvehx (vector bool short, int, short *);
14983 void vec_stvehx (vector bool short, int, unsigned short *);
14984 void vec_stvehx (vector pixel, int, short *);
14985 void vec_stvehx (vector pixel, int, unsigned short *);
14987 void vec_stvebx (vector signed char, int, signed char *);
14988 void vec_stvebx (vector unsigned char, int, unsigned char *);
14989 void vec_stvebx (vector bool char, int, signed char *);
14990 void vec_stvebx (vector bool char, int, unsigned char *);
14992 void vec_stl (vector float, int, vector float *);
14993 void vec_stl (vector float, int, float *);
14994 void vec_stl (vector signed int, int, vector signed int *);
14995 void vec_stl (vector signed int, int, int *);
14996 void vec_stl (vector unsigned int, int, vector unsigned int *);
14997 void vec_stl (vector unsigned int, int, unsigned int *);
14998 void vec_stl (vector bool int, int, vector bool int *);
14999 void vec_stl (vector bool int, int, unsigned int *);
15000 void vec_stl (vector bool int, int, int *);
15001 void vec_stl (vector signed short, int, vector signed short *);
15002 void vec_stl (vector signed short, int, short *);
15003 void vec_stl (vector unsigned short, int, vector unsigned short *);
15004 void vec_stl (vector unsigned short, int, unsigned short *);
15005 void vec_stl (vector bool short, int, vector bool short *);
15006 void vec_stl (vector bool short, int, unsigned short *);
15007 void vec_stl (vector bool short, int, short *);
15008 void vec_stl (vector pixel, int, vector pixel *);
15009 void vec_stl (vector pixel, int, unsigned short *);
15010 void vec_stl (vector pixel, int, short *);
15011 void vec_stl (vector signed char, int, vector signed char *);
15012 void vec_stl (vector signed char, int, signed char *);
15013 void vec_stl (vector unsigned char, int, vector unsigned char *);
15014 void vec_stl (vector unsigned char, int, unsigned char *);
15015 void vec_stl (vector bool char, int, vector bool char *);
15016 void vec_stl (vector bool char, int, unsigned char *);
15017 void vec_stl (vector bool char, int, signed char *);
15019 vector signed char vec_sub (vector bool char, vector signed char);
15020 vector signed char vec_sub (vector signed char, vector bool char);
15021 vector signed char vec_sub (vector signed char, vector signed char);
15022 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15023 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15024 vector unsigned char vec_sub (vector unsigned char,
15025                               vector unsigned char);
15026 vector signed short vec_sub (vector bool short, vector signed short);
15027 vector signed short vec_sub (vector signed short, vector bool short);
15028 vector signed short vec_sub (vector signed short, vector signed short);
15029 vector unsigned short vec_sub (vector bool short,
15030                                vector unsigned short);
15031 vector unsigned short vec_sub (vector unsigned short,
15032                                vector bool short);
15033 vector unsigned short vec_sub (vector unsigned short,
15034                                vector unsigned short);
15035 vector signed int vec_sub (vector bool int, vector signed int);
15036 vector signed int vec_sub (vector signed int, vector bool int);
15037 vector signed int vec_sub (vector signed int, vector signed int);
15038 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15039 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15040 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15041 vector float vec_sub (vector float, vector float);
15043 vector float vec_vsubfp (vector float, vector float);
15045 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15046 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15047 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15048 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15049 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15050 vector unsigned int vec_vsubuwm (vector unsigned int,
15051                                  vector unsigned int);
15053 vector signed short vec_vsubuhm (vector bool short,
15054                                  vector signed short);
15055 vector signed short vec_vsubuhm (vector signed short,
15056                                  vector bool short);
15057 vector signed short vec_vsubuhm (vector signed short,
15058                                  vector signed short);
15059 vector unsigned short vec_vsubuhm (vector bool short,
15060                                    vector unsigned short);
15061 vector unsigned short vec_vsubuhm (vector unsigned short,
15062                                    vector bool short);
15063 vector unsigned short vec_vsubuhm (vector unsigned short,
15064                                    vector unsigned short);
15066 vector signed char vec_vsububm (vector bool char, vector signed char);
15067 vector signed char vec_vsububm (vector signed char, vector bool char);
15068 vector signed char vec_vsububm (vector signed char, vector signed char);
15069 vector unsigned char vec_vsububm (vector bool char,
15070                                   vector unsigned char);
15071 vector unsigned char vec_vsububm (vector unsigned char,
15072                                   vector bool char);
15073 vector unsigned char vec_vsububm (vector unsigned char,
15074                                   vector unsigned char);
15076 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15078 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15079 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15080 vector unsigned char vec_subs (vector unsigned char,
15081                                vector unsigned char);
15082 vector signed char vec_subs (vector bool char, vector signed char);
15083 vector signed char vec_subs (vector signed char, vector bool char);
15084 vector signed char vec_subs (vector signed char, vector signed char);
15085 vector unsigned short vec_subs (vector bool short,
15086                                 vector unsigned short);
15087 vector unsigned short vec_subs (vector unsigned short,
15088                                 vector bool short);
15089 vector unsigned short vec_subs (vector unsigned short,
15090                                 vector unsigned short);
15091 vector signed short vec_subs (vector bool short, vector signed short);
15092 vector signed short vec_subs (vector signed short, vector bool short);
15093 vector signed short vec_subs (vector signed short, vector signed short);
15094 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15095 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15096 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15097 vector signed int vec_subs (vector bool int, vector signed int);
15098 vector signed int vec_subs (vector signed int, vector bool int);
15099 vector signed int vec_subs (vector signed int, vector signed int);
15101 vector signed int vec_vsubsws (vector bool int, vector signed int);
15102 vector signed int vec_vsubsws (vector signed int, vector bool int);
15103 vector signed int vec_vsubsws (vector signed int, vector signed int);
15105 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15106 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15107 vector unsigned int vec_vsubuws (vector unsigned int,
15108                                  vector unsigned int);
15110 vector signed short vec_vsubshs (vector bool short,
15111                                  vector signed short);
15112 vector signed short vec_vsubshs (vector signed short,
15113                                  vector bool short);
15114 vector signed short vec_vsubshs (vector signed short,
15115                                  vector signed short);
15117 vector unsigned short vec_vsubuhs (vector bool short,
15118                                    vector unsigned short);
15119 vector unsigned short vec_vsubuhs (vector unsigned short,
15120                                    vector bool short);
15121 vector unsigned short vec_vsubuhs (vector unsigned short,
15122                                    vector unsigned short);
15124 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15125 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15126 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15128 vector unsigned char vec_vsububs (vector bool char,
15129                                   vector unsigned char);
15130 vector unsigned char vec_vsububs (vector unsigned char,
15131                                   vector bool char);
15132 vector unsigned char vec_vsububs (vector unsigned char,
15133                                   vector unsigned char);
15135 vector unsigned int vec_sum4s (vector unsigned char,
15136                                vector unsigned int);
15137 vector signed int vec_sum4s (vector signed char, vector signed int);
15138 vector signed int vec_sum4s (vector signed short, vector signed int);
15140 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15142 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15144 vector unsigned int vec_vsum4ubs (vector unsigned char,
15145                                   vector unsigned int);
15147 vector signed int vec_sum2s (vector signed int, vector signed int);
15149 vector signed int vec_sums (vector signed int, vector signed int);
15151 vector float vec_trunc (vector float);
15153 vector signed short vec_unpackh (vector signed char);
15154 vector bool short vec_unpackh (vector bool char);
15155 vector signed int vec_unpackh (vector signed short);
15156 vector bool int vec_unpackh (vector bool short);
15157 vector unsigned int vec_unpackh (vector pixel);
15159 vector bool int vec_vupkhsh (vector bool short);
15160 vector signed int vec_vupkhsh (vector signed short);
15162 vector unsigned int vec_vupkhpx (vector pixel);
15164 vector bool short vec_vupkhsb (vector bool char);
15165 vector signed short vec_vupkhsb (vector signed char);
15167 vector signed short vec_unpackl (vector signed char);
15168 vector bool short vec_unpackl (vector bool char);
15169 vector unsigned int vec_unpackl (vector pixel);
15170 vector signed int vec_unpackl (vector signed short);
15171 vector bool int vec_unpackl (vector bool short);
15173 vector unsigned int vec_vupklpx (vector pixel);
15175 vector bool int vec_vupklsh (vector bool short);
15176 vector signed int vec_vupklsh (vector signed short);
15178 vector bool short vec_vupklsb (vector bool char);
15179 vector signed short vec_vupklsb (vector signed char);
15181 vector float vec_xor (vector float, vector float);
15182 vector float vec_xor (vector float, vector bool int);
15183 vector float vec_xor (vector bool int, vector float);
15184 vector bool int vec_xor (vector bool int, vector bool int);
15185 vector signed int vec_xor (vector bool int, vector signed int);
15186 vector signed int vec_xor (vector signed int, vector bool int);
15187 vector signed int vec_xor (vector signed int, vector signed int);
15188 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15189 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15190 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15191 vector bool short vec_xor (vector bool short, vector bool short);
15192 vector signed short vec_xor (vector bool short, vector signed short);
15193 vector signed short vec_xor (vector signed short, vector bool short);
15194 vector signed short vec_xor (vector signed short, vector signed short);
15195 vector unsigned short vec_xor (vector bool short,
15196                                vector unsigned short);
15197 vector unsigned short vec_xor (vector unsigned short,
15198                                vector bool short);
15199 vector unsigned short vec_xor (vector unsigned short,
15200                                vector unsigned short);
15201 vector signed char vec_xor (vector bool char, vector signed char);
15202 vector bool char vec_xor (vector bool char, vector bool char);
15203 vector signed char vec_xor (vector signed char, vector bool char);
15204 vector signed char vec_xor (vector signed char, vector signed char);
15205 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15206 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15207 vector unsigned char vec_xor (vector unsigned char,
15208                               vector unsigned char);
15210 int vec_all_eq (vector signed char, vector bool char);
15211 int vec_all_eq (vector signed char, vector signed char);
15212 int vec_all_eq (vector unsigned char, vector bool char);
15213 int vec_all_eq (vector unsigned char, vector unsigned char);
15214 int vec_all_eq (vector bool char, vector bool char);
15215 int vec_all_eq (vector bool char, vector unsigned char);
15216 int vec_all_eq (vector bool char, vector signed char);
15217 int vec_all_eq (vector signed short, vector bool short);
15218 int vec_all_eq (vector signed short, vector signed short);
15219 int vec_all_eq (vector unsigned short, vector bool short);
15220 int vec_all_eq (vector unsigned short, vector unsigned short);
15221 int vec_all_eq (vector bool short, vector bool short);
15222 int vec_all_eq (vector bool short, vector unsigned short);
15223 int vec_all_eq (vector bool short, vector signed short);
15224 int vec_all_eq (vector pixel, vector pixel);
15225 int vec_all_eq (vector signed int, vector bool int);
15226 int vec_all_eq (vector signed int, vector signed int);
15227 int vec_all_eq (vector unsigned int, vector bool int);
15228 int vec_all_eq (vector unsigned int, vector unsigned int);
15229 int vec_all_eq (vector bool int, vector bool int);
15230 int vec_all_eq (vector bool int, vector unsigned int);
15231 int vec_all_eq (vector bool int, vector signed int);
15232 int vec_all_eq (vector float, vector float);
15234 int vec_all_ge (vector bool char, vector unsigned char);
15235 int vec_all_ge (vector unsigned char, vector bool char);
15236 int vec_all_ge (vector unsigned char, vector unsigned char);
15237 int vec_all_ge (vector bool char, vector signed char);
15238 int vec_all_ge (vector signed char, vector bool char);
15239 int vec_all_ge (vector signed char, vector signed char);
15240 int vec_all_ge (vector bool short, vector unsigned short);
15241 int vec_all_ge (vector unsigned short, vector bool short);
15242 int vec_all_ge (vector unsigned short, vector unsigned short);
15243 int vec_all_ge (vector signed short, vector signed short);
15244 int vec_all_ge (vector bool short, vector signed short);
15245 int vec_all_ge (vector signed short, vector bool short);
15246 int vec_all_ge (vector bool int, vector unsigned int);
15247 int vec_all_ge (vector unsigned int, vector bool int);
15248 int vec_all_ge (vector unsigned int, vector unsigned int);
15249 int vec_all_ge (vector bool int, vector signed int);
15250 int vec_all_ge (vector signed int, vector bool int);
15251 int vec_all_ge (vector signed int, vector signed int);
15252 int vec_all_ge (vector float, vector float);
15254 int vec_all_gt (vector bool char, vector unsigned char);
15255 int vec_all_gt (vector unsigned char, vector bool char);
15256 int vec_all_gt (vector unsigned char, vector unsigned char);
15257 int vec_all_gt (vector bool char, vector signed char);
15258 int vec_all_gt (vector signed char, vector bool char);
15259 int vec_all_gt (vector signed char, vector signed char);
15260 int vec_all_gt (vector bool short, vector unsigned short);
15261 int vec_all_gt (vector unsigned short, vector bool short);
15262 int vec_all_gt (vector unsigned short, vector unsigned short);
15263 int vec_all_gt (vector bool short, vector signed short);
15264 int vec_all_gt (vector signed short, vector bool short);
15265 int vec_all_gt (vector signed short, vector signed short);
15266 int vec_all_gt (vector bool int, vector unsigned int);
15267 int vec_all_gt (vector unsigned int, vector bool int);
15268 int vec_all_gt (vector unsigned int, vector unsigned int);
15269 int vec_all_gt (vector bool int, vector signed int);
15270 int vec_all_gt (vector signed int, vector bool int);
15271 int vec_all_gt (vector signed int, vector signed int);
15272 int vec_all_gt (vector float, vector float);
15274 int vec_all_in (vector float, vector float);
15276 int vec_all_le (vector bool char, vector unsigned char);
15277 int vec_all_le (vector unsigned char, vector bool char);
15278 int vec_all_le (vector unsigned char, vector unsigned char);
15279 int vec_all_le (vector bool char, vector signed char);
15280 int vec_all_le (vector signed char, vector bool char);
15281 int vec_all_le (vector signed char, vector signed char);
15282 int vec_all_le (vector bool short, vector unsigned short);
15283 int vec_all_le (vector unsigned short, vector bool short);
15284 int vec_all_le (vector unsigned short, vector unsigned short);
15285 int vec_all_le (vector bool short, vector signed short);
15286 int vec_all_le (vector signed short, vector bool short);
15287 int vec_all_le (vector signed short, vector signed short);
15288 int vec_all_le (vector bool int, vector unsigned int);
15289 int vec_all_le (vector unsigned int, vector bool int);
15290 int vec_all_le (vector unsigned int, vector unsigned int);
15291 int vec_all_le (vector bool int, vector signed int);
15292 int vec_all_le (vector signed int, vector bool int);
15293 int vec_all_le (vector signed int, vector signed int);
15294 int vec_all_le (vector float, vector float);
15296 int vec_all_lt (vector bool char, vector unsigned char);
15297 int vec_all_lt (vector unsigned char, vector bool char);
15298 int vec_all_lt (vector unsigned char, vector unsigned char);
15299 int vec_all_lt (vector bool char, vector signed char);
15300 int vec_all_lt (vector signed char, vector bool char);
15301 int vec_all_lt (vector signed char, vector signed char);
15302 int vec_all_lt (vector bool short, vector unsigned short);
15303 int vec_all_lt (vector unsigned short, vector bool short);
15304 int vec_all_lt (vector unsigned short, vector unsigned short);
15305 int vec_all_lt (vector bool short, vector signed short);
15306 int vec_all_lt (vector signed short, vector bool short);
15307 int vec_all_lt (vector signed short, vector signed short);
15308 int vec_all_lt (vector bool int, vector unsigned int);
15309 int vec_all_lt (vector unsigned int, vector bool int);
15310 int vec_all_lt (vector unsigned int, vector unsigned int);
15311 int vec_all_lt (vector bool int, vector signed int);
15312 int vec_all_lt (vector signed int, vector bool int);
15313 int vec_all_lt (vector signed int, vector signed int);
15314 int vec_all_lt (vector float, vector float);
15316 int vec_all_nan (vector float);
15318 int vec_all_ne (vector signed char, vector bool char);
15319 int vec_all_ne (vector signed char, vector signed char);
15320 int vec_all_ne (vector unsigned char, vector bool char);
15321 int vec_all_ne (vector unsigned char, vector unsigned char);
15322 int vec_all_ne (vector bool char, vector bool char);
15323 int vec_all_ne (vector bool char, vector unsigned char);
15324 int vec_all_ne (vector bool char, vector signed char);
15325 int vec_all_ne (vector signed short, vector bool short);
15326 int vec_all_ne (vector signed short, vector signed short);
15327 int vec_all_ne (vector unsigned short, vector bool short);
15328 int vec_all_ne (vector unsigned short, vector unsigned short);
15329 int vec_all_ne (vector bool short, vector bool short);
15330 int vec_all_ne (vector bool short, vector unsigned short);
15331 int vec_all_ne (vector bool short, vector signed short);
15332 int vec_all_ne (vector pixel, vector pixel);
15333 int vec_all_ne (vector signed int, vector bool int);
15334 int vec_all_ne (vector signed int, vector signed int);
15335 int vec_all_ne (vector unsigned int, vector bool int);
15336 int vec_all_ne (vector unsigned int, vector unsigned int);
15337 int vec_all_ne (vector bool int, vector bool int);
15338 int vec_all_ne (vector bool int, vector unsigned int);
15339 int vec_all_ne (vector bool int, vector signed int);
15340 int vec_all_ne (vector float, vector float);
15342 int vec_all_nge (vector float, vector float);
15344 int vec_all_ngt (vector float, vector float);
15346 int vec_all_nle (vector float, vector float);
15348 int vec_all_nlt (vector float, vector float);
15350 int vec_all_numeric (vector float);
15352 int vec_any_eq (vector signed char, vector bool char);
15353 int vec_any_eq (vector signed char, vector signed char);
15354 int vec_any_eq (vector unsigned char, vector bool char);
15355 int vec_any_eq (vector unsigned char, vector unsigned char);
15356 int vec_any_eq (vector bool char, vector bool char);
15357 int vec_any_eq (vector bool char, vector unsigned char);
15358 int vec_any_eq (vector bool char, vector signed char);
15359 int vec_any_eq (vector signed short, vector bool short);
15360 int vec_any_eq (vector signed short, vector signed short);
15361 int vec_any_eq (vector unsigned short, vector bool short);
15362 int vec_any_eq (vector unsigned short, vector unsigned short);
15363 int vec_any_eq (vector bool short, vector bool short);
15364 int vec_any_eq (vector bool short, vector unsigned short);
15365 int vec_any_eq (vector bool short, vector signed short);
15366 int vec_any_eq (vector pixel, vector pixel);
15367 int vec_any_eq (vector signed int, vector bool int);
15368 int vec_any_eq (vector signed int, vector signed int);
15369 int vec_any_eq (vector unsigned int, vector bool int);
15370 int vec_any_eq (vector unsigned int, vector unsigned int);
15371 int vec_any_eq (vector bool int, vector bool int);
15372 int vec_any_eq (vector bool int, vector unsigned int);
15373 int vec_any_eq (vector bool int, vector signed int);
15374 int vec_any_eq (vector float, vector float);
15376 int vec_any_ge (vector signed char, vector bool char);
15377 int vec_any_ge (vector unsigned char, vector bool char);
15378 int vec_any_ge (vector unsigned char, vector unsigned char);
15379 int vec_any_ge (vector signed char, vector signed char);
15380 int vec_any_ge (vector bool char, vector unsigned char);
15381 int vec_any_ge (vector bool char, vector signed char);
15382 int vec_any_ge (vector unsigned short, vector bool short);
15383 int vec_any_ge (vector unsigned short, vector unsigned short);
15384 int vec_any_ge (vector signed short, vector signed short);
15385 int vec_any_ge (vector signed short, vector bool short);
15386 int vec_any_ge (vector bool short, vector unsigned short);
15387 int vec_any_ge (vector bool short, vector signed short);
15388 int vec_any_ge (vector signed int, vector bool int);
15389 int vec_any_ge (vector unsigned int, vector bool int);
15390 int vec_any_ge (vector unsigned int, vector unsigned int);
15391 int vec_any_ge (vector signed int, vector signed int);
15392 int vec_any_ge (vector bool int, vector unsigned int);
15393 int vec_any_ge (vector bool int, vector signed int);
15394 int vec_any_ge (vector float, vector float);
15396 int vec_any_gt (vector bool char, vector unsigned char);
15397 int vec_any_gt (vector unsigned char, vector bool char);
15398 int vec_any_gt (vector unsigned char, vector unsigned char);
15399 int vec_any_gt (vector bool char, vector signed char);
15400 int vec_any_gt (vector signed char, vector bool char);
15401 int vec_any_gt (vector signed char, vector signed char);
15402 int vec_any_gt (vector bool short, vector unsigned short);
15403 int vec_any_gt (vector unsigned short, vector bool short);
15404 int vec_any_gt (vector unsigned short, vector unsigned short);
15405 int vec_any_gt (vector bool short, vector signed short);
15406 int vec_any_gt (vector signed short, vector bool short);
15407 int vec_any_gt (vector signed short, vector signed short);
15408 int vec_any_gt (vector bool int, vector unsigned int);
15409 int vec_any_gt (vector unsigned int, vector bool int);
15410 int vec_any_gt (vector unsigned int, vector unsigned int);
15411 int vec_any_gt (vector bool int, vector signed int);
15412 int vec_any_gt (vector signed int, vector bool int);
15413 int vec_any_gt (vector signed int, vector signed int);
15414 int vec_any_gt (vector float, vector float);
15416 int vec_any_le (vector bool char, vector unsigned char);
15417 int vec_any_le (vector unsigned char, vector bool char);
15418 int vec_any_le (vector unsigned char, vector unsigned char);
15419 int vec_any_le (vector bool char, vector signed char);
15420 int vec_any_le (vector signed char, vector bool char);
15421 int vec_any_le (vector signed char, vector signed char);
15422 int vec_any_le (vector bool short, vector unsigned short);
15423 int vec_any_le (vector unsigned short, vector bool short);
15424 int vec_any_le (vector unsigned short, vector unsigned short);
15425 int vec_any_le (vector bool short, vector signed short);
15426 int vec_any_le (vector signed short, vector bool short);
15427 int vec_any_le (vector signed short, vector signed short);
15428 int vec_any_le (vector bool int, vector unsigned int);
15429 int vec_any_le (vector unsigned int, vector bool int);
15430 int vec_any_le (vector unsigned int, vector unsigned int);
15431 int vec_any_le (vector bool int, vector signed int);
15432 int vec_any_le (vector signed int, vector bool int);
15433 int vec_any_le (vector signed int, vector signed int);
15434 int vec_any_le (vector float, vector float);
15436 int vec_any_lt (vector bool char, vector unsigned char);
15437 int vec_any_lt (vector unsigned char, vector bool char);
15438 int vec_any_lt (vector unsigned char, vector unsigned char);
15439 int vec_any_lt (vector bool char, vector signed char);
15440 int vec_any_lt (vector signed char, vector bool char);
15441 int vec_any_lt (vector signed char, vector signed char);
15442 int vec_any_lt (vector bool short, vector unsigned short);
15443 int vec_any_lt (vector unsigned short, vector bool short);
15444 int vec_any_lt (vector unsigned short, vector unsigned short);
15445 int vec_any_lt (vector bool short, vector signed short);
15446 int vec_any_lt (vector signed short, vector bool short);
15447 int vec_any_lt (vector signed short, vector signed short);
15448 int vec_any_lt (vector bool int, vector unsigned int);
15449 int vec_any_lt (vector unsigned int, vector bool int);
15450 int vec_any_lt (vector unsigned int, vector unsigned int);
15451 int vec_any_lt (vector bool int, vector signed int);
15452 int vec_any_lt (vector signed int, vector bool int);
15453 int vec_any_lt (vector signed int, vector signed int);
15454 int vec_any_lt (vector float, vector float);
15456 int vec_any_nan (vector float);
15458 int vec_any_ne (vector signed char, vector bool char);
15459 int vec_any_ne (vector signed char, vector signed char);
15460 int vec_any_ne (vector unsigned char, vector bool char);
15461 int vec_any_ne (vector unsigned char, vector unsigned char);
15462 int vec_any_ne (vector bool char, vector bool char);
15463 int vec_any_ne (vector bool char, vector unsigned char);
15464 int vec_any_ne (vector bool char, vector signed char);
15465 int vec_any_ne (vector signed short, vector bool short);
15466 int vec_any_ne (vector signed short, vector signed short);
15467 int vec_any_ne (vector unsigned short, vector bool short);
15468 int vec_any_ne (vector unsigned short, vector unsigned short);
15469 int vec_any_ne (vector bool short, vector bool short);
15470 int vec_any_ne (vector bool short, vector unsigned short);
15471 int vec_any_ne (vector bool short, vector signed short);
15472 int vec_any_ne (vector pixel, vector pixel);
15473 int vec_any_ne (vector signed int, vector bool int);
15474 int vec_any_ne (vector signed int, vector signed int);
15475 int vec_any_ne (vector unsigned int, vector bool int);
15476 int vec_any_ne (vector unsigned int, vector unsigned int);
15477 int vec_any_ne (vector bool int, vector bool int);
15478 int vec_any_ne (vector bool int, vector unsigned int);
15479 int vec_any_ne (vector bool int, vector signed int);
15480 int vec_any_ne (vector float, vector float);
15482 int vec_any_nge (vector float, vector float);
15484 int vec_any_ngt (vector float, vector float);
15486 int vec_any_nle (vector float, vector float);
15488 int vec_any_nlt (vector float, vector float);
15490 int vec_any_numeric (vector float);
15492 int vec_any_out (vector float, vector float);
15493 @end smallexample
15495 If the vector/scalar (VSX) instruction set is available, the following
15496 additional functions are available:
15498 @smallexample
15499 vector double vec_abs (vector double);
15500 vector double vec_add (vector double, vector double);
15501 vector double vec_and (vector double, vector double);
15502 vector double vec_and (vector double, vector bool long);
15503 vector double vec_and (vector bool long, vector double);
15504 vector long vec_and (vector long, vector long);
15505 vector long vec_and (vector long, vector bool long);
15506 vector long vec_and (vector bool long, vector long);
15507 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15508 vector unsigned long vec_and (vector unsigned long, vector bool long);
15509 vector unsigned long vec_and (vector bool long, vector unsigned long);
15510 vector double vec_andc (vector double, vector double);
15511 vector double vec_andc (vector double, vector bool long);
15512 vector double vec_andc (vector bool long, vector double);
15513 vector long vec_andc (vector long, vector long);
15514 vector long vec_andc (vector long, vector bool long);
15515 vector long vec_andc (vector bool long, vector long);
15516 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15517 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15518 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15519 vector double vec_ceil (vector double);
15520 vector bool long vec_cmpeq (vector double, vector double);
15521 vector bool long vec_cmpge (vector double, vector double);
15522 vector bool long vec_cmpgt (vector double, vector double);
15523 vector bool long vec_cmple (vector double, vector double);
15524 vector bool long vec_cmplt (vector double, vector double);
15525 vector double vec_cpsgn (vector double, vector double);
15526 vector float vec_div (vector float, vector float);
15527 vector double vec_div (vector double, vector double);
15528 vector long vec_div (vector long, vector long);
15529 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15530 vector double vec_floor (vector double);
15531 vector double vec_ld (int, const vector double *);
15532 vector double vec_ld (int, const double *);
15533 vector double vec_ldl (int, const vector double *);
15534 vector double vec_ldl (int, const double *);
15535 vector unsigned char vec_lvsl (int, const volatile double *);
15536 vector unsigned char vec_lvsr (int, const volatile double *);
15537 vector double vec_madd (vector double, vector double, vector double);
15538 vector double vec_max (vector double, vector double);
15539 vector signed long vec_mergeh (vector signed long, vector signed long);
15540 vector signed long vec_mergeh (vector signed long, vector bool long);
15541 vector signed long vec_mergeh (vector bool long, vector signed long);
15542 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15543 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15544 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15545 vector signed long vec_mergel (vector signed long, vector signed long);
15546 vector signed long vec_mergel (vector signed long, vector bool long);
15547 vector signed long vec_mergel (vector bool long, vector signed long);
15548 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15549 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15550 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15551 vector double vec_min (vector double, vector double);
15552 vector float vec_msub (vector float, vector float, vector float);
15553 vector double vec_msub (vector double, vector double, vector double);
15554 vector float vec_mul (vector float, vector float);
15555 vector double vec_mul (vector double, vector double);
15556 vector long vec_mul (vector long, vector long);
15557 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15558 vector float vec_nearbyint (vector float);
15559 vector double vec_nearbyint (vector double);
15560 vector float vec_nmadd (vector float, vector float, vector float);
15561 vector double vec_nmadd (vector double, vector double, vector double);
15562 vector double vec_nmsub (vector double, vector double, vector double);
15563 vector double vec_nor (vector double, vector double);
15564 vector long vec_nor (vector long, vector long);
15565 vector long vec_nor (vector long, vector bool long);
15566 vector long vec_nor (vector bool long, vector long);
15567 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15568 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15569 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15570 vector double vec_or (vector double, vector double);
15571 vector double vec_or (vector double, vector bool long);
15572 vector double vec_or (vector bool long, vector double);
15573 vector long vec_or (vector long, vector long);
15574 vector long vec_or (vector long, vector bool long);
15575 vector long vec_or (vector bool long, vector long);
15576 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15577 vector unsigned long vec_or (vector unsigned long, vector bool long);
15578 vector unsigned long vec_or (vector bool long, vector unsigned long);
15579 vector double vec_perm (vector double, vector double, vector unsigned char);
15580 vector long vec_perm (vector long, vector long, vector unsigned char);
15581 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15582                                vector unsigned char);
15583 vector double vec_rint (vector double);
15584 vector double vec_recip (vector double, vector double);
15585 vector double vec_rsqrt (vector double);
15586 vector double vec_rsqrte (vector double);
15587 vector double vec_sel (vector double, vector double, vector bool long);
15588 vector double vec_sel (vector double, vector double, vector unsigned long);
15589 vector long vec_sel (vector long, vector long, vector long);
15590 vector long vec_sel (vector long, vector long, vector unsigned long);
15591 vector long vec_sel (vector long, vector long, vector bool long);
15592 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15593                               vector long);
15594 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15595                               vector unsigned long);
15596 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15597                               vector bool long);
15598 vector double vec_splats (double);
15599 vector signed long vec_splats (signed long);
15600 vector unsigned long vec_splats (unsigned long);
15601 vector float vec_sqrt (vector float);
15602 vector double vec_sqrt (vector double);
15603 void vec_st (vector double, int, vector double *);
15604 void vec_st (vector double, int, double *);
15605 vector double vec_sub (vector double, vector double);
15606 vector double vec_trunc (vector double);
15607 vector double vec_xor (vector double, vector double);
15608 vector double vec_xor (vector double, vector bool long);
15609 vector double vec_xor (vector bool long, vector double);
15610 vector long vec_xor (vector long, vector long);
15611 vector long vec_xor (vector long, vector bool long);
15612 vector long vec_xor (vector bool long, vector long);
15613 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15614 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15615 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15616 int vec_all_eq (vector double, vector double);
15617 int vec_all_ge (vector double, vector double);
15618 int vec_all_gt (vector double, vector double);
15619 int vec_all_le (vector double, vector double);
15620 int vec_all_lt (vector double, vector double);
15621 int vec_all_nan (vector double);
15622 int vec_all_ne (vector double, vector double);
15623 int vec_all_nge (vector double, vector double);
15624 int vec_all_ngt (vector double, vector double);
15625 int vec_all_nle (vector double, vector double);
15626 int vec_all_nlt (vector double, vector double);
15627 int vec_all_numeric (vector double);
15628 int vec_any_eq (vector double, vector double);
15629 int vec_any_ge (vector double, vector double);
15630 int vec_any_gt (vector double, vector double);
15631 int vec_any_le (vector double, vector double);
15632 int vec_any_lt (vector double, vector double);
15633 int vec_any_nan (vector double);
15634 int vec_any_ne (vector double, vector double);
15635 int vec_any_nge (vector double, vector double);
15636 int vec_any_ngt (vector double, vector double);
15637 int vec_any_nle (vector double, vector double);
15638 int vec_any_nlt (vector double, vector double);
15639 int vec_any_numeric (vector double);
15641 vector double vec_vsx_ld (int, const vector double *);
15642 vector double vec_vsx_ld (int, const double *);
15643 vector float vec_vsx_ld (int, const vector float *);
15644 vector float vec_vsx_ld (int, const float *);
15645 vector bool int vec_vsx_ld (int, const vector bool int *);
15646 vector signed int vec_vsx_ld (int, const vector signed int *);
15647 vector signed int vec_vsx_ld (int, const int *);
15648 vector signed int vec_vsx_ld (int, const long *);
15649 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15650 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15651 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15652 vector bool short vec_vsx_ld (int, const vector bool short *);
15653 vector pixel vec_vsx_ld (int, const vector pixel *);
15654 vector signed short vec_vsx_ld (int, const vector signed short *);
15655 vector signed short vec_vsx_ld (int, const short *);
15656 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15657 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15658 vector bool char vec_vsx_ld (int, const vector bool char *);
15659 vector signed char vec_vsx_ld (int, const vector signed char *);
15660 vector signed char vec_vsx_ld (int, const signed char *);
15661 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15662 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15664 void vec_vsx_st (vector double, int, vector double *);
15665 void vec_vsx_st (vector double, int, double *);
15666 void vec_vsx_st (vector float, int, vector float *);
15667 void vec_vsx_st (vector float, int, float *);
15668 void vec_vsx_st (vector signed int, int, vector signed int *);
15669 void vec_vsx_st (vector signed int, int, int *);
15670 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15671 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15672 void vec_vsx_st (vector bool int, int, vector bool int *);
15673 void vec_vsx_st (vector bool int, int, unsigned int *);
15674 void vec_vsx_st (vector bool int, int, int *);
15675 void vec_vsx_st (vector signed short, int, vector signed short *);
15676 void vec_vsx_st (vector signed short, int, short *);
15677 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15678 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15679 void vec_vsx_st (vector bool short, int, vector bool short *);
15680 void vec_vsx_st (vector bool short, int, unsigned short *);
15681 void vec_vsx_st (vector pixel, int, vector pixel *);
15682 void vec_vsx_st (vector pixel, int, unsigned short *);
15683 void vec_vsx_st (vector pixel, int, short *);
15684 void vec_vsx_st (vector bool short, int, short *);
15685 void vec_vsx_st (vector signed char, int, vector signed char *);
15686 void vec_vsx_st (vector signed char, int, signed char *);
15687 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15688 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15689 void vec_vsx_st (vector bool char, int, vector bool char *);
15690 void vec_vsx_st (vector bool char, int, unsigned char *);
15691 void vec_vsx_st (vector bool char, int, signed char *);
15693 vector double vec_xxpermdi (vector double, vector double, int);
15694 vector float vec_xxpermdi (vector float, vector float, int);
15695 vector long long vec_xxpermdi (vector long long, vector long long, int);
15696 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15697                                         vector unsigned long long, int);
15698 vector int vec_xxpermdi (vector int, vector int, int);
15699 vector unsigned int vec_xxpermdi (vector unsigned int,
15700                                   vector unsigned int, int);
15701 vector short vec_xxpermdi (vector short, vector short, int);
15702 vector unsigned short vec_xxpermdi (vector unsigned short,
15703                                     vector unsigned short, int);
15704 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15705 vector unsigned char vec_xxpermdi (vector unsigned char,
15706                                    vector unsigned char, int);
15708 vector double vec_xxsldi (vector double, vector double, int);
15709 vector float vec_xxsldi (vector float, vector float, int);
15710 vector long long vec_xxsldi (vector long long, vector long long, int);
15711 vector unsigned long long vec_xxsldi (vector unsigned long long,
15712                                       vector unsigned long long, int);
15713 vector int vec_xxsldi (vector int, vector int, int);
15714 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15715 vector short vec_xxsldi (vector short, vector short, int);
15716 vector unsigned short vec_xxsldi (vector unsigned short,
15717                                   vector unsigned short, int);
15718 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15719 vector unsigned char vec_xxsldi (vector unsigned char,
15720                                  vector unsigned char, int);
15721 @end smallexample
15723 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15724 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15725 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
15726 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15727 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15729 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15730 instruction set is available, the following additional functions are
15731 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
15732 can use @var{vector long} instead of @var{vector long long},
15733 @var{vector bool long} instead of @var{vector bool long long}, and
15734 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15736 @smallexample
15737 vector long long vec_abs (vector long long);
15739 vector long long vec_add (vector long long, vector long long);
15740 vector unsigned long long vec_add (vector unsigned long long,
15741                                    vector unsigned long long);
15743 int vec_all_eq (vector long long, vector long long);
15744 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15745 int vec_all_ge (vector long long, vector long long);
15746 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15747 int vec_all_gt (vector long long, vector long long);
15748 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15749 int vec_all_le (vector long long, vector long long);
15750 int vec_all_le (vector unsigned long long, vector unsigned long long);
15751 int vec_all_lt (vector long long, vector long long);
15752 int vec_all_lt (vector unsigned long long, vector unsigned long long);
15753 int vec_all_ne (vector long long, vector long long);
15754 int vec_all_ne (vector unsigned long long, vector unsigned long long);
15756 int vec_any_eq (vector long long, vector long long);
15757 int vec_any_eq (vector unsigned long long, vector unsigned long long);
15758 int vec_any_ge (vector long long, vector long long);
15759 int vec_any_ge (vector unsigned long long, vector unsigned long long);
15760 int vec_any_gt (vector long long, vector long long);
15761 int vec_any_gt (vector unsigned long long, vector unsigned long long);
15762 int vec_any_le (vector long long, vector long long);
15763 int vec_any_le (vector unsigned long long, vector unsigned long long);
15764 int vec_any_lt (vector long long, vector long long);
15765 int vec_any_lt (vector unsigned long long, vector unsigned long long);
15766 int vec_any_ne (vector long long, vector long long);
15767 int vec_any_ne (vector unsigned long long, vector unsigned long long);
15769 vector long long vec_eqv (vector long long, vector long long);
15770 vector long long vec_eqv (vector bool long long, vector long long);
15771 vector long long vec_eqv (vector long long, vector bool long long);
15772 vector unsigned long long vec_eqv (vector unsigned long long,
15773                                    vector unsigned long long);
15774 vector unsigned long long vec_eqv (vector bool long long,
15775                                    vector unsigned long long);
15776 vector unsigned long long vec_eqv (vector unsigned long long,
15777                                    vector bool long long);
15778 vector int vec_eqv (vector int, vector int);
15779 vector int vec_eqv (vector bool int, vector int);
15780 vector int vec_eqv (vector int, vector bool int);
15781 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15782 vector unsigned int vec_eqv (vector bool unsigned int,
15783                              vector unsigned int);
15784 vector unsigned int vec_eqv (vector unsigned int,
15785                              vector bool unsigned int);
15786 vector short vec_eqv (vector short, vector short);
15787 vector short vec_eqv (vector bool short, vector short);
15788 vector short vec_eqv (vector short, vector bool short);
15789 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15790 vector unsigned short vec_eqv (vector bool unsigned short,
15791                                vector unsigned short);
15792 vector unsigned short vec_eqv (vector unsigned short,
15793                                vector bool unsigned short);
15794 vector signed char vec_eqv (vector signed char, vector signed char);
15795 vector signed char vec_eqv (vector bool signed char, vector signed char);
15796 vector signed char vec_eqv (vector signed char, vector bool signed char);
15797 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15798 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15799 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15801 vector long long vec_max (vector long long, vector long long);
15802 vector unsigned long long vec_max (vector unsigned long long,
15803                                    vector unsigned long long);
15805 vector signed int vec_mergee (vector signed int, vector signed int);
15806 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
15807 vector bool int vec_mergee (vector bool int, vector bool int);
15809 vector signed int vec_mergeo (vector signed int, vector signed int);
15810 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
15811 vector bool int vec_mergeo (vector bool int, vector bool int);
15813 vector long long vec_min (vector long long, vector long long);
15814 vector unsigned long long vec_min (vector unsigned long long,
15815                                    vector unsigned long long);
15817 vector long long vec_nand (vector long long, vector long long);
15818 vector long long vec_nand (vector bool long long, vector long long);
15819 vector long long vec_nand (vector long long, vector bool long long);
15820 vector unsigned long long vec_nand (vector unsigned long long,
15821                                     vector unsigned long long);
15822 vector unsigned long long vec_nand (vector bool long long,
15823                                    vector unsigned long long);
15824 vector unsigned long long vec_nand (vector unsigned long long,
15825                                     vector bool long long);
15826 vector int vec_nand (vector int, vector int);
15827 vector int vec_nand (vector bool int, vector int);
15828 vector int vec_nand (vector int, vector bool int);
15829 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15830 vector unsigned int vec_nand (vector bool unsigned int,
15831                               vector unsigned int);
15832 vector unsigned int vec_nand (vector unsigned int,
15833                               vector bool unsigned int);
15834 vector short vec_nand (vector short, vector short);
15835 vector short vec_nand (vector bool short, vector short);
15836 vector short vec_nand (vector short, vector bool short);
15837 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15838 vector unsigned short vec_nand (vector bool unsigned short,
15839                                 vector unsigned short);
15840 vector unsigned short vec_nand (vector unsigned short,
15841                                 vector bool unsigned short);
15842 vector signed char vec_nand (vector signed char, vector signed char);
15843 vector signed char vec_nand (vector bool signed char, vector signed char);
15844 vector signed char vec_nand (vector signed char, vector bool signed char);
15845 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15846 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15847 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15849 vector long long vec_orc (vector long long, vector long long);
15850 vector long long vec_orc (vector bool long long, vector long long);
15851 vector long long vec_orc (vector long long, vector bool long long);
15852 vector unsigned long long vec_orc (vector unsigned long long,
15853                                    vector unsigned long long);
15854 vector unsigned long long vec_orc (vector bool long long,
15855                                    vector unsigned long long);
15856 vector unsigned long long vec_orc (vector unsigned long long,
15857                                    vector bool long long);
15858 vector int vec_orc (vector int, vector int);
15859 vector int vec_orc (vector bool int, vector int);
15860 vector int vec_orc (vector int, vector bool int);
15861 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15862 vector unsigned int vec_orc (vector bool unsigned int,
15863                              vector unsigned int);
15864 vector unsigned int vec_orc (vector unsigned int,
15865                              vector bool unsigned int);
15866 vector short vec_orc (vector short, vector short);
15867 vector short vec_orc (vector bool short, vector short);
15868 vector short vec_orc (vector short, vector bool short);
15869 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15870 vector unsigned short vec_orc (vector bool unsigned short,
15871                                vector unsigned short);
15872 vector unsigned short vec_orc (vector unsigned short,
15873                                vector bool unsigned short);
15874 vector signed char vec_orc (vector signed char, vector signed char);
15875 vector signed char vec_orc (vector bool signed char, vector signed char);
15876 vector signed char vec_orc (vector signed char, vector bool signed char);
15877 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15878 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15879 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15881 vector int vec_pack (vector long long, vector long long);
15882 vector unsigned int vec_pack (vector unsigned long long,
15883                               vector unsigned long long);
15884 vector bool int vec_pack (vector bool long long, vector bool long long);
15886 vector int vec_packs (vector long long, vector long long);
15887 vector unsigned int vec_packs (vector unsigned long long,
15888                                vector unsigned long long);
15890 vector unsigned int vec_packsu (vector long long, vector long long);
15891 vector unsigned int vec_packsu (vector unsigned long long,
15892                                 vector unsigned long long);
15894 vector long long vec_rl (vector long long,
15895                          vector unsigned long long);
15896 vector long long vec_rl (vector unsigned long long,
15897                          vector unsigned long long);
15899 vector long long vec_sl (vector long long, vector unsigned long long);
15900 vector long long vec_sl (vector unsigned long long,
15901                          vector unsigned long long);
15903 vector long long vec_sr (vector long long, vector unsigned long long);
15904 vector unsigned long long char vec_sr (vector unsigned long long,
15905                                        vector unsigned long long);
15907 vector long long vec_sra (vector long long, vector unsigned long long);
15908 vector unsigned long long vec_sra (vector unsigned long long,
15909                                    vector unsigned long long);
15911 vector long long vec_sub (vector long long, vector long long);
15912 vector unsigned long long vec_sub (vector unsigned long long,
15913                                    vector unsigned long long);
15915 vector long long vec_unpackh (vector int);
15916 vector unsigned long long vec_unpackh (vector unsigned int);
15918 vector long long vec_unpackl (vector int);
15919 vector unsigned long long vec_unpackl (vector unsigned int);
15921 vector long long vec_vaddudm (vector long long, vector long long);
15922 vector long long vec_vaddudm (vector bool long long, vector long long);
15923 vector long long vec_vaddudm (vector long long, vector bool long long);
15924 vector unsigned long long vec_vaddudm (vector unsigned long long,
15925                                        vector unsigned long long);
15926 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15927                                        vector unsigned long long);
15928 vector unsigned long long vec_vaddudm (vector unsigned long long,
15929                                        vector bool unsigned long long);
15931 vector long long vec_vbpermq (vector signed char, vector signed char);
15932 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15934 vector long long vec_cntlz (vector long long);
15935 vector unsigned long long vec_cntlz (vector unsigned long long);
15936 vector int vec_cntlz (vector int);
15937 vector unsigned int vec_cntlz (vector int);
15938 vector short vec_cntlz (vector short);
15939 vector unsigned short vec_cntlz (vector unsigned short);
15940 vector signed char vec_cntlz (vector signed char);
15941 vector unsigned char vec_cntlz (vector unsigned char);
15943 vector long long vec_vclz (vector long long);
15944 vector unsigned long long vec_vclz (vector unsigned long long);
15945 vector int vec_vclz (vector int);
15946 vector unsigned int vec_vclz (vector int);
15947 vector short vec_vclz (vector short);
15948 vector unsigned short vec_vclz (vector unsigned short);
15949 vector signed char vec_vclz (vector signed char);
15950 vector unsigned char vec_vclz (vector unsigned char);
15952 vector signed char vec_vclzb (vector signed char);
15953 vector unsigned char vec_vclzb (vector unsigned char);
15955 vector long long vec_vclzd (vector long long);
15956 vector unsigned long long vec_vclzd (vector unsigned long long);
15958 vector short vec_vclzh (vector short);
15959 vector unsigned short vec_vclzh (vector unsigned short);
15961 vector int vec_vclzw (vector int);
15962 vector unsigned int vec_vclzw (vector int);
15964 vector signed char vec_vgbbd (vector signed char);
15965 vector unsigned char vec_vgbbd (vector unsigned char);
15967 vector long long vec_vmaxsd (vector long long, vector long long);
15969 vector unsigned long long vec_vmaxud (vector unsigned long long,
15970                                       unsigned vector long long);
15972 vector long long vec_vminsd (vector long long, vector long long);
15974 vector unsigned long long vec_vminud (vector long long,
15975                                       vector long long);
15977 vector int vec_vpksdss (vector long long, vector long long);
15978 vector unsigned int vec_vpksdss (vector long long, vector long long);
15980 vector unsigned int vec_vpkudus (vector unsigned long long,
15981                                  vector unsigned long long);
15983 vector int vec_vpkudum (vector long long, vector long long);
15984 vector unsigned int vec_vpkudum (vector unsigned long long,
15985                                  vector unsigned long long);
15986 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15988 vector long long vec_vpopcnt (vector long long);
15989 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15990 vector int vec_vpopcnt (vector int);
15991 vector unsigned int vec_vpopcnt (vector int);
15992 vector short vec_vpopcnt (vector short);
15993 vector unsigned short vec_vpopcnt (vector unsigned short);
15994 vector signed char vec_vpopcnt (vector signed char);
15995 vector unsigned char vec_vpopcnt (vector unsigned char);
15997 vector signed char vec_vpopcntb (vector signed char);
15998 vector unsigned char vec_vpopcntb (vector unsigned char);
16000 vector long long vec_vpopcntd (vector long long);
16001 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16003 vector short vec_vpopcnth (vector short);
16004 vector unsigned short vec_vpopcnth (vector unsigned short);
16006 vector int vec_vpopcntw (vector int);
16007 vector unsigned int vec_vpopcntw (vector int);
16009 vector long long vec_vrld (vector long long, vector unsigned long long);
16010 vector unsigned long long vec_vrld (vector unsigned long long,
16011                                     vector unsigned long long);
16013 vector long long vec_vsld (vector long long, vector unsigned long long);
16014 vector long long vec_vsld (vector unsigned long long,
16015                            vector unsigned long long);
16017 vector long long vec_vsrad (vector long long, vector unsigned long long);
16018 vector unsigned long long vec_vsrad (vector unsigned long long,
16019                                      vector unsigned long long);
16021 vector long long vec_vsrd (vector long long, vector unsigned long long);
16022 vector unsigned long long char vec_vsrd (vector unsigned long long,
16023                                          vector unsigned long long);
16025 vector long long vec_vsubudm (vector long long, vector long long);
16026 vector long long vec_vsubudm (vector bool long long, vector long long);
16027 vector long long vec_vsubudm (vector long long, vector bool long long);
16028 vector unsigned long long vec_vsubudm (vector unsigned long long,
16029                                        vector unsigned long long);
16030 vector unsigned long long vec_vsubudm (vector bool long long,
16031                                        vector unsigned long long);
16032 vector unsigned long long vec_vsubudm (vector unsigned long long,
16033                                        vector bool long long);
16035 vector long long vec_vupkhsw (vector int);
16036 vector unsigned long long vec_vupkhsw (vector unsigned int);
16038 vector long long vec_vupklsw (vector int);
16039 vector unsigned long long vec_vupklsw (vector int);
16040 @end smallexample
16042 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16043 instruction set is available, the following additional functions are
16044 available for 64-bit targets.  New vector types
16045 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16046 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16047 builtins.
16049 The normal vector extract, and set operations work on
16050 @var{vector __int128_t} and @var{vector __uint128_t} types,
16051 but the index value must be 0.
16053 @smallexample
16054 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16055 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16057 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16058 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16060 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16061                                 vector __int128_t);
16062 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
16063                                  vector __uint128_t);
16065 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16066                                 vector __int128_t);
16067 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
16068                                  vector __uint128_t);
16070 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16071                                 vector __int128_t);
16072 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
16073                                  vector __uint128_t);
16075 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16076                                 vector __int128_t);
16077 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16078                                  vector __uint128_t);
16080 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16081 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16083 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16084 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16086 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16087 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16088 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16089 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16090 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16091 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16092 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16093 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16094 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16095 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16096 @end smallexample
16098 If the cryptographic instructions are enabled (@option{-mcrypto} or
16099 @option{-mcpu=power8}), the following builtins are enabled.
16101 @smallexample
16102 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16104 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16105                                                     vector unsigned long long);
16107 vector unsigned long long __builtin_crypto_vcipherlast
16108                                      (vector unsigned long long,
16109                                       vector unsigned long long);
16111 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16112                                                      vector unsigned long long);
16114 vector unsigned long long __builtin_crypto_vncipherlast
16115                                      (vector unsigned long long,
16116                                       vector unsigned long long);
16118 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16119                                                 vector unsigned char,
16120                                                 vector unsigned char);
16122 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16123                                                  vector unsigned short,
16124                                                  vector unsigned short);
16126 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16127                                                vector unsigned int,
16128                                                vector unsigned int);
16130 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16131                                                      vector unsigned long long,
16132                                                      vector unsigned long long);
16134 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16135                                                vector unsigned char);
16137 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16138                                                 vector unsigned short);
16140 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16141                                               vector unsigned int);
16143 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16144                                                     vector unsigned long long);
16146 vector unsigned long long __builtin_crypto_vshasigmad
16147                                (vector unsigned long long, int, int);
16149 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16150                                                  int, int);
16151 @end smallexample
16153 The second argument to the @var{__builtin_crypto_vshasigmad} and
16154 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16155 integer that is 0 or 1.  The third argument to these builtin functions
16156 must be a constant integer in the range of 0 to 15.
16158 @node PowerPC Hardware Transactional Memory Built-in Functions
16159 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16160 GCC provides two interfaces for accessing the Hardware Transactional
16161 Memory (HTM) instructions available on some of the PowerPC family
16162 of prcoessors (eg, POWER8).  The two interfaces come in a low level
16163 interface, consisting of built-in functions specific to PowerPC and a
16164 higher level interface consisting of inline functions that are common
16165 between PowerPC and S/390.
16167 @subsubsection PowerPC HTM Low Level Built-in Functions
16169 The following low level built-in functions are available with
16170 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16171 They all generate the machine instruction that is part of the name.
16173 The HTM built-ins return true or false depending on their success and
16174 their arguments match exactly the type and order of the associated
16175 hardware instruction's operands.  Refer to the ISA manual for a
16176 description of each instruction's operands.
16178 @smallexample
16179 unsigned int __builtin_tbegin (unsigned int)
16180 unsigned int __builtin_tend (unsigned int)
16182 unsigned int __builtin_tabort (unsigned int)
16183 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16184 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16185 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16186 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16188 unsigned int __builtin_tcheck (unsigned int)
16189 unsigned int __builtin_treclaim (unsigned int)
16190 unsigned int __builtin_trechkpt (void)
16191 unsigned int __builtin_tsr (unsigned int)
16192 @end smallexample
16194 In addition to the above HTM built-ins, we have added built-ins for
16195 some common extended mnemonics of the HTM instructions:
16197 @smallexample
16198 unsigned int __builtin_tendall (void)
16199 unsigned int __builtin_tresume (void)
16200 unsigned int __builtin_tsuspend (void)
16201 @end smallexample
16203 The following set of built-in functions are available to gain access
16204 to the HTM specific special purpose registers.
16206 @smallexample
16207 unsigned long __builtin_get_texasr (void)
16208 unsigned long __builtin_get_texasru (void)
16209 unsigned long __builtin_get_tfhar (void)
16210 unsigned long __builtin_get_tfiar (void)
16212 void __builtin_set_texasr (unsigned long);
16213 void __builtin_set_texasru (unsigned long);
16214 void __builtin_set_tfhar (unsigned long);
16215 void __builtin_set_tfiar (unsigned long);
16216 @end smallexample
16218 Example usage of these low level built-in functions may look like:
16220 @smallexample
16221 #include <htmintrin.h>
16223 int num_retries = 10;
16225 while (1)
16226   @{
16227     if (__builtin_tbegin (0))
16228       @{
16229         /* Transaction State Initiated.  */
16230         if (is_locked (lock))
16231           __builtin_tabort (0);
16232         ... transaction code...
16233         __builtin_tend (0);
16234         break;
16235       @}
16236     else
16237       @{
16238         /* Transaction State Failed.  Use locks if the transaction
16239            failure is "persistent" or we've tried too many times.  */
16240         if (num_retries-- <= 0
16241             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16242           @{
16243             acquire_lock (lock);
16244             ... non transactional fallback path...
16245             release_lock (lock);
16246             break;
16247           @}
16248       @}
16249   @}
16250 @end smallexample
16252 One final built-in function has been added that returns the value of
16253 the 2-bit Transaction State field of the Machine Status Register (MSR)
16254 as stored in @code{CR0}.
16256 @smallexample
16257 unsigned long __builtin_ttest (void)
16258 @end smallexample
16260 This built-in can be used to determine the current transaction state
16261 using the following code example:
16263 @smallexample
16264 #include <htmintrin.h>
16266 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16268 if (tx_state == _HTM_TRANSACTIONAL)
16269   @{
16270     /* Code to use in transactional state.  */
16271   @}
16272 else if (tx_state == _HTM_NONTRANSACTIONAL)
16273   @{
16274     /* Code to use in non-transactional state.  */
16275   @}
16276 else if (tx_state == _HTM_SUSPENDED)
16277   @{
16278     /* Code to use in transaction suspended state.  */
16279   @}
16280 @end smallexample
16282 @subsubsection PowerPC HTM High Level Inline Functions
16284 The following high level HTM interface is made available by including
16285 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16286 where CPU is `power8' or later.  This interface is common between PowerPC
16287 and S/390, allowing users to write one HTM source implementation that
16288 can be compiled and executed on either system.
16290 @smallexample
16291 long __TM_simple_begin (void)
16292 long __TM_begin (void* const TM_buff)
16293 long __TM_end (void)
16294 void __TM_abort (void)
16295 void __TM_named_abort (unsigned char const code)
16296 void __TM_resume (void)
16297 void __TM_suspend (void)
16299 long __TM_is_user_abort (void* const TM_buff)
16300 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16301 long __TM_is_illegal (void* const TM_buff)
16302 long __TM_is_footprint_exceeded (void* const TM_buff)
16303 long __TM_nesting_depth (void* const TM_buff)
16304 long __TM_is_nested_too_deep(void* const TM_buff)
16305 long __TM_is_conflict(void* const TM_buff)
16306 long __TM_is_failure_persistent(void* const TM_buff)
16307 long __TM_failure_address(void* const TM_buff)
16308 long long __TM_failure_code(void* const TM_buff)
16309 @end smallexample
16311 Using these common set of HTM inline functions, we can create
16312 a more portable version of the HTM example in the previous
16313 section that will work on either PowerPC or S/390:
16315 @smallexample
16316 #include <htmxlintrin.h>
16318 int num_retries = 10;
16319 TM_buff_type TM_buff;
16321 while (1)
16322   @{
16323     if (__TM_begin (TM_buff))
16324       @{
16325         /* Transaction State Initiated.  */
16326         if (is_locked (lock))
16327           __TM_abort ();
16328         ... transaction code...
16329         __TM_end ();
16330         break;
16331       @}
16332     else
16333       @{
16334         /* Transaction State Failed.  Use locks if the transaction
16335            failure is "persistent" or we've tried too many times.  */
16336         if (num_retries-- <= 0
16337             || __TM_is_failure_persistent (TM_buff))
16338           @{
16339             acquire_lock (lock);
16340             ... non transactional fallback path...
16341             release_lock (lock);
16342             break;
16343           @}
16344       @}
16345   @}
16346 @end smallexample
16348 @node RX Built-in Functions
16349 @subsection RX Built-in Functions
16350 GCC supports some of the RX instructions which cannot be expressed in
16351 the C programming language via the use of built-in functions.  The
16352 following functions are supported:
16354 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
16355 Generates the @code{brk} machine instruction.
16356 @end deftypefn
16358 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
16359 Generates the @code{clrpsw} machine instruction to clear the specified
16360 bit in the processor status word.
16361 @end deftypefn
16363 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
16364 Generates the @code{int} machine instruction to generate an interrupt
16365 with the specified value.
16366 @end deftypefn
16368 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
16369 Generates the @code{machi} machine instruction to add the result of
16370 multiplying the top 16 bits of the two arguments into the
16371 accumulator.
16372 @end deftypefn
16374 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
16375 Generates the @code{maclo} machine instruction to add the result of
16376 multiplying the bottom 16 bits of the two arguments into the
16377 accumulator.
16378 @end deftypefn
16380 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
16381 Generates the @code{mulhi} machine instruction to place the result of
16382 multiplying the top 16 bits of the two arguments into the
16383 accumulator.
16384 @end deftypefn
16386 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
16387 Generates the @code{mullo} machine instruction to place the result of
16388 multiplying the bottom 16 bits of the two arguments into the
16389 accumulator.
16390 @end deftypefn
16392 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
16393 Generates the @code{mvfachi} machine instruction to read the top
16394 32 bits of the accumulator.
16395 @end deftypefn
16397 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
16398 Generates the @code{mvfacmi} machine instruction to read the middle
16399 32 bits of the accumulator.
16400 @end deftypefn
16402 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
16403 Generates the @code{mvfc} machine instruction which reads the control
16404 register specified in its argument and returns its value.
16405 @end deftypefn
16407 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
16408 Generates the @code{mvtachi} machine instruction to set the top
16409 32 bits of the accumulator.
16410 @end deftypefn
16412 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
16413 Generates the @code{mvtaclo} machine instruction to set the bottom
16414 32 bits of the accumulator.
16415 @end deftypefn
16417 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
16418 Generates the @code{mvtc} machine instruction which sets control
16419 register number @code{reg} to @code{val}.
16420 @end deftypefn
16422 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
16423 Generates the @code{mvtipl} machine instruction set the interrupt
16424 priority level.
16425 @end deftypefn
16427 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
16428 Generates the @code{racw} machine instruction to round the accumulator
16429 according to the specified mode.
16430 @end deftypefn
16432 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
16433 Generates the @code{revw} machine instruction which swaps the bytes in
16434 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16435 and also bits 16--23 occupy bits 24--31 and vice versa.
16436 @end deftypefn
16438 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
16439 Generates the @code{rmpa} machine instruction which initiates a
16440 repeated multiply and accumulate sequence.
16441 @end deftypefn
16443 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
16444 Generates the @code{round} machine instruction which returns the
16445 floating-point argument rounded according to the current rounding mode
16446 set in the floating-point status word register.
16447 @end deftypefn
16449 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
16450 Generates the @code{sat} machine instruction which returns the
16451 saturated value of the argument.
16452 @end deftypefn
16454 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
16455 Generates the @code{setpsw} machine instruction to set the specified
16456 bit in the processor status word.
16457 @end deftypefn
16459 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
16460 Generates the @code{wait} machine instruction.
16461 @end deftypefn
16463 @node S/390 System z Built-in Functions
16464 @subsection S/390 System z Built-in Functions
16465 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16466 Generates the @code{tbegin} machine instruction starting a
16467 non-constraint hardware transaction.  If the parameter is non-NULL the
16468 memory area is used to store the transaction diagnostic buffer and
16469 will be passed as first operand to @code{tbegin}.  This buffer can be
16470 defined using the @code{struct __htm_tdb} C struct defined in
16471 @code{htmintrin.h} and must reside on a double-word boundary.  The
16472 second tbegin operand is set to @code{0xff0c}. This enables
16473 save/restore of all GPRs and disables aborts for FPR and AR
16474 manipulations inside the transaction body.  The condition code set by
16475 the tbegin instruction is returned as integer value.  The tbegin
16476 instruction by definition overwrites the content of all FPRs.  The
16477 compiler will generate code which saves and restores the FPRs.  For
16478 soft-float code it is recommended to used the @code{*_nofloat}
16479 variant.  In order to prevent a TDB from being written it is required
16480 to pass an constant zero value as parameter.  Passing the zero value
16481 through a variable is not sufficient.  Although modifications of
16482 access registers inside the transaction will not trigger an
16483 transaction abort it is not supported to actually modify them.  Access
16484 registers do not get saved when entering a transaction. They will have
16485 undefined state when reaching the abort code.
16486 @end deftypefn
16488 Macros for the possible return codes of tbegin are defined in the
16489 @code{htmintrin.h} header file:
16491 @table @code
16492 @item _HTM_TBEGIN_STARTED
16493 @code{tbegin} has been executed as part of normal processing.  The
16494 transaction body is supposed to be executed.
16495 @item _HTM_TBEGIN_INDETERMINATE
16496 The transaction was aborted due to an indeterminate condition which
16497 might be persistent.
16498 @item _HTM_TBEGIN_TRANSIENT
16499 The transaction aborted due to a transient failure.  The transaction
16500 should be re-executed in that case.
16501 @item _HTM_TBEGIN_PERSISTENT
16502 The transaction aborted due to a persistent failure.  Re-execution
16503 under same circumstances will not be productive.
16504 @end table
16506 @defmac _HTM_FIRST_USER_ABORT_CODE
16507 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16508 specifies the first abort code which can be used for
16509 @code{__builtin_tabort}.  Values below this threshold are reserved for
16510 machine use.
16511 @end defmac
16513 @deftp {Data type} {struct __htm_tdb}
16514 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16515 the structure of the transaction diagnostic block as specified in the
16516 Principles of Operation manual chapter 5-91.
16517 @end deftp
16519 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16520 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16521 Using this variant in code making use of FPRs will leave the FPRs in
16522 undefined state when entering the transaction abort handler code.
16523 @end deftypefn
16525 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16526 In addition to @code{__builtin_tbegin} a loop for transient failures
16527 is generated.  If tbegin returns a condition code of 2 the transaction
16528 will be retried as often as specified in the second argument.  The
16529 perform processor assist instruction is used to tell the CPU about the
16530 number of fails so far.
16531 @end deftypefn
16533 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16534 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16535 restores.  Using this variant in code making use of FPRs will leave
16536 the FPRs in undefined state when entering the transaction abort
16537 handler code.
16538 @end deftypefn
16540 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16541 Generates the @code{tbeginc} machine instruction starting a constraint
16542 hardware transaction.  The second operand is set to @code{0xff08}.
16543 @end deftypefn
16545 @deftypefn {Built-in Function} int __builtin_tend (void)
16546 Generates the @code{tend} machine instruction finishing a transaction
16547 and making the changes visible to other threads.  The condition code
16548 generated by tend is returned as integer value.
16549 @end deftypefn
16551 @deftypefn {Built-in Function} void __builtin_tabort (int)
16552 Generates the @code{tabort} machine instruction with the specified
16553 abort code.  Abort codes from 0 through 255 are reserved and will
16554 result in an error message.
16555 @end deftypefn
16557 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16558 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16559 integer parameter is loaded into rX and a value of zero is loaded into
16560 rY.  The integer parameter specifies the number of times the
16561 transaction repeatedly aborted.
16562 @end deftypefn
16564 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16565 Generates the @code{etnd} machine instruction.  The current nesting
16566 depth is returned as integer value.  For a nesting depth of 0 the code
16567 is not executed as part of an transaction.
16568 @end deftypefn
16570 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16572 Generates the @code{ntstg} machine instruction.  The second argument
16573 is written to the first arguments location.  The store operation will
16574 not be rolled-back in case of an transaction abort.
16575 @end deftypefn
16577 @node SH Built-in Functions
16578 @subsection SH Built-in Functions
16579 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16580 families of processors:
16582 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16583 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16584 used by system code that manages threads and execution contexts.  The compiler
16585 normally does not generate code that modifies the contents of @samp{GBR} and
16586 thus the value is preserved across function calls.  Changing the @samp{GBR}
16587 value in user code must be done with caution, since the compiler might use
16588 @samp{GBR} in order to access thread local variables.
16590 @end deftypefn
16592 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16593 Returns the value that is currently set in the @samp{GBR} register.
16594 Memory loads and stores that use the thread pointer as a base address are
16595 turned into @samp{GBR} based displacement loads and stores, if possible.
16596 For example:
16597 @smallexample
16598 struct my_tcb
16600    int a, b, c, d, e;
16603 int get_tcb_value (void)
16605   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16606   return ((my_tcb*)__builtin_thread_pointer ())->c;
16609 @end smallexample
16610 @end deftypefn
16612 @node SPARC VIS Built-in Functions
16613 @subsection SPARC VIS Built-in Functions
16615 GCC supports SIMD operations on the SPARC using both the generic vector
16616 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16617 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16618 switch, the VIS extension is exposed as the following built-in functions:
16620 @smallexample
16621 typedef int v1si __attribute__ ((vector_size (4)));
16622 typedef int v2si __attribute__ ((vector_size (8)));
16623 typedef short v4hi __attribute__ ((vector_size (8)));
16624 typedef short v2hi __attribute__ ((vector_size (4)));
16625 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16626 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16628 void __builtin_vis_write_gsr (int64_t);
16629 int64_t __builtin_vis_read_gsr (void);
16631 void * __builtin_vis_alignaddr (void *, long);
16632 void * __builtin_vis_alignaddrl (void *, long);
16633 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16634 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16635 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16636 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16638 v4hi __builtin_vis_fexpand (v4qi);
16640 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16641 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16642 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16643 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16644 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16645 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16646 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16648 v4qi __builtin_vis_fpack16 (v4hi);
16649 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16650 v2hi __builtin_vis_fpackfix (v2si);
16651 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16653 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16655 long __builtin_vis_edge8 (void *, void *);
16656 long __builtin_vis_edge8l (void *, void *);
16657 long __builtin_vis_edge16 (void *, void *);
16658 long __builtin_vis_edge16l (void *, void *);
16659 long __builtin_vis_edge32 (void *, void *);
16660 long __builtin_vis_edge32l (void *, void *);
16662 long __builtin_vis_fcmple16 (v4hi, v4hi);
16663 long __builtin_vis_fcmple32 (v2si, v2si);
16664 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16665 long __builtin_vis_fcmpne32 (v2si, v2si);
16666 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16667 long __builtin_vis_fcmpgt32 (v2si, v2si);
16668 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16669 long __builtin_vis_fcmpeq32 (v2si, v2si);
16671 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16672 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16673 v2si __builtin_vis_fpadd32 (v2si, v2si);
16674 v1si __builtin_vis_fpadd32s (v1si, v1si);
16675 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16676 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16677 v2si __builtin_vis_fpsub32 (v2si, v2si);
16678 v1si __builtin_vis_fpsub32s (v1si, v1si);
16680 long __builtin_vis_array8 (long, long);
16681 long __builtin_vis_array16 (long, long);
16682 long __builtin_vis_array32 (long, long);
16683 @end smallexample
16685 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16686 functions also become available:
16688 @smallexample
16689 long __builtin_vis_bmask (long, long);
16690 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16691 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16692 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16693 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16695 long __builtin_vis_edge8n (void *, void *);
16696 long __builtin_vis_edge8ln (void *, void *);
16697 long __builtin_vis_edge16n (void *, void *);
16698 long __builtin_vis_edge16ln (void *, void *);
16699 long __builtin_vis_edge32n (void *, void *);
16700 long __builtin_vis_edge32ln (void *, void *);
16701 @end smallexample
16703 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16704 functions also become available:
16706 @smallexample
16707 void __builtin_vis_cmask8 (long);
16708 void __builtin_vis_cmask16 (long);
16709 void __builtin_vis_cmask32 (long);
16711 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16713 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16714 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16715 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16716 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16717 v2si __builtin_vis_fsll16 (v2si, v2si);
16718 v2si __builtin_vis_fslas16 (v2si, v2si);
16719 v2si __builtin_vis_fsrl16 (v2si, v2si);
16720 v2si __builtin_vis_fsra16 (v2si, v2si);
16722 long __builtin_vis_pdistn (v8qi, v8qi);
16724 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16726 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16727 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16729 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16730 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16731 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16732 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16733 v2si __builtin_vis_fpadds32 (v2si, v2si);
16734 v1si __builtin_vis_fpadds32s (v1si, v1si);
16735 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16736 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16738 long __builtin_vis_fucmple8 (v8qi, v8qi);
16739 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16740 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16741 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16743 float __builtin_vis_fhadds (float, float);
16744 double __builtin_vis_fhaddd (double, double);
16745 float __builtin_vis_fhsubs (float, float);
16746 double __builtin_vis_fhsubd (double, double);
16747 float __builtin_vis_fnhadds (float, float);
16748 double __builtin_vis_fnhaddd (double, double);
16750 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16751 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16752 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16753 @end smallexample
16755 @node SPU Built-in Functions
16756 @subsection SPU Built-in Functions
16758 GCC provides extensions for the SPU processor as described in the
16759 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16760 found at @uref{http://cell.scei.co.jp/} or
16761 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
16762 implementation differs in several ways.
16764 @itemize @bullet
16766 @item
16767 The optional extension of specifying vector constants in parentheses is
16768 not supported.
16770 @item
16771 A vector initializer requires no cast if the vector constant is of the
16772 same type as the variable it is initializing.
16774 @item
16775 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16776 vector type is the default signedness of the base type.  The default
16777 varies depending on the operating system, so a portable program should
16778 always specify the signedness.
16780 @item
16781 By default, the keyword @code{__vector} is added. The macro
16782 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16783 undefined.
16785 @item
16786 GCC allows using a @code{typedef} name as the type specifier for a
16787 vector type.
16789 @item
16790 For C, overloaded functions are implemented with macros so the following
16791 does not work:
16793 @smallexample
16794   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16795 @end smallexample
16797 @noindent
16798 Since @code{spu_add} is a macro, the vector constant in the example
16799 is treated as four separate arguments.  Wrap the entire argument in
16800 parentheses for this to work.
16802 @item
16803 The extended version of @code{__builtin_expect} is not supported.
16805 @end itemize
16807 @emph{Note:} Only the interface described in the aforementioned
16808 specification is supported. Internally, GCC uses built-in functions to
16809 implement the required functionality, but these are not supported and
16810 are subject to change without notice.
16812 @node TI C6X Built-in Functions
16813 @subsection TI C6X Built-in Functions
16815 GCC provides intrinsics to access certain instructions of the TI C6X
16816 processors.  These intrinsics, listed below, are available after
16817 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
16818 to C6X instructions.
16820 @smallexample
16822 int _sadd (int, int)
16823 int _ssub (int, int)
16824 int _sadd2 (int, int)
16825 int _ssub2 (int, int)
16826 long long _mpy2 (int, int)
16827 long long _smpy2 (int, int)
16828 int _add4 (int, int)
16829 int _sub4 (int, int)
16830 int _saddu4 (int, int)
16832 int _smpy (int, int)
16833 int _smpyh (int, int)
16834 int _smpyhl (int, int)
16835 int _smpylh (int, int)
16837 int _sshl (int, int)
16838 int _subc (int, int)
16840 int _avg2 (int, int)
16841 int _avgu4 (int, int)
16843 int _clrr (int, int)
16844 int _extr (int, int)
16845 int _extru (int, int)
16846 int _abs (int)
16847 int _abs2 (int)
16849 @end smallexample
16851 @node TILE-Gx Built-in Functions
16852 @subsection TILE-Gx Built-in Functions
16854 GCC provides intrinsics to access every instruction of the TILE-Gx
16855 processor.  The intrinsics are of the form:
16857 @smallexample
16859 unsigned long long __insn_@var{op} (...)
16861 @end smallexample
16863 Where @var{op} is the name of the instruction.  Refer to the ISA manual
16864 for the complete list of instructions.
16866 GCC also provides intrinsics to directly access the network registers.
16867 The intrinsics are:
16869 @smallexample
16871 unsigned long long __tile_idn0_receive (void)
16872 unsigned long long __tile_idn1_receive (void)
16873 unsigned long long __tile_udn0_receive (void)
16874 unsigned long long __tile_udn1_receive (void)
16875 unsigned long long __tile_udn2_receive (void)
16876 unsigned long long __tile_udn3_receive (void)
16877 void __tile_idn_send (unsigned long long)
16878 void __tile_udn_send (unsigned long long)
16880 @end smallexample
16882 The intrinsic @code{void __tile_network_barrier (void)} is used to
16883 guarantee that no network operations before it are reordered with
16884 those after it.
16886 @node TILEPro Built-in Functions
16887 @subsection TILEPro Built-in Functions
16889 GCC provides intrinsics to access every instruction of the TILEPro
16890 processor.  The intrinsics are of the form:
16892 @smallexample
16894 unsigned __insn_@var{op} (...)
16896 @end smallexample
16898 @noindent
16899 where @var{op} is the name of the instruction.  Refer to the ISA manual
16900 for the complete list of instructions.
16902 GCC also provides intrinsics to directly access the network registers.
16903 The intrinsics are:
16905 @smallexample
16907 unsigned __tile_idn0_receive (void)
16908 unsigned __tile_idn1_receive (void)
16909 unsigned __tile_sn_receive (void)
16910 unsigned __tile_udn0_receive (void)
16911 unsigned __tile_udn1_receive (void)
16912 unsigned __tile_udn2_receive (void)
16913 unsigned __tile_udn3_receive (void)
16914 void __tile_idn_send (unsigned)
16915 void __tile_sn_send (unsigned)
16916 void __tile_udn_send (unsigned)
16918 @end smallexample
16920 The intrinsic @code{void __tile_network_barrier (void)} is used to
16921 guarantee that no network operations before it are reordered with
16922 those after it.
16924 @node Target Format Checks
16925 @section Format Checks Specific to Particular Target Machines
16927 For some target machines, GCC supports additional options to the
16928 format attribute
16929 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
16931 @menu
16932 * Solaris Format Checks::
16933 * Darwin Format Checks::
16934 @end menu
16936 @node Solaris Format Checks
16937 @subsection Solaris Format Checks
16939 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
16940 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
16941 conversions, and the two-argument @code{%b} conversion for displaying
16942 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
16944 @node Darwin Format Checks
16945 @subsection Darwin Format Checks
16947 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
16948 attribute context.  Declarations made with such attribution are parsed for correct syntax
16949 and format argument types.  However, parsing of the format string itself is currently undefined
16950 and is not carried out by this version of the compiler.
16952 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
16953 also be used as format arguments.  Note that the relevant headers are only likely to be
16954 available on Darwin (OSX) installations.  On such installations, the XCode and system
16955 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
16956 associated functions.
16958 @node Pragmas
16959 @section Pragmas Accepted by GCC
16960 @cindex pragmas
16961 @cindex @code{#pragma}
16963 GCC supports several types of pragmas, primarily in order to compile
16964 code originally written for other compilers.  Note that in general
16965 we do not recommend the use of pragmas; @xref{Function Attributes},
16966 for further explanation.
16968 @menu
16969 * ARM Pragmas::
16970 * M32C Pragmas::
16971 * MeP Pragmas::
16972 * RS/6000 and PowerPC Pragmas::
16973 * Darwin Pragmas::
16974 * Solaris Pragmas::
16975 * Symbol-Renaming Pragmas::
16976 * Structure-Packing Pragmas::
16977 * Weak Pragmas::
16978 * Diagnostic Pragmas::
16979 * Visibility Pragmas::
16980 * Push/Pop Macro Pragmas::
16981 * Function Specific Option Pragmas::
16982 * Loop-Specific Pragmas::
16983 @end menu
16985 @node ARM Pragmas
16986 @subsection ARM Pragmas
16988 The ARM target defines pragmas for controlling the default addition of
16989 @code{long_call} and @code{short_call} attributes to functions.
16990 @xref{Function Attributes}, for information about the effects of these
16991 attributes.
16993 @table @code
16994 @item long_calls
16995 @cindex pragma, long_calls
16996 Set all subsequent functions to have the @code{long_call} attribute.
16998 @item no_long_calls
16999 @cindex pragma, no_long_calls
17000 Set all subsequent functions to have the @code{short_call} attribute.
17002 @item long_calls_off
17003 @cindex pragma, long_calls_off
17004 Do not affect the @code{long_call} or @code{short_call} attributes of
17005 subsequent functions.
17006 @end table
17008 @node M32C Pragmas
17009 @subsection M32C Pragmas
17011 @table @code
17012 @item GCC memregs @var{number}
17013 @cindex pragma, memregs
17014 Overrides the command-line option @code{-memregs=} for the current
17015 file.  Use with care!  This pragma must be before any function in the
17016 file, and mixing different memregs values in different objects may
17017 make them incompatible.  This pragma is useful when a
17018 performance-critical function uses a memreg for temporary values,
17019 as it may allow you to reduce the number of memregs used.
17021 @item ADDRESS @var{name} @var{address}
17022 @cindex pragma, address
17023 For any declared symbols matching @var{name}, this does three things
17024 to that symbol: it forces the symbol to be located at the given
17025 address (a number), it forces the symbol to be volatile, and it
17026 changes the symbol's scope to be static.  This pragma exists for
17027 compatibility with other compilers, but note that the common
17028 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17029 instead).  Example:
17031 @smallexample
17032 #pragma ADDRESS port3 0x103
17033 char port3;
17034 @end smallexample
17036 @end table
17038 @node MeP Pragmas
17039 @subsection MeP Pragmas
17041 @table @code
17043 @item custom io_volatile (on|off)
17044 @cindex pragma, custom io_volatile
17045 Overrides the command-line option @code{-mio-volatile} for the current
17046 file.  Note that for compatibility with future GCC releases, this
17047 option should only be used once before any @code{io} variables in each
17048 file.
17050 @item GCC coprocessor available @var{registers}
17051 @cindex pragma, coprocessor available
17052 Specifies which coprocessor registers are available to the register
17053 allocator.  @var{registers} may be a single register, register range
17054 separated by ellipses, or comma-separated list of those.  Example:
17056 @smallexample
17057 #pragma GCC coprocessor available $c0...$c10, $c28
17058 @end smallexample
17060 @item GCC coprocessor call_saved @var{registers}
17061 @cindex pragma, coprocessor call_saved
17062 Specifies which coprocessor registers are to be saved and restored by
17063 any function using them.  @var{registers} may be a single register,
17064 register range separated by ellipses, or comma-separated list of
17065 those.  Example:
17067 @smallexample
17068 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17069 @end smallexample
17071 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17072 @cindex pragma, coprocessor subclass
17073 Creates and defines a register class.  These register classes can be
17074 used by inline @code{asm} constructs.  @var{registers} may be a single
17075 register, register range separated by ellipses, or comma-separated
17076 list of those.  Example:
17078 @smallexample
17079 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17081 asm ("cpfoo %0" : "=B" (x));
17082 @end smallexample
17084 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17085 @cindex pragma, disinterrupt
17086 For the named functions, the compiler adds code to disable interrupts
17087 for the duration of those functions.  If any functions so named 
17088 are not encountered in the source, a warning is emitted that the pragma is
17089 not used.  Examples:
17091 @smallexample
17092 #pragma disinterrupt foo
17093 #pragma disinterrupt bar, grill
17094 int foo () @{ @dots{} @}
17095 @end smallexample
17097 @item GCC call @var{name} , @var{name} @dots{}
17098 @cindex pragma, call
17099 For the named functions, the compiler always uses a register-indirect
17100 call model when calling the named functions.  Examples:
17102 @smallexample
17103 extern int foo ();
17104 #pragma call foo
17105 @end smallexample
17107 @end table
17109 @node RS/6000 and PowerPC Pragmas
17110 @subsection RS/6000 and PowerPC Pragmas
17112 The RS/6000 and PowerPC targets define one pragma for controlling
17113 whether or not the @code{longcall} attribute is added to function
17114 declarations by default.  This pragma overrides the @option{-mlongcall}
17115 option, but not the @code{longcall} and @code{shortcall} attributes.
17116 @xref{RS/6000 and PowerPC Options}, for more information about when long
17117 calls are and are not necessary.
17119 @table @code
17120 @item longcall (1)
17121 @cindex pragma, longcall
17122 Apply the @code{longcall} attribute to all subsequent function
17123 declarations.
17125 @item longcall (0)
17126 Do not apply the @code{longcall} attribute to subsequent function
17127 declarations.
17128 @end table
17130 @c Describe h8300 pragmas here.
17131 @c Describe sh pragmas here.
17132 @c Describe v850 pragmas here.
17134 @node Darwin Pragmas
17135 @subsection Darwin Pragmas
17137 The following pragmas are available for all architectures running the
17138 Darwin operating system.  These are useful for compatibility with other
17139 Mac OS compilers.
17141 @table @code
17142 @item mark @var{tokens}@dots{}
17143 @cindex pragma, mark
17144 This pragma is accepted, but has no effect.
17146 @item options align=@var{alignment}
17147 @cindex pragma, options align
17148 This pragma sets the alignment of fields in structures.  The values of
17149 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17150 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
17151 properly; to restore the previous setting, use @code{reset} for the
17152 @var{alignment}.
17154 @item segment @var{tokens}@dots{}
17155 @cindex pragma, segment
17156 This pragma is accepted, but has no effect.
17158 @item unused (@var{var} [, @var{var}]@dots{})
17159 @cindex pragma, unused
17160 This pragma declares variables to be possibly unused.  GCC does not
17161 produce warnings for the listed variables.  The effect is similar to
17162 that of the @code{unused} attribute, except that this pragma may appear
17163 anywhere within the variables' scopes.
17164 @end table
17166 @node Solaris Pragmas
17167 @subsection Solaris Pragmas
17169 The Solaris target supports @code{#pragma redefine_extname}
17170 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
17171 @code{#pragma} directives for compatibility with the system compiler.
17173 @table @code
17174 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17175 @cindex pragma, align
17177 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17178 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17179 Attributes}).  Macro expansion occurs on the arguments to this pragma
17180 when compiling C and Objective-C@.  It does not currently occur when
17181 compiling C++, but this is a bug which may be fixed in a future
17182 release.
17184 @item fini (@var{function} [, @var{function}]...)
17185 @cindex pragma, fini
17187 This pragma causes each listed @var{function} to be called after
17188 main, or during shared module unloading, by adding a call to the
17189 @code{.fini} section.
17191 @item init (@var{function} [, @var{function}]...)
17192 @cindex pragma, init
17194 This pragma causes each listed @var{function} to be called during
17195 initialization (before @code{main}) or during shared module loading, by
17196 adding a call to the @code{.init} section.
17198 @end table
17200 @node Symbol-Renaming Pragmas
17201 @subsection Symbol-Renaming Pragmas
17203 GCC supports a @code{#pragma} directive that changes the name used in
17204 assembly for a given declaration. This effect can also be achieved
17205 using the asm labels extension (@pxref{Asm Labels}).
17207 @table @code
17208 @item redefine_extname @var{oldname} @var{newname}
17209 @cindex pragma, redefine_extname
17211 This pragma gives the C function @var{oldname} the assembly symbol
17212 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17213 is defined if this pragma is available (currently on all platforms).
17214 @end table
17216 This pragma and the asm labels extension interact in a complicated
17217 manner.  Here are some corner cases you may want to be aware of:
17219 @enumerate
17220 @item This pragma silently applies only to declarations with external
17221 linkage.  Asm labels do not have this restriction.
17223 @item In C++, this pragma silently applies only to declarations with
17224 ``C'' linkage.  Again, asm labels do not have this restriction.
17226 @item If either of the ways of changing the assembly name of a
17227 declaration are applied to a declaration whose assembly name has
17228 already been determined (either by a previous use of one of these
17229 features, or because the compiler needed the assembly name in order to
17230 generate code), and the new name is different, a warning issues and
17231 the name does not change.
17233 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17234 always the C-language name.
17235 @end enumerate
17237 @node Structure-Packing Pragmas
17238 @subsection Structure-Packing Pragmas
17240 For compatibility with Microsoft Windows compilers, GCC supports a
17241 set of @code{#pragma} directives that change the maximum alignment of
17242 members of structures (other than zero-width bit-fields), unions, and
17243 classes subsequently defined. The @var{n} value below always is required
17244 to be a small power of two and specifies the new alignment in bytes.
17246 @enumerate
17247 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17248 @item @code{#pragma pack()} sets the alignment to the one that was in
17249 effect when compilation started (see also command-line option
17250 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17251 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17252 setting on an internal stack and then optionally sets the new alignment.
17253 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17254 saved at the top of the internal stack (and removes that stack entry).
17255 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17256 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17257 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17258 @code{#pragma pack(pop)}.
17259 @end enumerate
17261 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
17262 @code{#pragma} which lays out a structure as the documented
17263 @code{__attribute__ ((ms_struct))}.
17264 @enumerate
17265 @item @code{#pragma ms_struct on} turns on the layout for structures
17266 declared.
17267 @item @code{#pragma ms_struct off} turns off the layout for structures
17268 declared.
17269 @item @code{#pragma ms_struct reset} goes back to the default layout.
17270 @end enumerate
17272 @node Weak Pragmas
17273 @subsection Weak Pragmas
17275 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17276 directives for declaring symbols to be weak, and defining weak
17277 aliases.
17279 @table @code
17280 @item #pragma weak @var{symbol}
17281 @cindex pragma, weak
17282 This pragma declares @var{symbol} to be weak, as if the declaration
17283 had the attribute of the same name.  The pragma may appear before
17284 or after the declaration of @var{symbol}.  It is not an error for
17285 @var{symbol} to never be defined at all.
17287 @item #pragma weak @var{symbol1} = @var{symbol2}
17288 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17289 It is an error if @var{symbol2} is not defined in the current
17290 translation unit.
17291 @end table
17293 @node Diagnostic Pragmas
17294 @subsection Diagnostic Pragmas
17296 GCC allows the user to selectively enable or disable certain types of
17297 diagnostics, and change the kind of the diagnostic.  For example, a
17298 project's policy might require that all sources compile with
17299 @option{-Werror} but certain files might have exceptions allowing
17300 specific types of warnings.  Or, a project might selectively enable
17301 diagnostics and treat them as errors depending on which preprocessor
17302 macros are defined.
17304 @table @code
17305 @item #pragma GCC diagnostic @var{kind} @var{option}
17306 @cindex pragma, diagnostic
17308 Modifies the disposition of a diagnostic.  Note that not all
17309 diagnostics are modifiable; at the moment only warnings (normally
17310 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17311 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17312 are controllable and which option controls them.
17314 @var{kind} is @samp{error} to treat this diagnostic as an error,
17315 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17316 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17317 @var{option} is a double quoted string that matches the command-line
17318 option.
17320 @smallexample
17321 #pragma GCC diagnostic warning "-Wformat"
17322 #pragma GCC diagnostic error "-Wformat"
17323 #pragma GCC diagnostic ignored "-Wformat"
17324 @end smallexample
17326 Note that these pragmas override any command-line options.  GCC keeps
17327 track of the location of each pragma, and issues diagnostics according
17328 to the state as of that point in the source file.  Thus, pragmas occurring
17329 after a line do not affect diagnostics caused by that line.
17331 @item #pragma GCC diagnostic push
17332 @itemx #pragma GCC diagnostic pop
17334 Causes GCC to remember the state of the diagnostics as of each
17335 @code{push}, and restore to that point at each @code{pop}.  If a
17336 @code{pop} has no matching @code{push}, the command-line options are
17337 restored.
17339 @smallexample
17340 #pragma GCC diagnostic error "-Wuninitialized"
17341   foo(a);                       /* error is given for this one */
17342 #pragma GCC diagnostic push
17343 #pragma GCC diagnostic ignored "-Wuninitialized"
17344   foo(b);                       /* no diagnostic for this one */
17345 #pragma GCC diagnostic pop
17346   foo(c);                       /* error is given for this one */
17347 #pragma GCC diagnostic pop
17348   foo(d);                       /* depends on command-line options */
17349 @end smallexample
17351 @end table
17353 GCC also offers a simple mechanism for printing messages during
17354 compilation.
17356 @table @code
17357 @item #pragma message @var{string}
17358 @cindex pragma, diagnostic
17360 Prints @var{string} as a compiler message on compilation.  The message
17361 is informational only, and is neither a compilation warning nor an error.
17363 @smallexample
17364 #pragma message "Compiling " __FILE__ "..."
17365 @end smallexample
17367 @var{string} may be parenthesized, and is printed with location
17368 information.  For example,
17370 @smallexample
17371 #define DO_PRAGMA(x) _Pragma (#x)
17372 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17374 TODO(Remember to fix this)
17375 @end smallexample
17377 @noindent
17378 prints @samp{/tmp/file.c:4: note: #pragma message:
17379 TODO - Remember to fix this}.
17381 @end table
17383 @node Visibility Pragmas
17384 @subsection Visibility Pragmas
17386 @table @code
17387 @item #pragma GCC visibility push(@var{visibility})
17388 @itemx #pragma GCC visibility pop
17389 @cindex pragma, visibility
17391 This pragma allows the user to set the visibility for multiple
17392 declarations without having to give each a visibility attribute
17393 (@pxref{Function Attributes}).
17395 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17396 declarations.  Class members and template specializations are not
17397 affected; if you want to override the visibility for a particular
17398 member or instantiation, you must use an attribute.
17400 @end table
17403 @node Push/Pop Macro Pragmas
17404 @subsection Push/Pop Macro Pragmas
17406 For compatibility with Microsoft Windows compilers, GCC supports
17407 @samp{#pragma push_macro(@var{"macro_name"})}
17408 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17410 @table @code
17411 @item #pragma push_macro(@var{"macro_name"})
17412 @cindex pragma, push_macro
17413 This pragma saves the value of the macro named as @var{macro_name} to
17414 the top of the stack for this macro.
17416 @item #pragma pop_macro(@var{"macro_name"})
17417 @cindex pragma, pop_macro
17418 This pragma sets the value of the macro named as @var{macro_name} to
17419 the value on top of the stack for this macro. If the stack for
17420 @var{macro_name} is empty, the value of the macro remains unchanged.
17421 @end table
17423 For example:
17425 @smallexample
17426 #define X  1
17427 #pragma push_macro("X")
17428 #undef X
17429 #define X -1
17430 #pragma pop_macro("X")
17431 int x [X];
17432 @end smallexample
17434 @noindent
17435 In this example, the definition of X as 1 is saved by @code{#pragma
17436 push_macro} and restored by @code{#pragma pop_macro}.
17438 @node Function Specific Option Pragmas
17439 @subsection Function Specific Option Pragmas
17441 @table @code
17442 @item #pragma GCC target (@var{"string"}...)
17443 @cindex pragma GCC target
17445 This pragma allows you to set target specific options for functions
17446 defined later in the source file.  One or more strings can be
17447 specified.  Each function that is defined after this point is as
17448 if @code{attribute((target("STRING")))} was specified for that
17449 function.  The parenthesis around the options is optional.
17450 @xref{Function Attributes}, for more information about the
17451 @code{target} attribute and the attribute syntax.
17453 The @code{#pragma GCC target} pragma is presently implemented for
17454 i386/x86_64, PowerPC, and Nios II targets only.
17455 @end table
17457 @table @code
17458 @item #pragma GCC optimize (@var{"string"}...)
17459 @cindex pragma GCC optimize
17461 This pragma allows you to set global optimization options for functions
17462 defined later in the source file.  One or more strings can be
17463 specified.  Each function that is defined after this point is as
17464 if @code{attribute((optimize("STRING")))} was specified for that
17465 function.  The parenthesis around the options is optional.
17466 @xref{Function Attributes}, for more information about the
17467 @code{optimize} attribute and the attribute syntax.
17469 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17470 versions earlier than 4.4.
17471 @end table
17473 @table @code
17474 @item #pragma GCC push_options
17475 @itemx #pragma GCC pop_options
17476 @cindex pragma GCC push_options
17477 @cindex pragma GCC pop_options
17479 These pragmas maintain a stack of the current target and optimization
17480 options.  It is intended for include files where you temporarily want
17481 to switch to using a different @samp{#pragma GCC target} or
17482 @samp{#pragma GCC optimize} and then to pop back to the previous
17483 options.
17485 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17486 pragmas are not implemented in GCC versions earlier than 4.4.
17487 @end table
17489 @table @code
17490 @item #pragma GCC reset_options
17491 @cindex pragma GCC reset_options
17493 This pragma clears the current @code{#pragma GCC target} and
17494 @code{#pragma GCC optimize} to use the default switches as specified
17495 on the command line.
17497 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17498 versions earlier than 4.4.
17499 @end table
17501 @node Loop-Specific Pragmas
17502 @subsection Loop-Specific Pragmas
17504 @table @code
17505 @item #pragma GCC ivdep
17506 @cindex pragma GCC ivdep
17507 @end table
17509 With this pragma, the programmer asserts that there are no loop-carried
17510 dependencies which would prevent that consecutive iterations of
17511 the following loop can be executed concurrently with SIMD
17512 (single instruction multiple data) instructions.
17514 For example, the compiler can only unconditionally vectorize the following
17515 loop with the pragma:
17517 @smallexample
17518 void foo (int n, int *a, int *b, int *c)
17520   int i, j;
17521 #pragma GCC ivdep
17522   for (i = 0; i < n; ++i)
17523     a[i] = b[i] + c[i];
17525 @end smallexample
17527 @noindent
17528 In this example, using the @code{restrict} qualifier had the same
17529 effect. In the following example, that would not be possible. Assume
17530 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17531 that it can unconditionally vectorize the following loop:
17533 @smallexample
17534 void ignore_vec_dep (int *a, int k, int c, int m)
17536 #pragma GCC ivdep
17537   for (int i = 0; i < m; i++)
17538     a[i] = a[i + k] * c;
17540 @end smallexample
17543 @node Unnamed Fields
17544 @section Unnamed struct/union fields within structs/unions
17545 @cindex @code{struct}
17546 @cindex @code{union}
17548 As permitted by ISO C11 and for compatibility with other compilers,
17549 GCC allows you to define
17550 a structure or union that contains, as fields, structures and unions
17551 without names.  For example:
17553 @smallexample
17554 struct @{
17555   int a;
17556   union @{
17557     int b;
17558     float c;
17559   @};
17560   int d;
17561 @} foo;
17562 @end smallexample
17564 @noindent
17565 In this example, you are able to access members of the unnamed
17566 union with code like @samp{foo.b}.  Note that only unnamed structs and
17567 unions are allowed, you may not have, for example, an unnamed
17568 @code{int}.
17570 You must never create such structures that cause ambiguous field definitions.
17571 For example, in this structure:
17573 @smallexample
17574 struct @{
17575   int a;
17576   struct @{
17577     int a;
17578   @};
17579 @} foo;
17580 @end smallexample
17582 @noindent
17583 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17584 The compiler gives errors for such constructs.
17586 @opindex fms-extensions
17587 Unless @option{-fms-extensions} is used, the unnamed field must be a
17588 structure or union definition without a tag (for example, @samp{struct
17589 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
17590 also be a definition with a tag such as @samp{struct foo @{ int a;
17591 @};}, a reference to a previously defined structure or union such as
17592 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17593 previously defined structure or union type.
17595 @opindex fplan9-extensions
17596 The option @option{-fplan9-extensions} enables
17597 @option{-fms-extensions} as well as two other extensions.  First, a
17598 pointer to a structure is automatically converted to a pointer to an
17599 anonymous field for assignments and function calls.  For example:
17601 @smallexample
17602 struct s1 @{ int a; @};
17603 struct s2 @{ struct s1; @};
17604 extern void f1 (struct s1 *);
17605 void f2 (struct s2 *p) @{ f1 (p); @}
17606 @end smallexample
17608 @noindent
17609 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17610 converted into a pointer to the anonymous field.
17612 Second, when the type of an anonymous field is a @code{typedef} for a
17613 @code{struct} or @code{union}, code may refer to the field using the
17614 name of the @code{typedef}.
17616 @smallexample
17617 typedef struct @{ int a; @} s1;
17618 struct s2 @{ s1; @};
17619 s1 f1 (struct s2 *p) @{ return p->s1; @}
17620 @end smallexample
17622 These usages are only permitted when they are not ambiguous.
17624 @node Thread-Local
17625 @section Thread-Local Storage
17626 @cindex Thread-Local Storage
17627 @cindex @acronym{TLS}
17628 @cindex @code{__thread}
17630 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17631 are allocated such that there is one instance of the variable per extant
17632 thread.  The runtime model GCC uses to implement this originates
17633 in the IA-64 processor-specific ABI, but has since been migrated
17634 to other processors as well.  It requires significant support from
17635 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17636 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17637 is not available everywhere.
17639 At the user level, the extension is visible with a new storage
17640 class keyword: @code{__thread}.  For example:
17642 @smallexample
17643 __thread int i;
17644 extern __thread struct state s;
17645 static __thread char *p;
17646 @end smallexample
17648 The @code{__thread} specifier may be used alone, with the @code{extern}
17649 or @code{static} specifiers, but with no other storage class specifier.
17650 When used with @code{extern} or @code{static}, @code{__thread} must appear
17651 immediately after the other storage class specifier.
17653 The @code{__thread} specifier may be applied to any global, file-scoped
17654 static, function-scoped static, or static data member of a class.  It may
17655 not be applied to block-scoped automatic or non-static data member.
17657 When the address-of operator is applied to a thread-local variable, it is
17658 evaluated at run time and returns the address of the current thread's
17659 instance of that variable.  An address so obtained may be used by any
17660 thread.  When a thread terminates, any pointers to thread-local variables
17661 in that thread become invalid.
17663 No static initialization may refer to the address of a thread-local variable.
17665 In C++, if an initializer is present for a thread-local variable, it must
17666 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
17667 standard.
17669 See @uref{http://www.akkadia.org/drepper/tls.pdf,
17670 ELF Handling For Thread-Local Storage} for a detailed explanation of
17671 the four thread-local storage addressing models, and how the runtime
17672 is expected to function.
17674 @menu
17675 * C99 Thread-Local Edits::
17676 * C++98 Thread-Local Edits::
17677 @end menu
17679 @node C99 Thread-Local Edits
17680 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
17682 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
17683 that document the exact semantics of the language extension.
17685 @itemize @bullet
17686 @item
17687 @cite{5.1.2  Execution environments}
17689 Add new text after paragraph 1
17691 @quotation
17692 Within either execution environment, a @dfn{thread} is a flow of
17693 control within a program.  It is implementation defined whether
17694 or not there may be more than one thread associated with a program.
17695 It is implementation defined how threads beyond the first are
17696 created, the name and type of the function called at thread
17697 startup, and how threads may be terminated.  However, objects
17698 with thread storage duration shall be initialized before thread
17699 startup.
17700 @end quotation
17702 @item
17703 @cite{6.2.4  Storage durations of objects}
17705 Add new text before paragraph 3
17707 @quotation
17708 An object whose identifier is declared with the storage-class
17709 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
17710 Its lifetime is the entire execution of the thread, and its
17711 stored value is initialized only once, prior to thread startup.
17712 @end quotation
17714 @item
17715 @cite{6.4.1  Keywords}
17717 Add @code{__thread}.
17719 @item
17720 @cite{6.7.1  Storage-class specifiers}
17722 Add @code{__thread} to the list of storage class specifiers in
17723 paragraph 1.
17725 Change paragraph 2 to
17727 @quotation
17728 With the exception of @code{__thread}, at most one storage-class
17729 specifier may be given [@dots{}].  The @code{__thread} specifier may
17730 be used alone, or immediately following @code{extern} or
17731 @code{static}.
17732 @end quotation
17734 Add new text after paragraph 6
17736 @quotation
17737 The declaration of an identifier for a variable that has
17738 block scope that specifies @code{__thread} shall also
17739 specify either @code{extern} or @code{static}.
17741 The @code{__thread} specifier shall be used only with
17742 variables.
17743 @end quotation
17744 @end itemize
17746 @node C++98 Thread-Local Edits
17747 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
17749 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
17750 that document the exact semantics of the language extension.
17752 @itemize @bullet
17753 @item
17754 @b{[intro.execution]}
17756 New text after paragraph 4
17758 @quotation
17759 A @dfn{thread} is a flow of control within the abstract machine.
17760 It is implementation defined whether or not there may be more than
17761 one thread.
17762 @end quotation
17764 New text after paragraph 7
17766 @quotation
17767 It is unspecified whether additional action must be taken to
17768 ensure when and whether side effects are visible to other threads.
17769 @end quotation
17771 @item
17772 @b{[lex.key]}
17774 Add @code{__thread}.
17776 @item
17777 @b{[basic.start.main]}
17779 Add after paragraph 5
17781 @quotation
17782 The thread that begins execution at the @code{main} function is called
17783 the @dfn{main thread}.  It is implementation defined how functions
17784 beginning threads other than the main thread are designated or typed.
17785 A function so designated, as well as the @code{main} function, is called
17786 a @dfn{thread startup function}.  It is implementation defined what
17787 happens if a thread startup function returns.  It is implementation
17788 defined what happens to other threads when any thread calls @code{exit}.
17789 @end quotation
17791 @item
17792 @b{[basic.start.init]}
17794 Add after paragraph 4
17796 @quotation
17797 The storage for an object of thread storage duration shall be
17798 statically initialized before the first statement of the thread startup
17799 function.  An object of thread storage duration shall not require
17800 dynamic initialization.
17801 @end quotation
17803 @item
17804 @b{[basic.start.term]}
17806 Add after paragraph 3
17808 @quotation
17809 The type of an object with thread storage duration shall not have a
17810 non-trivial destructor, nor shall it be an array type whose elements
17811 (directly or indirectly) have non-trivial destructors.
17812 @end quotation
17814 @item
17815 @b{[basic.stc]}
17817 Add ``thread storage duration'' to the list in paragraph 1.
17819 Change paragraph 2
17821 @quotation
17822 Thread, static, and automatic storage durations are associated with
17823 objects introduced by declarations [@dots{}].
17824 @end quotation
17826 Add @code{__thread} to the list of specifiers in paragraph 3.
17828 @item
17829 @b{[basic.stc.thread]}
17831 New section before @b{[basic.stc.static]}
17833 @quotation
17834 The keyword @code{__thread} applied to a non-local object gives the
17835 object thread storage duration.
17837 A local variable or class data member declared both @code{static}
17838 and @code{__thread} gives the variable or member thread storage
17839 duration.
17840 @end quotation
17842 @item
17843 @b{[basic.stc.static]}
17845 Change paragraph 1
17847 @quotation
17848 All objects that have neither thread storage duration, dynamic
17849 storage duration nor are local [@dots{}].
17850 @end quotation
17852 @item
17853 @b{[dcl.stc]}
17855 Add @code{__thread} to the list in paragraph 1.
17857 Change paragraph 1
17859 @quotation
17860 With the exception of @code{__thread}, at most one
17861 @var{storage-class-specifier} shall appear in a given
17862 @var{decl-specifier-seq}.  The @code{__thread} specifier may
17863 be used alone, or immediately following the @code{extern} or
17864 @code{static} specifiers.  [@dots{}]
17865 @end quotation
17867 Add after paragraph 5
17869 @quotation
17870 The @code{__thread} specifier can be applied only to the names of objects
17871 and to anonymous unions.
17872 @end quotation
17874 @item
17875 @b{[class.mem]}
17877 Add after paragraph 6
17879 @quotation
17880 Non-@code{static} members shall not be @code{__thread}.
17881 @end quotation
17882 @end itemize
17884 @node Binary constants
17885 @section Binary constants using the @samp{0b} prefix
17886 @cindex Binary constants using the @samp{0b} prefix
17888 Integer constants can be written as binary constants, consisting of a
17889 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
17890 @samp{0B}.  This is particularly useful in environments that operate a
17891 lot on the bit level (like microcontrollers).
17893 The following statements are identical:
17895 @smallexample
17896 i =       42;
17897 i =     0x2a;
17898 i =      052;
17899 i = 0b101010;
17900 @end smallexample
17902 The type of these constants follows the same rules as for octal or
17903 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
17904 can be applied.
17906 @node C++ Extensions
17907 @chapter Extensions to the C++ Language
17908 @cindex extensions, C++ language
17909 @cindex C++ language extensions
17911 The GNU compiler provides these extensions to the C++ language (and you
17912 can also use most of the C language extensions in your C++ programs).  If you
17913 want to write code that checks whether these features are available, you can
17914 test for the GNU compiler the same way as for C programs: check for a
17915 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
17916 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
17917 Predefined Macros,cpp,The GNU C Preprocessor}).
17919 @menu
17920 * C++ Volatiles::       What constitutes an access to a volatile object.
17921 * Restricted Pointers:: C99 restricted pointers and references.
17922 * Vague Linkage::       Where G++ puts inlines, vtables and such.
17923 * C++ Interface::       You can use a single C++ header file for both
17924                         declarations and definitions.
17925 * Template Instantiation:: Methods for ensuring that exactly one copy of
17926                         each needed template instantiation is emitted.
17927 * Bound member functions:: You can extract a function pointer to the
17928                         method denoted by a @samp{->*} or @samp{.*} expression.
17929 * C++ Attributes::      Variable, function, and type attributes for C++ only.
17930 * Function Multiversioning::   Declaring multiple function versions.
17931 * Namespace Association:: Strong using-directives for namespace association.
17932 * Type Traits::         Compiler support for type traits
17933 * Java Exceptions::     Tweaking exception handling to work with Java.
17934 * Deprecated Features:: Things will disappear from G++.
17935 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
17936 @end menu
17938 @node C++ Volatiles
17939 @section When is a Volatile C++ Object Accessed?
17940 @cindex accessing volatiles
17941 @cindex volatile read
17942 @cindex volatile write
17943 @cindex volatile access
17945 The C++ standard differs from the C standard in its treatment of
17946 volatile objects.  It fails to specify what constitutes a volatile
17947 access, except to say that C++ should behave in a similar manner to C
17948 with respect to volatiles, where possible.  However, the different
17949 lvalueness of expressions between C and C++ complicate the behavior.
17950 G++ behaves the same as GCC for volatile access, @xref{C
17951 Extensions,,Volatiles}, for a description of GCC's behavior.
17953 The C and C++ language specifications differ when an object is
17954 accessed in a void context:
17956 @smallexample
17957 volatile int *src = @var{somevalue};
17958 *src;
17959 @end smallexample
17961 The C++ standard specifies that such expressions do not undergo lvalue
17962 to rvalue conversion, and that the type of the dereferenced object may
17963 be incomplete.  The C++ standard does not specify explicitly that it
17964 is lvalue to rvalue conversion that is responsible for causing an
17965 access.  There is reason to believe that it is, because otherwise
17966 certain simple expressions become undefined.  However, because it
17967 would surprise most programmers, G++ treats dereferencing a pointer to
17968 volatile object of complete type as GCC would do for an equivalent
17969 type in C@.  When the object has incomplete type, G++ issues a
17970 warning; if you wish to force an error, you must force a conversion to
17971 rvalue with, for instance, a static cast.
17973 When using a reference to volatile, G++ does not treat equivalent
17974 expressions as accesses to volatiles, but instead issues a warning that
17975 no volatile is accessed.  The rationale for this is that otherwise it
17976 becomes difficult to determine where volatile access occur, and not
17977 possible to ignore the return value from functions returning volatile
17978 references.  Again, if you wish to force a read, cast the reference to
17979 an rvalue.
17981 G++ implements the same behavior as GCC does when assigning to a
17982 volatile object---there is no reread of the assigned-to object, the
17983 assigned rvalue is reused.  Note that in C++ assignment expressions
17984 are lvalues, and if used as an lvalue, the volatile object is
17985 referred to.  For instance, @var{vref} refers to @var{vobj}, as
17986 expected, in the following example:
17988 @smallexample
17989 volatile int vobj;
17990 volatile int &vref = vobj = @var{something};
17991 @end smallexample
17993 @node Restricted Pointers
17994 @section Restricting Pointer Aliasing
17995 @cindex restricted pointers
17996 @cindex restricted references
17997 @cindex restricted this pointer
17999 As with the C front end, G++ understands the C99 feature of restricted pointers,
18000 specified with the @code{__restrict__}, or @code{__restrict} type
18001 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
18002 language flag, @code{restrict} is not a keyword in C++.
18004 In addition to allowing restricted pointers, you can specify restricted
18005 references, which indicate that the reference is not aliased in the local
18006 context.
18008 @smallexample
18009 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18011   /* @r{@dots{}} */
18013 @end smallexample
18015 @noindent
18016 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18017 @var{rref} refers to a (different) unaliased integer.
18019 You may also specify whether a member function's @var{this} pointer is
18020 unaliased by using @code{__restrict__} as a member function qualifier.
18022 @smallexample
18023 void T::fn () __restrict__
18025   /* @r{@dots{}} */
18027 @end smallexample
18029 @noindent
18030 Within the body of @code{T::fn}, @var{this} has the effective
18031 definition @code{T *__restrict__ const this}.  Notice that the
18032 interpretation of a @code{__restrict__} member function qualifier is
18033 different to that of @code{const} or @code{volatile} qualifier, in that it
18034 is applied to the pointer rather than the object.  This is consistent with
18035 other compilers that implement restricted pointers.
18037 As with all outermost parameter qualifiers, @code{__restrict__} is
18038 ignored in function definition matching.  This means you only need to
18039 specify @code{__restrict__} in a function definition, rather than
18040 in a function prototype as well.
18042 @node Vague Linkage
18043 @section Vague Linkage
18044 @cindex vague linkage
18046 There are several constructs in C++ that require space in the object
18047 file but are not clearly tied to a single translation unit.  We say that
18048 these constructs have ``vague linkage''.  Typically such constructs are
18049 emitted wherever they are needed, though sometimes we can be more
18050 clever.
18052 @table @asis
18053 @item Inline Functions
18054 Inline functions are typically defined in a header file which can be
18055 included in many different compilations.  Hopefully they can usually be
18056 inlined, but sometimes an out-of-line copy is necessary, if the address
18057 of the function is taken or if inlining fails.  In general, we emit an
18058 out-of-line copy in all translation units where one is needed.  As an
18059 exception, we only emit inline virtual functions with the vtable, since
18060 it always requires a copy.
18062 Local static variables and string constants used in an inline function
18063 are also considered to have vague linkage, since they must be shared
18064 between all inlined and out-of-line instances of the function.
18066 @item VTables
18067 @cindex vtable
18068 C++ virtual functions are implemented in most compilers using a lookup
18069 table, known as a vtable.  The vtable contains pointers to the virtual
18070 functions provided by a class, and each object of the class contains a
18071 pointer to its vtable (or vtables, in some multiple-inheritance
18072 situations).  If the class declares any non-inline, non-pure virtual
18073 functions, the first one is chosen as the ``key method'' for the class,
18074 and the vtable is only emitted in the translation unit where the key
18075 method is defined.
18077 @emph{Note:} If the chosen key method is later defined as inline, the
18078 vtable is still emitted in every translation unit that defines it.
18079 Make sure that any inline virtuals are declared inline in the class
18080 body, even if they are not defined there.
18082 @item @code{type_info} objects
18083 @cindex @code{type_info}
18084 @cindex RTTI
18085 C++ requires information about types to be written out in order to
18086 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18087 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18088 object is written out along with the vtable so that @samp{dynamic_cast}
18089 can determine the dynamic type of a class object at run time.  For all
18090 other types, we write out the @samp{type_info} object when it is used: when
18091 applying @samp{typeid} to an expression, throwing an object, or
18092 referring to a type in a catch clause or exception specification.
18094 @item Template Instantiations
18095 Most everything in this section also applies to template instantiations,
18096 but there are other options as well.
18097 @xref{Template Instantiation,,Where's the Template?}.
18099 @end table
18101 When used with GNU ld version 2.8 or later on an ELF system such as
18102 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18103 these constructs will be discarded at link time.  This is known as
18104 COMDAT support.
18106 On targets that don't support COMDAT, but do support weak symbols, GCC
18107 uses them.  This way one copy overrides all the others, but
18108 the unused copies still take up space in the executable.
18110 For targets that do not support either COMDAT or weak symbols,
18111 most entities with vague linkage are emitted as local symbols to
18112 avoid duplicate definition errors from the linker.  This does not happen
18113 for local statics in inlines, however, as having multiple copies
18114 almost certainly breaks things.
18116 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18117 another way to control placement of these constructs.
18119 @node C++ Interface
18120 @section #pragma interface and implementation
18122 @cindex interface and implementation headers, C++
18123 @cindex C++ interface and implementation headers
18124 @cindex pragmas, interface and implementation
18126 @code{#pragma interface} and @code{#pragma implementation} provide the
18127 user with a way of explicitly directing the compiler to emit entities
18128 with vague linkage (and debugging information) in a particular
18129 translation unit.
18131 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
18132 most cases, because of COMDAT support and the ``key method'' heuristic
18133 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
18134 program to grow due to unnecessary out-of-line copies of inline
18135 functions.  Currently (3.4) the only benefit of these
18136 @code{#pragma}s is reduced duplication of debugging information, and
18137 that should be addressed soon on DWARF 2 targets with the use of
18138 COMDAT groups.
18140 @table @code
18141 @item #pragma interface
18142 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18143 @kindex #pragma interface
18144 Use this directive in @emph{header files} that define object classes, to save
18145 space in most of the object files that use those classes.  Normally,
18146 local copies of certain information (backup copies of inline member
18147 functions, debugging information, and the internal tables that implement
18148 virtual functions) must be kept in each object file that includes class
18149 definitions.  You can use this pragma to avoid such duplication.  When a
18150 header file containing @samp{#pragma interface} is included in a
18151 compilation, this auxiliary information is not generated (unless
18152 the main input source file itself uses @samp{#pragma implementation}).
18153 Instead, the object files contain references to be resolved at link
18154 time.
18156 The second form of this directive is useful for the case where you have
18157 multiple headers with the same name in different directories.  If you
18158 use this form, you must specify the same string to @samp{#pragma
18159 implementation}.
18161 @item #pragma implementation
18162 @itemx #pragma implementation "@var{objects}.h"
18163 @kindex #pragma implementation
18164 Use this pragma in a @emph{main input file}, when you want full output from
18165 included header files to be generated (and made globally visible).  The
18166 included header file, in turn, should use @samp{#pragma interface}.
18167 Backup copies of inline member functions, debugging information, and the
18168 internal tables used to implement virtual functions are all generated in
18169 implementation files.
18171 @cindex implied @code{#pragma implementation}
18172 @cindex @code{#pragma implementation}, implied
18173 @cindex naming convention, implementation headers
18174 If you use @samp{#pragma implementation} with no argument, it applies to
18175 an include file with the same basename@footnote{A file's @dfn{basename}
18176 is the name stripped of all leading path information and of trailing
18177 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18178 file.  For example, in @file{allclass.cc}, giving just
18179 @samp{#pragma implementation}
18180 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18182 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
18183 an implementation file whenever you would include it from
18184 @file{allclass.cc} even if you never specified @samp{#pragma
18185 implementation}.  This was deemed to be more trouble than it was worth,
18186 however, and disabled.
18188 Use the string argument if you want a single implementation file to
18189 include code from multiple header files.  (You must also use
18190 @samp{#include} to include the header file; @samp{#pragma
18191 implementation} only specifies how to use the file---it doesn't actually
18192 include it.)
18194 There is no way to split up the contents of a single header file into
18195 multiple implementation files.
18196 @end table
18198 @cindex inlining and C++ pragmas
18199 @cindex C++ pragmas, effect on inlining
18200 @cindex pragmas in C++, effect on inlining
18201 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18202 effect on function inlining.
18204 If you define a class in a header file marked with @samp{#pragma
18205 interface}, the effect on an inline function defined in that class is
18206 similar to an explicit @code{extern} declaration---the compiler emits
18207 no code at all to define an independent version of the function.  Its
18208 definition is used only for inlining with its callers.
18210 @opindex fno-implement-inlines
18211 Conversely, when you include the same header file in a main source file
18212 that declares it as @samp{#pragma implementation}, the compiler emits
18213 code for the function itself; this defines a version of the function
18214 that can be found via pointers (or by callers compiled without
18215 inlining).  If all calls to the function can be inlined, you can avoid
18216 emitting the function by compiling with @option{-fno-implement-inlines}.
18217 If any calls are not inlined, you will get linker errors.
18219 @node Template Instantiation
18220 @section Where's the Template?
18221 @cindex template instantiation
18223 C++ templates are the first language feature to require more
18224 intelligence from the environment than one usually finds on a UNIX
18225 system.  Somehow the compiler and linker have to make sure that each
18226 template instance occurs exactly once in the executable if it is needed,
18227 and not at all otherwise.  There are two basic approaches to this
18228 problem, which are referred to as the Borland model and the Cfront model.
18230 @table @asis
18231 @item Borland model
18232 Borland C++ solved the template instantiation problem by adding the code
18233 equivalent of common blocks to their linker; the compiler emits template
18234 instances in each translation unit that uses them, and the linker
18235 collapses them together.  The advantage of this model is that the linker
18236 only has to consider the object files themselves; there is no external
18237 complexity to worry about.  This disadvantage is that compilation time
18238 is increased because the template code is being compiled repeatedly.
18239 Code written for this model tends to include definitions of all
18240 templates in the header file, since they must be seen to be
18241 instantiated.
18243 @item Cfront model
18244 The AT&T C++ translator, Cfront, solved the template instantiation
18245 problem by creating the notion of a template repository, an
18246 automatically maintained place where template instances are stored.  A
18247 more modern version of the repository works as follows: As individual
18248 object files are built, the compiler places any template definitions and
18249 instantiations encountered in the repository.  At link time, the link
18250 wrapper adds in the objects in the repository and compiles any needed
18251 instances that were not previously emitted.  The advantages of this
18252 model are more optimal compilation speed and the ability to use the
18253 system linker; to implement the Borland model a compiler vendor also
18254 needs to replace the linker.  The disadvantages are vastly increased
18255 complexity, and thus potential for error; for some code this can be
18256 just as transparent, but in practice it can been very difficult to build
18257 multiple programs in one directory and one program in multiple
18258 directories.  Code written for this model tends to separate definitions
18259 of non-inline member templates into a separate file, which should be
18260 compiled separately.
18261 @end table
18263 When used with GNU ld version 2.8 or later on an ELF system such as
18264 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18265 Borland model.  On other systems, G++ implements neither automatic
18266 model.
18268 You have the following options for dealing with template instantiations:
18270 @enumerate
18271 @item
18272 @opindex frepo
18273 Compile your template-using code with @option{-frepo}.  The compiler
18274 generates files with the extension @samp{.rpo} listing all of the
18275 template instantiations used in the corresponding object files that
18276 could be instantiated there; the link wrapper, @samp{collect2},
18277 then updates the @samp{.rpo} files to tell the compiler where to place
18278 those instantiations and rebuild any affected object files.  The
18279 link-time overhead is negligible after the first pass, as the compiler
18280 continues to place the instantiations in the same files.
18282 This is your best option for application code written for the Borland
18283 model, as it just works.  Code written for the Cfront model 
18284 needs to be modified so that the template definitions are available at
18285 one or more points of instantiation; usually this is as simple as adding
18286 @code{#include <tmethods.cc>} to the end of each template header.
18288 For library code, if you want the library to provide all of the template
18289 instantiations it needs, just try to link all of its object files
18290 together; the link will fail, but cause the instantiations to be
18291 generated as a side effect.  Be warned, however, that this may cause
18292 conflicts if multiple libraries try to provide the same instantiations.
18293 For greater control, use explicit instantiation as described in the next
18294 option.
18296 @item
18297 @opindex fno-implicit-templates
18298 Compile your code with @option{-fno-implicit-templates} to disable the
18299 implicit generation of template instances, and explicitly instantiate
18300 all the ones you use.  This approach requires more knowledge of exactly
18301 which instances you need than do the others, but it's less
18302 mysterious and allows greater control.  You can scatter the explicit
18303 instantiations throughout your program, perhaps putting them in the
18304 translation units where the instances are used or the translation units
18305 that define the templates themselves; you can put all of the explicit
18306 instantiations you need into one big file; or you can create small files
18307 like
18309 @smallexample
18310 #include "Foo.h"
18311 #include "Foo.cc"
18313 template class Foo<int>;
18314 template ostream& operator <<
18315                 (ostream&, const Foo<int>&);
18316 @end smallexample
18318 @noindent
18319 for each of the instances you need, and create a template instantiation
18320 library from those.
18322 If you are using Cfront-model code, you can probably get away with not
18323 using @option{-fno-implicit-templates} when compiling files that don't
18324 @samp{#include} the member template definitions.
18326 If you use one big file to do the instantiations, you may want to
18327 compile it without @option{-fno-implicit-templates} so you get all of the
18328 instances required by your explicit instantiations (but not by any
18329 other files) without having to specify them as well.
18331 The ISO C++ 2011 standard allows forward declaration of explicit
18332 instantiations (with @code{extern}). G++ supports explicit instantiation
18333 declarations in C++98 mode and has extended the template instantiation
18334 syntax to support instantiation of the compiler support data for a
18335 template class (i.e.@: the vtable) without instantiating any of its
18336 members (with @code{inline}), and instantiation of only the static data
18337 members of a template class, without the support data or member
18338 functions (with @code{static}):
18340 @smallexample
18341 extern template int max (int, int);
18342 inline template class Foo<int>;
18343 static template class Foo<int>;
18344 @end smallexample
18346 @item
18347 Do nothing.  Pretend G++ does implement automatic instantiation
18348 management.  Code written for the Borland model works fine, but
18349 each translation unit contains instances of each of the templates it
18350 uses.  In a large program, this can lead to an unacceptable amount of code
18351 duplication.
18352 @end enumerate
18354 @node Bound member functions
18355 @section Extracting the function pointer from a bound pointer to member function
18356 @cindex pmf
18357 @cindex pointer to member function
18358 @cindex bound pointer to member function
18360 In C++, pointer to member functions (PMFs) are implemented using a wide
18361 pointer of sorts to handle all the possible call mechanisms; the PMF
18362 needs to store information about how to adjust the @samp{this} pointer,
18363 and if the function pointed to is virtual, where to find the vtable, and
18364 where in the vtable to look for the member function.  If you are using
18365 PMFs in an inner loop, you should really reconsider that decision.  If
18366 that is not an option, you can extract the pointer to the function that
18367 would be called for a given object/PMF pair and call it directly inside
18368 the inner loop, to save a bit of time.
18370 Note that you still pay the penalty for the call through a
18371 function pointer; on most modern architectures, such a call defeats the
18372 branch prediction features of the CPU@.  This is also true of normal
18373 virtual function calls.
18375 The syntax for this extension is
18377 @smallexample
18378 extern A a;
18379 extern int (A::*fp)();
18380 typedef int (*fptr)(A *);
18382 fptr p = (fptr)(a.*fp);
18383 @end smallexample
18385 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18386 no object is needed to obtain the address of the function.  They can be
18387 converted to function pointers directly:
18389 @smallexample
18390 fptr p1 = (fptr)(&A::foo);
18391 @end smallexample
18393 @opindex Wno-pmf-conversions
18394 You must specify @option{-Wno-pmf-conversions} to use this extension.
18396 @node C++ Attributes
18397 @section C++-Specific Variable, Function, and Type Attributes
18399 Some attributes only make sense for C++ programs.
18401 @table @code
18402 @item abi_tag ("@var{tag}", ...)
18403 @cindex @code{abi_tag} attribute
18404 The @code{abi_tag} attribute can be applied to a function or class
18405 declaration.  It modifies the mangled name of the function or class to
18406 incorporate the tag name, in order to distinguish the function or
18407 class from an earlier version with a different ABI; perhaps the class
18408 has changed size, or the function has a different return type that is
18409 not encoded in the mangled name.
18411 The argument can be a list of strings of arbitrary length.  The
18412 strings are sorted on output, so the order of the list is
18413 unimportant.
18415 A redeclaration of a function or class must not add new ABI tags,
18416 since doing so would change the mangled name.
18418 The ABI tags apply to a name, so all instantiations and
18419 specializations of a template have the same tags.  The attribute will
18420 be ignored if applied to an explicit specialization or instantiation.
18422 The @option{-Wabi-tag} flag enables a warning about a class which does
18423 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18424 that needs to coexist with an earlier ABI, using this option can help
18425 to find all affected types that need to be tagged.
18427 @item init_priority (@var{priority})
18428 @cindex @code{init_priority} attribute
18431 In Standard C++, objects defined at namespace scope are guaranteed to be
18432 initialized in an order in strict accordance with that of their definitions
18433 @emph{in a given translation unit}.  No guarantee is made for initializations
18434 across translation units.  However, GNU C++ allows users to control the
18435 order of initialization of objects defined at namespace scope with the
18436 @code{init_priority} attribute by specifying a relative @var{priority},
18437 a constant integral expression currently bounded between 101 and 65535
18438 inclusive.  Lower numbers indicate a higher priority.
18440 In the following example, @code{A} would normally be created before
18441 @code{B}, but the @code{init_priority} attribute reverses that order:
18443 @smallexample
18444 Some_Class  A  __attribute__ ((init_priority (2000)));
18445 Some_Class  B  __attribute__ ((init_priority (543)));
18446 @end smallexample
18448 @noindent
18449 Note that the particular values of @var{priority} do not matter; only their
18450 relative ordering.
18452 @item java_interface
18453 @cindex @code{java_interface} attribute
18455 This type attribute informs C++ that the class is a Java interface.  It may
18456 only be applied to classes declared within an @code{extern "Java"} block.
18457 Calls to methods declared in this interface are dispatched using GCJ's
18458 interface table mechanism, instead of regular virtual table dispatch.
18460 @item warn_unused
18461 @cindex @code{warn_unused} attribute
18463 For C++ types with non-trivial constructors and/or destructors it is
18464 impossible for the compiler to determine whether a variable of this
18465 type is truly unused if it is not referenced. This type attribute
18466 informs the compiler that variables of this type should be warned
18467 about if they appear to be unused, just like variables of fundamental
18468 types.
18470 This attribute is appropriate for types which just represent a value,
18471 such as @code{std::string}; it is not appropriate for types which
18472 control a resource, such as @code{std::mutex}.
18474 This attribute is also accepted in C, but it is unnecessary because C
18475 does not have constructors or destructors.
18477 @end table
18479 See also @ref{Namespace Association}.
18481 @node Function Multiversioning
18482 @section Function Multiversioning
18483 @cindex function versions
18485 With the GNU C++ front end, for target i386, you may specify multiple
18486 versions of a function, where each function is specialized for a
18487 specific target feature.  At runtime, the appropriate version of the
18488 function is automatically executed depending on the characteristics of
18489 the execution platform.  Here is an example.
18491 @smallexample
18492 __attribute__ ((target ("default")))
18493 int foo ()
18495   // The default version of foo.
18496   return 0;
18499 __attribute__ ((target ("sse4.2")))
18500 int foo ()
18502   // foo version for SSE4.2
18503   return 1;
18506 __attribute__ ((target ("arch=atom")))
18507 int foo ()
18509   // foo version for the Intel ATOM processor
18510   return 2;
18513 __attribute__ ((target ("arch=amdfam10")))
18514 int foo ()
18516   // foo version for the AMD Family 0x10 processors.
18517   return 3;
18520 int main ()
18522   int (*p)() = &foo;
18523   assert ((*p) () == foo ());
18524   return 0;
18526 @end smallexample
18528 In the above example, four versions of function foo are created. The
18529 first version of foo with the target attribute "default" is the default
18530 version.  This version gets executed when no other target specific
18531 version qualifies for execution on a particular platform. A new version
18532 of foo is created by using the same function signature but with a
18533 different target string.  Function foo is called or a pointer to it is
18534 taken just like a regular function.  GCC takes care of doing the
18535 dispatching to call the right version at runtime.  Refer to the
18536 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18537 Function Multiversioning} for more details.
18539 @node Namespace Association
18540 @section Namespace Association
18542 @strong{Caution:} The semantics of this extension are equivalent
18543 to C++ 2011 inline namespaces.  Users should use inline namespaces
18544 instead as this extension will be removed in future versions of G++.
18546 A using-directive with @code{__attribute ((strong))} is stronger
18547 than a normal using-directive in two ways:
18549 @itemize @bullet
18550 @item
18551 Templates from the used namespace can be specialized and explicitly
18552 instantiated as though they were members of the using namespace.
18554 @item
18555 The using namespace is considered an associated namespace of all
18556 templates in the used namespace for purposes of argument-dependent
18557 name lookup.
18558 @end itemize
18560 The used namespace must be nested within the using namespace so that
18561 normal unqualified lookup works properly.
18563 This is useful for composing a namespace transparently from
18564 implementation namespaces.  For example:
18566 @smallexample
18567 namespace std @{
18568   namespace debug @{
18569     template <class T> struct A @{ @};
18570   @}
18571   using namespace debug __attribute ((__strong__));
18572   template <> struct A<int> @{ @};   // @r{OK to specialize}
18574   template <class T> void f (A<T>);
18577 int main()
18579   f (std::A<float>());             // @r{lookup finds} std::f
18580   f (std::A<int>());
18582 @end smallexample
18584 @node Type Traits
18585 @section Type Traits
18587 The C++ front end implements syntactic extensions that allow
18588 compile-time determination of 
18589 various characteristics of a type (or of a
18590 pair of types).
18592 @table @code
18593 @item __has_nothrow_assign (type)
18594 If @code{type} is const qualified or is a reference type then the trait is
18595 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18596 is true, else if @code{type} is a cv class or union type with copy assignment
18597 operators that are known not to throw an exception then the trait is true,
18598 else it is false.  Requires: @code{type} shall be a complete type,
18599 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18601 @item __has_nothrow_copy (type)
18602 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18603 @code{type} is a cv class or union type with copy constructors that
18604 are known not to throw an exception then the trait is true, else it is false.
18605 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18606 @code{void}, or an array of unknown bound.
18608 @item __has_nothrow_constructor (type)
18609 If @code{__has_trivial_constructor (type)} is true then the trait is
18610 true, else if @code{type} is a cv class or union type (or array
18611 thereof) with a default constructor that is known not to throw an
18612 exception then the trait is true, else it is false.  Requires:
18613 @code{type} shall be a complete type, (possibly cv-qualified)
18614 @code{void}, or an array of unknown bound.
18616 @item __has_trivial_assign (type)
18617 If @code{type} is const qualified or is a reference type then the trait is
18618 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
18619 true, else if @code{type} is a cv class or union type with a trivial
18620 copy assignment ([class.copy]) then the trait is true, else it is
18621 false.  Requires: @code{type} shall be a complete type, (possibly
18622 cv-qualified) @code{void}, or an array of unknown bound.
18624 @item __has_trivial_copy (type)
18625 If @code{__is_pod (type)} is true or @code{type} is a reference type
18626 then the trait is true, else if @code{type} is a cv class or union type
18627 with a trivial copy constructor ([class.copy]) then the trait
18628 is true, else it is false.  Requires: @code{type} shall be a complete
18629 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18631 @item __has_trivial_constructor (type)
18632 If @code{__is_pod (type)} is true then the trait is true, else if
18633 @code{type} is a cv class or union type (or array thereof) with a
18634 trivial default constructor ([class.ctor]) then the trait is true,
18635 else it is false.  Requires: @code{type} shall be a complete
18636 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18638 @item __has_trivial_destructor (type)
18639 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18640 the trait is true, else if @code{type} is a cv class or union type (or
18641 array thereof) with a trivial destructor ([class.dtor]) then the trait
18642 is true, else it is false.  Requires: @code{type} shall be a complete
18643 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18645 @item __has_virtual_destructor (type)
18646 If @code{type} is a class type with a virtual destructor
18647 ([class.dtor]) then the trait is true, else it is false.  Requires:
18648 @code{type} shall be a complete type, (possibly cv-qualified)
18649 @code{void}, or an array of unknown bound.
18651 @item __is_abstract (type)
18652 If @code{type} is an abstract class ([class.abstract]) then the trait
18653 is true, else it is false.  Requires: @code{type} shall be a complete
18654 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18656 @item __is_base_of (base_type, derived_type)
18657 If @code{base_type} is a base class of @code{derived_type}
18658 ([class.derived]) then the trait is true, otherwise it is false.
18659 Top-level cv qualifications of @code{base_type} and
18660 @code{derived_type} are ignored.  For the purposes of this trait, a
18661 class type is considered is own base.  Requires: if @code{__is_class
18662 (base_type)} and @code{__is_class (derived_type)} are true and
18663 @code{base_type} and @code{derived_type} are not the same type
18664 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
18665 type.  Diagnostic is produced if this requirement is not met.
18667 @item __is_class (type)
18668 If @code{type} is a cv class type, and not a union type
18669 ([basic.compound]) the trait is true, else it is false.
18671 @item __is_empty (type)
18672 If @code{__is_class (type)} is false then the trait is false.
18673 Otherwise @code{type} is considered empty if and only if: @code{type}
18674 has no non-static data members, or all non-static data members, if
18675 any, are bit-fields of length 0, and @code{type} has no virtual
18676 members, and @code{type} has no virtual base classes, and @code{type}
18677 has no base classes @code{base_type} for which
18678 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
18679 be a complete type, (possibly cv-qualified) @code{void}, or an array
18680 of unknown bound.
18682 @item __is_enum (type)
18683 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
18684 true, else it is false.
18686 @item __is_literal_type (type)
18687 If @code{type} is a literal type ([basic.types]) the trait is
18688 true, else it is false.  Requires: @code{type} shall be a complete type,
18689 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18691 @item __is_pod (type)
18692 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
18693 else it is false.  Requires: @code{type} shall be a complete type,
18694 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18696 @item __is_polymorphic (type)
18697 If @code{type} is a polymorphic class ([class.virtual]) then the trait
18698 is true, else it is false.  Requires: @code{type} shall be a complete
18699 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18701 @item __is_standard_layout (type)
18702 If @code{type} is a standard-layout type ([basic.types]) the trait is
18703 true, else it is false.  Requires: @code{type} shall be a complete
18704 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18706 @item __is_trivial (type)
18707 If @code{type} is a trivial type ([basic.types]) the trait is
18708 true, else it is false.  Requires: @code{type} shall be a complete
18709 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18711 @item __is_union (type)
18712 If @code{type} is a cv union type ([basic.compound]) the trait is
18713 true, else it is false.
18715 @item __underlying_type (type)
18716 The underlying type of @code{type}.  Requires: @code{type} shall be
18717 an enumeration type ([dcl.enum]).
18719 @end table
18721 @node Java Exceptions
18722 @section Java Exceptions
18724 The Java language uses a slightly different exception handling model
18725 from C++.  Normally, GNU C++ automatically detects when you are
18726 writing C++ code that uses Java exceptions, and handle them
18727 appropriately.  However, if C++ code only needs to execute destructors
18728 when Java exceptions are thrown through it, GCC guesses incorrectly.
18729 Sample problematic code is:
18731 @smallexample
18732   struct S @{ ~S(); @};
18733   extern void bar();    // @r{is written in Java, and may throw exceptions}
18734   void foo()
18735   @{
18736     S s;
18737     bar();
18738   @}
18739 @end smallexample
18741 @noindent
18742 The usual effect of an incorrect guess is a link failure, complaining of
18743 a missing routine called @samp{__gxx_personality_v0}.
18745 You can inform the compiler that Java exceptions are to be used in a
18746 translation unit, irrespective of what it might think, by writing
18747 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
18748 @samp{#pragma} must appear before any functions that throw or catch
18749 exceptions, or run destructors when exceptions are thrown through them.
18751 You cannot mix Java and C++ exceptions in the same translation unit.  It
18752 is believed to be safe to throw a C++ exception from one file through
18753 another file compiled for the Java exception model, or vice versa, but
18754 there may be bugs in this area.
18756 @node Deprecated Features
18757 @section Deprecated Features
18759 In the past, the GNU C++ compiler was extended to experiment with new
18760 features, at a time when the C++ language was still evolving.  Now that
18761 the C++ standard is complete, some of those features are superseded by
18762 superior alternatives.  Using the old features might cause a warning in
18763 some cases that the feature will be dropped in the future.  In other
18764 cases, the feature might be gone already.
18766 While the list below is not exhaustive, it documents some of the options
18767 that are now deprecated:
18769 @table @code
18770 @item -fexternal-templates
18771 @itemx -falt-external-templates
18772 These are two of the many ways for G++ to implement template
18773 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
18774 defines how template definitions have to be organized across
18775 implementation units.  G++ has an implicit instantiation mechanism that
18776 should work just fine for standard-conforming code.
18778 @item -fstrict-prototype
18779 @itemx -fno-strict-prototype
18780 Previously it was possible to use an empty prototype parameter list to
18781 indicate an unspecified number of parameters (like C), rather than no
18782 parameters, as C++ demands.  This feature has been removed, except where
18783 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
18784 @end table
18786 G++ allows a virtual function returning @samp{void *} to be overridden
18787 by one returning a different pointer type.  This extension to the
18788 covariant return type rules is now deprecated and will be removed from a
18789 future version.
18791 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
18792 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
18793 and are now removed from G++.  Code using these operators should be
18794 modified to use @code{std::min} and @code{std::max} instead.
18796 The named return value extension has been deprecated, and is now
18797 removed from G++.
18799 The use of initializer lists with new expressions has been deprecated,
18800 and is now removed from G++.
18802 Floating and complex non-type template parameters have been deprecated,
18803 and are now removed from G++.
18805 The implicit typename extension has been deprecated and is now
18806 removed from G++.
18808 The use of default arguments in function pointers, function typedefs
18809 and other places where they are not permitted by the standard is
18810 deprecated and will be removed from a future version of G++.
18812 G++ allows floating-point literals to appear in integral constant expressions,
18813 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
18814 This extension is deprecated and will be removed from a future version.
18816 G++ allows static data members of const floating-point type to be declared
18817 with an initializer in a class definition. The standard only allows
18818 initializers for static members of const integral types and const
18819 enumeration types so this extension has been deprecated and will be removed
18820 from a future version.
18822 @node Backwards Compatibility
18823 @section Backwards Compatibility
18824 @cindex Backwards Compatibility
18825 @cindex ARM [Annotated C++ Reference Manual]
18827 Now that there is a definitive ISO standard C++, G++ has a specification
18828 to adhere to.  The C++ language evolved over time, and features that
18829 used to be acceptable in previous drafts of the standard, such as the ARM
18830 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
18831 compilation of C++ written to such drafts, G++ contains some backwards
18832 compatibilities.  @emph{All such backwards compatibility features are
18833 liable to disappear in future versions of G++.} They should be considered
18834 deprecated.   @xref{Deprecated Features}.
18836 @table @code
18837 @item For scope
18838 If a variable is declared at for scope, it used to remain in scope until
18839 the end of the scope that contained the for statement (rather than just
18840 within the for scope).  G++ retains this, but issues a warning, if such a
18841 variable is accessed outside the for scope.
18843 @item Implicit C language
18844 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
18845 scope to set the language.  On such systems, all header files are
18846 implicitly scoped inside a C language scope.  Also, an empty prototype
18847 @code{()} is treated as an unspecified number of arguments, rather
18848 than no arguments, as C++ demands.
18849 @end table
18851 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
18852 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign