jit: document union types
[official-gcc.git] / gcc / doc / extend.texi
blobbb858a84f96052b8df55fe00b5903ab4744d26a2
1 @c Copyright (C) 1988-2015 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes::     Specifying attributes of types.
61 * Label Attributes::    Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Attribute Syntax::    Formal syntax for attributes.
64 * Function Prototypes:: Prototype declarations and old-style definitions.
65 * C++ Comments::        C++ comments are recognized.
66 * Dollar Signs::        Dollar sign is allowed in identifiers.
67 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
68 * Alignment::           Inquiring about the alignment of a type or variable.
69 * Inline::              Defining inline functions (as fast as macros).
70 * Volatiles::           What constitutes an access to a volatile object.
71 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
72 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
73 * Incomplete Enums::    @code{enum foo;}, with details to follow.
74 * Function Names::      Printable strings which are the name of the current
75                         function.
76 * Return Address::      Getting the return or frame address of a function.
77 * Vector Extensions::   Using vector instructions through built-in functions.
78 * Offsetof::            Special syntax for implementing @code{offsetof}.
79 * __sync Builtins::     Legacy built-in functions for atomic memory access.
80 * __atomic Builtins::   Atomic built-in functions with memory model.
81 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
82                         arithmetic overflow checking.
83 * x86 specific memory model extensions for transactional memory:: x86 memory models.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
85                         checking.
86 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
87 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
88 * Other Builtins::      Other built-in functions.
89 * Target Builtins::     Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas::             Pragmas accepted by GCC.
92 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
93 * Thread-Local::        Per-thread variables.
94 * Binary constants::    Binary constants using the @samp{0b} prefix.
95 @end menu
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@.  This allows you to use loops, switches, and local variables
108 within an expression.
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces.  For
112 example:
114 @smallexample
115 (@{ int y = foo (); int z;
116    if (y > 0) z = y;
117    else z = - y;
118    z; @})
119 @end smallexample
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct.  (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once).  For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects.  In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
147 @smallexample
148 #define maxint(a,b) \
149   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression.  For instance, if @code{A} is a class, then
163 @smallexample
164         A a;
166         (@{a;@}).Foo ()
167 @end smallexample
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end.  This makes statement
177 expressions inside macros slightly different from function calls.  In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call.  In the statement expression case they are destroyed during
181 the statement expression.  For instance,
183 @smallexample
184 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
187 void foo ()
189   macro (X ());
190   function (X ());
192 @end smallexample
194 @noindent
195 has different places where temporaries are destroyed.  For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}.  In the @code{function} case that
198 temporary is destroyed when the function returns.
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++.  (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted.  Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression.  In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression.  For example,
220 @smallexample
221   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}.  If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope.  A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
239 A local label declaration looks like this:
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
245 @noindent
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself.  You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
259 The local label feature is useful for complex macros.  If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them.  However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function.  A
264 local label avoids this problem.  For example:
266 @smallexample
267 #define SEARCH(value, array, target)              \
268 do @{                                              \
269   __label__ found;                                \
270   typeof (target) _SEARCH_target = (target);      \
271   typeof (*(array)) *_SEARCH_array = (array);     \
272   int i, j;                                       \
273   int value;                                      \
274   for (i = 0; i < max; i++)                       \
275     for (j = 0; j < max; j++)                     \
276       if (_SEARCH_array[i][j] == _SEARCH_target)  \
277         @{ (value) = i; goto found; @}              \
278   (value) = -1;                                   \
279  found:;                                          \
280 @} while (0)
281 @end smallexample
283 This could also be written using a statement expression:
285 @smallexample
286 #define SEARCH(array, target)                     \
287 (@{                                                \
288   __label__ found;                                \
289   typeof (target) _SEARCH_target = (target);      \
290   typeof (*(array)) *_SEARCH_array = (array);     \
291   int i, j;                                       \
292   int value;                                      \
293   for (i = 0; i < max; i++)                       \
294     for (j = 0; j < max; j++)                     \
295       if (_SEARCH_array[i][j] == _SEARCH_target)  \
296         @{ value = i; goto found; @}                \
297   value = -1;                                     \
298  found:                                           \
299   value;                                          \
301 @end smallexample
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any.  @xref{Nested Functions}, for details.
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}.  The
315 value has type @code{void *}.  This value is a constant and can be used
316 wherever a constant of that type is valid.  For example:
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
324 To use these values, you need to be able to jump to one.  This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}.  For example,
330 @smallexample
331 goto *ptr;
332 @end smallexample
334 @noindent
335 Any expression of type @code{void *} is allowed.
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
344 @noindent
345 Then you can select a label with indexing, like this:
347 @smallexample
348 goto *array[i];
349 @end smallexample
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement.  The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen.  The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
369 An alternate way to write the above example is
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373                              &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned.  If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning.  If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
405 @smallexample
406 @group
407 foo (double a, double b)
409   double square (double z) @{ return z * z; @}
411   return square (a) + square (b);
413 @end group
414 @end smallexample
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition.  This is
418 called @dfn{lexical scoping}.  For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
425   int access (int *array, int index)
426     @{ return array[index + offset]; @}
427   int i;
428   /* @r{@dots{}} */
429   for (i = 0; i < size; i++)
430     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
432 @end group
433 @end smallexample
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
442 @smallexample
443 hack (int *array, int size)
445   void store (int index, int value)
446     @{ array[index] = value; @}
448   intermediate (store, size);
450 @end smallexample
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument.  If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose.  If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk.  If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}.  This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}).  Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well.  Here is an example:
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
481   __label__ failure;
482   int access (int *array, int index)
483     @{
484       if (index > size)
485         goto failure;
486       return array[index + offset];
487     @}
488   int i;
489   /* @r{@dots{}} */
490   for (i = 0; i < size; i++)
491     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492   /* @r{@dots{}} */
493   return 0;
495  /* @r{Control comes here from @code{access}
496     if it detects an error.}  */
497  failure:
498   return -1;
500 @end group
501 @end smallexample
503 A nested function always has no linkage.  Declaring one with
504 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
508 @smallexample
509 bar (int *array, int offset, int size)
511   __label__ failure;
512   auto int access (int *, int);
513   /* @r{@dots{}} */
514   int access (int *array, int index)
515     @{
516       if (index > size)
517         goto failure;
518       return array[index + offset];
519     @}
520   /* @r{@dots{}} */
522 @end smallexample
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
532 of the arguments.
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
537 that data type).
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language.  It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack.  Then it returns the
552 address of that block.
553 @end deftypefn
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
558 and @var{size}.
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}.  The data
566 is saved in a block of memory allocated on the stack.
568 It is not always simple to compute the proper value for @var{size}.  The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
571 area.
572 @end deftypefn
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function.  You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
578 @end deftypefn
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function.  It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments.  This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable.  For example:
590 @smallexample
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
595   int r = fprintf (f, "myprintf: ");
596   if (r < 0)
597     return r;
598   int s = fprintf (f, format, __builtin_va_arg_pack ());
599   if (s < 0)
600     return s;
601   return r + s;
603 @end smallexample
604 @end deftypefn
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function.  It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
614 @smallexample
615 #ifdef __OPTIMIZE__
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
619   if (__builtin_va_arg_pack_len () > 1)
620     warn_open_too_many_arguments ();
622   if (__builtin_constant_p (oflag))
623     @{
624       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625         @{
626           warn_open_missing_mode ();
627           return __open_2 (path, oflag);
628         @}
629       return open (path, oflag, __builtin_va_arg_pack ());
630     @}
632   if (__builtin_va_arg_pack_len () < 1)
633     return __open_2 (path, oflag);
635   return open (path, oflag, __builtin_va_arg_pack ());
637 #endif
638 @end smallexample
639 @end deftypefn
641 @node Typeof
642 @section Referring to a Type with @code{typeof}
643 @findex typeof
644 @findex sizeof
645 @cindex macros, types of arguments
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type.  Here is an example with an expression:
654 @smallexample
655 typeof (x[0](1))
656 @end smallexample
658 @noindent
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
662 Here is an example with a typename as the argument:
664 @smallexample
665 typeof (int *)
666 @end smallexample
668 @noindent
669 Here the type described is that of pointers to @code{int}.
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used.  For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
681 such a type.
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
689 @smallexample
690 #define max(a,b) \
691   (@{ typeof (a) _a = (a); \
692       typeof (b) _b = (b); \
693     _a > _b ? _a : _b; @})
694 @end smallexample
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}.  Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
709 @noindent
710 Some more examples of the use of @code{typeof}:
712 @itemize @bullet
713 @item
714 This declares @code{y} with the type of what @code{x} points to.
716 @smallexample
717 typeof (*x) y;
718 @end smallexample
720 @item
721 This declares @code{y} as an array of such values.
723 @smallexample
724 typeof (*x) y[4];
725 @end smallexample
727 @item
728 This declares @code{y} as an array of pointers to characters:
730 @smallexample
731 typeof (typeof (char *)[4]) y;
732 @end smallexample
734 @noindent
735 It is equivalent to the following traditional C declaration:
737 @smallexample
738 char *y[4];
739 @end smallexample
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
744 @smallexample
745 #define pointer(T)  typeof(T *)
746 #define array(T, N) typeof(T [N])
747 @end smallexample
749 @noindent
750 Now the declaration can be rewritten this way:
752 @smallexample
753 array (pointer (char), 4) y;
754 @end smallexample
756 @noindent
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
759 @end itemize
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}.  In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer.  (In C++, you should use C++11
767 @code{auto} for this purpose.)  Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
770 @smallexample
771 #define max(a,b) \
772   (@{ __auto_type _a = (a); \
773       __auto_type _b = (b); \
774     _a > _b ? _a : _b; @})
775 @end smallexample
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
779 @itemize @bullet
780 @item Each argument to the macro appears only once in the expansion of
781 the macro.  This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
783 such macros.
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
788 @end itemize
790 @node Conditionals
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
798 The middle operand in a conditional expression may be omitted.  Then
799 if the first operand is nonzero, its value is the value of the conditional
800 expression.
802 Therefore, the expression
804 @smallexample
805 x ? : y
806 @end smallexample
808 @noindent
809 has the value of @code{x} if that is nonzero; otherwise, the value of
810 @code{y}.
812 This example is perfectly equivalent to
814 @smallexample
815 x ? x : y
816 @end smallexample
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
820 @noindent
821 In this simple case, the ability to omit the middle operand is not
822 especially useful.  When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect.  Then repeating
824 the operand in the middle would perform the side effect twice.  Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
828 @node __int128
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
839 @node Long Long
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer.  To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer.  To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines.  Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction.  Division and shifts are open-coded only on machines that
860 provide special support.  The operations that are not open-coded use
861 special library routines that come with GCC@.
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes.  If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}.  The best way to avoid such problems is to use prototypes.
871 @node Complex
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++.  GCC also supports complex integer data
879 types which are not part of ISO C99.  You can declare complex types
880 using the keyword @code{_Complex}.  As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
888 complete.
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}.  Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant.  This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
900 @cindex @code{__real__} keyword
901 @cindex @code{__imag__} keyword
902 To extract the real part of a complex-valued expression @var{exp}, write
903 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
904 extract the imaginary part.  This is a GNU extension; for values of
905 floating type, you should use the ISO C99 functions @code{crealf},
906 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
907 @code{cimagl}, declared in @code{<complex.h>} and also provided as
908 built-in functions by GCC@.
910 @cindex complex conjugation
911 The operator @samp{~} performs complex conjugation when used on a value
912 with a complex type.  This is a GNU extension; for values of
913 floating type, you should use the ISO C99 functions @code{conjf},
914 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
915 provided as built-in functions by GCC@.
917 GCC can allocate complex automatic variables in a noncontiguous
918 fashion; it's even possible for the real part to be in a register while
919 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
920 debug info format can represent this, so use of DWARF 2 is recommended.
921 If you are using the stabs debug info format, GCC describes a noncontiguous
922 complex variable as if it were two separate variables of noncomplex type.
923 If the variable's actual name is @code{foo}, the two fictitious
924 variables are named @code{foo$real} and @code{foo$imag}.  You can
925 examine and set these two fictitious variables with your debugger.
927 @node Floating Types
928 @section Additional Floating Types
929 @cindex additional floating types
930 @cindex @code{__float80} data type
931 @cindex @code{__float128} data type
932 @cindex @code{w} floating point suffix
933 @cindex @code{q} floating point suffix
934 @cindex @code{W} floating point suffix
935 @cindex @code{Q} floating point suffix
937 As an extension, GNU C supports additional floating
938 types, @code{__float80} and @code{__float128} to support 80-bit
939 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
940 Support for additional types includes the arithmetic operators:
941 add, subtract, multiply, divide; unary arithmetic operators;
942 relational operators; equality operators; and conversions to and from
943 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
944 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
945 for @code{_float128}.  You can declare complex types using the
946 corresponding internal complex type, @code{XCmode} for @code{__float80}
947 type and @code{TCmode} for @code{__float128} type:
949 @smallexample
950 typedef _Complex float __attribute__((mode(TC))) _Complex128;
951 typedef _Complex float __attribute__((mode(XC))) _Complex80;
952 @end smallexample
954 Not all targets support additional floating-point types.  @code{__float80}
955 and @code{__float128} types are supported on x86 and IA-64 targets.
956 The @code{__float128} type is supported on hppa HP-UX targets.
958 @node Half-Precision
959 @section Half-Precision Floating Point
960 @cindex half-precision floating point
961 @cindex @code{__fp16} data type
963 On ARM targets, GCC supports half-precision (16-bit) floating point via
964 the @code{__fp16} type.  You must enable this type explicitly
965 with the @option{-mfp16-format} command-line option in order to use it.
967 ARM supports two incompatible representations for half-precision
968 floating-point values.  You must choose one of the representations and
969 use it consistently in your program.
971 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
972 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
973 There are 11 bits of significand precision, approximately 3
974 decimal digits.
976 Specifying @option{-mfp16-format=alternative} selects the ARM
977 alternative format.  This representation is similar to the IEEE
978 format, but does not support infinities or NaNs.  Instead, the range
979 of exponents is extended, so that this format can represent normalized
980 values in the range of @math{2^{-14}} to 131008.
982 The @code{__fp16} type is a storage format only.  For purposes
983 of arithmetic and other operations, @code{__fp16} values in C or C++
984 expressions are automatically promoted to @code{float}.  In addition,
985 you cannot declare a function with a return value or parameters
986 of type @code{__fp16}.
988 Note that conversions from @code{double} to @code{__fp16}
989 involve an intermediate conversion to @code{float}.  Because
990 of rounding, this can sometimes produce a different result than a
991 direct conversion.
993 ARM provides hardware support for conversions between
994 @code{__fp16} and @code{float} values
995 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
996 code using these hardware instructions if you compile with
997 options to select an FPU that provides them;
998 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
999 in addition to the @option{-mfp16-format} option to select
1000 a half-precision format.
1002 Language-level support for the @code{__fp16} data type is
1003 independent of whether GCC generates code using hardware floating-point
1004 instructions.  In cases where hardware support is not specified, GCC
1005 implements conversions between @code{__fp16} and @code{float} values
1006 as library calls.
1008 @node Decimal Float
1009 @section Decimal Floating Types
1010 @cindex decimal floating types
1011 @cindex @code{_Decimal32} data type
1012 @cindex @code{_Decimal64} data type
1013 @cindex @code{_Decimal128} data type
1014 @cindex @code{df} integer suffix
1015 @cindex @code{dd} integer suffix
1016 @cindex @code{dl} integer suffix
1017 @cindex @code{DF} integer suffix
1018 @cindex @code{DD} integer suffix
1019 @cindex @code{DL} integer suffix
1021 As an extension, GNU C supports decimal floating types as
1022 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1023 floating types in GCC will evolve as the draft technical report changes.
1024 Calling conventions for any target might also change.  Not all targets
1025 support decimal floating types.
1027 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1028 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1029 @code{float}, @code{double}, and @code{long double} whose radix is not
1030 specified by the C standard but is usually two.
1032 Support for decimal floating types includes the arithmetic operators
1033 add, subtract, multiply, divide; unary arithmetic operators;
1034 relational operators; equality operators; and conversions to and from
1035 integer and other floating types.  Use a suffix @samp{df} or
1036 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1037 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1038 @code{_Decimal128}.
1040 GCC support of decimal float as specified by the draft technical report
1041 is incomplete:
1043 @itemize @bullet
1044 @item
1045 When the value of a decimal floating type cannot be represented in the
1046 integer type to which it is being converted, the result is undefined
1047 rather than the result value specified by the draft technical report.
1049 @item
1050 GCC does not provide the C library functionality associated with
1051 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1052 @file{wchar.h}, which must come from a separate C library implementation.
1053 Because of this the GNU C compiler does not define macro
1054 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1055 the technical report.
1056 @end itemize
1058 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1059 are supported by the DWARF 2 debug information format.
1061 @node Hex Floats
1062 @section Hex Floats
1063 @cindex hex floats
1065 ISO C99 supports floating-point numbers written not only in the usual
1066 decimal notation, such as @code{1.55e1}, but also numbers such as
1067 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1068 supports this in C90 mode (except in some cases when strictly
1069 conforming) and in C++.  In that format the
1070 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1071 mandatory.  The exponent is a decimal number that indicates the power of
1072 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1073 @tex
1074 $1 {15\over16}$,
1075 @end tex
1076 @ifnottex
1077 1 15/16,
1078 @end ifnottex
1079 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1080 is the same as @code{1.55e1}.
1082 Unlike for floating-point numbers in the decimal notation the exponent
1083 is always required in the hexadecimal notation.  Otherwise the compiler
1084 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1085 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1086 extension for floating-point constants of type @code{float}.
1088 @node Fixed-Point
1089 @section Fixed-Point Types
1090 @cindex fixed-point types
1091 @cindex @code{_Fract} data type
1092 @cindex @code{_Accum} data type
1093 @cindex @code{_Sat} data type
1094 @cindex @code{hr} fixed-suffix
1095 @cindex @code{r} fixed-suffix
1096 @cindex @code{lr} fixed-suffix
1097 @cindex @code{llr} fixed-suffix
1098 @cindex @code{uhr} fixed-suffix
1099 @cindex @code{ur} fixed-suffix
1100 @cindex @code{ulr} fixed-suffix
1101 @cindex @code{ullr} fixed-suffix
1102 @cindex @code{hk} fixed-suffix
1103 @cindex @code{k} fixed-suffix
1104 @cindex @code{lk} fixed-suffix
1105 @cindex @code{llk} fixed-suffix
1106 @cindex @code{uhk} fixed-suffix
1107 @cindex @code{uk} fixed-suffix
1108 @cindex @code{ulk} fixed-suffix
1109 @cindex @code{ullk} fixed-suffix
1110 @cindex @code{HR} fixed-suffix
1111 @cindex @code{R} fixed-suffix
1112 @cindex @code{LR} fixed-suffix
1113 @cindex @code{LLR} fixed-suffix
1114 @cindex @code{UHR} fixed-suffix
1115 @cindex @code{UR} fixed-suffix
1116 @cindex @code{ULR} fixed-suffix
1117 @cindex @code{ULLR} fixed-suffix
1118 @cindex @code{HK} fixed-suffix
1119 @cindex @code{K} fixed-suffix
1120 @cindex @code{LK} fixed-suffix
1121 @cindex @code{LLK} fixed-suffix
1122 @cindex @code{UHK} fixed-suffix
1123 @cindex @code{UK} fixed-suffix
1124 @cindex @code{ULK} fixed-suffix
1125 @cindex @code{ULLK} fixed-suffix
1127 As an extension, GNU C supports fixed-point types as
1128 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1129 types in GCC will evolve as the draft technical report changes.
1130 Calling conventions for any target might also change.  Not all targets
1131 support fixed-point types.
1133 The fixed-point types are
1134 @code{short _Fract},
1135 @code{_Fract},
1136 @code{long _Fract},
1137 @code{long long _Fract},
1138 @code{unsigned short _Fract},
1139 @code{unsigned _Fract},
1140 @code{unsigned long _Fract},
1141 @code{unsigned long long _Fract},
1142 @code{_Sat short _Fract},
1143 @code{_Sat _Fract},
1144 @code{_Sat long _Fract},
1145 @code{_Sat long long _Fract},
1146 @code{_Sat unsigned short _Fract},
1147 @code{_Sat unsigned _Fract},
1148 @code{_Sat unsigned long _Fract},
1149 @code{_Sat unsigned long long _Fract},
1150 @code{short _Accum},
1151 @code{_Accum},
1152 @code{long _Accum},
1153 @code{long long _Accum},
1154 @code{unsigned short _Accum},
1155 @code{unsigned _Accum},
1156 @code{unsigned long _Accum},
1157 @code{unsigned long long _Accum},
1158 @code{_Sat short _Accum},
1159 @code{_Sat _Accum},
1160 @code{_Sat long _Accum},
1161 @code{_Sat long long _Accum},
1162 @code{_Sat unsigned short _Accum},
1163 @code{_Sat unsigned _Accum},
1164 @code{_Sat unsigned long _Accum},
1165 @code{_Sat unsigned long long _Accum}.
1167 Fixed-point data values contain fractional and optional integral parts.
1168 The format of fixed-point data varies and depends on the target machine.
1170 Support for fixed-point types includes:
1171 @itemize @bullet
1172 @item
1173 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1174 @item
1175 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1176 @item
1177 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1178 @item
1179 binary shift operators (@code{<<}, @code{>>})
1180 @item
1181 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1182 @item
1183 equality operators (@code{==}, @code{!=})
1184 @item
1185 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1186 @code{<<=}, @code{>>=})
1187 @item
1188 conversions to and from integer, floating-point, or fixed-point types
1189 @end itemize
1191 Use a suffix in a fixed-point literal constant:
1192 @itemize
1193 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1194 @code{_Sat short _Fract}
1195 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1196 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1197 @code{_Sat long _Fract}
1198 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1199 @code{_Sat long long _Fract}
1200 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1201 @code{_Sat unsigned short _Fract}
1202 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1203 @code{_Sat unsigned _Fract}
1204 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1205 @code{_Sat unsigned long _Fract}
1206 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1207 and @code{_Sat unsigned long long _Fract}
1208 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1209 @code{_Sat short _Accum}
1210 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1211 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1212 @code{_Sat long _Accum}
1213 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1214 @code{_Sat long long _Accum}
1215 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1216 @code{_Sat unsigned short _Accum}
1217 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1218 @code{_Sat unsigned _Accum}
1219 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1220 @code{_Sat unsigned long _Accum}
1221 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1222 and @code{_Sat unsigned long long _Accum}
1223 @end itemize
1225 GCC support of fixed-point types as specified by the draft technical report
1226 is incomplete:
1228 @itemize @bullet
1229 @item
1230 Pragmas to control overflow and rounding behaviors are not implemented.
1231 @end itemize
1233 Fixed-point types are supported by the DWARF 2 debug information format.
1235 @node Named Address Spaces
1236 @section Named Address Spaces
1237 @cindex Named Address Spaces
1239 As an extension, GNU C supports named address spaces as
1240 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1241 address spaces in GCC will evolve as the draft technical report
1242 changes.  Calling conventions for any target might also change.  At
1243 present, only the AVR, SPU, M32C, and RL78 targets support address
1244 spaces other than the generic address space.
1246 Address space identifiers may be used exactly like any other C type
1247 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1248 document for more details.
1250 @anchor{AVR Named Address Spaces}
1251 @subsection AVR Named Address Spaces
1253 On the AVR target, there are several address spaces that can be used
1254 in order to put read-only data into the flash memory and access that
1255 data by means of the special instructions @code{LPM} or @code{ELPM}
1256 needed to read from flash.
1258 Per default, any data including read-only data is located in RAM
1259 (the generic address space) so that non-generic address spaces are
1260 needed to locate read-only data in flash memory
1261 @emph{and} to generate the right instructions to access this data
1262 without using (inline) assembler code.
1264 @table @code
1265 @item __flash
1266 @cindex @code{__flash} AVR Named Address Spaces
1267 The @code{__flash} qualifier locates data in the
1268 @code{.progmem.data} section. Data is read using the @code{LPM}
1269 instruction. Pointers to this address space are 16 bits wide.
1271 @item __flash1
1272 @itemx __flash2
1273 @itemx __flash3
1274 @itemx __flash4
1275 @itemx __flash5
1276 @cindex @code{__flash1} AVR Named Address Spaces
1277 @cindex @code{__flash2} AVR Named Address Spaces
1278 @cindex @code{__flash3} AVR Named Address Spaces
1279 @cindex @code{__flash4} AVR Named Address Spaces
1280 @cindex @code{__flash5} AVR Named Address Spaces
1281 These are 16-bit address spaces locating data in section
1282 @code{.progmem@var{N}.data} where @var{N} refers to
1283 address space @code{__flash@var{N}}.
1284 The compiler sets the @code{RAMPZ} segment register appropriately 
1285 before reading data by means of the @code{ELPM} instruction.
1287 @item __memx
1288 @cindex @code{__memx} AVR Named Address Spaces
1289 This is a 24-bit address space that linearizes flash and RAM:
1290 If the high bit of the address is set, data is read from
1291 RAM using the lower two bytes as RAM address.
1292 If the high bit of the address is clear, data is read from flash
1293 with @code{RAMPZ} set according to the high byte of the address.
1294 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1296 Objects in this address space are located in @code{.progmemx.data}.
1297 @end table
1299 @b{Example}
1301 @smallexample
1302 char my_read (const __flash char ** p)
1304     /* p is a pointer to RAM that points to a pointer to flash.
1305        The first indirection of p reads that flash pointer
1306        from RAM and the second indirection reads a char from this
1307        flash address.  */
1309     return **p;
1312 /* Locate array[] in flash memory */
1313 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1315 int i = 1;
1317 int main (void)
1319    /* Return 17 by reading from flash memory */
1320    return array[array[i]];
1322 @end smallexample
1324 @noindent
1325 For each named address space supported by avr-gcc there is an equally
1326 named but uppercase built-in macro defined. 
1327 The purpose is to facilitate testing if respective address space
1328 support is available or not:
1330 @smallexample
1331 #ifdef __FLASH
1332 const __flash int var = 1;
1334 int read_var (void)
1336     return var;
1338 #else
1339 #include <avr/pgmspace.h> /* From AVR-LibC */
1341 const int var PROGMEM = 1;
1343 int read_var (void)
1345     return (int) pgm_read_word (&var);
1347 #endif /* __FLASH */
1348 @end smallexample
1350 @noindent
1351 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1352 locates data in flash but
1353 accesses to these data read from generic address space, i.e.@:
1354 from RAM,
1355 so that you need special accessors like @code{pgm_read_byte}
1356 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1357 together with attribute @code{progmem}.
1359 @noindent
1360 @b{Limitations and caveats}
1362 @itemize
1363 @item
1364 Reading across the 64@tie{}KiB section boundary of
1365 the @code{__flash} or @code{__flash@var{N}} address spaces
1366 shows undefined behavior. The only address space that
1367 supports reading across the 64@tie{}KiB flash segment boundaries is
1368 @code{__memx}.
1370 @item
1371 If you use one of the @code{__flash@var{N}} address spaces
1372 you must arrange your linker script to locate the
1373 @code{.progmem@var{N}.data} sections according to your needs.
1375 @item
1376 Any data or pointers to the non-generic address spaces must
1377 be qualified as @code{const}, i.e.@: as read-only data.
1378 This still applies if the data in one of these address
1379 spaces like software version number or calibration lookup table are intended to
1380 be changed after load time by, say, a boot loader. In this case
1381 the right qualification is @code{const} @code{volatile} so that the compiler
1382 must not optimize away known values or insert them
1383 as immediates into operands of instructions.
1385 @item
1386 The following code initializes a variable @code{pfoo}
1387 located in static storage with a 24-bit address:
1388 @smallexample
1389 extern const __memx char foo;
1390 const __memx void *pfoo = &foo;
1391 @end smallexample
1393 @noindent
1394 Such code requires at least binutils 2.23, see
1395 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1397 @end itemize
1399 @subsection M32C Named Address Spaces
1400 @cindex @code{__far} M32C Named Address Spaces
1402 On the M32C target, with the R8C and M16C CPU variants, variables
1403 qualified with @code{__far} are accessed using 32-bit addresses in
1404 order to access memory beyond the first 64@tie{}Ki bytes.  If
1405 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1406 effect.
1408 @subsection RL78 Named Address Spaces
1409 @cindex @code{__far} RL78 Named Address Spaces
1411 On the RL78 target, variables qualified with @code{__far} are accessed
1412 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1413 addresses.  Non-far variables are assumed to appear in the topmost
1414 64@tie{}KiB of the address space.
1416 @subsection SPU Named Address Spaces
1417 @cindex @code{__ea} SPU Named Address Spaces
1419 On the SPU target variables may be declared as
1420 belonging to another address space by qualifying the type with the
1421 @code{__ea} address space identifier:
1423 @smallexample
1424 extern int __ea i;
1425 @end smallexample
1427 @noindent 
1428 The compiler generates special code to access the variable @code{i}.
1429 It may use runtime library
1430 support, or generate special machine instructions to access that address
1431 space.
1433 @node Zero Length
1434 @section Arrays of Length Zero
1435 @cindex arrays of length zero
1436 @cindex zero-length arrays
1437 @cindex length-zero arrays
1438 @cindex flexible array members
1440 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1441 last element of a structure that is really a header for a variable-length
1442 object:
1444 @smallexample
1445 struct line @{
1446   int length;
1447   char contents[0];
1450 struct line *thisline = (struct line *)
1451   malloc (sizeof (struct line) + this_length);
1452 thisline->length = this_length;
1453 @end smallexample
1455 In ISO C90, you would have to give @code{contents} a length of 1, which
1456 means either you waste space or complicate the argument to @code{malloc}.
1458 In ISO C99, you would use a @dfn{flexible array member}, which is
1459 slightly different in syntax and semantics:
1461 @itemize @bullet
1462 @item
1463 Flexible array members are written as @code{contents[]} without
1464 the @code{0}.
1466 @item
1467 Flexible array members have incomplete type, and so the @code{sizeof}
1468 operator may not be applied.  As a quirk of the original implementation
1469 of zero-length arrays, @code{sizeof} evaluates to zero.
1471 @item
1472 Flexible array members may only appear as the last member of a
1473 @code{struct} that is otherwise non-empty.
1475 @item
1476 A structure containing a flexible array member, or a union containing
1477 such a structure (possibly recursively), may not be a member of a
1478 structure or an element of an array.  (However, these uses are
1479 permitted by GCC as extensions.)
1480 @end itemize
1482 Non-empty initialization of zero-length
1483 arrays is treated like any case where there are more initializer
1484 elements than the array holds, in that a suitable warning about ``excess
1485 elements in array'' is given, and the excess elements (all of them, in
1486 this case) are ignored.
1488 GCC allows static initialization of flexible array members.
1489 This is equivalent to defining a new structure containing the original
1490 structure followed by an array of sufficient size to contain the data.
1491 E.g.@: in the following, @code{f1} is constructed as if it were declared
1492 like @code{f2}.
1494 @smallexample
1495 struct f1 @{
1496   int x; int y[];
1497 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1499 struct f2 @{
1500   struct f1 f1; int data[3];
1501 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1502 @end smallexample
1504 @noindent
1505 The convenience of this extension is that @code{f1} has the desired
1506 type, eliminating the need to consistently refer to @code{f2.f1}.
1508 This has symmetry with normal static arrays, in that an array of
1509 unknown size is also written with @code{[]}.
1511 Of course, this extension only makes sense if the extra data comes at
1512 the end of a top-level object, as otherwise we would be overwriting
1513 data at subsequent offsets.  To avoid undue complication and confusion
1514 with initialization of deeply nested arrays, we simply disallow any
1515 non-empty initialization except when the structure is the top-level
1516 object.  For example:
1518 @smallexample
1519 struct foo @{ int x; int y[]; @};
1520 struct bar @{ struct foo z; @};
1522 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1523 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1524 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1525 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1526 @end smallexample
1528 @node Empty Structures
1529 @section Structures with No Members
1530 @cindex empty structures
1531 @cindex zero-size structures
1533 GCC permits a C structure to have no members:
1535 @smallexample
1536 struct empty @{
1538 @end smallexample
1540 The structure has size zero.  In C++, empty structures are part
1541 of the language.  G++ treats empty structures as if they had a single
1542 member of type @code{char}.
1544 @node Variable Length
1545 @section Arrays of Variable Length
1546 @cindex variable-length arrays
1547 @cindex arrays of variable length
1548 @cindex VLAs
1550 Variable-length automatic arrays are allowed in ISO C99, and as an
1551 extension GCC accepts them in C90 mode and in C++.  These arrays are
1552 declared like any other automatic arrays, but with a length that is not
1553 a constant expression.  The storage is allocated at the point of
1554 declaration and deallocated when the block scope containing the declaration
1555 exits.  For
1556 example:
1558 @smallexample
1559 FILE *
1560 concat_fopen (char *s1, char *s2, char *mode)
1562   char str[strlen (s1) + strlen (s2) + 1];
1563   strcpy (str, s1);
1564   strcat (str, s2);
1565   return fopen (str, mode);
1567 @end smallexample
1569 @cindex scope of a variable length array
1570 @cindex variable-length array scope
1571 @cindex deallocating variable length arrays
1572 Jumping or breaking out of the scope of the array name deallocates the
1573 storage.  Jumping into the scope is not allowed; you get an error
1574 message for it.
1576 @cindex variable-length array in a structure
1577 As an extension, GCC accepts variable-length arrays as a member of
1578 a structure or a union.  For example:
1580 @smallexample
1581 void
1582 foo (int n)
1584   struct S @{ int x[n]; @};
1586 @end smallexample
1588 @cindex @code{alloca} vs variable-length arrays
1589 You can use the function @code{alloca} to get an effect much like
1590 variable-length arrays.  The function @code{alloca} is available in
1591 many other C implementations (but not in all).  On the other hand,
1592 variable-length arrays are more elegant.
1594 There are other differences between these two methods.  Space allocated
1595 with @code{alloca} exists until the containing @emph{function} returns.
1596 The space for a variable-length array is deallocated as soon as the array
1597 name's scope ends.  (If you use both variable-length arrays and
1598 @code{alloca} in the same function, deallocation of a variable-length array
1599 also deallocates anything more recently allocated with @code{alloca}.)
1601 You can also use variable-length arrays as arguments to functions:
1603 @smallexample
1604 struct entry
1605 tester (int len, char data[len][len])
1607   /* @r{@dots{}} */
1609 @end smallexample
1611 The length of an array is computed once when the storage is allocated
1612 and is remembered for the scope of the array in case you access it with
1613 @code{sizeof}.
1615 If you want to pass the array first and the length afterward, you can
1616 use a forward declaration in the parameter list---another GNU extension.
1618 @smallexample
1619 struct entry
1620 tester (int len; char data[len][len], int len)
1622   /* @r{@dots{}} */
1624 @end smallexample
1626 @cindex parameter forward declaration
1627 The @samp{int len} before the semicolon is a @dfn{parameter forward
1628 declaration}, and it serves the purpose of making the name @code{len}
1629 known when the declaration of @code{data} is parsed.
1631 You can write any number of such parameter forward declarations in the
1632 parameter list.  They can be separated by commas or semicolons, but the
1633 last one must end with a semicolon, which is followed by the ``real''
1634 parameter declarations.  Each forward declaration must match a ``real''
1635 declaration in parameter name and data type.  ISO C99 does not support
1636 parameter forward declarations.
1638 @node Variadic Macros
1639 @section Macros with a Variable Number of Arguments.
1640 @cindex variable number of arguments
1641 @cindex macro with variable arguments
1642 @cindex rest argument (in macro)
1643 @cindex variadic macros
1645 In the ISO C standard of 1999, a macro can be declared to accept a
1646 variable number of arguments much as a function can.  The syntax for
1647 defining the macro is similar to that of a function.  Here is an
1648 example:
1650 @smallexample
1651 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1652 @end smallexample
1654 @noindent
1655 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1656 such a macro, it represents the zero or more tokens until the closing
1657 parenthesis that ends the invocation, including any commas.  This set of
1658 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1659 wherever it appears.  See the CPP manual for more information.
1661 GCC has long supported variadic macros, and used a different syntax that
1662 allowed you to give a name to the variable arguments just like any other
1663 argument.  Here is an example:
1665 @smallexample
1666 #define debug(format, args...) fprintf (stderr, format, args)
1667 @end smallexample
1669 @noindent
1670 This is in all ways equivalent to the ISO C example above, but arguably
1671 more readable and descriptive.
1673 GNU CPP has two further variadic macro extensions, and permits them to
1674 be used with either of the above forms of macro definition.
1676 In standard C, you are not allowed to leave the variable argument out
1677 entirely; but you are allowed to pass an empty argument.  For example,
1678 this invocation is invalid in ISO C, because there is no comma after
1679 the string:
1681 @smallexample
1682 debug ("A message")
1683 @end smallexample
1685 GNU CPP permits you to completely omit the variable arguments in this
1686 way.  In the above examples, the compiler would complain, though since
1687 the expansion of the macro still has the extra comma after the format
1688 string.
1690 To help solve this problem, CPP behaves specially for variable arguments
1691 used with the token paste operator, @samp{##}.  If instead you write
1693 @smallexample
1694 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1695 @end smallexample
1697 @noindent
1698 and if the variable arguments are omitted or empty, the @samp{##}
1699 operator causes the preprocessor to remove the comma before it.  If you
1700 do provide some variable arguments in your macro invocation, GNU CPP
1701 does not complain about the paste operation and instead places the
1702 variable arguments after the comma.  Just like any other pasted macro
1703 argument, these arguments are not macro expanded.
1705 @node Escaped Newlines
1706 @section Slightly Looser Rules for Escaped Newlines
1707 @cindex escaped newlines
1708 @cindex newlines (escaped)
1710 The preprocessor treatment of escaped newlines is more relaxed 
1711 than that specified by the C90 standard, which requires the newline
1712 to immediately follow a backslash.  
1713 GCC's implementation allows whitespace in the form
1714 of spaces, horizontal and vertical tabs, and form feeds between the
1715 backslash and the subsequent newline.  The preprocessor issues a
1716 warning, but treats it as a valid escaped newline and combines the two
1717 lines to form a single logical line.  This works within comments and
1718 tokens, as well as between tokens.  Comments are @emph{not} treated as
1719 whitespace for the purposes of this relaxation, since they have not
1720 yet been replaced with spaces.
1722 @node Subscripting
1723 @section Non-Lvalue Arrays May Have Subscripts
1724 @cindex subscripting
1725 @cindex arrays, non-lvalue
1727 @cindex subscripting and function values
1728 In ISO C99, arrays that are not lvalues still decay to pointers, and
1729 may be subscripted, although they may not be modified or used after
1730 the next sequence point and the unary @samp{&} operator may not be
1731 applied to them.  As an extension, GNU C allows such arrays to be
1732 subscripted in C90 mode, though otherwise they do not decay to
1733 pointers outside C99 mode.  For example,
1734 this is valid in GNU C though not valid in C90:
1736 @smallexample
1737 @group
1738 struct foo @{int a[4];@};
1740 struct foo f();
1742 bar (int index)
1744   return f().a[index];
1746 @end group
1747 @end smallexample
1749 @node Pointer Arith
1750 @section Arithmetic on @code{void}- and Function-Pointers
1751 @cindex void pointers, arithmetic
1752 @cindex void, size of pointer to
1753 @cindex function pointers, arithmetic
1754 @cindex function, size of pointer to
1756 In GNU C, addition and subtraction operations are supported on pointers to
1757 @code{void} and on pointers to functions.  This is done by treating the
1758 size of a @code{void} or of a function as 1.
1760 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1761 and on function types, and returns 1.
1763 @opindex Wpointer-arith
1764 The option @option{-Wpointer-arith} requests a warning if these extensions
1765 are used.
1767 @node Pointers to Arrays
1768 @section Pointers to Arrays with Qualifiers Work as Expected
1769 @cindex pointers to arrays
1770 @cindex const qualifier
1772 In GNU C, pointers to arrays with qualifiers work similar to pointers
1773 to other qualified types. For example, a value of type @code{int (*)[5]}
1774 can be used to initialize a variable of type @code{const int (*)[5]}.
1775 These types are incompatible in ISO C because the @code{const} qualifier
1776 is formally attached to the element type of the array and not the
1777 array itself.
1779 @smallexample
1780 extern void
1781 transpose (int N, int M, double out[M][N], const double in[N][M]);
1782 double x[3][2];
1783 double y[2][3];
1784 @r{@dots{}}
1785 transpose(3, 2, y, x);
1786 @end smallexample
1788 @node Initializers
1789 @section Non-Constant Initializers
1790 @cindex initializers, non-constant
1791 @cindex non-constant initializers
1793 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1794 automatic variable are not required to be constant expressions in GNU C@.
1795 Here is an example of an initializer with run-time varying elements:
1797 @smallexample
1798 foo (float f, float g)
1800   float beat_freqs[2] = @{ f-g, f+g @};
1801   /* @r{@dots{}} */
1803 @end smallexample
1805 @node Compound Literals
1806 @section Compound Literals
1807 @cindex constructor expressions
1808 @cindex initializations in expressions
1809 @cindex structures, constructor expression
1810 @cindex expressions, constructor
1811 @cindex compound literals
1812 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1814 ISO C99 supports compound literals.  A compound literal looks like
1815 a cast containing an initializer.  Its value is an object of the
1816 type specified in the cast, containing the elements specified in
1817 the initializer; it is an lvalue.  As an extension, GCC supports
1818 compound literals in C90 mode and in C++, though the semantics are
1819 somewhat different in C++.
1821 Usually, the specified type is a structure.  Assume that
1822 @code{struct foo} and @code{structure} are declared as shown:
1824 @smallexample
1825 struct foo @{int a; char b[2];@} structure;
1826 @end smallexample
1828 @noindent
1829 Here is an example of constructing a @code{struct foo} with a compound literal:
1831 @smallexample
1832 structure = ((struct foo) @{x + y, 'a', 0@});
1833 @end smallexample
1835 @noindent
1836 This is equivalent to writing the following:
1838 @smallexample
1840   struct foo temp = @{x + y, 'a', 0@};
1841   structure = temp;
1843 @end smallexample
1845 You can also construct an array, though this is dangerous in C++, as
1846 explained below.  If all the elements of the compound literal are
1847 (made up of) simple constant expressions, suitable for use in
1848 initializers of objects of static storage duration, then the compound
1849 literal can be coerced to a pointer to its first element and used in
1850 such an initializer, as shown here:
1852 @smallexample
1853 char **foo = (char *[]) @{ "x", "y", "z" @};
1854 @end smallexample
1856 Compound literals for scalar types and union types are
1857 also allowed, but then the compound literal is equivalent
1858 to a cast.
1860 As a GNU extension, GCC allows initialization of objects with static storage
1861 duration by compound literals (which is not possible in ISO C99, because
1862 the initializer is not a constant).
1863 It is handled as if the object is initialized only with the bracket
1864 enclosed list if the types of the compound literal and the object match.
1865 The initializer list of the compound literal must be constant.
1866 If the object being initialized has array type of unknown size, the size is
1867 determined by compound literal size.
1869 @smallexample
1870 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1871 static int y[] = (int []) @{1, 2, 3@};
1872 static int z[] = (int [3]) @{1@};
1873 @end smallexample
1875 @noindent
1876 The above lines are equivalent to the following:
1877 @smallexample
1878 static struct foo x = @{1, 'a', 'b'@};
1879 static int y[] = @{1, 2, 3@};
1880 static int z[] = @{1, 0, 0@};
1881 @end smallexample
1883 In C, a compound literal designates an unnamed object with static or
1884 automatic storage duration.  In C++, a compound literal designates a
1885 temporary object, which only lives until the end of its
1886 full-expression.  As a result, well-defined C code that takes the
1887 address of a subobject of a compound literal can be undefined in C++,
1888 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1889 For instance, if the array compound literal example above appeared
1890 inside a function, any subsequent use of @samp{foo} in C++ has
1891 undefined behavior because the lifetime of the array ends after the
1892 declaration of @samp{foo}.  
1894 As an optimization, the C++ compiler sometimes gives array compound
1895 literals longer lifetimes: when the array either appears outside a
1896 function or has const-qualified type.  If @samp{foo} and its
1897 initializer had elements of @samp{char *const} type rather than
1898 @samp{char *}, or if @samp{foo} were a global variable, the array
1899 would have static storage duration.  But it is probably safest just to
1900 avoid the use of array compound literals in code compiled as C++.
1902 @node Designated Inits
1903 @section Designated Initializers
1904 @cindex initializers with labeled elements
1905 @cindex labeled elements in initializers
1906 @cindex case labels in initializers
1907 @cindex designated initializers
1909 Standard C90 requires the elements of an initializer to appear in a fixed
1910 order, the same as the order of the elements in the array or structure
1911 being initialized.
1913 In ISO C99 you can give the elements in any order, specifying the array
1914 indices or structure field names they apply to, and GNU C allows this as
1915 an extension in C90 mode as well.  This extension is not
1916 implemented in GNU C++.
1918 To specify an array index, write
1919 @samp{[@var{index}] =} before the element value.  For example,
1921 @smallexample
1922 int a[6] = @{ [4] = 29, [2] = 15 @};
1923 @end smallexample
1925 @noindent
1926 is equivalent to
1928 @smallexample
1929 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1930 @end smallexample
1932 @noindent
1933 The index values must be constant expressions, even if the array being
1934 initialized is automatic.
1936 An alternative syntax for this that has been obsolete since GCC 2.5 but
1937 GCC still accepts is to write @samp{[@var{index}]} before the element
1938 value, with no @samp{=}.
1940 To initialize a range of elements to the same value, write
1941 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1942 extension.  For example,
1944 @smallexample
1945 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1946 @end smallexample
1948 @noindent
1949 If the value in it has side-effects, the side-effects happen only once,
1950 not for each initialized field by the range initializer.
1952 @noindent
1953 Note that the length of the array is the highest value specified
1954 plus one.
1956 In a structure initializer, specify the name of a field to initialize
1957 with @samp{.@var{fieldname} =} before the element value.  For example,
1958 given the following structure,
1960 @smallexample
1961 struct point @{ int x, y; @};
1962 @end smallexample
1964 @noindent
1965 the following initialization
1967 @smallexample
1968 struct point p = @{ .y = yvalue, .x = xvalue @};
1969 @end smallexample
1971 @noindent
1972 is equivalent to
1974 @smallexample
1975 struct point p = @{ xvalue, yvalue @};
1976 @end smallexample
1978 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1979 @samp{@var{fieldname}:}, as shown here:
1981 @smallexample
1982 struct point p = @{ y: yvalue, x: xvalue @};
1983 @end smallexample
1985 Omitted field members are implicitly initialized the same as objects
1986 that have static storage duration.
1988 @cindex designators
1989 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1990 @dfn{designator}.  You can also use a designator (or the obsolete colon
1991 syntax) when initializing a union, to specify which element of the union
1992 should be used.  For example,
1994 @smallexample
1995 union foo @{ int i; double d; @};
1997 union foo f = @{ .d = 4 @};
1998 @end smallexample
2000 @noindent
2001 converts 4 to a @code{double} to store it in the union using
2002 the second element.  By contrast, casting 4 to type @code{union foo}
2003 stores it into the union as the integer @code{i}, since it is
2004 an integer.  (@xref{Cast to Union}.)
2006 You can combine this technique of naming elements with ordinary C
2007 initialization of successive elements.  Each initializer element that
2008 does not have a designator applies to the next consecutive element of the
2009 array or structure.  For example,
2011 @smallexample
2012 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2013 @end smallexample
2015 @noindent
2016 is equivalent to
2018 @smallexample
2019 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2020 @end smallexample
2022 Labeling the elements of an array initializer is especially useful
2023 when the indices are characters or belong to an @code{enum} type.
2024 For example:
2026 @smallexample
2027 int whitespace[256]
2028   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2029       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2030 @end smallexample
2032 @cindex designator lists
2033 You can also write a series of @samp{.@var{fieldname}} and
2034 @samp{[@var{index}]} designators before an @samp{=} to specify a
2035 nested subobject to initialize; the list is taken relative to the
2036 subobject corresponding to the closest surrounding brace pair.  For
2037 example, with the @samp{struct point} declaration above:
2039 @smallexample
2040 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2041 @end smallexample
2043 @noindent
2044 If the same field is initialized multiple times, it has the value from
2045 the last initialization.  If any such overridden initialization has
2046 side-effect, it is unspecified whether the side-effect happens or not.
2047 Currently, GCC discards them and issues a warning.
2049 @node Case Ranges
2050 @section Case Ranges
2051 @cindex case ranges
2052 @cindex ranges in case statements
2054 You can specify a range of consecutive values in a single @code{case} label,
2055 like this:
2057 @smallexample
2058 case @var{low} ... @var{high}:
2059 @end smallexample
2061 @noindent
2062 This has the same effect as the proper number of individual @code{case}
2063 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2065 This feature is especially useful for ranges of ASCII character codes:
2067 @smallexample
2068 case 'A' ... 'Z':
2069 @end smallexample
2071 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2072 it may be parsed wrong when you use it with integer values.  For example,
2073 write this:
2075 @smallexample
2076 case 1 ... 5:
2077 @end smallexample
2079 @noindent
2080 rather than this:
2082 @smallexample
2083 case 1...5:
2084 @end smallexample
2086 @node Cast to Union
2087 @section Cast to a Union Type
2088 @cindex cast to a union
2089 @cindex union, casting to a
2091 A cast to union type is similar to other casts, except that the type
2092 specified is a union type.  You can specify the type either with
2093 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2094 a constructor, not a cast, and hence does not yield an lvalue like
2095 normal casts.  (@xref{Compound Literals}.)
2097 The types that may be cast to the union type are those of the members
2098 of the union.  Thus, given the following union and variables:
2100 @smallexample
2101 union foo @{ int i; double d; @};
2102 int x;
2103 double y;
2104 @end smallexample
2106 @noindent
2107 both @code{x} and @code{y} can be cast to type @code{union foo}.
2109 Using the cast as the right-hand side of an assignment to a variable of
2110 union type is equivalent to storing in a member of the union:
2112 @smallexample
2113 union foo u;
2114 /* @r{@dots{}} */
2115 u = (union foo) x  @equiv{}  u.i = x
2116 u = (union foo) y  @equiv{}  u.d = y
2117 @end smallexample
2119 You can also use the union cast as a function argument:
2121 @smallexample
2122 void hack (union foo);
2123 /* @r{@dots{}} */
2124 hack ((union foo) x);
2125 @end smallexample
2127 @node Mixed Declarations
2128 @section Mixed Declarations and Code
2129 @cindex mixed declarations and code
2130 @cindex declarations, mixed with code
2131 @cindex code, mixed with declarations
2133 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2134 within compound statements.  As an extension, GNU C also allows this in
2135 C90 mode.  For example, you could do:
2137 @smallexample
2138 int i;
2139 /* @r{@dots{}} */
2140 i++;
2141 int j = i + 2;
2142 @end smallexample
2144 Each identifier is visible from where it is declared until the end of
2145 the enclosing block.
2147 @node Function Attributes
2148 @section Declaring Attributes of Functions
2149 @cindex function attributes
2150 @cindex declaring attributes of functions
2151 @cindex @code{volatile} applied to function
2152 @cindex @code{const} applied to function
2154 In GNU C, you can use function attributes to declare certain things
2155 about functions called in your program which help the compiler
2156 optimize calls and check your code more carefully.  For example, you
2157 can use attributes to declare that a function never returns
2158 (@code{noreturn}), returns a value depending only on its arguments
2159 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2161 You can also use attributes to control memory placement, code
2162 generation options or call/return conventions within the function
2163 being annotated.  Many of these attributes are target-specific.  For
2164 example, many targets support attributes for defining interrupt
2165 handler functions, which typically must follow special register usage
2166 and return conventions.
2168 Function attributes are introduced by the @code{__attribute__} keyword
2169 on a declaration, followed by an attribute specification inside double
2170 parentheses.  You can specify multiple attributes in a declaration by
2171 separating them by commas within the double parentheses or by
2172 immediately following an attribute declaration with another attribute
2173 declaration.  @xref{Attribute Syntax}, for the exact rules on
2174 attribute syntax and placement.
2176 GCC also supports attributes on
2177 variable declarations (@pxref{Variable Attributes}),
2178 labels (@pxref{Label Attributes}),
2179 enumerators (@pxref{Enumerator Attributes}),
2180 and types (@pxref{Type Attributes}).
2182 There is some overlap between the purposes of attributes and pragmas
2183 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2184 found convenient to use @code{__attribute__} to achieve a natural
2185 attachment of attributes to their corresponding declarations, whereas
2186 @code{#pragma} is of use for compatibility with other compilers
2187 or constructs that do not naturally form part of the grammar.
2189 In addition to the attributes documented here,
2190 GCC plugins may provide their own attributes.
2192 @menu
2193 * Common Function Attributes::
2194 * ARC Function Attributes::
2195 * ARM Function Attributes::
2196 * AVR Function Attributes::
2197 * Blackfin Function Attributes::
2198 * CR16 Function Attributes::
2199 * Epiphany Function Attributes::
2200 * H8/300 Function Attributes::
2201 * IA-64 Function Attributes::
2202 * M32C Function Attributes::
2203 * M32R/D Function Attributes::
2204 * m68k Function Attributes::
2205 * MCORE Function Attributes::
2206 * MeP Function Attributes::
2207 * MicroBlaze Function Attributes::
2208 * Microsoft Windows Function Attributes::
2209 * MIPS Function Attributes::
2210 * MSP430 Function Attributes::
2211 * NDS32 Function Attributes::
2212 * Nios II Function Attributes::
2213 * PowerPC Function Attributes::
2214 * RL78 Function Attributes::
2215 * RX Function Attributes::
2216 * S/390 Function Attributes::
2217 * SH Function Attributes::
2218 * SPU Function Attributes::
2219 * Symbian OS Function Attributes::
2220 * Visium Function Attributes::
2221 * x86 Function Attributes::
2222 * Xstormy16 Function Attributes::
2223 @end menu
2225 @node Common Function Attributes
2226 @subsection Common Function Attributes
2228 The following attributes are supported on most targets.
2230 @table @code
2231 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2233 @item alias ("@var{target}")
2234 @cindex @code{alias} function attribute
2235 The @code{alias} attribute causes the declaration to be emitted as an
2236 alias for another symbol, which must be specified.  For instance,
2238 @smallexample
2239 void __f () @{ /* @r{Do something.} */; @}
2240 void f () __attribute__ ((weak, alias ("__f")));
2241 @end smallexample
2243 @noindent
2244 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2245 mangled name for the target must be used.  It is an error if @samp{__f}
2246 is not defined in the same translation unit.
2248 This attribute requires assembler and object file support,
2249 and may not be available on all targets.
2251 @item aligned (@var{alignment})
2252 @cindex @code{aligned} function attribute
2253 This attribute specifies a minimum alignment for the function,
2254 measured in bytes.
2256 You cannot use this attribute to decrease the alignment of a function,
2257 only to increase it.  However, when you explicitly specify a function
2258 alignment this overrides the effect of the
2259 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2260 function.
2262 Note that the effectiveness of @code{aligned} attributes may be
2263 limited by inherent limitations in your linker.  On many systems, the
2264 linker is only able to arrange for functions to be aligned up to a
2265 certain maximum alignment.  (For some linkers, the maximum supported
2266 alignment may be very very small.)  See your linker documentation for
2267 further information.
2269 The @code{aligned} attribute can also be used for variables and fields
2270 (@pxref{Variable Attributes}.)
2272 @item alloc_align
2273 @cindex @code{alloc_align} function attribute
2274 The @code{alloc_align} attribute is used to tell the compiler that the
2275 function return value points to memory, where the returned pointer minimum
2276 alignment is given by one of the functions parameters.  GCC uses this
2277 information to improve pointer alignment analysis.
2279 The function parameter denoting the allocated alignment is specified by
2280 one integer argument, whose number is the argument of the attribute.
2281 Argument numbering starts at one.
2283 For instance,
2285 @smallexample
2286 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2287 @end smallexample
2289 @noindent
2290 declares that @code{my_memalign} returns memory with minimum alignment
2291 given by parameter 1.
2293 @item alloc_size
2294 @cindex @code{alloc_size} function attribute
2295 The @code{alloc_size} attribute is used to tell the compiler that the
2296 function return value points to memory, where the size is given by
2297 one or two of the functions parameters.  GCC uses this
2298 information to improve the correctness of @code{__builtin_object_size}.
2300 The function parameter(s) denoting the allocated size are specified by
2301 one or two integer arguments supplied to the attribute.  The allocated size
2302 is either the value of the single function argument specified or the product
2303 of the two function arguments specified.  Argument numbering starts at
2304 one.
2306 For instance,
2308 @smallexample
2309 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2310 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2311 @end smallexample
2313 @noindent
2314 declares that @code{my_calloc} returns memory of the size given by
2315 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2316 of the size given by parameter 2.
2318 @item always_inline
2319 @cindex @code{always_inline} function attribute
2320 Generally, functions are not inlined unless optimization is specified.
2321 For functions declared inline, this attribute inlines the function
2322 independent of any restrictions that otherwise apply to inlining.
2323 Failure to inline such a function is diagnosed as an error.
2324 Note that if such a function is called indirectly the compiler may
2325 or may not inline it depending on optimization level and a failure
2326 to inline an indirect call may or may not be diagnosed.
2328 @item artificial
2329 @cindex @code{artificial} function attribute
2330 This attribute is useful for small inline wrappers that if possible
2331 should appear during debugging as a unit.  Depending on the debug
2332 info format it either means marking the function as artificial
2333 or using the caller location for all instructions within the inlined
2334 body.
2336 @item assume_aligned
2337 @cindex @code{assume_aligned} function attribute
2338 The @code{assume_aligned} attribute is used to tell the compiler that the
2339 function return value points to memory, where the returned pointer minimum
2340 alignment is given by the first argument.
2341 If the attribute has two arguments, the second argument is misalignment offset.
2343 For instance
2345 @smallexample
2346 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2347 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2348 @end smallexample
2350 @noindent
2351 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2352 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2353 to 8.
2355 @item bnd_instrument
2356 @cindex @code{bnd_instrument} function attribute
2357 The @code{bnd_instrument} attribute on functions is used to inform the
2358 compiler that the function should be instrumented when compiled
2359 with the @option{-fchkp-instrument-marked-only} option.
2361 @item bnd_legacy
2362 @cindex @code{bnd_legacy} function attribute
2363 @cindex Pointer Bounds Checker attributes
2364 The @code{bnd_legacy} attribute on functions is used to inform the
2365 compiler that the function should not be instrumented when compiled
2366 with the @option{-fcheck-pointer-bounds} option.
2368 @item cold
2369 @cindex @code{cold} function attribute
2370 The @code{cold} attribute on functions is used to inform the compiler that
2371 the function is unlikely to be executed.  The function is optimized for
2372 size rather than speed and on many targets it is placed into a special
2373 subsection of the text section so all cold functions appear close together,
2374 improving code locality of non-cold parts of program.  The paths leading
2375 to calls of cold functions within code are marked as unlikely by the branch
2376 prediction mechanism.  It is thus useful to mark functions used to handle
2377 unlikely conditions, such as @code{perror}, as cold to improve optimization
2378 of hot functions that do call marked functions in rare occasions.
2380 When profile feedback is available, via @option{-fprofile-use}, cold functions
2381 are automatically detected and this attribute is ignored.
2383 @item const
2384 @cindex @code{const} function attribute
2385 @cindex functions that have no side effects
2386 Many functions do not examine any values except their arguments, and
2387 have no effects except the return value.  Basically this is just slightly
2388 more strict class than the @code{pure} attribute below, since function is not
2389 allowed to read global memory.
2391 @cindex pointer arguments
2392 Note that a function that has pointer arguments and examines the data
2393 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2394 function that calls a non-@code{const} function usually must not be
2395 @code{const}.  It does not make sense for a @code{const} function to
2396 return @code{void}.
2398 @item constructor
2399 @itemx destructor
2400 @itemx constructor (@var{priority})
2401 @itemx destructor (@var{priority})
2402 @cindex @code{constructor} function attribute
2403 @cindex @code{destructor} function attribute
2404 The @code{constructor} attribute causes the function to be called
2405 automatically before execution enters @code{main ()}.  Similarly, the
2406 @code{destructor} attribute causes the function to be called
2407 automatically after @code{main ()} completes or @code{exit ()} is
2408 called.  Functions with these attributes are useful for
2409 initializing data that is used implicitly during the execution of
2410 the program.
2412 You may provide an optional integer priority to control the order in
2413 which constructor and destructor functions are run.  A constructor
2414 with a smaller priority number runs before a constructor with a larger
2415 priority number; the opposite relationship holds for destructors.  So,
2416 if you have a constructor that allocates a resource and a destructor
2417 that deallocates the same resource, both functions typically have the
2418 same priority.  The priorities for constructor and destructor
2419 functions are the same as those specified for namespace-scope C++
2420 objects (@pxref{C++ Attributes}).
2422 These attributes are not currently implemented for Objective-C@.
2424 @item deprecated
2425 @itemx deprecated (@var{msg})
2426 @cindex @code{deprecated} function attribute
2427 The @code{deprecated} attribute results in a warning if the function
2428 is used anywhere in the source file.  This is useful when identifying
2429 functions that are expected to be removed in a future version of a
2430 program.  The warning also includes the location of the declaration
2431 of the deprecated function, to enable users to easily find further
2432 information about why the function is deprecated, or what they should
2433 do instead.  Note that the warnings only occurs for uses:
2435 @smallexample
2436 int old_fn () __attribute__ ((deprecated));
2437 int old_fn ();
2438 int (*fn_ptr)() = old_fn;
2439 @end smallexample
2441 @noindent
2442 results in a warning on line 3 but not line 2.  The optional @var{msg}
2443 argument, which must be a string, is printed in the warning if
2444 present.
2446 The @code{deprecated} attribute can also be used for variables and
2447 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2449 @item error ("@var{message}")
2450 @itemx warning ("@var{message}")
2451 @cindex @code{error} function attribute
2452 @cindex @code{warning} function attribute
2453 If the @code{error} or @code{warning} attribute 
2454 is used on a function declaration and a call to such a function
2455 is not eliminated through dead code elimination or other optimizations, 
2456 an error or warning (respectively) that includes @var{message} is diagnosed.  
2457 This is useful
2458 for compile-time checking, especially together with @code{__builtin_constant_p}
2459 and inline functions where checking the inline function arguments is not
2460 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2462 While it is possible to leave the function undefined and thus invoke
2463 a link failure (to define the function with
2464 a message in @code{.gnu.warning*} section),
2465 when using these attributes the problem is diagnosed
2466 earlier and with exact location of the call even in presence of inline
2467 functions or when not emitting debugging information.
2469 @item externally_visible
2470 @cindex @code{externally_visible} function attribute
2471 This attribute, attached to a global variable or function, nullifies
2472 the effect of the @option{-fwhole-program} command-line option, so the
2473 object remains visible outside the current compilation unit.
2475 If @option{-fwhole-program} is used together with @option{-flto} and 
2476 @command{gold} is used as the linker plugin, 
2477 @code{externally_visible} attributes are automatically added to functions 
2478 (not variable yet due to a current @command{gold} issue) 
2479 that are accessed outside of LTO objects according to resolution file
2480 produced by @command{gold}.
2481 For other linkers that cannot generate resolution file,
2482 explicit @code{externally_visible} attributes are still necessary.
2484 @item flatten
2485 @cindex @code{flatten} function attribute
2486 Generally, inlining into a function is limited.  For a function marked with
2487 this attribute, every call inside this function is inlined, if possible.
2488 Whether the function itself is considered for inlining depends on its size and
2489 the current inlining parameters.
2491 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2492 @cindex @code{format} function attribute
2493 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2494 @opindex Wformat
2495 The @code{format} attribute specifies that a function takes @code{printf},
2496 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2497 should be type-checked against a format string.  For example, the
2498 declaration:
2500 @smallexample
2501 extern int
2502 my_printf (void *my_object, const char *my_format, ...)
2503       __attribute__ ((format (printf, 2, 3)));
2504 @end smallexample
2506 @noindent
2507 causes the compiler to check the arguments in calls to @code{my_printf}
2508 for consistency with the @code{printf} style format string argument
2509 @code{my_format}.
2511 The parameter @var{archetype} determines how the format string is
2512 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2513 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2514 @code{strfmon}.  (You can also use @code{__printf__},
2515 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2516 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2517 @code{ms_strftime} are also present.
2518 @var{archetype} values such as @code{printf} refer to the formats accepted
2519 by the system's C runtime library,
2520 while values prefixed with @samp{gnu_} always refer
2521 to the formats accepted by the GNU C Library.  On Microsoft Windows
2522 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2523 @file{msvcrt.dll} library.
2524 The parameter @var{string-index}
2525 specifies which argument is the format string argument (starting
2526 from 1), while @var{first-to-check} is the number of the first
2527 argument to check against the format string.  For functions
2528 where the arguments are not available to be checked (such as
2529 @code{vprintf}), specify the third parameter as zero.  In this case the
2530 compiler only checks the format string for consistency.  For
2531 @code{strftime} formats, the third parameter is required to be zero.
2532 Since non-static C++ methods have an implicit @code{this} argument, the
2533 arguments of such methods should be counted from two, not one, when
2534 giving values for @var{string-index} and @var{first-to-check}.
2536 In the example above, the format string (@code{my_format}) is the second
2537 argument of the function @code{my_print}, and the arguments to check
2538 start with the third argument, so the correct parameters for the format
2539 attribute are 2 and 3.
2541 @opindex ffreestanding
2542 @opindex fno-builtin
2543 The @code{format} attribute allows you to identify your own functions
2544 that take format strings as arguments, so that GCC can check the
2545 calls to these functions for errors.  The compiler always (unless
2546 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2547 for the standard library functions @code{printf}, @code{fprintf},
2548 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2549 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2550 warnings are requested (using @option{-Wformat}), so there is no need to
2551 modify the header file @file{stdio.h}.  In C99 mode, the functions
2552 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2553 @code{vsscanf} are also checked.  Except in strictly conforming C
2554 standard modes, the X/Open function @code{strfmon} is also checked as
2555 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2556 @xref{C Dialect Options,,Options Controlling C Dialect}.
2558 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2559 recognized in the same context.  Declarations including these format attributes
2560 are parsed for correct syntax, however the result of checking of such format
2561 strings is not yet defined, and is not carried out by this version of the
2562 compiler.
2564 The target may also provide additional types of format checks.
2565 @xref{Target Format Checks,,Format Checks Specific to Particular
2566 Target Machines}.
2568 @item format_arg (@var{string-index})
2569 @cindex @code{format_arg} function attribute
2570 @opindex Wformat-nonliteral
2571 The @code{format_arg} attribute specifies that a function takes a format
2572 string for a @code{printf}, @code{scanf}, @code{strftime} or
2573 @code{strfmon} style function and modifies it (for example, to translate
2574 it into another language), so the result can be passed to a
2575 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2576 function (with the remaining arguments to the format function the same
2577 as they would have been for the unmodified string).  For example, the
2578 declaration:
2580 @smallexample
2581 extern char *
2582 my_dgettext (char *my_domain, const char *my_format)
2583       __attribute__ ((format_arg (2)));
2584 @end smallexample
2586 @noindent
2587 causes the compiler to check the arguments in calls to a @code{printf},
2588 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2589 format string argument is a call to the @code{my_dgettext} function, for
2590 consistency with the format string argument @code{my_format}.  If the
2591 @code{format_arg} attribute had not been specified, all the compiler
2592 could tell in such calls to format functions would be that the format
2593 string argument is not constant; this would generate a warning when
2594 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2595 without the attribute.
2597 The parameter @var{string-index} specifies which argument is the format
2598 string argument (starting from one).  Since non-static C++ methods have
2599 an implicit @code{this} argument, the arguments of such methods should
2600 be counted from two.
2602 The @code{format_arg} attribute allows you to identify your own
2603 functions that modify format strings, so that GCC can check the
2604 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2605 type function whose operands are a call to one of your own function.
2606 The compiler always treats @code{gettext}, @code{dgettext}, and
2607 @code{dcgettext} in this manner except when strict ISO C support is
2608 requested by @option{-ansi} or an appropriate @option{-std} option, or
2609 @option{-ffreestanding} or @option{-fno-builtin}
2610 is used.  @xref{C Dialect Options,,Options
2611 Controlling C Dialect}.
2613 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2614 @code{NSString} reference for compatibility with the @code{format} attribute
2615 above.
2617 The target may also allow additional types in @code{format-arg} attributes.
2618 @xref{Target Format Checks,,Format Checks Specific to Particular
2619 Target Machines}.
2621 @item gnu_inline
2622 @cindex @code{gnu_inline} function attribute
2623 This attribute should be used with a function that is also declared
2624 with the @code{inline} keyword.  It directs GCC to treat the function
2625 as if it were defined in gnu90 mode even when compiling in C99 or
2626 gnu99 mode.
2628 If the function is declared @code{extern}, then this definition of the
2629 function is used only for inlining.  In no case is the function
2630 compiled as a standalone function, not even if you take its address
2631 explicitly.  Such an address becomes an external reference, as if you
2632 had only declared the function, and had not defined it.  This has
2633 almost the effect of a macro.  The way to use this is to put a
2634 function definition in a header file with this attribute, and put
2635 another copy of the function, without @code{extern}, in a library
2636 file.  The definition in the header file causes most calls to the
2637 function to be inlined.  If any uses of the function remain, they
2638 refer to the single copy in the library.  Note that the two
2639 definitions of the functions need not be precisely the same, although
2640 if they do not have the same effect your program may behave oddly.
2642 In C, if the function is neither @code{extern} nor @code{static}, then
2643 the function is compiled as a standalone function, as well as being
2644 inlined where possible.
2646 This is how GCC traditionally handled functions declared
2647 @code{inline}.  Since ISO C99 specifies a different semantics for
2648 @code{inline}, this function attribute is provided as a transition
2649 measure and as a useful feature in its own right.  This attribute is
2650 available in GCC 4.1.3 and later.  It is available if either of the
2651 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2652 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2653 Function is As Fast As a Macro}.
2655 In C++, this attribute does not depend on @code{extern} in any way,
2656 but it still requires the @code{inline} keyword to enable its special
2657 behavior.
2659 @item hot
2660 @cindex @code{hot} function attribute
2661 The @code{hot} attribute on a function is used to inform the compiler that
2662 the function is a hot spot of the compiled program.  The function is
2663 optimized more aggressively and on many targets it is placed into a special
2664 subsection of the text section so all hot functions appear close together,
2665 improving locality.
2667 When profile feedback is available, via @option{-fprofile-use}, hot functions
2668 are automatically detected and this attribute is ignored.
2670 @item ifunc ("@var{resolver}")
2671 @cindex @code{ifunc} function attribute
2672 @cindex indirect functions
2673 @cindex functions that are dynamically resolved
2674 The @code{ifunc} attribute is used to mark a function as an indirect
2675 function using the STT_GNU_IFUNC symbol type extension to the ELF
2676 standard.  This allows the resolution of the symbol value to be
2677 determined dynamically at load time, and an optimized version of the
2678 routine can be selected for the particular processor or other system
2679 characteristics determined then.  To use this attribute, first define
2680 the implementation functions available, and a resolver function that
2681 returns a pointer to the selected implementation function.  The
2682 implementation functions' declarations must match the API of the
2683 function being implemented, the resolver's declaration is be a
2684 function returning pointer to void function returning void:
2686 @smallexample
2687 void *my_memcpy (void *dst, const void *src, size_t len)
2689   @dots{}
2692 static void (*resolve_memcpy (void)) (void)
2694   return my_memcpy; // we'll just always select this routine
2696 @end smallexample
2698 @noindent
2699 The exported header file declaring the function the user calls would
2700 contain:
2702 @smallexample
2703 extern void *memcpy (void *, const void *, size_t);
2704 @end smallexample
2706 @noindent
2707 allowing the user to call this as a regular function, unaware of the
2708 implementation.  Finally, the indirect function needs to be defined in
2709 the same translation unit as the resolver function:
2711 @smallexample
2712 void *memcpy (void *, const void *, size_t)
2713      __attribute__ ((ifunc ("resolve_memcpy")));
2714 @end smallexample
2716 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2717 and GNU C Library version 2.11.1 are required to use this feature.
2719 @item interrupt
2720 @itemx interrupt_handler
2721 Many GCC back ends support attributes to indicate that a function is
2722 an interrupt handler, which tells the compiler to generate function
2723 entry and exit sequences that differ from those from regular
2724 functions.  The exact syntax and behavior are target-specific;
2725 refer to the following subsections for details.
2727 @item leaf
2728 @cindex @code{leaf} function attribute
2729 Calls to external functions with this attribute must return to the current
2730 compilation unit only by return or by exception handling.  In particular, leaf
2731 functions are not allowed to call callback function passed to it from the current
2732 compilation unit or directly call functions exported by the unit or longjmp
2733 into the unit.  Leaf function might still call functions from other compilation
2734 units and thus they are not necessarily leaf in the sense that they contain no
2735 function calls at all.
2737 The attribute is intended for library functions to improve dataflow analysis.
2738 The compiler takes the hint that any data not escaping the current compilation unit can
2739 not be used or modified by the leaf function.  For example, the @code{sin} function
2740 is a leaf function, but @code{qsort} is not.
2742 Note that leaf functions might invoke signals and signal handlers might be
2743 defined in the current compilation unit and use static variables.  The only
2744 compliant way to write such a signal handler is to declare such variables
2745 @code{volatile}.
2747 The attribute has no effect on functions defined within the current compilation
2748 unit.  This is to allow easy merging of multiple compilation units into one,
2749 for example, by using the link-time optimization.  For this reason the
2750 attribute is not allowed on types to annotate indirect calls.
2753 @item malloc
2754 @cindex @code{malloc} function attribute
2755 @cindex functions that behave like malloc
2756 This tells the compiler that a function is @code{malloc}-like, i.e.,
2757 that the pointer @var{P} returned by the function cannot alias any
2758 other pointer valid when the function returns, and moreover no
2759 pointers to valid objects occur in any storage addressed by @var{P}.
2761 Using this attribute can improve optimization.  Functions like
2762 @code{malloc} and @code{calloc} have this property because they return
2763 a pointer to uninitialized or zeroed-out storage.  However, functions
2764 like @code{realloc} do not have this property, as they can return a
2765 pointer to storage containing pointers.
2767 @item no_icf
2768 @cindex @code{no_icf} function attribute
2769 This function attribute prevents a functions from being merged with another
2770 semantically equivalent function.
2772 @item no_instrument_function
2773 @cindex @code{no_instrument_function} function attribute
2774 @opindex finstrument-functions
2775 If @option{-finstrument-functions} is given, profiling function calls are
2776 generated at entry and exit of most user-compiled functions.
2777 Functions with this attribute are not so instrumented.
2779 @item no_reorder
2780 @cindex @code{no_reorder} function attribute
2781 Do not reorder functions or variables marked @code{no_reorder}
2782 against each other or top level assembler statements the executable.
2783 The actual order in the program will depend on the linker command
2784 line. Static variables marked like this are also not removed.
2785 This has a similar effect
2786 as the @option{-fno-toplevel-reorder} option, but only applies to the
2787 marked symbols.
2789 @item no_sanitize_address
2790 @itemx no_address_safety_analysis
2791 @cindex @code{no_sanitize_address} function attribute
2792 The @code{no_sanitize_address} attribute on functions is used
2793 to inform the compiler that it should not instrument memory accesses
2794 in the function when compiling with the @option{-fsanitize=address} option.
2795 The @code{no_address_safety_analysis} is a deprecated alias of the
2796 @code{no_sanitize_address} attribute, new code should use
2797 @code{no_sanitize_address}.
2799 @item no_sanitize_thread
2800 @cindex @code{no_sanitize_thread} function attribute
2801 The @code{no_sanitize_thread} attribute on functions is used
2802 to inform the compiler that it should not instrument memory accesses
2803 in the function when compiling with the @option{-fsanitize=thread} option.
2805 @item no_sanitize_undefined
2806 @cindex @code{no_sanitize_undefined} function attribute
2807 The @code{no_sanitize_undefined} attribute on functions is used
2808 to inform the compiler that it should not check for undefined behavior
2809 in the function when compiling with the @option{-fsanitize=undefined} option.
2811 @item no_split_stack
2812 @cindex @code{no_split_stack} function attribute
2813 @opindex fsplit-stack
2814 If @option{-fsplit-stack} is given, functions have a small
2815 prologue which decides whether to split the stack.  Functions with the
2816 @code{no_split_stack} attribute do not have that prologue, and thus
2817 may run with only a small amount of stack space available.
2819 @item noclone
2820 @cindex @code{noclone} function attribute
2821 This function attribute prevents a function from being considered for
2822 cloning---a mechanism that produces specialized copies of functions
2823 and which is (currently) performed by interprocedural constant
2824 propagation.
2826 @item noinline
2827 @cindex @code{noinline} function attribute
2828 This function attribute prevents a function from being considered for
2829 inlining.
2830 @c Don't enumerate the optimizations by name here; we try to be
2831 @c future-compatible with this mechanism.
2832 If the function does not have side-effects, there are optimizations
2833 other than inlining that cause function calls to be optimized away,
2834 although the function call is live.  To keep such calls from being
2835 optimized away, put
2836 @smallexample
2837 asm ("");
2838 @end smallexample
2840 @noindent
2841 (@pxref{Extended Asm}) in the called function, to serve as a special
2842 side-effect.
2844 @item nonnull (@var{arg-index}, @dots{})
2845 @cindex @code{nonnull} function attribute
2846 @cindex functions with non-null pointer arguments
2847 The @code{nonnull} attribute specifies that some function parameters should
2848 be non-null pointers.  For instance, the declaration:
2850 @smallexample
2851 extern void *
2852 my_memcpy (void *dest, const void *src, size_t len)
2853         __attribute__((nonnull (1, 2)));
2854 @end smallexample
2856 @noindent
2857 causes the compiler to check that, in calls to @code{my_memcpy},
2858 arguments @var{dest} and @var{src} are non-null.  If the compiler
2859 determines that a null pointer is passed in an argument slot marked
2860 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2861 is issued.  The compiler may also choose to make optimizations based
2862 on the knowledge that certain function arguments will never be null.
2864 If no argument index list is given to the @code{nonnull} attribute,
2865 all pointer arguments are marked as non-null.  To illustrate, the
2866 following declaration is equivalent to the previous example:
2868 @smallexample
2869 extern void *
2870 my_memcpy (void *dest, const void *src, size_t len)
2871         __attribute__((nonnull));
2872 @end smallexample
2874 @item noreturn
2875 @cindex @code{noreturn} function attribute
2876 @cindex functions that never return
2877 A few standard library functions, such as @code{abort} and @code{exit},
2878 cannot return.  GCC knows this automatically.  Some programs define
2879 their own functions that never return.  You can declare them
2880 @code{noreturn} to tell the compiler this fact.  For example,
2882 @smallexample
2883 @group
2884 void fatal () __attribute__ ((noreturn));
2886 void
2887 fatal (/* @r{@dots{}} */)
2889   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2890   exit (1);
2892 @end group
2893 @end smallexample
2895 The @code{noreturn} keyword tells the compiler to assume that
2896 @code{fatal} cannot return.  It can then optimize without regard to what
2897 would happen if @code{fatal} ever did return.  This makes slightly
2898 better code.  More importantly, it helps avoid spurious warnings of
2899 uninitialized variables.
2901 The @code{noreturn} keyword does not affect the exceptional path when that
2902 applies: a @code{noreturn}-marked function may still return to the caller
2903 by throwing an exception or calling @code{longjmp}.
2905 Do not assume that registers saved by the calling function are
2906 restored before calling the @code{noreturn} function.
2908 It does not make sense for a @code{noreturn} function to have a return
2909 type other than @code{void}.
2911 @item nothrow
2912 @cindex @code{nothrow} function attribute
2913 The @code{nothrow} attribute is used to inform the compiler that a
2914 function cannot throw an exception.  For example, most functions in
2915 the standard C library can be guaranteed not to throw an exception
2916 with the notable exceptions of @code{qsort} and @code{bsearch} that
2917 take function pointer arguments.
2919 @item noplt
2920 @cindex @code{noplt} function attribute
2921 The @code{noplt} attribute is the counterpart to option @option{-fno-plt} and
2922 does not use PLT for calls to functions marked with this attribute in position
2923 independent code. 
2925 @smallexample
2926 @group
2927 /* Externally defined function foo.  */
2928 int foo () __attribute__ ((noplt));
2931 main (/* @r{@dots{}} */)
2933   /* @r{@dots{}} */
2934   foo ();
2935   /* @r{@dots{}} */
2937 @end group
2938 @end smallexample
2940 The @code{noplt} attribute on function foo tells the compiler to assume that
2941 the function foo is externally defined and the call to foo must avoid the PLT
2942 in position independent code.
2944 Additionally, a few targets also convert calls to those functions that are
2945 marked to not use the PLT to use the GOT instead for non-position independent
2946 code.
2948 @item optimize
2949 @cindex @code{optimize} function attribute
2950 The @code{optimize} attribute is used to specify that a function is to
2951 be compiled with different optimization options than specified on the
2952 command line.  Arguments can either be numbers or strings.  Numbers
2953 are assumed to be an optimization level.  Strings that begin with
2954 @code{O} are assumed to be an optimization option, while other options
2955 are assumed to be used with a @code{-f} prefix.  You can also use the
2956 @samp{#pragma GCC optimize} pragma to set the optimization options
2957 that affect more than one function.
2958 @xref{Function Specific Option Pragmas}, for details about the
2959 @samp{#pragma GCC optimize} pragma.
2961 This can be used for instance to have frequently-executed functions
2962 compiled with more aggressive optimization options that produce faster
2963 and larger code, while other functions can be compiled with less
2964 aggressive options.
2966 @item pure
2967 @cindex @code{pure} function attribute
2968 @cindex functions that have no side effects
2969 Many functions have no effects except the return value and their
2970 return value depends only on the parameters and/or global variables.
2971 Such a function can be subject
2972 to common subexpression elimination and loop optimization just as an
2973 arithmetic operator would be.  These functions should be declared
2974 with the attribute @code{pure}.  For example,
2976 @smallexample
2977 int square (int) __attribute__ ((pure));
2978 @end smallexample
2980 @noindent
2981 says that the hypothetical function @code{square} is safe to call
2982 fewer times than the program says.
2984 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
2985 Interesting non-pure functions are functions with infinite loops or those
2986 depending on volatile memory or other system resource, that may change between
2987 two consecutive calls (such as @code{feof} in a multithreading environment).
2989 @item returns_nonnull
2990 @cindex @code{returns_nonnull} function attribute
2991 The @code{returns_nonnull} attribute specifies that the function
2992 return value should be a non-null pointer.  For instance, the declaration:
2994 @smallexample
2995 extern void *
2996 mymalloc (size_t len) __attribute__((returns_nonnull));
2997 @end smallexample
2999 @noindent
3000 lets the compiler optimize callers based on the knowledge
3001 that the return value will never be null.
3003 @item returns_twice
3004 @cindex @code{returns_twice} function attribute
3005 @cindex functions that return more than once
3006 The @code{returns_twice} attribute tells the compiler that a function may
3007 return more than one time.  The compiler ensures that all registers
3008 are dead before calling such a function and emits a warning about
3009 the variables that may be clobbered after the second return from the
3010 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3011 The @code{longjmp}-like counterpart of such function, if any, might need
3012 to be marked with the @code{noreturn} attribute.
3014 @item section ("@var{section-name}")
3015 @cindex @code{section} function attribute
3016 @cindex functions in arbitrary sections
3017 Normally, the compiler places the code it generates in the @code{text} section.
3018 Sometimes, however, you need additional sections, or you need certain
3019 particular functions to appear in special sections.  The @code{section}
3020 attribute specifies that a function lives in a particular section.
3021 For example, the declaration:
3023 @smallexample
3024 extern void foobar (void) __attribute__ ((section ("bar")));
3025 @end smallexample
3027 @noindent
3028 puts the function @code{foobar} in the @code{bar} section.
3030 Some file formats do not support arbitrary sections so the @code{section}
3031 attribute is not available on all platforms.
3032 If you need to map the entire contents of a module to a particular
3033 section, consider using the facilities of the linker instead.
3035 @item sentinel
3036 @cindex @code{sentinel} function attribute
3037 This function attribute ensures that a parameter in a function call is
3038 an explicit @code{NULL}.  The attribute is only valid on variadic
3039 functions.  By default, the sentinel is located at position zero, the
3040 last parameter of the function call.  If an optional integer position
3041 argument P is supplied to the attribute, the sentinel must be located at
3042 position P counting backwards from the end of the argument list.
3044 @smallexample
3045 __attribute__ ((sentinel))
3046 is equivalent to
3047 __attribute__ ((sentinel(0)))
3048 @end smallexample
3050 The attribute is automatically set with a position of 0 for the built-in
3051 functions @code{execl} and @code{execlp}.  The built-in function
3052 @code{execle} has the attribute set with a position of 1.
3054 A valid @code{NULL} in this context is defined as zero with any pointer
3055 type.  If your system defines the @code{NULL} macro with an integer type
3056 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3057 with a copy that redefines NULL appropriately.
3059 The warnings for missing or incorrect sentinels are enabled with
3060 @option{-Wformat}.
3062 @item stack_protect
3063 @cindex @code{stack_protect} function attribute
3064 This function attribute make a stack protection of the function if 
3065 flags @option{fstack-protector} or @option{fstack-protector-strong}
3066 or @option{fstack-protector-explicit} are set.
3068 @item target (@var{options})
3069 @cindex @code{target} function attribute
3070 Multiple target back ends implement the @code{target} attribute
3071 to specify that a function is to
3072 be compiled with different target options than specified on the
3073 command line.  This can be used for instance to have functions
3074 compiled with a different ISA (instruction set architecture) than the
3075 default.  You can also use the @samp{#pragma GCC target} pragma to set
3076 more than one function to be compiled with specific target options.
3077 @xref{Function Specific Option Pragmas}, for details about the
3078 @samp{#pragma GCC target} pragma.
3080 For instance, on an x86, you could declare one function with the
3081 @code{target("sse4.1,arch=core2")} attribute and another with
3082 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3083 compiling the first function with @option{-msse4.1} and
3084 @option{-march=core2} options, and the second function with
3085 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3086 to make sure that a function is only invoked on a machine that
3087 supports the particular ISA it is compiled for (for example by using
3088 @code{cpuid} on x86 to determine what feature bits and architecture
3089 family are used).
3091 @smallexample
3092 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3093 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3094 @end smallexample
3096 You can either use multiple
3097 strings separated by commas to specify multiple options,
3098 or separate the options with a comma (@samp{,}) within a single string.
3100 The options supported are specific to each target; refer to @ref{x86
3101 Function Attributes}, @ref{PowerPC Function Attributes},
3102 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3103 for details.
3105 @item unused
3106 @cindex @code{unused} function attribute
3107 This attribute, attached to a function, means that the function is meant
3108 to be possibly unused.  GCC does not produce a warning for this
3109 function.
3111 @item used
3112 @cindex @code{used} function attribute
3113 This attribute, attached to a function, means that code must be emitted
3114 for the function even if it appears that the function is not referenced.
3115 This is useful, for example, when the function is referenced only in
3116 inline assembly.
3118 When applied to a member function of a C++ class template, the
3119 attribute also means that the function is instantiated if the
3120 class itself is instantiated.
3122 @item visibility ("@var{visibility_type}")
3123 @cindex @code{visibility} function attribute
3124 This attribute affects the linkage of the declaration to which it is attached.
3125 There are four supported @var{visibility_type} values: default,
3126 hidden, protected or internal visibility.
3128 @smallexample
3129 void __attribute__ ((visibility ("protected")))
3130 f () @{ /* @r{Do something.} */; @}
3131 int i __attribute__ ((visibility ("hidden")));
3132 @end smallexample
3134 The possible values of @var{visibility_type} correspond to the
3135 visibility settings in the ELF gABI.
3137 @table @code
3138 @c keep this list of visibilities in alphabetical order.
3140 @item default
3141 Default visibility is the normal case for the object file format.
3142 This value is available for the visibility attribute to override other
3143 options that may change the assumed visibility of entities.
3145 On ELF, default visibility means that the declaration is visible to other
3146 modules and, in shared libraries, means that the declared entity may be
3147 overridden.
3149 On Darwin, default visibility means that the declaration is visible to
3150 other modules.
3152 Default visibility corresponds to ``external linkage'' in the language.
3154 @item hidden
3155 Hidden visibility indicates that the entity declared has a new
3156 form of linkage, which we call ``hidden linkage''.  Two
3157 declarations of an object with hidden linkage refer to the same object
3158 if they are in the same shared object.
3160 @item internal
3161 Internal visibility is like hidden visibility, but with additional
3162 processor specific semantics.  Unless otherwise specified by the
3163 psABI, GCC defines internal visibility to mean that a function is
3164 @emph{never} called from another module.  Compare this with hidden
3165 functions which, while they cannot be referenced directly by other
3166 modules, can be referenced indirectly via function pointers.  By
3167 indicating that a function cannot be called from outside the module,
3168 GCC may for instance omit the load of a PIC register since it is known
3169 that the calling function loaded the correct value.
3171 @item protected
3172 Protected visibility is like default visibility except that it
3173 indicates that references within the defining module bind to the
3174 definition in that module.  That is, the declared entity cannot be
3175 overridden by another module.
3177 @end table
3179 All visibilities are supported on many, but not all, ELF targets
3180 (supported when the assembler supports the @samp{.visibility}
3181 pseudo-op).  Default visibility is supported everywhere.  Hidden
3182 visibility is supported on Darwin targets.
3184 The visibility attribute should be applied only to declarations that
3185 would otherwise have external linkage.  The attribute should be applied
3186 consistently, so that the same entity should not be declared with
3187 different settings of the attribute.
3189 In C++, the visibility attribute applies to types as well as functions
3190 and objects, because in C++ types have linkage.  A class must not have
3191 greater visibility than its non-static data member types and bases,
3192 and class members default to the visibility of their class.  Also, a
3193 declaration without explicit visibility is limited to the visibility
3194 of its type.
3196 In C++, you can mark member functions and static member variables of a
3197 class with the visibility attribute.  This is useful if you know a
3198 particular method or static member variable should only be used from
3199 one shared object; then you can mark it hidden while the rest of the
3200 class has default visibility.  Care must be taken to avoid breaking
3201 the One Definition Rule; for example, it is usually not useful to mark
3202 an inline method as hidden without marking the whole class as hidden.
3204 A C++ namespace declaration can also have the visibility attribute.
3206 @smallexample
3207 namespace nspace1 __attribute__ ((visibility ("protected")))
3208 @{ /* @r{Do something.} */; @}
3209 @end smallexample
3211 This attribute applies only to the particular namespace body, not to
3212 other definitions of the same namespace; it is equivalent to using
3213 @samp{#pragma GCC visibility} before and after the namespace
3214 definition (@pxref{Visibility Pragmas}).
3216 In C++, if a template argument has limited visibility, this
3217 restriction is implicitly propagated to the template instantiation.
3218 Otherwise, template instantiations and specializations default to the
3219 visibility of their template.
3221 If both the template and enclosing class have explicit visibility, the
3222 visibility from the template is used.
3224 @item warn_unused_result
3225 @cindex @code{warn_unused_result} function attribute
3226 The @code{warn_unused_result} attribute causes a warning to be emitted
3227 if a caller of the function with this attribute does not use its
3228 return value.  This is useful for functions where not checking
3229 the result is either a security problem or always a bug, such as
3230 @code{realloc}.
3232 @smallexample
3233 int fn () __attribute__ ((warn_unused_result));
3234 int foo ()
3236   if (fn () < 0) return -1;
3237   fn ();
3238   return 0;
3240 @end smallexample
3242 @noindent
3243 results in warning on line 5.
3245 @item weak
3246 @cindex @code{weak} function attribute
3247 The @code{weak} attribute causes the declaration to be emitted as a weak
3248 symbol rather than a global.  This is primarily useful in defining
3249 library functions that can be overridden in user code, though it can
3250 also be used with non-function declarations.  Weak symbols are supported
3251 for ELF targets, and also for a.out targets when using the GNU assembler
3252 and linker.
3254 @item weakref
3255 @itemx weakref ("@var{target}")
3256 @cindex @code{weakref} function attribute
3257 The @code{weakref} attribute marks a declaration as a weak reference.
3258 Without arguments, it should be accompanied by an @code{alias} attribute
3259 naming the target symbol.  Optionally, the @var{target} may be given as
3260 an argument to @code{weakref} itself.  In either case, @code{weakref}
3261 implicitly marks the declaration as @code{weak}.  Without a
3262 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3263 @code{weakref} is equivalent to @code{weak}.
3265 @smallexample
3266 static int x() __attribute__ ((weakref ("y")));
3267 /* is equivalent to... */
3268 static int x() __attribute__ ((weak, weakref, alias ("y")));
3269 /* and to... */
3270 static int x() __attribute__ ((weakref));
3271 static int x() __attribute__ ((alias ("y")));
3272 @end smallexample
3274 A weak reference is an alias that does not by itself require a
3275 definition to be given for the target symbol.  If the target symbol is
3276 only referenced through weak references, then it becomes a @code{weak}
3277 undefined symbol.  If it is directly referenced, however, then such
3278 strong references prevail, and a definition is required for the
3279 symbol, not necessarily in the same translation unit.
3281 The effect is equivalent to moving all references to the alias to a
3282 separate translation unit, renaming the alias to the aliased symbol,
3283 declaring it as weak, compiling the two separate translation units and
3284 performing a reloadable link on them.
3286 At present, a declaration to which @code{weakref} is attached can
3287 only be @code{static}.
3289 @item lower
3290 @itemx upper
3291 @itemx either
3292 @cindex lower memory region on the MSP430
3293 @cindex upper memory region on the MSP430
3294 @cindex either memory region on the MSP430
3295 On the MSP430 target these attributes can be used to specify whether
3296 the function or variable should be placed into low memory, high
3297 memory, or the placement should be left to the linker to decide.  The
3298 attributes are only significant if compiling for the MSP430X
3299 architecture.
3301 The attributes work in conjunction with a linker script that has been
3302 augmented to specify where to place sections with a @code{.lower} and
3303 a @code{.upper} prefix.  So for example as well as placing the
3304 @code{.data} section the script would also specify the placement of a
3305 @code{.lower.data} and a @code{.upper.data} section.  The intention
3306 being that @code{lower} sections are placed into a small but easier to
3307 access memory region and the upper sections are placed into a larger, but
3308 slower to access region.
3310 The @code{either} attribute is special.  It tells the linker to place
3311 the object into the corresponding @code{lower} section if there is
3312 room for it.  If there is insufficient room then the object is placed
3313 into the corresponding @code{upper} section instead.  Note - the
3314 placement algorithm is not very sophisticated.  It will not attempt to
3315 find an optimal packing of the @code{lower} sections.  It just makes
3316 one pass over the objects and does the best that it can.  Using the
3317 @option{-ffunction-sections} and @option{-fdata-sections} command line
3318 options can help the packing however, since they produce smaller,
3319 easier to pack regions.
3321 @end table
3323 @c This is the end of the target-independent attribute table
3326 @node ARC Function Attributes
3327 @subsection ARC Function Attributes
3329 These function attributes are supported by the ARC back end:
3331 @table @code
3332 @item interrupt
3333 @cindex @code{interrupt} function attribute, ARC
3334 Use this attribute to indicate
3335 that the specified function is an interrupt handler.  The compiler generates
3336 function entry and exit sequences suitable for use in an interrupt handler
3337 when this attribute is present.
3339 On the ARC, you must specify the kind of interrupt to be handled
3340 in a parameter to the interrupt attribute like this:
3342 @smallexample
3343 void f () __attribute__ ((interrupt ("ilink1")));
3344 @end smallexample
3346 Permissible values for this parameter are: @w{@code{ilink1}} and
3347 @w{@code{ilink2}}.
3349 @item long_call
3350 @itemx medium_call
3351 @itemx short_call
3352 @cindex @code{long_call} function attribute, ARC
3353 @cindex @code{medium_call} function attribute, ARC
3354 @cindex @code{short_call} function attribute, ARC
3355 @cindex indirect calls, ARC
3356 These attributes specify how a particular function is called.
3357 These attributes override the
3358 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3359 command-line switches and @code{#pragma long_calls} settings.
3361 For ARC, a function marked with the @code{long_call} attribute is
3362 always called using register-indirect jump-and-link instructions,
3363 thereby enabling the called function to be placed anywhere within the
3364 32-bit address space.  A function marked with the @code{medium_call}
3365 attribute will always be close enough to be called with an unconditional
3366 branch-and-link instruction, which has a 25-bit offset from
3367 the call site.  A function marked with the @code{short_call}
3368 attribute will always be close enough to be called with a conditional
3369 branch-and-link instruction, which has a 21-bit offset from
3370 the call site.
3371 @end table
3373 @node ARM Function Attributes
3374 @subsection ARM Function Attributes
3376 These function attributes are supported for ARM targets:
3378 @table @code
3379 @item interrupt
3380 @cindex @code{interrupt} function attribute, ARM
3381 Use this attribute to indicate
3382 that the specified function is an interrupt handler.  The compiler generates
3383 function entry and exit sequences suitable for use in an interrupt handler
3384 when this attribute is present.
3386 You can specify the kind of interrupt to be handled by
3387 adding an optional parameter to the interrupt attribute like this:
3389 @smallexample
3390 void f () __attribute__ ((interrupt ("IRQ")));
3391 @end smallexample
3393 @noindent
3394 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3395 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3397 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3398 may be called with a word-aligned stack pointer.
3400 @item isr
3401 @cindex @code{isr} function attribute, ARM
3402 Use this attribute on ARM to write Interrupt Service Routines. This is an
3403 alias to the @code{interrupt} attribute above.
3405 @item long_call
3406 @itemx short_call
3407 @cindex @code{long_call} function attribute, ARM
3408 @cindex @code{short_call} function attribute, ARM
3409 @cindex indirect calls, ARM
3410 These attributes specify how a particular function is called.
3411 These attributes override the
3412 @option{-mlong-calls} (@pxref{ARM Options})
3413 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3414 @code{long_call} attribute indicates that the function might be far
3415 away from the call site and require a different (more expensive)
3416 calling sequence.   The @code{short_call} attribute always places
3417 the offset to the function from the call site into the @samp{BL}
3418 instruction directly.
3420 @item naked
3421 @cindex @code{naked} function attribute, ARM
3422 This attribute allows the compiler to construct the
3423 requisite function declaration, while allowing the body of the
3424 function to be assembly code. The specified function will not have
3425 prologue/epilogue sequences generated by the compiler. Only basic
3426 @code{asm} statements can safely be included in naked functions
3427 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3428 basic @code{asm} and C code may appear to work, they cannot be
3429 depended upon to work reliably and are not supported.
3431 @item pcs
3432 @cindex @code{pcs} function attribute, ARM
3434 The @code{pcs} attribute can be used to control the calling convention
3435 used for a function on ARM.  The attribute takes an argument that specifies
3436 the calling convention to use.
3438 When compiling using the AAPCS ABI (or a variant of it) then valid
3439 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3440 order to use a variant other than @code{"aapcs"} then the compiler must
3441 be permitted to use the appropriate co-processor registers (i.e., the
3442 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3443 For example,
3445 @smallexample
3446 /* Argument passed in r0, and result returned in r0+r1.  */
3447 double f2d (float) __attribute__((pcs("aapcs")));
3448 @end smallexample
3450 Variadic functions always use the @code{"aapcs"} calling convention and
3451 the compiler rejects attempts to specify an alternative.
3453 @item target (@var{options})
3454 @cindex @code{target} function attribute
3455 As discussed in @ref{Common Function Attributes}, this attribute 
3456 allows specification of target-specific compilation options.
3458 On ARM, the following options are allowed:
3460 @table @samp
3461 @item thumb
3462 @cindex @code{target("thumb")} function attribute, ARM
3463 Force code generation in the Thumb (T16/T32) ISA, depending on the
3464 architecture level.
3466 @item arm
3467 @cindex @code{target("arm")} function attribute, ARM
3468 Force code generation in the ARM (A32) ISA.
3469 @end table
3471 Functions from different modes can be inlined in the caller's mode.
3473 @end table
3475 @node AVR Function Attributes
3476 @subsection AVR Function Attributes
3478 These function attributes are supported by the AVR back end:
3480 @table @code
3481 @item interrupt
3482 @cindex @code{interrupt} function attribute, AVR
3483 Use this attribute to indicate
3484 that the specified function is an interrupt handler.  The compiler generates
3485 function entry and exit sequences suitable for use in an interrupt handler
3486 when this attribute is present.
3488 On the AVR, the hardware globally disables interrupts when an
3489 interrupt is executed.  The first instruction of an interrupt handler
3490 declared with this attribute is a @code{SEI} instruction to
3491 re-enable interrupts.  See also the @code{signal} function attribute
3492 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3493 @code{interrupt} are specified for the same function, @code{signal}
3494 is silently ignored.
3496 @item naked
3497 @cindex @code{naked} function attribute, AVR
3498 This attribute allows the compiler to construct the
3499 requisite function declaration, while allowing the body of the
3500 function to be assembly code. The specified function will not have
3501 prologue/epilogue sequences generated by the compiler. Only basic
3502 @code{asm} statements can safely be included in naked functions
3503 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3504 basic @code{asm} and C code may appear to work, they cannot be
3505 depended upon to work reliably and are not supported.
3507 @item OS_main
3508 @itemx OS_task
3509 @cindex @code{OS_main} function attribute, AVR
3510 @cindex @code{OS_task} function attribute, AVR
3511 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3512 do not save/restore any call-saved register in their prologue/epilogue.
3514 The @code{OS_main} attribute can be used when there @emph{is
3515 guarantee} that interrupts are disabled at the time when the function
3516 is entered.  This saves resources when the stack pointer has to be
3517 changed to set up a frame for local variables.
3519 The @code{OS_task} attribute can be used when there is @emph{no
3520 guarantee} that interrupts are disabled at that time when the function
3521 is entered like for, e@.g@. task functions in a multi-threading operating
3522 system. In that case, changing the stack pointer register is
3523 guarded by save/clear/restore of the global interrupt enable flag.
3525 The differences to the @code{naked} function attribute are:
3526 @itemize @bullet
3527 @item @code{naked} functions do not have a return instruction whereas 
3528 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3529 @code{RETI} return instruction.
3530 @item @code{naked} functions do not set up a frame for local variables
3531 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3532 as needed.
3533 @end itemize
3535 @item signal
3536 @cindex @code{signal} function attribute, AVR
3537 Use this attribute on the AVR to indicate that the specified
3538 function is an interrupt handler.  The compiler generates function
3539 entry and exit sequences suitable for use in an interrupt handler when this
3540 attribute is present.
3542 See also the @code{interrupt} function attribute. 
3544 The AVR hardware globally disables interrupts when an interrupt is executed.
3545 Interrupt handler functions defined with the @code{signal} attribute
3546 do not re-enable interrupts.  It is save to enable interrupts in a
3547 @code{signal} handler.  This ``save'' only applies to the code
3548 generated by the compiler and not to the IRQ layout of the
3549 application which is responsibility of the application.
3551 If both @code{signal} and @code{interrupt} are specified for the same
3552 function, @code{signal} is silently ignored.
3553 @end table
3555 @node Blackfin Function Attributes
3556 @subsection Blackfin Function Attributes
3558 These function attributes are supported by the Blackfin back end:
3560 @table @code
3562 @item exception_handler
3563 @cindex @code{exception_handler} function attribute
3564 @cindex exception handler functions, Blackfin
3565 Use this attribute on the Blackfin to indicate that the specified function
3566 is an exception handler.  The compiler generates function entry and
3567 exit sequences suitable for use in an exception handler when this
3568 attribute is present.
3570 @item interrupt_handler
3571 @cindex @code{interrupt_handler} function attribute, Blackfin
3572 Use this attribute to
3573 indicate that the specified function is an interrupt handler.  The compiler
3574 generates function entry and exit sequences suitable for use in an
3575 interrupt handler when this attribute is present.
3577 @item kspisusp
3578 @cindex @code{kspisusp} function attribute, Blackfin
3579 @cindex User stack pointer in interrupts on the Blackfin
3580 When used together with @code{interrupt_handler}, @code{exception_handler}
3581 or @code{nmi_handler}, code is generated to load the stack pointer
3582 from the USP register in the function prologue.
3584 @item l1_text
3585 @cindex @code{l1_text} function attribute, Blackfin
3586 This attribute specifies a function to be placed into L1 Instruction
3587 SRAM@. The function is put into a specific section named @code{.l1.text}.
3588 With @option{-mfdpic}, function calls with a such function as the callee
3589 or caller uses inlined PLT.
3591 @item l2
3592 @cindex @code{l2} function attribute, Blackfin
3593 This attribute specifies a function to be placed into L2
3594 SRAM. The function is put into a specific section named
3595 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3596 an inlined PLT.
3598 @item longcall
3599 @itemx shortcall
3600 @cindex indirect calls, Blackfin
3601 @cindex @code{longcall} function attribute, Blackfin
3602 @cindex @code{shortcall} function attribute, Blackfin
3603 The @code{longcall} attribute
3604 indicates that the function might be far away from the call site and
3605 require a different (more expensive) calling sequence.  The
3606 @code{shortcall} attribute indicates that the function is always close
3607 enough for the shorter calling sequence to be used.  These attributes
3608 override the @option{-mlongcall} switch.
3610 @item nesting
3611 @cindex @code{nesting} function attribute, Blackfin
3612 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3613 Use this attribute together with @code{interrupt_handler},
3614 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3615 entry code should enable nested interrupts or exceptions.
3617 @item nmi_handler
3618 @cindex @code{nmi_handler} function attribute, Blackfin
3619 @cindex NMI handler functions on the Blackfin processor
3620 Use this attribute on the Blackfin to indicate that the specified function
3621 is an NMI handler.  The compiler generates function entry and
3622 exit sequences suitable for use in an NMI handler when this
3623 attribute is present.
3625 @item saveall
3626 @cindex @code{saveall} function attribute, Blackfin
3627 @cindex save all registers on the Blackfin
3628 Use this attribute to indicate that
3629 all registers except the stack pointer should be saved in the prologue
3630 regardless of whether they are used or not.
3631 @end table
3633 @node CR16 Function Attributes
3634 @subsection CR16 Function Attributes
3636 These function attributes are supported by the CR16 back end:
3638 @table @code
3639 @item interrupt
3640 @cindex @code{interrupt} function attribute, CR16
3641 Use this attribute to indicate
3642 that the specified function is an interrupt handler.  The compiler generates
3643 function entry and exit sequences suitable for use in an interrupt handler
3644 when this attribute is present.
3645 @end table
3647 @node Epiphany Function Attributes
3648 @subsection Epiphany Function Attributes
3650 These function attributes are supported by the Epiphany back end:
3652 @table @code
3653 @item disinterrupt
3654 @cindex @code{disinterrupt} function attribute, Epiphany
3655 This attribute causes the compiler to emit
3656 instructions to disable interrupts for the duration of the given
3657 function.
3659 @item forwarder_section
3660 @cindex @code{forwarder_section} function attribute, Epiphany
3661 This attribute modifies the behavior of an interrupt handler.
3662 The interrupt handler may be in external memory which cannot be
3663 reached by a branch instruction, so generate a local memory trampoline
3664 to transfer control.  The single parameter identifies the section where
3665 the trampoline is placed.
3667 @item interrupt
3668 @cindex @code{interrupt} function attribute, Epiphany
3669 Use this attribute to indicate
3670 that the specified function is an interrupt handler.  The compiler generates
3671 function entry and exit sequences suitable for use in an interrupt handler
3672 when this attribute is present.  It may also generate
3673 a special section with code to initialize the interrupt vector table.
3675 On Epiphany targets one or more optional parameters can be added like this:
3677 @smallexample
3678 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3679 @end smallexample
3681 Permissible values for these parameters are: @w{@code{reset}},
3682 @w{@code{software_exception}}, @w{@code{page_miss}},
3683 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3684 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3685 Multiple parameters indicate that multiple entries in the interrupt
3686 vector table should be initialized for this function, i.e.@: for each
3687 parameter @w{@var{name}}, a jump to the function is emitted in
3688 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3689 entirely, in which case no interrupt vector table entry is provided.
3691 Note that interrupts are enabled inside the function
3692 unless the @code{disinterrupt} attribute is also specified.
3694 The following examples are all valid uses of these attributes on
3695 Epiphany targets:
3696 @smallexample
3697 void __attribute__ ((interrupt)) universal_handler ();
3698 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3699 void __attribute__ ((interrupt ("dma0, dma1"))) 
3700   universal_dma_handler ();
3701 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3702   fast_timer_handler ();
3703 void __attribute__ ((interrupt ("dma0, dma1"), 
3704                      forwarder_section ("tramp")))
3705   external_dma_handler ();
3706 @end smallexample
3708 @item long_call
3709 @itemx short_call
3710 @cindex @code{long_call} function attribute, Epiphany
3711 @cindex @code{short_call} function attribute, Epiphany
3712 @cindex indirect calls, Epiphany
3713 These attributes specify how a particular function is called.
3714 These attributes override the
3715 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3716 command-line switch and @code{#pragma long_calls} settings.
3717 @end table
3720 @node H8/300 Function Attributes
3721 @subsection H8/300 Function Attributes
3723 These function attributes are available for H8/300 targets:
3725 @table @code
3726 @item function_vector
3727 @cindex @code{function_vector} function attribute, H8/300
3728 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
3729 that the specified function should be called through the function vector.
3730 Calling a function through the function vector reduces code size; however,
3731 the function vector has a limited size (maximum 128 entries on the H8/300
3732 and 64 entries on the H8/300H and H8S)
3733 and shares space with the interrupt vector.
3735 @item interrupt_handler
3736 @cindex @code{interrupt_handler} function attribute, H8/300
3737 Use this attribute on the H8/300, H8/300H, and H8S to
3738 indicate that the specified function is an interrupt handler.  The compiler
3739 generates function entry and exit sequences suitable for use in an
3740 interrupt handler when this attribute is present.
3742 @item saveall
3743 @cindex @code{saveall} function attribute, H8/300
3744 @cindex save all registers on the H8/300, H8/300H, and H8S
3745 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3746 all registers except the stack pointer should be saved in the prologue
3747 regardless of whether they are used or not.
3748 @end table
3750 @node IA-64 Function Attributes
3751 @subsection IA-64 Function Attributes
3753 These function attributes are supported on IA-64 targets:
3755 @table @code
3756 @item syscall_linkage
3757 @cindex @code{syscall_linkage} function attribute, IA-64
3758 This attribute is used to modify the IA-64 calling convention by marking
3759 all input registers as live at all function exits.  This makes it possible
3760 to restart a system call after an interrupt without having to save/restore
3761 the input registers.  This also prevents kernel data from leaking into
3762 application code.
3764 @item version_id
3765 @cindex @code{version_id} function attribute, IA-64
3766 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
3767 symbol to contain a version string, thus allowing for function level
3768 versioning.  HP-UX system header files may use function level versioning
3769 for some system calls.
3771 @smallexample
3772 extern int foo () __attribute__((version_id ("20040821")));
3773 @end smallexample
3775 @noindent
3776 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
3777 @end table
3779 @node M32C Function Attributes
3780 @subsection M32C Function Attributes
3782 These function attributes are supported by the M32C back end:
3784 @table @code
3785 @item bank_switch
3786 @cindex @code{bank_switch} function attribute, M32C
3787 When added to an interrupt handler with the M32C port, causes the
3788 prologue and epilogue to use bank switching to preserve the registers
3789 rather than saving them on the stack.
3791 @item fast_interrupt
3792 @cindex @code{fast_interrupt} function attribute, M32C
3793 Use this attribute on the M32C port to indicate that the specified
3794 function is a fast interrupt handler.  This is just like the
3795 @code{interrupt} attribute, except that @code{freit} is used to return
3796 instead of @code{reit}.
3798 @item function_vector
3799 @cindex @code{function_vector} function attribute, M16C/M32C
3800 On M16C/M32C targets, the @code{function_vector} attribute declares a
3801 special page subroutine call function. Use of this attribute reduces
3802 the code size by 2 bytes for each call generated to the
3803 subroutine. The argument to the attribute is the vector number entry
3804 from the special page vector table which contains the 16 low-order
3805 bits of the subroutine's entry address. Each vector table has special
3806 page number (18 to 255) that is used in @code{jsrs} instructions.
3807 Jump addresses of the routines are generated by adding 0x0F0000 (in
3808 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
3809 2-byte addresses set in the vector table. Therefore you need to ensure
3810 that all the special page vector routines should get mapped within the
3811 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
3812 (for M32C).
3814 In the following example 2 bytes are saved for each call to
3815 function @code{foo}.
3817 @smallexample
3818 void foo (void) __attribute__((function_vector(0x18)));
3819 void foo (void)
3823 void bar (void)
3825     foo();
3827 @end smallexample
3829 If functions are defined in one file and are called in another file,
3830 then be sure to write this declaration in both files.
3832 This attribute is ignored for R8C target.
3834 @item interrupt
3835 @cindex @code{interrupt} function attribute, M32C
3836 Use this attribute to indicate
3837 that the specified function is an interrupt handler.  The compiler generates
3838 function entry and exit sequences suitable for use in an interrupt handler
3839 when this attribute is present.
3840 @end table
3842 @node M32R/D Function Attributes
3843 @subsection M32R/D Function Attributes
3845 These function attributes are supported by the M32R/D back end:
3847 @table @code
3848 @item interrupt
3849 @cindex @code{interrupt} function attribute, M32R/D
3850 Use this attribute to indicate
3851 that the specified function is an interrupt handler.  The compiler generates
3852 function entry and exit sequences suitable for use in an interrupt handler
3853 when this attribute is present.
3855 @item model (@var{model-name})
3856 @cindex @code{model} function attribute, M32R/D
3857 @cindex function addressability on the M32R/D
3859 On the M32R/D, use this attribute to set the addressability of an
3860 object, and of the code generated for a function.  The identifier
3861 @var{model-name} is one of @code{small}, @code{medium}, or
3862 @code{large}, representing each of the code models.
3864 Small model objects live in the lower 16MB of memory (so that their
3865 addresses can be loaded with the @code{ld24} instruction), and are
3866 callable with the @code{bl} instruction.
3868 Medium model objects may live anywhere in the 32-bit address space (the
3869 compiler generates @code{seth/add3} instructions to load their addresses),
3870 and are callable with the @code{bl} instruction.
3872 Large model objects may live anywhere in the 32-bit address space (the
3873 compiler generates @code{seth/add3} instructions to load their addresses),
3874 and may not be reachable with the @code{bl} instruction (the compiler
3875 generates the much slower @code{seth/add3/jl} instruction sequence).
3876 @end table
3878 @node m68k Function Attributes
3879 @subsection m68k Function Attributes
3881 These function attributes are supported by the m68k back end:
3883 @table @code
3884 @item interrupt
3885 @itemx interrupt_handler
3886 @cindex @code{interrupt} function attribute, m68k
3887 @cindex @code{interrupt_handler} function attribute, m68k
3888 Use this attribute to
3889 indicate that the specified function is an interrupt handler.  The compiler
3890 generates function entry and exit sequences suitable for use in an
3891 interrupt handler when this attribute is present.  Either name may be used.
3893 @item interrupt_thread
3894 @cindex @code{interrupt_thread} function attribute, fido
3895 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3896 that the specified function is an interrupt handler that is designed
3897 to run as a thread.  The compiler omits generate prologue/epilogue
3898 sequences and replaces the return instruction with a @code{sleep}
3899 instruction.  This attribute is available only on fido.
3900 @end table
3902 @node MCORE Function Attributes
3903 @subsection MCORE Function Attributes
3905 These function attributes are supported by the MCORE back end:
3907 @table @code
3908 @item naked
3909 @cindex @code{naked} function attribute, MCORE
3910 This attribute allows the compiler to construct the
3911 requisite function declaration, while allowing the body of the
3912 function to be assembly code. The specified function will not have
3913 prologue/epilogue sequences generated by the compiler. Only basic
3914 @code{asm} statements can safely be included in naked functions
3915 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3916 basic @code{asm} and C code may appear to work, they cannot be
3917 depended upon to work reliably and are not supported.
3918 @end table
3920 @node MeP Function Attributes
3921 @subsection MeP Function Attributes
3923 These function attributes are supported by the MeP back end:
3925 @table @code
3926 @item disinterrupt
3927 @cindex @code{disinterrupt} function attribute, MeP
3928 On MeP targets, this attribute causes the compiler to emit
3929 instructions to disable interrupts for the duration of the given
3930 function.
3932 @item interrupt
3933 @cindex @code{interrupt} function attribute, MeP
3934 Use this attribute to indicate
3935 that the specified function is an interrupt handler.  The compiler generates
3936 function entry and exit sequences suitable for use in an interrupt handler
3937 when this attribute is present.
3939 @item near
3940 @cindex @code{near} function attribute, MeP
3941 This attribute causes the compiler to assume the called
3942 function is close enough to use the normal calling convention,
3943 overriding the @option{-mtf} command-line option.
3945 @item far
3946 @cindex @code{far} function attribute, MeP
3947 On MeP targets this causes the compiler to use a calling convention
3948 that assumes the called function is too far away for the built-in
3949 addressing modes.
3951 @item vliw
3952 @cindex @code{vliw} function attribute, MeP
3953 The @code{vliw} attribute tells the compiler to emit
3954 instructions in VLIW mode instead of core mode.  Note that this
3955 attribute is not allowed unless a VLIW coprocessor has been configured
3956 and enabled through command-line options.
3957 @end table
3959 @node MicroBlaze Function Attributes
3960 @subsection MicroBlaze Function Attributes
3962 These function attributes are supported on MicroBlaze targets:
3964 @table @code
3965 @item save_volatiles
3966 @cindex @code{save_volatiles} function attribute, MicroBlaze
3967 Use this attribute to indicate that the function is
3968 an interrupt handler.  All volatile registers (in addition to non-volatile
3969 registers) are saved in the function prologue.  If the function is a leaf
3970 function, only volatiles used by the function are saved.  A normal function
3971 return is generated instead of a return from interrupt.
3973 @item break_handler
3974 @cindex @code{break_handler} function attribute, MicroBlaze
3975 @cindex break handler functions
3976 Use this attribute to indicate that
3977 the specified function is a break handler.  The compiler generates function
3978 entry and exit sequences suitable for use in an break handler when this
3979 attribute is present. The return from @code{break_handler} is done through
3980 the @code{rtbd} instead of @code{rtsd}.
3982 @smallexample
3983 void f () __attribute__ ((break_handler));
3984 @end smallexample
3985 @end table
3987 @node Microsoft Windows Function Attributes
3988 @subsection Microsoft Windows Function Attributes
3990 The following attributes are available on Microsoft Windows and Symbian OS
3991 targets.
3993 @table @code
3994 @item dllexport
3995 @cindex @code{dllexport} function attribute
3996 @cindex @code{__declspec(dllexport)}
3997 On Microsoft Windows targets and Symbian OS targets the
3998 @code{dllexport} attribute causes the compiler to provide a global
3999 pointer to a pointer in a DLL, so that it can be referenced with the
4000 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4001 name is formed by combining @code{_imp__} and the function or variable
4002 name.
4004 You can use @code{__declspec(dllexport)} as a synonym for
4005 @code{__attribute__ ((dllexport))} for compatibility with other
4006 compilers.
4008 On systems that support the @code{visibility} attribute, this
4009 attribute also implies ``default'' visibility.  It is an error to
4010 explicitly specify any other visibility.
4012 GCC's default behavior is to emit all inline functions with the
4013 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4014 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4015 ignore the attribute for inlined functions unless the 
4016 @option{-fkeep-inline-functions} flag is used instead.
4018 The attribute is ignored for undefined symbols.
4020 When applied to C++ classes, the attribute marks defined non-inlined
4021 member functions and static data members as exports.  Static consts
4022 initialized in-class are not marked unless they are also defined
4023 out-of-class.
4025 For Microsoft Windows targets there are alternative methods for
4026 including the symbol in the DLL's export table such as using a
4027 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4028 the @option{--export-all} linker flag.
4030 @item dllimport
4031 @cindex @code{dllimport} function attribute
4032 @cindex @code{__declspec(dllimport)}
4033 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4034 attribute causes the compiler to reference a function or variable via
4035 a global pointer to a pointer that is set up by the DLL exporting the
4036 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4037 targets, the pointer name is formed by combining @code{_imp__} and the
4038 function or variable name.
4040 You can use @code{__declspec(dllimport)} as a synonym for
4041 @code{__attribute__ ((dllimport))} for compatibility with other
4042 compilers.
4044 On systems that support the @code{visibility} attribute, this
4045 attribute also implies ``default'' visibility.  It is an error to
4046 explicitly specify any other visibility.
4048 Currently, the attribute is ignored for inlined functions.  If the
4049 attribute is applied to a symbol @emph{definition}, an error is reported.
4050 If a symbol previously declared @code{dllimport} is later defined, the
4051 attribute is ignored in subsequent references, and a warning is emitted.
4052 The attribute is also overridden by a subsequent declaration as
4053 @code{dllexport}.
4055 When applied to C++ classes, the attribute marks non-inlined
4056 member functions and static data members as imports.  However, the
4057 attribute is ignored for virtual methods to allow creation of vtables
4058 using thunks.
4060 On the SH Symbian OS target the @code{dllimport} attribute also has
4061 another affect---it can cause the vtable and run-time type information
4062 for a class to be exported.  This happens when the class has a
4063 dllimported constructor or a non-inline, non-pure virtual function
4064 and, for either of those two conditions, the class also has an inline
4065 constructor or destructor and has a key function that is defined in
4066 the current translation unit.
4068 For Microsoft Windows targets the use of the @code{dllimport}
4069 attribute on functions is not necessary, but provides a small
4070 performance benefit by eliminating a thunk in the DLL@.  The use of the
4071 @code{dllimport} attribute on imported variables can be avoided by passing the
4072 @option{--enable-auto-import} switch to the GNU linker.  As with
4073 functions, using the attribute for a variable eliminates a thunk in
4074 the DLL@.
4076 One drawback to using this attribute is that a pointer to a
4077 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4078 address. However, a pointer to a @emph{function} with the
4079 @code{dllimport} attribute can be used as a constant initializer; in
4080 this case, the address of a stub function in the import lib is
4081 referenced.  On Microsoft Windows targets, the attribute can be disabled
4082 for functions by setting the @option{-mnop-fun-dllimport} flag.
4083 @end table
4085 @node MIPS Function Attributes
4086 @subsection MIPS Function Attributes
4088 These function attributes are supported by the MIPS back end:
4090 @table @code
4091 @item interrupt
4092 @cindex @code{interrupt} function attribute, MIPS
4093 Use this attribute to indicate
4094 that the specified function is an interrupt handler.  The compiler generates
4095 function entry and exit sequences suitable for use in an interrupt handler
4096 when this attribute is present.
4098 You can use the following attributes to modify the behavior
4099 of an interrupt handler:
4100 @table @code
4101 @item use_shadow_register_set
4102 @cindex @code{use_shadow_register_set} function attribute, MIPS
4103 Assume that the handler uses a shadow register set, instead of
4104 the main general-purpose registers.
4106 @item keep_interrupts_masked
4107 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4108 Keep interrupts masked for the whole function.  Without this attribute,
4109 GCC tries to reenable interrupts for as much of the function as it can.
4111 @item use_debug_exception_return
4112 @cindex @code{use_debug_exception_return} function attribute, MIPS
4113 Return using the @code{deret} instruction.  Interrupt handlers that don't
4114 have this attribute return using @code{eret} instead.
4115 @end table
4117 You can use any combination of these attributes, as shown below:
4118 @smallexample
4119 void __attribute__ ((interrupt)) v0 ();
4120 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4121 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4122 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4123 void __attribute__ ((interrupt, use_shadow_register_set,
4124                      keep_interrupts_masked)) v4 ();
4125 void __attribute__ ((interrupt, use_shadow_register_set,
4126                      use_debug_exception_return)) v5 ();
4127 void __attribute__ ((interrupt, keep_interrupts_masked,
4128                      use_debug_exception_return)) v6 ();
4129 void __attribute__ ((interrupt, use_shadow_register_set,
4130                      keep_interrupts_masked,
4131                      use_debug_exception_return)) v7 ();
4132 @end smallexample
4134 @item long_call
4135 @itemx near
4136 @itemx far
4137 @cindex indirect calls, MIPS
4138 @cindex @code{long_call} function attribute, MIPS
4139 @cindex @code{near} function attribute, MIPS
4140 @cindex @code{far} function attribute, MIPS
4141 These attributes specify how a particular function is called on MIPS@.
4142 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4143 command-line switch.  The @code{long_call} and @code{far} attributes are
4144 synonyms, and cause the compiler to always call
4145 the function by first loading its address into a register, and then using
4146 the contents of that register.  The @code{near} attribute has the opposite
4147 effect; it specifies that non-PIC calls should be made using the more
4148 efficient @code{jal} instruction.
4150 @item mips16
4151 @itemx nomips16
4152 @cindex @code{mips16} function attribute, MIPS
4153 @cindex @code{nomips16} function attribute, MIPS
4155 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4156 function attributes to locally select or turn off MIPS16 code generation.
4157 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4158 while MIPS16 code generation is disabled for functions with the
4159 @code{nomips16} attribute.  These attributes override the
4160 @option{-mips16} and @option{-mno-mips16} options on the command line
4161 (@pxref{MIPS Options}).
4163 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4164 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4165 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4166 may interact badly with some GCC extensions such as @code{__builtin_apply}
4167 (@pxref{Constructing Calls}).
4169 @item micromips, MIPS
4170 @itemx nomicromips, MIPS
4171 @cindex @code{micromips} function attribute
4172 @cindex @code{nomicromips} function attribute
4174 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4175 function attributes to locally select or turn off microMIPS code generation.
4176 A function with the @code{micromips} attribute is emitted as microMIPS code,
4177 while microMIPS code generation is disabled for functions with the
4178 @code{nomicromips} attribute.  These attributes override the
4179 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4180 (@pxref{MIPS Options}).
4182 When compiling files containing mixed microMIPS and non-microMIPS code, the
4183 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4184 command line,
4185 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4186 may interact badly with some GCC extensions such as @code{__builtin_apply}
4187 (@pxref{Constructing Calls}).
4189 @item nocompression
4190 @cindex @code{nocompression} function attribute, MIPS
4191 On MIPS targets, you can use the @code{nocompression} function attribute
4192 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4193 overrides the @option{-mips16} and @option{-mmicromips} options on the
4194 command line (@pxref{MIPS Options}).
4195 @end table
4197 @node MSP430 Function Attributes
4198 @subsection MSP430 Function Attributes
4200 These function attributes are supported by the MSP430 back end:
4202 @table @code
4203 @item critical
4204 @cindex @code{critical} function attribute, MSP430
4205 Critical functions disable interrupts upon entry and restore the
4206 previous interrupt state upon exit.  Critical functions cannot also
4207 have the @code{naked} or @code{reentrant} attributes.  They can have
4208 the @code{interrupt} attribute.
4210 @item interrupt
4211 @cindex @code{interrupt} function attribute, MSP430
4212 Use this attribute to indicate
4213 that the specified function is an interrupt handler.  The compiler generates
4214 function entry and exit sequences suitable for use in an interrupt handler
4215 when this attribute is present.
4217 You can provide an argument to the interrupt
4218 attribute which specifies a name or number.  If the argument is a
4219 number it indicates the slot in the interrupt vector table (0 - 31) to
4220 which this handler should be assigned.  If the argument is a name it
4221 is treated as a symbolic name for the vector slot.  These names should
4222 match up with appropriate entries in the linker script.  By default
4223 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4224 @code{reset} for vector 31 are recognized.
4226 @item naked
4227 @cindex @code{naked} function attribute, MSP430
4228 This attribute allows the compiler to construct the
4229 requisite function declaration, while allowing the body of the
4230 function to be assembly code. The specified function will not have
4231 prologue/epilogue sequences generated by the compiler. Only basic
4232 @code{asm} statements can safely be included in naked functions
4233 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4234 basic @code{asm} and C code may appear to work, they cannot be
4235 depended upon to work reliably and are not supported.
4237 @item reentrant
4238 @cindex @code{reentrant} function attribute, MSP430
4239 Reentrant functions disable interrupts upon entry and enable them
4240 upon exit.  Reentrant functions cannot also have the @code{naked}
4241 or @code{critical} attributes.  They can have the @code{interrupt}
4242 attribute.
4244 @item wakeup
4245 @cindex @code{wakeup} function attribute, MSP430
4246 This attribute only applies to interrupt functions.  It is silently
4247 ignored if applied to a non-interrupt function.  A wakeup interrupt
4248 function will rouse the processor from any low-power state that it
4249 might be in when the function exits.
4250 @end table
4252 @node NDS32 Function Attributes
4253 @subsection NDS32 Function Attributes
4255 These function attributes are supported by the NDS32 back end:
4257 @table @code
4258 @item exception
4259 @cindex @code{exception} function attribute
4260 @cindex exception handler functions, NDS32
4261 Use this attribute on the NDS32 target to indicate that the specified function
4262 is an exception handler.  The compiler will generate corresponding sections
4263 for use in an exception handler.
4265 @item interrupt
4266 @cindex @code{interrupt} function attribute, NDS32
4267 On NDS32 target, this attribute indicates that the specified function
4268 is an interrupt handler.  The compiler generates corresponding sections
4269 for use in an interrupt handler.  You can use the following attributes
4270 to modify the behavior:
4271 @table @code
4272 @item nested
4273 @cindex @code{nested} function attribute, NDS32
4274 This interrupt service routine is interruptible.
4275 @item not_nested
4276 @cindex @code{not_nested} function attribute, NDS32
4277 This interrupt service routine is not interruptible.
4278 @item nested_ready
4279 @cindex @code{nested_ready} function attribute, NDS32
4280 This interrupt service routine is interruptible after @code{PSW.GIE}
4281 (global interrupt enable) is set.  This allows interrupt service routine to
4282 finish some short critical code before enabling interrupts.
4283 @item save_all
4284 @cindex @code{save_all} function attribute, NDS32
4285 The system will help save all registers into stack before entering
4286 interrupt handler.
4287 @item partial_save
4288 @cindex @code{partial_save} function attribute, NDS32
4289 The system will help save caller registers into stack before entering
4290 interrupt handler.
4291 @end table
4293 @item naked
4294 @cindex @code{naked} function attribute, NDS32
4295 This attribute allows the compiler to construct the
4296 requisite function declaration, while allowing the body of the
4297 function to be assembly code. The specified function will not have
4298 prologue/epilogue sequences generated by the compiler. Only basic
4299 @code{asm} statements can safely be included in naked functions
4300 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4301 basic @code{asm} and C code may appear to work, they cannot be
4302 depended upon to work reliably and are not supported.
4304 @item reset
4305 @cindex @code{reset} function attribute, NDS32
4306 @cindex reset handler functions
4307 Use this attribute on the NDS32 target to indicate that the specified function
4308 is a reset handler.  The compiler will generate corresponding sections
4309 for use in a reset handler.  You can use the following attributes
4310 to provide extra exception handling:
4311 @table @code
4312 @item nmi
4313 @cindex @code{nmi} function attribute, NDS32
4314 Provide a user-defined function to handle NMI exception.
4315 @item warm
4316 @cindex @code{warm} function attribute, NDS32
4317 Provide a user-defined function to handle warm reset exception.
4318 @end table
4319 @end table
4321 @node Nios II Function Attributes
4322 @subsection Nios II Function Attributes
4324 These function attributes are supported by the Nios II back end:
4326 @table @code
4327 @item target (@var{options})
4328 @cindex @code{target} function attribute
4329 As discussed in @ref{Common Function Attributes}, this attribute 
4330 allows specification of target-specific compilation options.
4332 When compiling for Nios II, the following options are allowed:
4334 @table @samp
4335 @item custom-@var{insn}=@var{N}
4336 @itemx no-custom-@var{insn}
4337 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4338 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4339 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4340 custom instruction with encoding @var{N} when generating code that uses 
4341 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4342 the custom instruction @var{insn}.
4343 These target attributes correspond to the
4344 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4345 command-line options, and support the same set of @var{insn} keywords.
4346 @xref{Nios II Options}, for more information.
4348 @item custom-fpu-cfg=@var{name}
4349 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4350 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4351 command-line option, to select a predefined set of custom instructions
4352 named @var{name}.
4353 @xref{Nios II Options}, for more information.
4354 @end table
4355 @end table
4357 @node PowerPC Function Attributes
4358 @subsection PowerPC Function Attributes
4360 These function attributes are supported by the PowerPC back end:
4362 @table @code
4363 @item longcall
4364 @itemx shortcall
4365 @cindex indirect calls, PowerPC
4366 @cindex @code{longcall} function attribute, PowerPC
4367 @cindex @code{shortcall} function attribute, PowerPC
4368 The @code{longcall} attribute
4369 indicates that the function might be far away from the call site and
4370 require a different (more expensive) calling sequence.  The
4371 @code{shortcall} attribute indicates that the function is always close
4372 enough for the shorter calling sequence to be used.  These attributes
4373 override both the @option{-mlongcall} switch and
4374 the @code{#pragma longcall} setting.
4376 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4377 calls are necessary.
4379 @item target (@var{options})
4380 @cindex @code{target} function attribute
4381 As discussed in @ref{Common Function Attributes}, this attribute 
4382 allows specification of target-specific compilation options.
4384 On the PowerPC, the following options are allowed:
4386 @table @samp
4387 @item altivec
4388 @itemx no-altivec
4389 @cindex @code{target("altivec")} function attribute, PowerPC
4390 Generate code that uses (does not use) AltiVec instructions.  In
4391 32-bit code, you cannot enable AltiVec instructions unless
4392 @option{-mabi=altivec} is used on the command line.
4394 @item cmpb
4395 @itemx no-cmpb
4396 @cindex @code{target("cmpb")} function attribute, PowerPC
4397 Generate code that uses (does not use) the compare bytes instruction
4398 implemented on the POWER6 processor and other processors that support
4399 the PowerPC V2.05 architecture.
4401 @item dlmzb
4402 @itemx no-dlmzb
4403 @cindex @code{target("dlmzb")} function attribute, PowerPC
4404 Generate code that uses (does not use) the string-search @samp{dlmzb}
4405 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4406 generated by default when targeting those processors.
4408 @item fprnd
4409 @itemx no-fprnd
4410 @cindex @code{target("fprnd")} function attribute, PowerPC
4411 Generate code that uses (does not use) the FP round to integer
4412 instructions implemented on the POWER5+ processor and other processors
4413 that support the PowerPC V2.03 architecture.
4415 @item hard-dfp
4416 @itemx no-hard-dfp
4417 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4418 Generate code that uses (does not use) the decimal floating-point
4419 instructions implemented on some POWER processors.
4421 @item isel
4422 @itemx no-isel
4423 @cindex @code{target("isel")} function attribute, PowerPC
4424 Generate code that uses (does not use) ISEL instruction.
4426 @item mfcrf
4427 @itemx no-mfcrf
4428 @cindex @code{target("mfcrf")} function attribute, PowerPC
4429 Generate code that uses (does not use) the move from condition
4430 register field instruction implemented on the POWER4 processor and
4431 other processors that support the PowerPC V2.01 architecture.
4433 @item mfpgpr
4434 @itemx no-mfpgpr
4435 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4436 Generate code that uses (does not use) the FP move to/from general
4437 purpose register instructions implemented on the POWER6X processor and
4438 other processors that support the extended PowerPC V2.05 architecture.
4440 @item mulhw
4441 @itemx no-mulhw
4442 @cindex @code{target("mulhw")} function attribute, PowerPC
4443 Generate code that uses (does not use) the half-word multiply and
4444 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4445 These instructions are generated by default when targeting those
4446 processors.
4448 @item multiple
4449 @itemx no-multiple
4450 @cindex @code{target("multiple")} function attribute, PowerPC
4451 Generate code that uses (does not use) the load multiple word
4452 instructions and the store multiple word instructions.
4454 @item update
4455 @itemx no-update
4456 @cindex @code{target("update")} function attribute, PowerPC
4457 Generate code that uses (does not use) the load or store instructions
4458 that update the base register to the address of the calculated memory
4459 location.
4461 @item popcntb
4462 @itemx no-popcntb
4463 @cindex @code{target("popcntb")} function attribute, PowerPC
4464 Generate code that uses (does not use) the popcount and double-precision
4465 FP reciprocal estimate instruction implemented on the POWER5
4466 processor and other processors that support the PowerPC V2.02
4467 architecture.
4469 @item popcntd
4470 @itemx no-popcntd
4471 @cindex @code{target("popcntd")} function attribute, PowerPC
4472 Generate code that uses (does not use) the popcount instruction
4473 implemented on the POWER7 processor and other processors that support
4474 the PowerPC V2.06 architecture.
4476 @item powerpc-gfxopt
4477 @itemx no-powerpc-gfxopt
4478 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4479 Generate code that uses (does not use) the optional PowerPC
4480 architecture instructions in the Graphics group, including
4481 floating-point select.
4483 @item powerpc-gpopt
4484 @itemx no-powerpc-gpopt
4485 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4486 Generate code that uses (does not use) the optional PowerPC
4487 architecture instructions in the General Purpose group, including
4488 floating-point square root.
4490 @item recip-precision
4491 @itemx no-recip-precision
4492 @cindex @code{target("recip-precision")} function attribute, PowerPC
4493 Assume (do not assume) that the reciprocal estimate instructions
4494 provide higher-precision estimates than is mandated by the PowerPC
4495 ABI.
4497 @item string
4498 @itemx no-string
4499 @cindex @code{target("string")} function attribute, PowerPC
4500 Generate code that uses (does not use) the load string instructions
4501 and the store string word instructions to save multiple registers and
4502 do small block moves.
4504 @item vsx
4505 @itemx no-vsx
4506 @cindex @code{target("vsx")} function attribute, PowerPC
4507 Generate code that uses (does not use) vector/scalar (VSX)
4508 instructions, and also enable the use of built-in functions that allow
4509 more direct access to the VSX instruction set.  In 32-bit code, you
4510 cannot enable VSX or AltiVec instructions unless
4511 @option{-mabi=altivec} is used on the command line.
4513 @item friz
4514 @itemx no-friz
4515 @cindex @code{target("friz")} function attribute, PowerPC
4516 Generate (do not generate) the @code{friz} instruction when the
4517 @option{-funsafe-math-optimizations} option is used to optimize
4518 rounding a floating-point value to 64-bit integer and back to floating
4519 point.  The @code{friz} instruction does not return the same value if
4520 the floating-point number is too large to fit in an integer.
4522 @item avoid-indexed-addresses
4523 @itemx no-avoid-indexed-addresses
4524 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4525 Generate code that tries to avoid (not avoid) the use of indexed load
4526 or store instructions.
4528 @item paired
4529 @itemx no-paired
4530 @cindex @code{target("paired")} function attribute, PowerPC
4531 Generate code that uses (does not use) the generation of PAIRED simd
4532 instructions.
4534 @item longcall
4535 @itemx no-longcall
4536 @cindex @code{target("longcall")} function attribute, PowerPC
4537 Generate code that assumes (does not assume) that all calls are far
4538 away so that a longer more expensive calling sequence is required.
4540 @item cpu=@var{CPU}
4541 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4542 Specify the architecture to generate code for when compiling the
4543 function.  If you select the @code{target("cpu=power7")} attribute when
4544 generating 32-bit code, VSX and AltiVec instructions are not generated
4545 unless you use the @option{-mabi=altivec} option on the command line.
4547 @item tune=@var{TUNE}
4548 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4549 Specify the architecture to tune for when compiling the function.  If
4550 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4551 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4552 compilation tunes for the @var{CPU} architecture, and not the
4553 default tuning specified on the command line.
4554 @end table
4556 On the PowerPC, the inliner does not inline a
4557 function that has different target options than the caller, unless the
4558 callee has a subset of the target options of the caller.
4559 @end table
4561 @node RL78 Function Attributes
4562 @subsection RL78 Function Attributes
4564 These function attributes are supported by the RL78 back end:
4566 @table @code
4567 @item interrupt
4568 @itemx brk_interrupt
4569 @cindex @code{interrupt} function attribute, RL78
4570 @cindex @code{brk_interrupt} function attribute, RL78
4571 These attributes indicate
4572 that the specified function is an interrupt handler.  The compiler generates
4573 function entry and exit sequences suitable for use in an interrupt handler
4574 when this attribute is present.
4576 Use @code{brk_interrupt} instead of @code{interrupt} for
4577 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4578 that must end with @code{RETB} instead of @code{RETI}).
4580 @item naked
4581 @cindex @code{naked} function attribute, RL78
4582 This attribute allows the compiler to construct the
4583 requisite function declaration, while allowing the body of the
4584 function to be assembly code. The specified function will not have
4585 prologue/epilogue sequences generated by the compiler. Only basic
4586 @code{asm} statements can safely be included in naked functions
4587 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4588 basic @code{asm} and C code may appear to work, they cannot be
4589 depended upon to work reliably and are not supported.
4590 @end table
4592 @node RX Function Attributes
4593 @subsection RX Function Attributes
4595 These function attributes are supported by the RX back end:
4597 @table @code
4598 @item fast_interrupt
4599 @cindex @code{fast_interrupt} function attribute, RX
4600 Use this attribute on the RX port to indicate that the specified
4601 function is a fast interrupt handler.  This is just like the
4602 @code{interrupt} attribute, except that @code{freit} is used to return
4603 instead of @code{reit}.
4605 @item interrupt
4606 @cindex @code{interrupt} function attribute, RX
4607 Use this attribute to indicate
4608 that the specified function is an interrupt handler.  The compiler generates
4609 function entry and exit sequences suitable for use in an interrupt handler
4610 when this attribute is present.
4612 On RX targets, you may specify one or more vector numbers as arguments
4613 to the attribute, as well as naming an alternate table name.
4614 Parameters are handled sequentially, so one handler can be assigned to
4615 multiple entries in multiple tables.  One may also pass the magic
4616 string @code{"$default"} which causes the function to be used for any
4617 unfilled slots in the current table.
4619 This example shows a simple assignment of a function to one vector in
4620 the default table (note that preprocessor macros may be used for
4621 chip-specific symbolic vector names):
4622 @smallexample
4623 void __attribute__ ((interrupt (5))) txd1_handler ();
4624 @end smallexample
4626 This example assigns a function to two slots in the default table
4627 (using preprocessor macros defined elsewhere) and makes it the default
4628 for the @code{dct} table:
4629 @smallexample
4630 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4631         txd1_handler ();
4632 @end smallexample
4634 @item naked
4635 @cindex @code{naked} function attribute, RX
4636 This attribute allows the compiler to construct the
4637 requisite function declaration, while allowing the body of the
4638 function to be assembly code. The specified function will not have
4639 prologue/epilogue sequences generated by the compiler. Only basic
4640 @code{asm} statements can safely be included in naked functions
4641 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4642 basic @code{asm} and C code may appear to work, they cannot be
4643 depended upon to work reliably and are not supported.
4645 @item vector
4646 @cindex @code{vector} function attribute, RX
4647 This RX attribute is similar to the @code{interrupt} attribute, including its
4648 parameters, but does not make the function an interrupt-handler type
4649 function (i.e. it retains the normal C function calling ABI).  See the
4650 @code{interrupt} attribute for a description of its arguments.
4651 @end table
4653 @node S/390 Function Attributes
4654 @subsection S/390 Function Attributes
4656 These function attributes are supported on the S/390:
4658 @table @code
4659 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4660 @cindex @code{hotpatch} function attribute, S/390
4662 On S/390 System z targets, you can use this function attribute to
4663 make GCC generate a ``hot-patching'' function prologue.  If the
4664 @option{-mhotpatch=} command-line option is used at the same time,
4665 the @code{hotpatch} attribute takes precedence.  The first of the
4666 two arguments specifies the number of halfwords to be added before
4667 the function label.  A second argument can be used to specify the
4668 number of halfwords to be added after the function label.  For
4669 both arguments the maximum allowed value is 1000000.
4671 If both arguments are zero, hotpatching is disabled.
4672 @end table
4674 @node SH Function Attributes
4675 @subsection SH Function Attributes
4677 These function attributes are supported on the SH family of processors:
4679 @table @code
4680 @item function_vector
4681 @cindex @code{function_vector} function attribute, SH
4682 @cindex calling functions through the function vector on SH2A
4683 On SH2A targets, this attribute declares a function to be called using the
4684 TBR relative addressing mode.  The argument to this attribute is the entry
4685 number of the same function in a vector table containing all the TBR
4686 relative addressable functions.  For correct operation the TBR must be setup
4687 accordingly to point to the start of the vector table before any functions with
4688 this attribute are invoked.  Usually a good place to do the initialization is
4689 the startup routine.  The TBR relative vector table can have at max 256 function
4690 entries.  The jumps to these functions are generated using a SH2A specific,
4691 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
4692 from GNU binutils version 2.7 or later for this attribute to work correctly.
4694 In an application, for a function being called once, this attribute
4695 saves at least 8 bytes of code; and if other successive calls are being
4696 made to the same function, it saves 2 bytes of code per each of these
4697 calls.
4699 @item interrupt_handler
4700 @cindex @code{interrupt_handler} function attribute, SH
4701 Use this attribute to
4702 indicate that the specified function is an interrupt handler.  The compiler
4703 generates function entry and exit sequences suitable for use in an
4704 interrupt handler when this attribute is present.
4706 @item nosave_low_regs
4707 @cindex @code{nosave_low_regs} function attribute, SH
4708 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
4709 function should not save and restore registers R0..R7.  This can be used on SH3*
4710 and SH4* targets that have a second R0..R7 register bank for non-reentrant
4711 interrupt handlers.
4713 @item renesas
4714 @cindex @code{renesas} function attribute, SH
4715 On SH targets this attribute specifies that the function or struct follows the
4716 Renesas ABI.
4718 @item resbank
4719 @cindex @code{resbank} function attribute, SH
4720 On the SH2A target, this attribute enables the high-speed register
4721 saving and restoration using a register bank for @code{interrupt_handler}
4722 routines.  Saving to the bank is performed automatically after the CPU
4723 accepts an interrupt that uses a register bank.
4725 The nineteen 32-bit registers comprising general register R0 to R14,
4726 control register GBR, and system registers MACH, MACL, and PR and the
4727 vector table address offset are saved into a register bank.  Register
4728 banks are stacked in first-in last-out (FILO) sequence.  Restoration
4729 from the bank is executed by issuing a RESBANK instruction.
4731 @item sp_switch
4732 @cindex @code{sp_switch} function attribute, SH
4733 Use this attribute on the SH to indicate an @code{interrupt_handler}
4734 function should switch to an alternate stack.  It expects a string
4735 argument that names a global variable holding the address of the
4736 alternate stack.
4738 @smallexample
4739 void *alt_stack;
4740 void f () __attribute__ ((interrupt_handler,
4741                           sp_switch ("alt_stack")));
4742 @end smallexample
4744 @item trap_exit
4745 @cindex @code{trap_exit} function attribute, SH
4746 Use this attribute on the SH for an @code{interrupt_handler} to return using
4747 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4748 argument specifying the trap number to be used.
4750 @item trapa_handler
4751 @cindex @code{trapa_handler} function attribute, SH
4752 On SH targets this function attribute is similar to @code{interrupt_handler}
4753 but it does not save and restore all registers.
4754 @end table
4756 @node SPU Function Attributes
4757 @subsection SPU Function Attributes
4759 These function attributes are supported by the SPU back end:
4761 @table @code
4762 @item naked
4763 @cindex @code{naked} function attribute, SPU
4764 This attribute allows the compiler to construct the
4765 requisite function declaration, while allowing the body of the
4766 function to be assembly code. The specified function will not have
4767 prologue/epilogue sequences generated by the compiler. Only basic
4768 @code{asm} statements can safely be included in naked functions
4769 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4770 basic @code{asm} and C code may appear to work, they cannot be
4771 depended upon to work reliably and are not supported.
4772 @end table
4774 @node Symbian OS Function Attributes
4775 @subsection Symbian OS Function Attributes
4777 @xref{Microsoft Windows Function Attributes}, for discussion of the
4778 @code{dllexport} and @code{dllimport} attributes.
4780 @node Visium Function Attributes
4781 @subsection Visium Function Attributes
4783 These function attributes are supported by the Visium back end:
4785 @table @code
4786 @item interrupt
4787 @cindex @code{interrupt} function attribute, Visium
4788 Use this attribute to indicate
4789 that the specified function is an interrupt handler.  The compiler generates
4790 function entry and exit sequences suitable for use in an interrupt handler
4791 when this attribute is present.
4792 @end table
4794 @node x86 Function Attributes
4795 @subsection x86 Function Attributes
4797 These function attributes are supported by the x86 back end:
4799 @table @code
4800 @item cdecl
4801 @cindex @code{cdecl} function attribute, x86-32
4802 @cindex functions that pop the argument stack on x86-32
4803 @opindex mrtd
4804 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
4805 assume that the calling function pops off the stack space used to
4806 pass arguments.  This is
4807 useful to override the effects of the @option{-mrtd} switch.
4809 @item fastcall
4810 @cindex @code{fastcall} function attribute, x86-32
4811 @cindex functions that pop the argument stack on x86-32
4812 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
4813 pass the first argument (if of integral type) in the register ECX and
4814 the second argument (if of integral type) in the register EDX@.  Subsequent
4815 and other typed arguments are passed on the stack.  The called function
4816 pops the arguments off the stack.  If the number of arguments is variable all
4817 arguments are pushed on the stack.
4819 @item thiscall
4820 @cindex @code{thiscall} function attribute, x86-32
4821 @cindex functions that pop the argument stack on x86-32
4822 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
4823 pass the first argument (if of integral type) in the register ECX.
4824 Subsequent and other typed arguments are passed on the stack. The called
4825 function pops the arguments off the stack.
4826 If the number of arguments is variable all arguments are pushed on the
4827 stack.
4828 The @code{thiscall} attribute is intended for C++ non-static member functions.
4829 As a GCC extension, this calling convention can be used for C functions
4830 and for static member methods.
4832 @item ms_abi
4833 @itemx sysv_abi
4834 @cindex @code{ms_abi} function attribute, x86
4835 @cindex @code{sysv_abi} function attribute, x86
4837 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
4838 to indicate which calling convention should be used for a function.  The
4839 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
4840 while the @code{sysv_abi} attribute tells the compiler to use the ABI
4841 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
4842 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
4844 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
4845 requires the @option{-maccumulate-outgoing-args} option.
4847 @item callee_pop_aggregate_return (@var{number})
4848 @cindex @code{callee_pop_aggregate_return} function attribute, x86
4850 On x86-32 targets, you can use this attribute to control how
4851 aggregates are returned in memory.  If the caller is responsible for
4852 popping the hidden pointer together with the rest of the arguments, specify
4853 @var{number} equal to zero.  If callee is responsible for popping the
4854 hidden pointer, specify @var{number} equal to one.  
4856 The default x86-32 ABI assumes that the callee pops the
4857 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
4858 the compiler assumes that the
4859 caller pops the stack for hidden pointer.
4861 @item ms_hook_prologue
4862 @cindex @code{ms_hook_prologue} function attribute, x86
4864 On 32-bit and 64-bit x86 targets, you can use
4865 this function attribute to make GCC generate the ``hot-patching'' function
4866 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
4867 and newer.
4869 @item regparm (@var{number})
4870 @cindex @code{regparm} function attribute, x86
4871 @cindex functions that are passed arguments in registers on x86-32
4872 On x86-32 targets, the @code{regparm} attribute causes the compiler to
4873 pass arguments number one to @var{number} if they are of integral type
4874 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
4875 take a variable number of arguments continue to be passed all of their
4876 arguments on the stack.
4878 Beware that on some ELF systems this attribute is unsuitable for
4879 global functions in shared libraries with lazy binding (which is the
4880 default).  Lazy binding sends the first call via resolving code in
4881 the loader, which might assume EAX, EDX and ECX can be clobbered, as
4882 per the standard calling conventions.  Solaris 8 is affected by this.
4883 Systems with the GNU C Library version 2.1 or higher
4884 and FreeBSD are believed to be
4885 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
4886 disabled with the linker or the loader if desired, to avoid the
4887 problem.)
4889 @item sseregparm
4890 @cindex @code{sseregparm} function attribute, x86
4891 On x86-32 targets with SSE support, the @code{sseregparm} attribute
4892 causes the compiler to pass up to 3 floating-point arguments in
4893 SSE registers instead of on the stack.  Functions that take a
4894 variable number of arguments continue to pass all of their
4895 floating-point arguments on the stack.
4897 @item force_align_arg_pointer
4898 @cindex @code{force_align_arg_pointer} function attribute, x86
4899 On x86 targets, the @code{force_align_arg_pointer} attribute may be
4900 applied to individual function definitions, generating an alternate
4901 prologue and epilogue that realigns the run-time stack if necessary.
4902 This supports mixing legacy codes that run with a 4-byte aligned stack
4903 with modern codes that keep a 16-byte stack for SSE compatibility.
4905 @item stdcall
4906 @cindex @code{stdcall} function attribute, x86-32
4907 @cindex functions that pop the argument stack on x86-32
4908 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
4909 assume that the called function pops off the stack space used to
4910 pass arguments, unless it takes a variable number of arguments.
4912 @item target (@var{options})
4913 @cindex @code{target} function attribute
4914 As discussed in @ref{Common Function Attributes}, this attribute 
4915 allows specification of target-specific compilation options.
4917 On the x86, the following options are allowed:
4918 @table @samp
4919 @item abm
4920 @itemx no-abm
4921 @cindex @code{target("abm")} function attribute, x86
4922 Enable/disable the generation of the advanced bit instructions.
4924 @item aes
4925 @itemx no-aes
4926 @cindex @code{target("aes")} function attribute, x86
4927 Enable/disable the generation of the AES instructions.
4929 @item default
4930 @cindex @code{target("default")} function attribute, x86
4931 @xref{Function Multiversioning}, where it is used to specify the
4932 default function version.
4934 @item mmx
4935 @itemx no-mmx
4936 @cindex @code{target("mmx")} function attribute, x86
4937 Enable/disable the generation of the MMX instructions.
4939 @item pclmul
4940 @itemx no-pclmul
4941 @cindex @code{target("pclmul")} function attribute, x86
4942 Enable/disable the generation of the PCLMUL instructions.
4944 @item popcnt
4945 @itemx no-popcnt
4946 @cindex @code{target("popcnt")} function attribute, x86
4947 Enable/disable the generation of the POPCNT instruction.
4949 @item sse
4950 @itemx no-sse
4951 @cindex @code{target("sse")} function attribute, x86
4952 Enable/disable the generation of the SSE instructions.
4954 @item sse2
4955 @itemx no-sse2
4956 @cindex @code{target("sse2")} function attribute, x86
4957 Enable/disable the generation of the SSE2 instructions.
4959 @item sse3
4960 @itemx no-sse3
4961 @cindex @code{target("sse3")} function attribute, x86
4962 Enable/disable the generation of the SSE3 instructions.
4964 @item sse4
4965 @itemx no-sse4
4966 @cindex @code{target("sse4")} function attribute, x86
4967 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4968 and SSE4.2).
4970 @item sse4.1
4971 @itemx no-sse4.1
4972 @cindex @code{target("sse4.1")} function attribute, x86
4973 Enable/disable the generation of the sse4.1 instructions.
4975 @item sse4.2
4976 @itemx no-sse4.2
4977 @cindex @code{target("sse4.2")} function attribute, x86
4978 Enable/disable the generation of the sse4.2 instructions.
4980 @item sse4a
4981 @itemx no-sse4a
4982 @cindex @code{target("sse4a")} function attribute, x86
4983 Enable/disable the generation of the SSE4A instructions.
4985 @item fma4
4986 @itemx no-fma4
4987 @cindex @code{target("fma4")} function attribute, x86
4988 Enable/disable the generation of the FMA4 instructions.
4990 @item xop
4991 @itemx no-xop
4992 @cindex @code{target("xop")} function attribute, x86
4993 Enable/disable the generation of the XOP instructions.
4995 @item lwp
4996 @itemx no-lwp
4997 @cindex @code{target("lwp")} function attribute, x86
4998 Enable/disable the generation of the LWP instructions.
5000 @item ssse3
5001 @itemx no-ssse3
5002 @cindex @code{target("ssse3")} function attribute, x86
5003 Enable/disable the generation of the SSSE3 instructions.
5005 @item cld
5006 @itemx no-cld
5007 @cindex @code{target("cld")} function attribute, x86
5008 Enable/disable the generation of the CLD before string moves.
5010 @item fancy-math-387
5011 @itemx no-fancy-math-387
5012 @cindex @code{target("fancy-math-387")} function attribute, x86
5013 Enable/disable the generation of the @code{sin}, @code{cos}, and
5014 @code{sqrt} instructions on the 387 floating-point unit.
5016 @item fused-madd
5017 @itemx no-fused-madd
5018 @cindex @code{target("fused-madd")} function attribute, x86
5019 Enable/disable the generation of the fused multiply/add instructions.
5021 @item ieee-fp
5022 @itemx no-ieee-fp
5023 @cindex @code{target("ieee-fp")} function attribute, x86
5024 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5026 @item inline-all-stringops
5027 @itemx no-inline-all-stringops
5028 @cindex @code{target("inline-all-stringops")} function attribute, x86
5029 Enable/disable inlining of string operations.
5031 @item inline-stringops-dynamically
5032 @itemx no-inline-stringops-dynamically
5033 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5034 Enable/disable the generation of the inline code to do small string
5035 operations and calling the library routines for large operations.
5037 @item align-stringops
5038 @itemx no-align-stringops
5039 @cindex @code{target("align-stringops")} function attribute, x86
5040 Do/do not align destination of inlined string operations.
5042 @item recip
5043 @itemx no-recip
5044 @cindex @code{target("recip")} function attribute, x86
5045 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5046 instructions followed an additional Newton-Raphson step instead of
5047 doing a floating-point division.
5049 @item arch=@var{ARCH}
5050 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5051 Specify the architecture to generate code for in compiling the function.
5053 @item tune=@var{TUNE}
5054 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5055 Specify the architecture to tune for in compiling the function.
5057 @item fpmath=@var{FPMATH}
5058 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5059 Specify which floating-point unit to use.  You must specify the
5060 @code{target("fpmath=sse,387")} option as
5061 @code{target("fpmath=sse+387")} because the comma would separate
5062 different options.
5063 @end table
5065 On the x86, the inliner does not inline a
5066 function that has different target options than the caller, unless the
5067 callee has a subset of the target options of the caller.  For example
5068 a function declared with @code{target("sse3")} can inline a function
5069 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5070 @end table
5072 @node Xstormy16 Function Attributes
5073 @subsection Xstormy16 Function Attributes
5075 These function attributes are supported by the Xstormy16 back end:
5077 @table @code
5078 @item interrupt
5079 @cindex @code{interrupt} function attribute, Xstormy16
5080 Use this attribute to indicate
5081 that the specified function is an interrupt handler.  The compiler generates
5082 function entry and exit sequences suitable for use in an interrupt handler
5083 when this attribute is present.
5084 @end table
5086 @node Variable Attributes
5087 @section Specifying Attributes of Variables
5088 @cindex attribute of variables
5089 @cindex variable attributes
5091 The keyword @code{__attribute__} allows you to specify special
5092 attributes of variables or structure fields.  This keyword is followed
5093 by an attribute specification inside double parentheses.  Some
5094 attributes are currently defined generically for variables.
5095 Other attributes are defined for variables on particular target
5096 systems.  Other attributes are available for functions
5097 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5098 enumerators (@pxref{Enumerator Attributes}), and for types
5099 (@pxref{Type Attributes}).
5100 Other front ends might define more attributes
5101 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5103 @xref{Attribute Syntax}, for details of the exact syntax for using
5104 attributes.
5106 @menu
5107 * Common Variable Attributes::
5108 * AVR Variable Attributes::
5109 * Blackfin Variable Attributes::
5110 * H8/300 Variable Attributes::
5111 * IA-64 Variable Attributes::
5112 * M32R/D Variable Attributes::
5113 * MeP Variable Attributes::
5114 * Microsoft Windows Variable Attributes::
5115 * PowerPC Variable Attributes::
5116 * SPU Variable Attributes::
5117 * x86 Variable Attributes::
5118 * Xstormy16 Variable Attributes::
5119 @end menu
5121 @node Common Variable Attributes
5122 @subsection Common Variable Attributes
5124 The following attributes are supported on most targets.
5126 @table @code
5127 @cindex @code{aligned} variable attribute
5128 @item aligned (@var{alignment})
5129 This attribute specifies a minimum alignment for the variable or
5130 structure field, measured in bytes.  For example, the declaration:
5132 @smallexample
5133 int x __attribute__ ((aligned (16))) = 0;
5134 @end smallexample
5136 @noindent
5137 causes the compiler to allocate the global variable @code{x} on a
5138 16-byte boundary.  On a 68040, this could be used in conjunction with
5139 an @code{asm} expression to access the @code{move16} instruction which
5140 requires 16-byte aligned operands.
5142 You can also specify the alignment of structure fields.  For example, to
5143 create a double-word aligned @code{int} pair, you could write:
5145 @smallexample
5146 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5147 @end smallexample
5149 @noindent
5150 This is an alternative to creating a union with a @code{double} member,
5151 which forces the union to be double-word aligned.
5153 As in the preceding examples, you can explicitly specify the alignment
5154 (in bytes) that you wish the compiler to use for a given variable or
5155 structure field.  Alternatively, you can leave out the alignment factor
5156 and just ask the compiler to align a variable or field to the
5157 default alignment for the target architecture you are compiling for.
5158 The default alignment is sufficient for all scalar types, but may not be
5159 enough for all vector types on a target that supports vector operations.
5160 The default alignment is fixed for a particular target ABI.
5162 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5163 which is the largest alignment ever used for any data type on the
5164 target machine you are compiling for.  For example, you could write:
5166 @smallexample
5167 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5168 @end smallexample
5170 The compiler automatically sets the alignment for the declared
5171 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5172 often make copy operations more efficient, because the compiler can
5173 use whatever instructions copy the biggest chunks of memory when
5174 performing copies to or from the variables or fields that you have
5175 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5176 may change depending on command-line options.
5178 When used on a struct, or struct member, the @code{aligned} attribute can
5179 only increase the alignment; in order to decrease it, the @code{packed}
5180 attribute must be specified as well.  When used as part of a typedef, the
5181 @code{aligned} attribute can both increase and decrease alignment, and
5182 specifying the @code{packed} attribute generates a warning.
5184 Note that the effectiveness of @code{aligned} attributes may be limited
5185 by inherent limitations in your linker.  On many systems, the linker is
5186 only able to arrange for variables to be aligned up to a certain maximum
5187 alignment.  (For some linkers, the maximum supported alignment may
5188 be very very small.)  If your linker is only able to align variables
5189 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5190 in an @code{__attribute__} still only provides you with 8-byte
5191 alignment.  See your linker documentation for further information.
5193 The @code{aligned} attribute can also be used for functions
5194 (@pxref{Common Function Attributes}.)
5196 @item cleanup (@var{cleanup_function})
5197 @cindex @code{cleanup} variable attribute
5198 The @code{cleanup} attribute runs a function when the variable goes
5199 out of scope.  This attribute can only be applied to auto function
5200 scope variables; it may not be applied to parameters or variables
5201 with static storage duration.  The function must take one parameter,
5202 a pointer to a type compatible with the variable.  The return value
5203 of the function (if any) is ignored.
5205 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5206 is run during the stack unwinding that happens during the
5207 processing of the exception.  Note that the @code{cleanup} attribute
5208 does not allow the exception to be caught, only to perform an action.
5209 It is undefined what happens if @var{cleanup_function} does not
5210 return normally.
5212 @item common
5213 @itemx nocommon
5214 @cindex @code{common} variable attribute
5215 @cindex @code{nocommon} variable attribute
5216 @opindex fcommon
5217 @opindex fno-common
5218 The @code{common} attribute requests GCC to place a variable in
5219 ``common'' storage.  The @code{nocommon} attribute requests the
5220 opposite---to allocate space for it directly.
5222 These attributes override the default chosen by the
5223 @option{-fno-common} and @option{-fcommon} flags respectively.
5225 @item deprecated
5226 @itemx deprecated (@var{msg})
5227 @cindex @code{deprecated} variable attribute
5228 The @code{deprecated} attribute results in a warning if the variable
5229 is used anywhere in the source file.  This is useful when identifying
5230 variables that are expected to be removed in a future version of a
5231 program.  The warning also includes the location of the declaration
5232 of the deprecated variable, to enable users to easily find further
5233 information about why the variable is deprecated, or what they should
5234 do instead.  Note that the warning only occurs for uses:
5236 @smallexample
5237 extern int old_var __attribute__ ((deprecated));
5238 extern int old_var;
5239 int new_fn () @{ return old_var; @}
5240 @end smallexample
5242 @noindent
5243 results in a warning on line 3 but not line 2.  The optional @var{msg}
5244 argument, which must be a string, is printed in the warning if
5245 present.
5247 The @code{deprecated} attribute can also be used for functions and
5248 types (@pxref{Common Function Attributes},
5249 @pxref{Common Type Attributes}).
5251 @item mode (@var{mode})
5252 @cindex @code{mode} variable attribute
5253 This attribute specifies the data type for the declaration---whichever
5254 type corresponds to the mode @var{mode}.  This in effect lets you
5255 request an integer or floating-point type according to its width.
5257 You may also specify a mode of @code{byte} or @code{__byte__} to
5258 indicate the mode corresponding to a one-byte integer, @code{word} or
5259 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5260 or @code{__pointer__} for the mode used to represent pointers.
5262 @item packed
5263 @cindex @code{packed} variable attribute
5264 The @code{packed} attribute specifies that a variable or structure field
5265 should have the smallest possible alignment---one byte for a variable,
5266 and one bit for a field, unless you specify a larger value with the
5267 @code{aligned} attribute.
5269 Here is a structure in which the field @code{x} is packed, so that it
5270 immediately follows @code{a}:
5272 @smallexample
5273 struct foo
5275   char a;
5276   int x[2] __attribute__ ((packed));
5278 @end smallexample
5280 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5281 @code{packed} attribute on bit-fields of type @code{char}.  This has
5282 been fixed in GCC 4.4 but the change can lead to differences in the
5283 structure layout.  See the documentation of
5284 @option{-Wpacked-bitfield-compat} for more information.
5286 @item section ("@var{section-name}")
5287 @cindex @code{section} variable attribute
5288 Normally, the compiler places the objects it generates in sections like
5289 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5290 or you need certain particular variables to appear in special sections,
5291 for example to map to special hardware.  The @code{section}
5292 attribute specifies that a variable (or function) lives in a particular
5293 section.  For example, this small program uses several specific section names:
5295 @smallexample
5296 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5297 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5298 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5299 int init_data __attribute__ ((section ("INITDATA")));
5301 main()
5303   /* @r{Initialize stack pointer} */
5304   init_sp (stack + sizeof (stack));
5306   /* @r{Initialize initialized data} */
5307   memcpy (&init_data, &data, &edata - &data);
5309   /* @r{Turn on the serial ports} */
5310   init_duart (&a);
5311   init_duart (&b);
5313 @end smallexample
5315 @noindent
5316 Use the @code{section} attribute with
5317 @emph{global} variables and not @emph{local} variables,
5318 as shown in the example.
5320 You may use the @code{section} attribute with initialized or
5321 uninitialized global variables but the linker requires
5322 each object be defined once, with the exception that uninitialized
5323 variables tentatively go in the @code{common} (or @code{bss}) section
5324 and can be multiply ``defined''.  Using the @code{section} attribute
5325 changes what section the variable goes into and may cause the
5326 linker to issue an error if an uninitialized variable has multiple
5327 definitions.  You can force a variable to be initialized with the
5328 @option{-fno-common} flag or the @code{nocommon} attribute.
5330 Some file formats do not support arbitrary sections so the @code{section}
5331 attribute is not available on all platforms.
5332 If you need to map the entire contents of a module to a particular
5333 section, consider using the facilities of the linker instead.
5335 @item tls_model ("@var{tls_model}")
5336 @cindex @code{tls_model} variable attribute
5337 The @code{tls_model} attribute sets thread-local storage model
5338 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5339 overriding @option{-ftls-model=} command-line switch on a per-variable
5340 basis.
5341 The @var{tls_model} argument should be one of @code{global-dynamic},
5342 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5344 Not all targets support this attribute.
5346 @item unused
5347 @cindex @code{unused} variable attribute
5348 This attribute, attached to a variable, means that the variable is meant
5349 to be possibly unused.  GCC does not produce a warning for this
5350 variable.
5352 @item used
5353 @cindex @code{used} variable attribute
5354 This attribute, attached to a variable with static storage, means that
5355 the variable must be emitted even if it appears that the variable is not
5356 referenced.
5358 When applied to a static data member of a C++ class template, the
5359 attribute also means that the member is instantiated if the
5360 class itself is instantiated.
5362 @item vector_size (@var{bytes})
5363 @cindex @code{vector_size} variable attribute
5364 This attribute specifies the vector size for the variable, measured in
5365 bytes.  For example, the declaration:
5367 @smallexample
5368 int foo __attribute__ ((vector_size (16)));
5369 @end smallexample
5371 @noindent
5372 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5373 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5374 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5376 This attribute is only applicable to integral and float scalars,
5377 although arrays, pointers, and function return values are allowed in
5378 conjunction with this construct.
5380 Aggregates with this attribute are invalid, even if they are of the same
5381 size as a corresponding scalar.  For example, the declaration:
5383 @smallexample
5384 struct S @{ int a; @};
5385 struct S  __attribute__ ((vector_size (16))) foo;
5386 @end smallexample
5388 @noindent
5389 is invalid even if the size of the structure is the same as the size of
5390 the @code{int}.
5392 @item weak
5393 @cindex @code{weak} variable attribute
5394 The @code{weak} attribute is described in
5395 @ref{Common Function Attributes}.
5397 @end table
5399 @node AVR Variable Attributes
5400 @subsection AVR Variable Attributes
5402 @table @code
5403 @item progmem
5404 @cindex @code{progmem} variable attribute, AVR
5405 The @code{progmem} attribute is used on the AVR to place read-only
5406 data in the non-volatile program memory (flash). The @code{progmem}
5407 attribute accomplishes this by putting respective variables into a
5408 section whose name starts with @code{.progmem}.
5410 This attribute works similar to the @code{section} attribute
5411 but adds additional checking. Notice that just like the
5412 @code{section} attribute, @code{progmem} affects the location
5413 of the data but not how this data is accessed.
5415 In order to read data located with the @code{progmem} attribute
5416 (inline) assembler must be used.
5417 @smallexample
5418 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5419 #include <avr/pgmspace.h> 
5421 /* Locate var in flash memory */
5422 const int var[2] PROGMEM = @{ 1, 2 @};
5424 int read_var (int i)
5426     /* Access var[] by accessor macro from avr/pgmspace.h */
5427     return (int) pgm_read_word (& var[i]);
5429 @end smallexample
5431 AVR is a Harvard architecture processor and data and read-only data
5432 normally resides in the data memory (RAM).
5434 See also the @ref{AVR Named Address Spaces} section for
5435 an alternate way to locate and access data in flash memory.
5437 @item io
5438 @itemx io (@var{addr})
5439 @cindex @code{io} variable attribute, AVR
5440 Variables with the @code{io} attribute are used to address
5441 memory-mapped peripherals in the io address range.
5442 If an address is specified, the variable
5443 is assigned that address, and the value is interpreted as an
5444 address in the data address space.
5445 Example:
5447 @smallexample
5448 volatile int porta __attribute__((io (0x22)));
5449 @end smallexample
5451 The address specified in the address in the data address range.
5453 Otherwise, the variable it is not assigned an address, but the
5454 compiler will still use in/out instructions where applicable,
5455 assuming some other module assigns an address in the io address range.
5456 Example:
5458 @smallexample
5459 extern volatile int porta __attribute__((io));
5460 @end smallexample
5462 @item io_low
5463 @itemx io_low (@var{addr})
5464 @cindex @code{io_low} variable attribute, AVR
5465 This is like the @code{io} attribute, but additionally it informs the
5466 compiler that the object lies in the lower half of the I/O area,
5467 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5468 instructions.
5470 @item address
5471 @itemx address (@var{addr})
5472 @cindex @code{address} variable attribute, AVR
5473 Variables with the @code{address} attribute are used to address
5474 memory-mapped peripherals that may lie outside the io address range.
5476 @smallexample
5477 volatile int porta __attribute__((address (0x600)));
5478 @end smallexample
5480 @end table
5482 @node Blackfin Variable Attributes
5483 @subsection Blackfin Variable Attributes
5485 Three attributes are currently defined for the Blackfin.
5487 @table @code
5488 @item l1_data
5489 @itemx l1_data_A
5490 @itemx l1_data_B
5491 @cindex @code{l1_data} variable attribute, Blackfin
5492 @cindex @code{l1_data_A} variable attribute, Blackfin
5493 @cindex @code{l1_data_B} variable attribute, Blackfin
5494 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5495 Variables with @code{l1_data} attribute are put into the specific section
5496 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5497 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5498 attribute are put into the specific section named @code{.l1.data.B}.
5500 @item l2
5501 @cindex @code{l2} variable attribute, Blackfin
5502 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5503 Variables with @code{l2} attribute are put into the specific section
5504 named @code{.l2.data}.
5505 @end table
5507 @node H8/300 Variable Attributes
5508 @subsection H8/300 Variable Attributes
5510 These variable attributes are available for H8/300 targets:
5512 @table @code
5513 @item eightbit_data
5514 @cindex @code{eightbit_data} variable attribute, H8/300
5515 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5516 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5517 variable should be placed into the eight-bit data section.
5518 The compiler generates more efficient code for certain operations
5519 on data in the eight-bit data area.  Note the eight-bit data area is limited to
5520 256 bytes of data.
5522 You must use GAS and GLD from GNU binutils version 2.7 or later for
5523 this attribute to work correctly.
5525 @item tiny_data
5526 @cindex @code{tiny_data} variable attribute, H8/300
5527 @cindex tiny data section on the H8/300H and H8S
5528 Use this attribute on the H8/300H and H8S to indicate that the specified
5529 variable should be placed into the tiny data section.
5530 The compiler generates more efficient code for loads and stores
5531 on data in the tiny data section.  Note the tiny data area is limited to
5532 slightly under 32KB of data.
5534 @end table
5536 @node IA-64 Variable Attributes
5537 @subsection IA-64 Variable Attributes
5539 The IA-64 back end supports the following variable attribute:
5541 @table @code
5542 @item model (@var{model-name})
5543 @cindex @code{model} variable attribute, IA-64
5545 On IA-64, use this attribute to set the addressability of an object.
5546 At present, the only supported identifier for @var{model-name} is
5547 @code{small}, indicating addressability via ``small'' (22-bit)
5548 addresses (so that their addresses can be loaded with the @code{addl}
5549 instruction).  Caveat: such addressing is by definition not position
5550 independent and hence this attribute must not be used for objects
5551 defined by shared libraries.
5553 @end table
5555 @node M32R/D Variable Attributes
5556 @subsection M32R/D Variable Attributes
5558 One attribute is currently defined for the M32R/D@.
5560 @table @code
5561 @item model (@var{model-name})
5562 @cindex @code{model-name} variable attribute, M32R/D
5563 @cindex variable addressability on the M32R/D
5564 Use this attribute on the M32R/D to set the addressability of an object.
5565 The identifier @var{model-name} is one of @code{small}, @code{medium},
5566 or @code{large}, representing each of the code models.
5568 Small model objects live in the lower 16MB of memory (so that their
5569 addresses can be loaded with the @code{ld24} instruction).
5571 Medium and large model objects may live anywhere in the 32-bit address space
5572 (the compiler generates @code{seth/add3} instructions to load their
5573 addresses).
5574 @end table
5576 @node MeP Variable Attributes
5577 @subsection MeP Variable Attributes
5579 The MeP target has a number of addressing modes and busses.  The
5580 @code{near} space spans the standard memory space's first 16 megabytes
5581 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5582 The @code{based} space is a 128-byte region in the memory space that
5583 is addressed relative to the @code{$tp} register.  The @code{tiny}
5584 space is a 65536-byte region relative to the @code{$gp} register.  In
5585 addition to these memory regions, the MeP target has a separate 16-bit
5586 control bus which is specified with @code{cb} attributes.
5588 @table @code
5590 @item based
5591 @cindex @code{based} variable attribute, MeP
5592 Any variable with the @code{based} attribute is assigned to the
5593 @code{.based} section, and is accessed with relative to the
5594 @code{$tp} register.
5596 @item tiny
5597 @cindex @code{tiny} variable attribute, MeP
5598 Likewise, the @code{tiny} attribute assigned variables to the
5599 @code{.tiny} section, relative to the @code{$gp} register.
5601 @item near
5602 @cindex @code{near} variable attribute, MeP
5603 Variables with the @code{near} attribute are assumed to have addresses
5604 that fit in a 24-bit addressing mode.  This is the default for large
5605 variables (@code{-mtiny=4} is the default) but this attribute can
5606 override @code{-mtiny=} for small variables, or override @code{-ml}.
5608 @item far
5609 @cindex @code{far} variable attribute, MeP
5610 Variables with the @code{far} attribute are addressed using a full
5611 32-bit address.  Since this covers the entire memory space, this
5612 allows modules to make no assumptions about where variables might be
5613 stored.
5615 @item io
5616 @cindex @code{io} variable attribute, MeP
5617 @itemx io (@var{addr})
5618 Variables with the @code{io} attribute are used to address
5619 memory-mapped peripherals.  If an address is specified, the variable
5620 is assigned that address, else it is not assigned an address (it is
5621 assumed some other module assigns an address).  Example:
5623 @smallexample
5624 int timer_count __attribute__((io(0x123)));
5625 @end smallexample
5627 @item cb
5628 @itemx cb (@var{addr})
5629 @cindex @code{cb} variable attribute, MeP
5630 Variables with the @code{cb} attribute are used to access the control
5631 bus, using special instructions.  @code{addr} indicates the control bus
5632 address.  Example:
5634 @smallexample
5635 int cpu_clock __attribute__((cb(0x123)));
5636 @end smallexample
5638 @end table
5640 @node Microsoft Windows Variable Attributes
5641 @subsection Microsoft Windows Variable Attributes
5643 You can use these attributes on Microsoft Windows targets.
5644 @ref{x86 Variable Attributes} for additional Windows compatibility
5645 attributes available on all x86 targets.
5647 @table @code
5648 @item dllimport
5649 @itemx dllexport
5650 @cindex @code{dllimport} variable attribute
5651 @cindex @code{dllexport} variable attribute
5652 The @code{dllimport} and @code{dllexport} attributes are described in
5653 @ref{Microsoft Windows Function Attributes}.
5655 @item selectany
5656 @cindex @code{selectany} variable attribute
5657 The @code{selectany} attribute causes an initialized global variable to
5658 have link-once semantics.  When multiple definitions of the variable are
5659 encountered by the linker, the first is selected and the remainder are
5660 discarded.  Following usage by the Microsoft compiler, the linker is told
5661 @emph{not} to warn about size or content differences of the multiple
5662 definitions.
5664 Although the primary usage of this attribute is for POD types, the
5665 attribute can also be applied to global C++ objects that are initialized
5666 by a constructor.  In this case, the static initialization and destruction
5667 code for the object is emitted in each translation defining the object,
5668 but the calls to the constructor and destructor are protected by a
5669 link-once guard variable.
5671 The @code{selectany} attribute is only available on Microsoft Windows
5672 targets.  You can use @code{__declspec (selectany)} as a synonym for
5673 @code{__attribute__ ((selectany))} for compatibility with other
5674 compilers.
5676 @item shared
5677 @cindex @code{shared} variable attribute
5678 On Microsoft Windows, in addition to putting variable definitions in a named
5679 section, the section can also be shared among all running copies of an
5680 executable or DLL@.  For example, this small program defines shared data
5681 by putting it in a named section @code{shared} and marking the section
5682 shareable:
5684 @smallexample
5685 int foo __attribute__((section ("shared"), shared)) = 0;
5688 main()
5690   /* @r{Read and write foo.  All running
5691      copies see the same value.}  */
5692   return 0;
5694 @end smallexample
5696 @noindent
5697 You may only use the @code{shared} attribute along with @code{section}
5698 attribute with a fully-initialized global definition because of the way
5699 linkers work.  See @code{section} attribute for more information.
5701 The @code{shared} attribute is only available on Microsoft Windows@.
5703 @end table
5705 @node PowerPC Variable Attributes
5706 @subsection PowerPC Variable Attributes
5708 Three attributes currently are defined for PowerPC configurations:
5709 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5711 @cindex @code{ms_struct} variable attribute, PowerPC
5712 @cindex @code{gcc_struct} variable attribute, PowerPC
5713 For full documentation of the struct attributes please see the
5714 documentation in @ref{x86 Variable Attributes}.
5716 @cindex @code{altivec} variable attribute, PowerPC
5717 For documentation of @code{altivec} attribute please see the
5718 documentation in @ref{PowerPC Type Attributes}.
5720 @node SPU Variable Attributes
5721 @subsection SPU Variable Attributes
5723 @cindex @code{spu_vector} variable attribute, SPU
5724 The SPU supports the @code{spu_vector} attribute for variables.  For
5725 documentation of this attribute please see the documentation in
5726 @ref{SPU Type Attributes}.
5728 @node x86 Variable Attributes
5729 @subsection x86 Variable Attributes
5731 Two attributes are currently defined for x86 configurations:
5732 @code{ms_struct} and @code{gcc_struct}.
5734 @table @code
5735 @item ms_struct
5736 @itemx gcc_struct
5737 @cindex @code{ms_struct} variable attribute, x86
5738 @cindex @code{gcc_struct} variable attribute, x86
5740 If @code{packed} is used on a structure, or if bit-fields are used,
5741 it may be that the Microsoft ABI lays out the structure differently
5742 than the way GCC normally does.  Particularly when moving packed
5743 data between functions compiled with GCC and the native Microsoft compiler
5744 (either via function call or as data in a file), it may be necessary to access
5745 either format.
5747 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
5748 compilers to match the native Microsoft compiler.
5750 The Microsoft structure layout algorithm is fairly simple with the exception
5751 of the bit-field packing.  
5752 The padding and alignment of members of structures and whether a bit-field 
5753 can straddle a storage-unit boundary are determine by these rules:
5755 @enumerate
5756 @item Structure members are stored sequentially in the order in which they are
5757 declared: the first member has the lowest memory address and the last member
5758 the highest.
5760 @item Every data object has an alignment requirement.  The alignment requirement
5761 for all data except structures, unions, and arrays is either the size of the
5762 object or the current packing size (specified with either the
5763 @code{aligned} attribute or the @code{pack} pragma),
5764 whichever is less.  For structures, unions, and arrays,
5765 the alignment requirement is the largest alignment requirement of its members.
5766 Every object is allocated an offset so that:
5768 @smallexample
5769 offset % alignment_requirement == 0
5770 @end smallexample
5772 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5773 unit if the integral types are the same size and if the next bit-field fits
5774 into the current allocation unit without crossing the boundary imposed by the
5775 common alignment requirements of the bit-fields.
5776 @end enumerate
5778 MSVC interprets zero-length bit-fields in the following ways:
5780 @enumerate
5781 @item If a zero-length bit-field is inserted between two bit-fields that
5782 are normally coalesced, the bit-fields are not coalesced.
5784 For example:
5786 @smallexample
5787 struct
5788  @{
5789    unsigned long bf_1 : 12;
5790    unsigned long : 0;
5791    unsigned long bf_2 : 12;
5792  @} t1;
5793 @end smallexample
5795 @noindent
5796 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5797 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5799 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5800 alignment of the zero-length bit-field is greater than the member that follows it,
5801 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5803 For example:
5805 @smallexample
5806 struct
5807  @{
5808    char foo : 4;
5809    short : 0;
5810    char bar;
5811  @} t2;
5813 struct
5814  @{
5815    char foo : 4;
5816    short : 0;
5817    double bar;
5818  @} t3;
5819 @end smallexample
5821 @noindent
5822 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5823 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5824 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5825 of the structure.
5827 Taking this into account, it is important to note the following:
5829 @enumerate
5830 @item If a zero-length bit-field follows a normal bit-field, the type of the
5831 zero-length bit-field may affect the alignment of the structure as whole. For
5832 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5833 normal bit-field, and is of type short.
5835 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5836 still affect the alignment of the structure:
5838 @smallexample
5839 struct
5840  @{
5841    char foo : 6;
5842    long : 0;
5843  @} t4;
5844 @end smallexample
5846 @noindent
5847 Here, @code{t4} takes up 4 bytes.
5848 @end enumerate
5850 @item Zero-length bit-fields following non-bit-field members are ignored:
5852 @smallexample
5853 struct
5854  @{
5855    char foo;
5856    long : 0;
5857    char bar;
5858  @} t5;
5859 @end smallexample
5861 @noindent
5862 Here, @code{t5} takes up 2 bytes.
5863 @end enumerate
5864 @end table
5866 @node Xstormy16 Variable Attributes
5867 @subsection Xstormy16 Variable Attributes
5869 One attribute is currently defined for xstormy16 configurations:
5870 @code{below100}.
5872 @table @code
5873 @item below100
5874 @cindex @code{below100} variable attribute, Xstormy16
5876 If a variable has the @code{below100} attribute (@code{BELOW100} is
5877 allowed also), GCC places the variable in the first 0x100 bytes of
5878 memory and use special opcodes to access it.  Such variables are
5879 placed in either the @code{.bss_below100} section or the
5880 @code{.data_below100} section.
5882 @end table
5884 @node Type Attributes
5885 @section Specifying Attributes of Types
5886 @cindex attribute of types
5887 @cindex type attributes
5889 The keyword @code{__attribute__} allows you to specify special
5890 attributes of types.  Some type attributes apply only to @code{struct}
5891 and @code{union} types, while others can apply to any type defined
5892 via a @code{typedef} declaration.  Other attributes are defined for
5893 functions (@pxref{Function Attributes}), labels (@pxref{Label 
5894 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
5895 variables (@pxref{Variable Attributes}).
5897 The @code{__attribute__} keyword is followed by an attribute specification
5898 inside double parentheses.  
5900 You may specify type attributes in an enum, struct or union type
5901 declaration or definition by placing them immediately after the
5902 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
5903 syntax is to place them just past the closing curly brace of the
5904 definition.
5906 You can also include type attributes in a @code{typedef} declaration.
5907 @xref{Attribute Syntax}, for details of the exact syntax for using
5908 attributes.
5910 @menu
5911 * Common Type Attributes::
5912 * ARM Type Attributes::
5913 * MeP Type Attributes::
5914 * PowerPC Type Attributes::
5915 * SPU Type Attributes::
5916 * x86 Type Attributes::
5917 @end menu
5919 @node Common Type Attributes
5920 @subsection Common Type Attributes
5922 The following type attributes are supported on most targets.
5924 @table @code
5925 @cindex @code{aligned} type attribute
5926 @item aligned (@var{alignment})
5927 This attribute specifies a minimum alignment (in bytes) for variables
5928 of the specified type.  For example, the declarations:
5930 @smallexample
5931 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5932 typedef int more_aligned_int __attribute__ ((aligned (8)));
5933 @end smallexample
5935 @noindent
5936 force the compiler to ensure (as far as it can) that each variable whose
5937 type is @code{struct S} or @code{more_aligned_int} is allocated and
5938 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5939 variables of type @code{struct S} aligned to 8-byte boundaries allows
5940 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5941 store) instructions when copying one variable of type @code{struct S} to
5942 another, thus improving run-time efficiency.
5944 Note that the alignment of any given @code{struct} or @code{union} type
5945 is required by the ISO C standard to be at least a perfect multiple of
5946 the lowest common multiple of the alignments of all of the members of
5947 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5948 effectively adjust the alignment of a @code{struct} or @code{union}
5949 type by attaching an @code{aligned} attribute to any one of the members
5950 of such a type, but the notation illustrated in the example above is a
5951 more obvious, intuitive, and readable way to request the compiler to
5952 adjust the alignment of an entire @code{struct} or @code{union} type.
5954 As in the preceding example, you can explicitly specify the alignment
5955 (in bytes) that you wish the compiler to use for a given @code{struct}
5956 or @code{union} type.  Alternatively, you can leave out the alignment factor
5957 and just ask the compiler to align a type to the maximum
5958 useful alignment for the target machine you are compiling for.  For
5959 example, you could write:
5961 @smallexample
5962 struct S @{ short f[3]; @} __attribute__ ((aligned));
5963 @end smallexample
5965 Whenever you leave out the alignment factor in an @code{aligned}
5966 attribute specification, the compiler automatically sets the alignment
5967 for the type to the largest alignment that is ever used for any data
5968 type on the target machine you are compiling for.  Doing this can often
5969 make copy operations more efficient, because the compiler can use
5970 whatever instructions copy the biggest chunks of memory when performing
5971 copies to or from the variables that have types that you have aligned
5972 this way.
5974 In the example above, if the size of each @code{short} is 2 bytes, then
5975 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5976 power of two that is greater than or equal to that is 8, so the
5977 compiler sets the alignment for the entire @code{struct S} type to 8
5978 bytes.
5980 Note that although you can ask the compiler to select a time-efficient
5981 alignment for a given type and then declare only individual stand-alone
5982 objects of that type, the compiler's ability to select a time-efficient
5983 alignment is primarily useful only when you plan to create arrays of
5984 variables having the relevant (efficiently aligned) type.  If you
5985 declare or use arrays of variables of an efficiently-aligned type, then
5986 it is likely that your program also does pointer arithmetic (or
5987 subscripting, which amounts to the same thing) on pointers to the
5988 relevant type, and the code that the compiler generates for these
5989 pointer arithmetic operations is often more efficient for
5990 efficiently-aligned types than for other types.
5992 The @code{aligned} attribute can only increase the alignment; but you
5993 can decrease it by specifying @code{packed} as well.  See below.
5995 Note that the effectiveness of @code{aligned} attributes may be limited
5996 by inherent limitations in your linker.  On many systems, the linker is
5997 only able to arrange for variables to be aligned up to a certain maximum
5998 alignment.  (For some linkers, the maximum supported alignment may
5999 be very very small.)  If your linker is only able to align variables
6000 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6001 in an @code{__attribute__} still only provides you with 8-byte
6002 alignment.  See your linker documentation for further information.
6004 @opindex fshort-enums
6005 Specifying this attribute for @code{struct} and @code{union} types is
6006 equivalent to specifying the @code{packed} attribute on each of the
6007 structure or union members.  Specifying the @option{-fshort-enums}
6008 flag on the line is equivalent to specifying the @code{packed}
6009 attribute on all @code{enum} definitions.
6011 In the following example @code{struct my_packed_struct}'s members are
6012 packed closely together, but the internal layout of its @code{s} member
6013 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6014 be packed too.
6016 @smallexample
6017 struct my_unpacked_struct
6018  @{
6019     char c;
6020     int i;
6021  @};
6023 struct __attribute__ ((__packed__)) my_packed_struct
6024   @{
6025      char c;
6026      int  i;
6027      struct my_unpacked_struct s;
6028   @};
6029 @end smallexample
6031 You may only specify this attribute on the definition of an @code{enum},
6032 @code{struct} or @code{union}, not on a @code{typedef} that does not
6033 also define the enumerated type, structure or union.
6035 @item bnd_variable_size
6036 @cindex @code{bnd_variable_size} type attribute
6037 @cindex Pointer Bounds Checker attributes
6038 When applied to a structure field, this attribute tells Pointer
6039 Bounds Checker that the size of this field should not be computed
6040 using static type information.  It may be used to mark variably-sized
6041 static array fields placed at the end of a structure.
6043 @smallexample
6044 struct S
6046   int size;
6047   char data[1];
6049 S *p = (S *)malloc (sizeof(S) + 100);
6050 p->data[10] = 0; //Bounds violation
6051 @end smallexample
6053 @noindent
6054 By using an attribute for the field we may avoid unwanted bound
6055 violation checks:
6057 @smallexample
6058 struct S
6060   int size;
6061   char data[1] __attribute__((bnd_variable_size));
6063 S *p = (S *)malloc (sizeof(S) + 100);
6064 p->data[10] = 0; //OK
6065 @end smallexample
6067 @item deprecated
6068 @itemx deprecated (@var{msg})
6069 @cindex @code{deprecated} type attribute
6070 The @code{deprecated} attribute results in a warning if the type
6071 is used anywhere in the source file.  This is useful when identifying
6072 types that are expected to be removed in a future version of a program.
6073 If possible, the warning also includes the location of the declaration
6074 of the deprecated type, to enable users to easily find further
6075 information about why the type is deprecated, or what they should do
6076 instead.  Note that the warnings only occur for uses and then only
6077 if the type is being applied to an identifier that itself is not being
6078 declared as deprecated.
6080 @smallexample
6081 typedef int T1 __attribute__ ((deprecated));
6082 T1 x;
6083 typedef T1 T2;
6084 T2 y;
6085 typedef T1 T3 __attribute__ ((deprecated));
6086 T3 z __attribute__ ((deprecated));
6087 @end smallexample
6089 @noindent
6090 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
6091 warning is issued for line 4 because T2 is not explicitly
6092 deprecated.  Line 5 has no warning because T3 is explicitly
6093 deprecated.  Similarly for line 6.  The optional @var{msg}
6094 argument, which must be a string, is printed in the warning if
6095 present.
6097 The @code{deprecated} attribute can also be used for functions and
6098 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6100 @item designated_init
6101 @cindex @code{designated_init} type attribute
6102 This attribute may only be applied to structure types.  It indicates
6103 that any initialization of an object of this type must use designated
6104 initializers rather than positional initializers.  The intent of this
6105 attribute is to allow the programmer to indicate that a structure's
6106 layout may change, and that therefore relying on positional
6107 initialization will result in future breakage.
6109 GCC emits warnings based on this attribute by default; use
6110 @option{-Wno-designated-init} to suppress them.
6112 @item may_alias
6113 @cindex @code{may_alias} type attribute
6114 Accesses through pointers to types with this attribute are not subject
6115 to type-based alias analysis, but are instead assumed to be able to alias
6116 any other type of objects.
6117 In the context of section 6.5 paragraph 7 of the C99 standard,
6118 an lvalue expression
6119 dereferencing such a pointer is treated like having a character type.
6120 See @option{-fstrict-aliasing} for more information on aliasing issues.
6121 This extension exists to support some vector APIs, in which pointers to
6122 one vector type are permitted to alias pointers to a different vector type.
6124 Note that an object of a type with this attribute does not have any
6125 special semantics.
6127 Example of use:
6129 @smallexample
6130 typedef short __attribute__((__may_alias__)) short_a;
6133 main (void)
6135   int a = 0x12345678;
6136   short_a *b = (short_a *) &a;
6138   b[1] = 0;
6140   if (a == 0x12345678)
6141     abort();
6143   exit(0);
6145 @end smallexample
6147 @noindent
6148 If you replaced @code{short_a} with @code{short} in the variable
6149 declaration, the above program would abort when compiled with
6150 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6151 above.
6153 @item packed
6154 @cindex @code{packed} type attribute
6155 This attribute, attached to @code{struct} or @code{union} type
6156 definition, specifies that each member (other than zero-width bit-fields)
6157 of the structure or union is placed to minimize the memory required.  When
6158 attached to an @code{enum} definition, it indicates that the smallest
6159 integral type should be used.
6161 @item transparent_union
6162 @cindex @code{transparent_union} type attribute
6164 This attribute, attached to a @code{union} type definition, indicates
6165 that any function parameter having that union type causes calls to that
6166 function to be treated in a special way.
6168 First, the argument corresponding to a transparent union type can be of
6169 any type in the union; no cast is required.  Also, if the union contains
6170 a pointer type, the corresponding argument can be a null pointer
6171 constant or a void pointer expression; and if the union contains a void
6172 pointer type, the corresponding argument can be any pointer expression.
6173 If the union member type is a pointer, qualifiers like @code{const} on
6174 the referenced type must be respected, just as with normal pointer
6175 conversions.
6177 Second, the argument is passed to the function using the calling
6178 conventions of the first member of the transparent union, not the calling
6179 conventions of the union itself.  All members of the union must have the
6180 same machine representation; this is necessary for this argument passing
6181 to work properly.
6183 Transparent unions are designed for library functions that have multiple
6184 interfaces for compatibility reasons.  For example, suppose the
6185 @code{wait} function must accept either a value of type @code{int *} to
6186 comply with POSIX, or a value of type @code{union wait *} to comply with
6187 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
6188 @code{wait} would accept both kinds of arguments, but it would also
6189 accept any other pointer type and this would make argument type checking
6190 less useful.  Instead, @code{<sys/wait.h>} might define the interface
6191 as follows:
6193 @smallexample
6194 typedef union __attribute__ ((__transparent_union__))
6195   @{
6196     int *__ip;
6197     union wait *__up;
6198   @} wait_status_ptr_t;
6200 pid_t wait (wait_status_ptr_t);
6201 @end smallexample
6203 @noindent
6204 This interface allows either @code{int *} or @code{union wait *}
6205 arguments to be passed, using the @code{int *} calling convention.
6206 The program can call @code{wait} with arguments of either type:
6208 @smallexample
6209 int w1 () @{ int w; return wait (&w); @}
6210 int w2 () @{ union wait w; return wait (&w); @}
6211 @end smallexample
6213 @noindent
6214 With this interface, @code{wait}'s implementation might look like this:
6216 @smallexample
6217 pid_t wait (wait_status_ptr_t p)
6219   return waitpid (-1, p.__ip, 0);
6221 @end smallexample
6223 @item unused
6224 @cindex @code{unused} type attribute
6225 When attached to a type (including a @code{union} or a @code{struct}),
6226 this attribute means that variables of that type are meant to appear
6227 possibly unused.  GCC does not produce a warning for any variables of
6228 that type, even if the variable appears to do nothing.  This is often
6229 the case with lock or thread classes, which are usually defined and then
6230 not referenced, but contain constructors and destructors that have
6231 nontrivial bookkeeping functions.
6233 @item visibility
6234 @cindex @code{visibility} type attribute
6235 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6236 applied to class, struct, union and enum types.  Unlike other type
6237 attributes, the attribute must appear between the initial keyword and
6238 the name of the type; it cannot appear after the body of the type.
6240 Note that the type visibility is applied to vague linkage entities
6241 associated with the class (vtable, typeinfo node, etc.).  In
6242 particular, if a class is thrown as an exception in one shared object
6243 and caught in another, the class must have default visibility.
6244 Otherwise the two shared objects are unable to use the same
6245 typeinfo node and exception handling will break.
6247 @end table
6249 To specify multiple attributes, separate them by commas within the
6250 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6251 packed))}.
6253 @node ARM Type Attributes
6254 @subsection ARM Type Attributes
6256 @cindex @code{notshared} type attribute, ARM
6257 On those ARM targets that support @code{dllimport} (such as Symbian
6258 OS), you can use the @code{notshared} attribute to indicate that the
6259 virtual table and other similar data for a class should not be
6260 exported from a DLL@.  For example:
6262 @smallexample
6263 class __declspec(notshared) C @{
6264 public:
6265   __declspec(dllimport) C();
6266   virtual void f();
6269 __declspec(dllexport)
6270 C::C() @{@}
6271 @end smallexample
6273 @noindent
6274 In this code, @code{C::C} is exported from the current DLL, but the
6275 virtual table for @code{C} is not exported.  (You can use
6276 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6277 most Symbian OS code uses @code{__declspec}.)
6279 @node MeP Type Attributes
6280 @subsection MeP Type Attributes
6282 @cindex @code{based} type attribute, MeP
6283 @cindex @code{tiny} type attribute, MeP
6284 @cindex @code{near} type attribute, MeP
6285 @cindex @code{far} type attribute, MeP
6286 Many of the MeP variable attributes may be applied to types as well.
6287 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6288 @code{far} attributes may be applied to either.  The @code{io} and
6289 @code{cb} attributes may not be applied to types.
6291 @node PowerPC Type Attributes
6292 @subsection PowerPC Type Attributes
6294 Three attributes currently are defined for PowerPC configurations:
6295 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6297 @cindex @code{ms_struct} type attribute, PowerPC
6298 @cindex @code{gcc_struct} type attribute, PowerPC
6299 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6300 attributes please see the documentation in @ref{x86 Type Attributes}.
6302 @cindex @code{altivec} type attribute, PowerPC
6303 The @code{altivec} attribute allows one to declare AltiVec vector data
6304 types supported by the AltiVec Programming Interface Manual.  The
6305 attribute requires an argument to specify one of three vector types:
6306 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6307 and @code{bool__} (always followed by unsigned).
6309 @smallexample
6310 __attribute__((altivec(vector__)))
6311 __attribute__((altivec(pixel__))) unsigned short
6312 __attribute__((altivec(bool__))) unsigned
6313 @end smallexample
6315 These attributes mainly are intended to support the @code{__vector},
6316 @code{__pixel}, and @code{__bool} AltiVec keywords.
6318 @node SPU Type Attributes
6319 @subsection SPU Type Attributes
6321 @cindex @code{spu_vector} type attribute, SPU
6322 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6323 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6324 Language Extensions Specification.  It is intended to support the
6325 @code{__vector} keyword.
6327 @node x86 Type Attributes
6328 @subsection x86 Type Attributes
6330 Two attributes are currently defined for x86 configurations:
6331 @code{ms_struct} and @code{gcc_struct}.
6333 @table @code
6335 @item ms_struct
6336 @itemx gcc_struct
6337 @cindex @code{ms_struct} type attribute, x86
6338 @cindex @code{gcc_struct} type attribute, x86
6340 If @code{packed} is used on a structure, or if bit-fields are used
6341 it may be that the Microsoft ABI packs them differently
6342 than GCC normally packs them.  Particularly when moving packed
6343 data between functions compiled with GCC and the native Microsoft compiler
6344 (either via function call or as data in a file), it may be necessary to access
6345 either format.
6347 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6348 compilers to match the native Microsoft compiler.
6349 @end table
6351 @node Label Attributes
6352 @section Label Attributes
6353 @cindex Label Attributes
6355 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
6356 details of the exact syntax for using attributes.  Other attributes are 
6357 available for functions (@pxref{Function Attributes}), variables 
6358 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6359 and for types (@pxref{Type Attributes}).
6361 This example uses the @code{cold} label attribute to indicate the 
6362 @code{ErrorHandling} branch is unlikely to be taken and that the
6363 @code{ErrorHandling} label is unused:
6365 @smallexample
6367    asm goto ("some asm" : : : : NoError);
6369 /* This branch (the fall-through from the asm) is less commonly used */
6370 ErrorHandling: 
6371    __attribute__((cold, unused)); /* Semi-colon is required here */
6372    printf("error\n");
6373    return 0;
6375 NoError:
6376    printf("no error\n");
6377    return 1;
6378 @end smallexample
6380 @table @code
6381 @item unused
6382 @cindex @code{unused} label attribute
6383 This feature is intended for program-generated code that may contain 
6384 unused labels, but which is compiled with @option{-Wall}.  It is
6385 not normally appropriate to use in it human-written code, though it
6386 could be useful in cases where the code that jumps to the label is
6387 contained within an @code{#ifdef} conditional.
6389 @item hot
6390 @cindex @code{hot} label attribute
6391 The @code{hot} attribute on a label is used to inform the compiler that
6392 the path following the label is more likely than paths that are not so
6393 annotated.  This attribute is used in cases where @code{__builtin_expect}
6394 cannot be used, for instance with computed goto or @code{asm goto}.
6396 @item cold
6397 @cindex @code{cold} label attribute
6398 The @code{cold} attribute on labels is used to inform the compiler that
6399 the path following the label is unlikely to be executed.  This attribute
6400 is used in cases where @code{__builtin_expect} cannot be used, for instance
6401 with computed goto or @code{asm goto}.
6403 @end table
6405 @node Enumerator Attributes
6406 @section Enumerator Attributes
6407 @cindex Enumerator Attributes
6409 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
6410 details of the exact syntax for using attributes.  Other attributes are
6411 available for functions (@pxref{Function Attributes}), variables
6412 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6413 and for types (@pxref{Type Attributes}).
6415 This example uses the @code{deprecated} enumerator attribute to indicate the
6416 @code{oldval} enumerator is deprecated:
6418 @smallexample
6419 enum E @{
6420   oldval __attribute__((deprecated)),
6421   newval
6425 fn (void)
6427   return oldval;
6429 @end smallexample
6431 @table @code
6432 @item deprecated
6433 @cindex @code{deprecated} enumerator attribute
6434 The @code{deprecated} attribute results in a warning if the enumerator
6435 is used anywhere in the source file.  This is useful when identifying
6436 enumerators that are expected to be removed in a future version of a
6437 program.  The warning also includes the location of the declaration
6438 of the deprecated enumerator, to enable users to easily find further
6439 information about why the enumerator is deprecated, or what they should
6440 do instead.  Note that the warnings only occurs for uses.
6442 @end table
6444 @node Attribute Syntax
6445 @section Attribute Syntax
6446 @cindex attribute syntax
6448 This section describes the syntax with which @code{__attribute__} may be
6449 used, and the constructs to which attribute specifiers bind, for the C
6450 language.  Some details may vary for C++ and Objective-C@.  Because of
6451 infelicities in the grammar for attributes, some forms described here
6452 may not be successfully parsed in all cases.
6454 There are some problems with the semantics of attributes in C++.  For
6455 example, there are no manglings for attributes, although they may affect
6456 code generation, so problems may arise when attributed types are used in
6457 conjunction with templates or overloading.  Similarly, @code{typeid}
6458 does not distinguish between types with different attributes.  Support
6459 for attributes in C++ may be restricted in future to attributes on
6460 declarations only, but not on nested declarators.
6462 @xref{Function Attributes}, for details of the semantics of attributes
6463 applying to functions.  @xref{Variable Attributes}, for details of the
6464 semantics of attributes applying to variables.  @xref{Type Attributes},
6465 for details of the semantics of attributes applying to structure, union
6466 and enumerated types.
6467 @xref{Label Attributes}, for details of the semantics of attributes 
6468 applying to labels.
6469 @xref{Enumerator Attributes}, for details of the semantics of attributes
6470 applying to enumerators.
6472 An @dfn{attribute specifier} is of the form
6473 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
6474 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6475 each attribute is one of the following:
6477 @itemize @bullet
6478 @item
6479 Empty.  Empty attributes are ignored.
6481 @item
6482 An attribute name
6483 (which may be an identifier such as @code{unused}, or a reserved
6484 word such as @code{const}).
6486 @item
6487 An attribute name followed by a parenthesized list of
6488 parameters for the attribute.
6489 These parameters take one of the following forms:
6491 @itemize @bullet
6492 @item
6493 An identifier.  For example, @code{mode} attributes use this form.
6495 @item
6496 An identifier followed by a comma and a non-empty comma-separated list
6497 of expressions.  For example, @code{format} attributes use this form.
6499 @item
6500 A possibly empty comma-separated list of expressions.  For example,
6501 @code{format_arg} attributes use this form with the list being a single
6502 integer constant expression, and @code{alias} attributes use this form
6503 with the list being a single string constant.
6504 @end itemize
6505 @end itemize
6507 An @dfn{attribute specifier list} is a sequence of one or more attribute
6508 specifiers, not separated by any other tokens.
6510 You may optionally specify attribute names with @samp{__}
6511 preceding and following the name.
6512 This allows you to use them in header files without
6513 being concerned about a possible macro of the same name.  For example,
6514 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6517 @subsubheading Label Attributes
6519 In GNU C, an attribute specifier list may appear after the colon following a
6520 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
6521 attributes on labels if the attribute specifier is immediately
6522 followed by a semicolon (i.e., the label applies to an empty
6523 statement).  If the semicolon is missing, C++ label attributes are
6524 ambiguous, as it is permissible for a declaration, which could begin
6525 with an attribute list, to be labelled in C++.  Declarations cannot be
6526 labelled in C90 or C99, so the ambiguity does not arise there.
6528 @subsubheading Enumerator Attributes
6530 In GNU C, an attribute specifier list may appear as part of an enumerator.
6531 The attribute goes after the enumeration constant, before @code{=}, if
6532 present.  The optional attribute in the enumerator appertains to the
6533 enumeration constant.  It is not possible to place the attribute after
6534 the constant expression, if present.
6536 @subsubheading Type Attributes
6538 An attribute specifier list may appear as part of a @code{struct},
6539 @code{union} or @code{enum} specifier.  It may go either immediately
6540 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6541 the closing brace.  The former syntax is preferred.
6542 Where attribute specifiers follow the closing brace, they are considered
6543 to relate to the structure, union or enumerated type defined, not to any
6544 enclosing declaration the type specifier appears in, and the type
6545 defined is not complete until after the attribute specifiers.
6546 @c Otherwise, there would be the following problems: a shift/reduce
6547 @c conflict between attributes binding the struct/union/enum and
6548 @c binding to the list of specifiers/qualifiers; and "aligned"
6549 @c attributes could use sizeof for the structure, but the size could be
6550 @c changed later by "packed" attributes.
6553 @subsubheading All other attributes
6555 Otherwise, an attribute specifier appears as part of a declaration,
6556 counting declarations of unnamed parameters and type names, and relates
6557 to that declaration (which may be nested in another declaration, for
6558 example in the case of a parameter declaration), or to a particular declarator
6559 within a declaration.  Where an
6560 attribute specifier is applied to a parameter declared as a function or
6561 an array, it should apply to the function or array rather than the
6562 pointer to which the parameter is implicitly converted, but this is not
6563 yet correctly implemented.
6565 Any list of specifiers and qualifiers at the start of a declaration may
6566 contain attribute specifiers, whether or not such a list may in that
6567 context contain storage class specifiers.  (Some attributes, however,
6568 are essentially in the nature of storage class specifiers, and only make
6569 sense where storage class specifiers may be used; for example,
6570 @code{section}.)  There is one necessary limitation to this syntax: the
6571 first old-style parameter declaration in a function definition cannot
6572 begin with an attribute specifier, because such an attribute applies to
6573 the function instead by syntax described below (which, however, is not
6574 yet implemented in this case).  In some other cases, attribute
6575 specifiers are permitted by this grammar but not yet supported by the
6576 compiler.  All attribute specifiers in this place relate to the
6577 declaration as a whole.  In the obsolescent usage where a type of
6578 @code{int} is implied by the absence of type specifiers, such a list of
6579 specifiers and qualifiers may be an attribute specifier list with no
6580 other specifiers or qualifiers.
6582 At present, the first parameter in a function prototype must have some
6583 type specifier that is not an attribute specifier; this resolves an
6584 ambiguity in the interpretation of @code{void f(int
6585 (__attribute__((foo)) x))}, but is subject to change.  At present, if
6586 the parentheses of a function declarator contain only attributes then
6587 those attributes are ignored, rather than yielding an error or warning
6588 or implying a single parameter of type int, but this is subject to
6589 change.
6591 An attribute specifier list may appear immediately before a declarator
6592 (other than the first) in a comma-separated list of declarators in a
6593 declaration of more than one identifier using a single list of
6594 specifiers and qualifiers.  Such attribute specifiers apply
6595 only to the identifier before whose declarator they appear.  For
6596 example, in
6598 @smallexample
6599 __attribute__((noreturn)) void d0 (void),
6600     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6601      d2 (void);
6602 @end smallexample
6604 @noindent
6605 the @code{noreturn} attribute applies to all the functions
6606 declared; the @code{format} attribute only applies to @code{d1}.
6608 An attribute specifier list may appear immediately before the comma,
6609 @code{=} or semicolon terminating the declaration of an identifier other
6610 than a function definition.  Such attribute specifiers apply
6611 to the declared object or function.  Where an
6612 assembler name for an object or function is specified (@pxref{Asm
6613 Labels}), the attribute must follow the @code{asm}
6614 specification.
6616 An attribute specifier list may, in future, be permitted to appear after
6617 the declarator in a function definition (before any old-style parameter
6618 declarations or the function body).
6620 Attribute specifiers may be mixed with type qualifiers appearing inside
6621 the @code{[]} of a parameter array declarator, in the C99 construct by
6622 which such qualifiers are applied to the pointer to which the array is
6623 implicitly converted.  Such attribute specifiers apply to the pointer,
6624 not to the array, but at present this is not implemented and they are
6625 ignored.
6627 An attribute specifier list may appear at the start of a nested
6628 declarator.  At present, there are some limitations in this usage: the
6629 attributes correctly apply to the declarator, but for most individual
6630 attributes the semantics this implies are not implemented.
6631 When attribute specifiers follow the @code{*} of a pointer
6632 declarator, they may be mixed with any type qualifiers present.
6633 The following describes the formal semantics of this syntax.  It makes the
6634 most sense if you are familiar with the formal specification of
6635 declarators in the ISO C standard.
6637 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
6638 D1}, where @code{T} contains declaration specifiers that specify a type
6639 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
6640 contains an identifier @var{ident}.  The type specified for @var{ident}
6641 for derived declarators whose type does not include an attribute
6642 specifier is as in the ISO C standard.
6644 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
6645 and the declaration @code{T D} specifies the type
6646 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6647 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6648 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
6650 If @code{D1} has the form @code{*
6651 @var{type-qualifier-and-attribute-specifier-list} D}, and the
6652 declaration @code{T D} specifies the type
6653 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6654 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6655 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
6656 @var{ident}.
6658 For example,
6660 @smallexample
6661 void (__attribute__((noreturn)) ****f) (void);
6662 @end smallexample
6664 @noindent
6665 specifies the type ``pointer to pointer to pointer to pointer to
6666 non-returning function returning @code{void}''.  As another example,
6668 @smallexample
6669 char *__attribute__((aligned(8))) *f;
6670 @end smallexample
6672 @noindent
6673 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
6674 Note again that this does not work with most attributes; for example,
6675 the usage of @samp{aligned} and @samp{noreturn} attributes given above
6676 is not yet supported.
6678 For compatibility with existing code written for compiler versions that
6679 did not implement attributes on nested declarators, some laxity is
6680 allowed in the placing of attributes.  If an attribute that only applies
6681 to types is applied to a declaration, it is treated as applying to
6682 the type of that declaration.  If an attribute that only applies to
6683 declarations is applied to the type of a declaration, it is treated
6684 as applying to that declaration; and, for compatibility with code
6685 placing the attributes immediately before the identifier declared, such
6686 an attribute applied to a function return type is treated as
6687 applying to the function type, and such an attribute applied to an array
6688 element type is treated as applying to the array type.  If an
6689 attribute that only applies to function types is applied to a
6690 pointer-to-function type, it is treated as applying to the pointer
6691 target type; if such an attribute is applied to a function return type
6692 that is not a pointer-to-function type, it is treated as applying
6693 to the function type.
6695 @node Function Prototypes
6696 @section Prototypes and Old-Style Function Definitions
6697 @cindex function prototype declarations
6698 @cindex old-style function definitions
6699 @cindex promotion of formal parameters
6701 GNU C extends ISO C to allow a function prototype to override a later
6702 old-style non-prototype definition.  Consider the following example:
6704 @smallexample
6705 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
6706 #ifdef __STDC__
6707 #define P(x) x
6708 #else
6709 #define P(x) ()
6710 #endif
6712 /* @r{Prototype function declaration.}  */
6713 int isroot P((uid_t));
6715 /* @r{Old-style function definition.}  */
6717 isroot (x)   /* @r{??? lossage here ???} */
6718      uid_t x;
6720   return x == 0;
6722 @end smallexample
6724 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
6725 not allow this example, because subword arguments in old-style
6726 non-prototype definitions are promoted.  Therefore in this example the
6727 function definition's argument is really an @code{int}, which does not
6728 match the prototype argument type of @code{short}.
6730 This restriction of ISO C makes it hard to write code that is portable
6731 to traditional C compilers, because the programmer does not know
6732 whether the @code{uid_t} type is @code{short}, @code{int}, or
6733 @code{long}.  Therefore, in cases like these GNU C allows a prototype
6734 to override a later old-style definition.  More precisely, in GNU C, a
6735 function prototype argument type overrides the argument type specified
6736 by a later old-style definition if the former type is the same as the
6737 latter type before promotion.  Thus in GNU C the above example is
6738 equivalent to the following:
6740 @smallexample
6741 int isroot (uid_t);
6744 isroot (uid_t x)
6746   return x == 0;
6748 @end smallexample
6750 @noindent
6751 GNU C++ does not support old-style function definitions, so this
6752 extension is irrelevant.
6754 @node C++ Comments
6755 @section C++ Style Comments
6756 @cindex @code{//}
6757 @cindex C++ comments
6758 @cindex comments, C++ style
6760 In GNU C, you may use C++ style comments, which start with @samp{//} and
6761 continue until the end of the line.  Many other C implementations allow
6762 such comments, and they are included in the 1999 C standard.  However,
6763 C++ style comments are not recognized if you specify an @option{-std}
6764 option specifying a version of ISO C before C99, or @option{-ansi}
6765 (equivalent to @option{-std=c90}).
6767 @node Dollar Signs
6768 @section Dollar Signs in Identifier Names
6769 @cindex $
6770 @cindex dollar signs in identifier names
6771 @cindex identifier names, dollar signs in
6773 In GNU C, you may normally use dollar signs in identifier names.
6774 This is because many traditional C implementations allow such identifiers.
6775 However, dollar signs in identifiers are not supported on a few target
6776 machines, typically because the target assembler does not allow them.
6778 @node Character Escapes
6779 @section The Character @key{ESC} in Constants
6781 You can use the sequence @samp{\e} in a string or character constant to
6782 stand for the ASCII character @key{ESC}.
6784 @node Alignment
6785 @section Inquiring on Alignment of Types or Variables
6786 @cindex alignment
6787 @cindex type alignment
6788 @cindex variable alignment
6790 The keyword @code{__alignof__} allows you to inquire about how an object
6791 is aligned, or the minimum alignment usually required by a type.  Its
6792 syntax is just like @code{sizeof}.
6794 For example, if the target machine requires a @code{double} value to be
6795 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6796 This is true on many RISC machines.  On more traditional machine
6797 designs, @code{__alignof__ (double)} is 4 or even 2.
6799 Some machines never actually require alignment; they allow reference to any
6800 data type even at an odd address.  For these machines, @code{__alignof__}
6801 reports the smallest alignment that GCC gives the data type, usually as
6802 mandated by the target ABI.
6804 If the operand of @code{__alignof__} is an lvalue rather than a type,
6805 its value is the required alignment for its type, taking into account
6806 any minimum alignment specified with GCC's @code{__attribute__}
6807 extension (@pxref{Variable Attributes}).  For example, after this
6808 declaration:
6810 @smallexample
6811 struct foo @{ int x; char y; @} foo1;
6812 @end smallexample
6814 @noindent
6815 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6816 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6818 It is an error to ask for the alignment of an incomplete type.
6821 @node Inline
6822 @section An Inline Function is As Fast As a Macro
6823 @cindex inline functions
6824 @cindex integrating function code
6825 @cindex open coding
6826 @cindex macros, inline alternative
6828 By declaring a function inline, you can direct GCC to make
6829 calls to that function faster.  One way GCC can achieve this is to
6830 integrate that function's code into the code for its callers.  This
6831 makes execution faster by eliminating the function-call overhead; in
6832 addition, if any of the actual argument values are constant, their
6833 known values may permit simplifications at compile time so that not
6834 all of the inline function's code needs to be included.  The effect on
6835 code size is less predictable; object code may be larger or smaller
6836 with function inlining, depending on the particular case.  You can
6837 also direct GCC to try to integrate all ``simple enough'' functions
6838 into their callers with the option @option{-finline-functions}.
6840 GCC implements three different semantics of declaring a function
6841 inline.  One is available with @option{-std=gnu89} or
6842 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6843 on all inline declarations, another when
6844 @option{-std=c99}, @option{-std=c11},
6845 @option{-std=gnu99} or @option{-std=gnu11}
6846 (without @option{-fgnu89-inline}), and the third
6847 is used when compiling C++.
6849 To declare a function inline, use the @code{inline} keyword in its
6850 declaration, like this:
6852 @smallexample
6853 static inline int
6854 inc (int *a)
6856   return (*a)++;
6858 @end smallexample
6860 If you are writing a header file to be included in ISO C90 programs, write
6861 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6863 The three types of inlining behave similarly in two important cases:
6864 when the @code{inline} keyword is used on a @code{static} function,
6865 like the example above, and when a function is first declared without
6866 using the @code{inline} keyword and then is defined with
6867 @code{inline}, like this:
6869 @smallexample
6870 extern int inc (int *a);
6871 inline int
6872 inc (int *a)
6874   return (*a)++;
6876 @end smallexample
6878 In both of these common cases, the program behaves the same as if you
6879 had not used the @code{inline} keyword, except for its speed.
6881 @cindex inline functions, omission of
6882 @opindex fkeep-inline-functions
6883 When a function is both inline and @code{static}, if all calls to the
6884 function are integrated into the caller, and the function's address is
6885 never used, then the function's own assembler code is never referenced.
6886 In this case, GCC does not actually output assembler code for the
6887 function, unless you specify the option @option{-fkeep-inline-functions}.
6888 Some calls cannot be integrated for various reasons (in particular,
6889 calls that precede the function's definition cannot be integrated, and
6890 neither can recursive calls within the definition).  If there is a
6891 nonintegrated call, then the function is compiled to assembler code as
6892 usual.  The function must also be compiled as usual if the program
6893 refers to its address, because that can't be inlined.
6895 @opindex Winline
6896 Note that certain usages in a function definition can make it unsuitable
6897 for inline substitution.  Among these usages are: variadic functions, use of
6898 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6899 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6900 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6901 warns when a function marked @code{inline} could not be substituted,
6902 and gives the reason for the failure.
6904 @cindex automatic @code{inline} for C++ member fns
6905 @cindex @code{inline} automatic for C++ member fns
6906 @cindex member fns, automatically @code{inline}
6907 @cindex C++ member fns, automatically @code{inline}
6908 @opindex fno-default-inline
6909 As required by ISO C++, GCC considers member functions defined within
6910 the body of a class to be marked inline even if they are
6911 not explicitly declared with the @code{inline} keyword.  You can
6912 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6913 Options,,Options Controlling C++ Dialect}.
6915 GCC does not inline any functions when not optimizing unless you specify
6916 the @samp{always_inline} attribute for the function, like this:
6918 @smallexample
6919 /* @r{Prototype.}  */
6920 inline void foo (const char) __attribute__((always_inline));
6921 @end smallexample
6923 The remainder of this section is specific to GNU C90 inlining.
6925 @cindex non-static inline function
6926 When an inline function is not @code{static}, then the compiler must assume
6927 that there may be calls from other source files; since a global symbol can
6928 be defined only once in any program, the function must not be defined in
6929 the other source files, so the calls therein cannot be integrated.
6930 Therefore, a non-@code{static} inline function is always compiled on its
6931 own in the usual fashion.
6933 If you specify both @code{inline} and @code{extern} in the function
6934 definition, then the definition is used only for inlining.  In no case
6935 is the function compiled on its own, not even if you refer to its
6936 address explicitly.  Such an address becomes an external reference, as
6937 if you had only declared the function, and had not defined it.
6939 This combination of @code{inline} and @code{extern} has almost the
6940 effect of a macro.  The way to use it is to put a function definition in
6941 a header file with these keywords, and put another copy of the
6942 definition (lacking @code{inline} and @code{extern}) in a library file.
6943 The definition in the header file causes most calls to the function
6944 to be inlined.  If any uses of the function remain, they refer to
6945 the single copy in the library.
6947 @node Volatiles
6948 @section When is a Volatile Object Accessed?
6949 @cindex accessing volatiles
6950 @cindex volatile read
6951 @cindex volatile write
6952 @cindex volatile access
6954 C has the concept of volatile objects.  These are normally accessed by
6955 pointers and used for accessing hardware or inter-thread
6956 communication.  The standard encourages compilers to refrain from
6957 optimizations concerning accesses to volatile objects, but leaves it
6958 implementation defined as to what constitutes a volatile access.  The
6959 minimum requirement is that at a sequence point all previous accesses
6960 to volatile objects have stabilized and no subsequent accesses have
6961 occurred.  Thus an implementation is free to reorder and combine
6962 volatile accesses that occur between sequence points, but cannot do
6963 so for accesses across a sequence point.  The use of volatile does
6964 not allow you to violate the restriction on updating objects multiple
6965 times between two sequence points.
6967 Accesses to non-volatile objects are not ordered with respect to
6968 volatile accesses.  You cannot use a volatile object as a memory
6969 barrier to order a sequence of writes to non-volatile memory.  For
6970 instance:
6972 @smallexample
6973 int *ptr = @var{something};
6974 volatile int vobj;
6975 *ptr = @var{something};
6976 vobj = 1;
6977 @end smallexample
6979 @noindent
6980 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6981 that the write to @var{*ptr} occurs by the time the update
6982 of @var{vobj} happens.  If you need this guarantee, you must use
6983 a stronger memory barrier such as:
6985 @smallexample
6986 int *ptr = @var{something};
6987 volatile int vobj;
6988 *ptr = @var{something};
6989 asm volatile ("" : : : "memory");
6990 vobj = 1;
6991 @end smallexample
6993 A scalar volatile object is read when it is accessed in a void context:
6995 @smallexample
6996 volatile int *src = @var{somevalue};
6997 *src;
6998 @end smallexample
7000 Such expressions are rvalues, and GCC implements this as a
7001 read of the volatile object being pointed to.
7003 Assignments are also expressions and have an rvalue.  However when
7004 assigning to a scalar volatile, the volatile object is not reread,
7005 regardless of whether the assignment expression's rvalue is used or
7006 not.  If the assignment's rvalue is used, the value is that assigned
7007 to the volatile object.  For instance, there is no read of @var{vobj}
7008 in all the following cases:
7010 @smallexample
7011 int obj;
7012 volatile int vobj;
7013 vobj = @var{something};
7014 obj = vobj = @var{something};
7015 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7016 obj = (@var{something}, vobj = @var{anotherthing});
7017 @end smallexample
7019 If you need to read the volatile object after an assignment has
7020 occurred, you must use a separate expression with an intervening
7021 sequence point.
7023 As bit-fields are not individually addressable, volatile bit-fields may
7024 be implicitly read when written to, or when adjacent bit-fields are
7025 accessed.  Bit-field operations may be optimized such that adjacent
7026 bit-fields are only partially accessed, if they straddle a storage unit
7027 boundary.  For these reasons it is unwise to use volatile bit-fields to
7028 access hardware.
7030 @node Using Assembly Language with C
7031 @section How to Use Inline Assembly Language in C Code
7032 @cindex @code{asm} keyword
7033 @cindex assembly language in C
7034 @cindex inline assembly language
7035 @cindex mixing assembly language and C
7037 The @code{asm} keyword allows you to embed assembler instructions
7038 within C code.  GCC provides two forms of inline @code{asm}
7039 statements.  A @dfn{basic @code{asm}} statement is one with no
7040 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7041 statement (@pxref{Extended Asm}) includes one or more operands.  
7042 The extended form is preferred for mixing C and assembly language
7043 within a function, but to include assembly language at
7044 top level you must use basic @code{asm}.
7046 You can also use the @code{asm} keyword to override the assembler name
7047 for a C symbol, or to place a C variable in a specific register.
7049 @menu
7050 * Basic Asm::          Inline assembler without operands.
7051 * Extended Asm::       Inline assembler with operands.
7052 * Constraints::        Constraints for @code{asm} operands
7053 * Asm Labels::         Specifying the assembler name to use for a C symbol.
7054 * Explicit Reg Vars::  Defining variables residing in specified registers.
7055 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
7056 @end menu
7058 @node Basic Asm
7059 @subsection Basic Asm --- Assembler Instructions Without Operands
7060 @cindex basic @code{asm}
7061 @cindex assembly language in C, basic
7063 A basic @code{asm} statement has the following syntax:
7065 @example
7066 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7067 @end example
7069 The @code{asm} keyword is a GNU extension.
7070 When writing code that can be compiled with @option{-ansi} and the
7071 various @option{-std} options, use @code{__asm__} instead of 
7072 @code{asm} (@pxref{Alternate Keywords}).
7074 @subsubheading Qualifiers
7075 @table @code
7076 @item volatile
7077 The optional @code{volatile} qualifier has no effect. 
7078 All basic @code{asm} blocks are implicitly volatile.
7079 @end table
7081 @subsubheading Parameters
7082 @table @var
7084 @item AssemblerInstructions
7085 This is a literal string that specifies the assembler code. The string can 
7086 contain any instructions recognized by the assembler, including directives. 
7087 GCC does not parse the assembler instructions themselves and 
7088 does not know what they mean or even whether they are valid assembler input. 
7090 You may place multiple assembler instructions together in a single @code{asm} 
7091 string, separated by the characters normally used in assembly code for the 
7092 system. A combination that works in most places is a newline to break the 
7093 line, plus a tab character (written as @samp{\n\t}).
7094 Some assemblers allow semicolons as a line separator. However, 
7095 note that some assembler dialects use semicolons to start a comment. 
7096 @end table
7098 @subsubheading Remarks
7099 Using extended @code{asm} typically produces smaller, safer, and more
7100 efficient code, and in most cases it is a better solution than basic
7101 @code{asm}.  However, there are two situations where only basic @code{asm}
7102 can be used:
7104 @itemize @bullet
7105 @item
7106 Extended @code{asm} statements have to be inside a C
7107 function, so to write inline assembly language at file scope (``top-level''),
7108 outside of C functions, you must use basic @code{asm}.
7109 You can use this technique to emit assembler directives,
7110 define assembly language macros that can be invoked elsewhere in the file,
7111 or write entire functions in assembly language.
7113 @item
7114 Functions declared
7115 with the @code{naked} attribute also require basic @code{asm}
7116 (@pxref{Function Attributes}).
7117 @end itemize
7119 Safely accessing C data and calling functions from basic @code{asm} is more 
7120 complex than it may appear. To access C data, it is better to use extended 
7121 @code{asm}.
7123 Do not expect a sequence of @code{asm} statements to remain perfectly 
7124 consecutive after compilation. If certain instructions need to remain 
7125 consecutive in the output, put them in a single multi-instruction @code{asm}
7126 statement. Note that GCC's optimizers can move @code{asm} statements 
7127 relative to other code, including across jumps.
7129 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7130 GCC does not know about these jumps, and therefore cannot take 
7131 account of them when deciding how to optimize. Jumps from @code{asm} to C 
7132 labels are only supported in extended @code{asm}.
7134 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7135 assembly code when optimizing. This can lead to unexpected duplicate 
7136 symbol errors during compilation if your assembly code defines symbols or 
7137 labels.
7139 Since GCC does not parse the @var{AssemblerInstructions}, it has no 
7140 visibility of any symbols it references. This may result in GCC discarding 
7141 those symbols as unreferenced.
7143 The compiler copies the assembler instructions in a basic @code{asm} 
7144 verbatim to the assembly language output file, without 
7145 processing dialects or any of the @samp{%} operators that are available with
7146 extended @code{asm}. This results in minor differences between basic 
7147 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
7148 registers you might use @samp{%eax} in basic @code{asm} and
7149 @samp{%%eax} in extended @code{asm}.
7151 On targets such as x86 that support multiple assembler dialects,
7152 all basic @code{asm} blocks use the assembler dialect specified by the 
7153 @option{-masm} command-line option (@pxref{x86 Options}).  
7154 Basic @code{asm} provides no
7155 mechanism to provide different assembler strings for different dialects.
7157 Here is an example of basic @code{asm} for i386:
7159 @example
7160 /* Note that this code will not compile with -masm=intel */
7161 #define DebugBreak() asm("int $3")
7162 @end example
7164 @node Extended Asm
7165 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7166 @cindex extended @code{asm}
7167 @cindex assembly language in C, extended
7169 With extended @code{asm} you can read and write C variables from 
7170 assembler and perform jumps from assembler code to C labels.  
7171 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7172 the operand parameters after the assembler template:
7174 @example
7175 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
7176                  : @var{OutputOperands} 
7177                  @r{[} : @var{InputOperands}
7178                  @r{[} : @var{Clobbers} @r{]} @r{]})
7180 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
7181                       : 
7182                       : @var{InputOperands}
7183                       : @var{Clobbers}
7184                       : @var{GotoLabels})
7185 @end example
7187 The @code{asm} keyword is a GNU extension.
7188 When writing code that can be compiled with @option{-ansi} and the
7189 various @option{-std} options, use @code{__asm__} instead of 
7190 @code{asm} (@pxref{Alternate Keywords}).
7192 @subsubheading Qualifiers
7193 @table @code
7195 @item volatile
7196 The typical use of extended @code{asm} statements is to manipulate input 
7197 values to produce output values. However, your @code{asm} statements may 
7198 also produce side effects. If so, you may need to use the @code{volatile} 
7199 qualifier to disable certain optimizations. @xref{Volatile}.
7201 @item goto
7202 This qualifier informs the compiler that the @code{asm} statement may 
7203 perform a jump to one of the labels listed in the @var{GotoLabels}.
7204 @xref{GotoLabels}.
7205 @end table
7207 @subsubheading Parameters
7208 @table @var
7209 @item AssemblerTemplate
7210 This is a literal string that is the template for the assembler code. It is a 
7211 combination of fixed text and tokens that refer to the input, output, 
7212 and goto parameters. @xref{AssemblerTemplate}.
7214 @item OutputOperands
7215 A comma-separated list of the C variables modified by the instructions in the 
7216 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
7218 @item InputOperands
7219 A comma-separated list of C expressions read by the instructions in the 
7220 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
7222 @item Clobbers
7223 A comma-separated list of registers or other values changed by the 
7224 @var{AssemblerTemplate}, beyond those listed as outputs.
7225 An empty list is permitted.  @xref{Clobbers}.
7227 @item GotoLabels
7228 When you are using the @code{goto} form of @code{asm}, this section contains 
7229 the list of all C labels to which the code in the 
7230 @var{AssemblerTemplate} may jump. 
7231 @xref{GotoLabels}.
7233 @code{asm} statements may not perform jumps into other @code{asm} statements,
7234 only to the listed @var{GotoLabels}.
7235 GCC's optimizers do not know about other jumps; therefore they cannot take 
7236 account of them when deciding how to optimize.
7237 @end table
7239 The total number of input + output + goto operands is limited to 30.
7241 @subsubheading Remarks
7242 The @code{asm} statement allows you to include assembly instructions directly 
7243 within C code. This may help you to maximize performance in time-sensitive 
7244 code or to access assembly instructions that are not readily available to C 
7245 programs.
7247 Note that extended @code{asm} statements must be inside a function. Only 
7248 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7249 Functions declared with the @code{naked} attribute also require basic 
7250 @code{asm} (@pxref{Function Attributes}).
7252 While the uses of @code{asm} are many and varied, it may help to think of an 
7253 @code{asm} statement as a series of low-level instructions that convert input 
7254 parameters to output parameters. So a simple (if not particularly useful) 
7255 example for i386 using @code{asm} might look like this:
7257 @example
7258 int src = 1;
7259 int dst;   
7261 asm ("mov %1, %0\n\t"
7262     "add $1, %0"
7263     : "=r" (dst) 
7264     : "r" (src));
7266 printf("%d\n", dst);
7267 @end example
7269 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7271 @anchor{Volatile}
7272 @subsubsection Volatile
7273 @cindex volatile @code{asm}
7274 @cindex @code{asm} volatile
7276 GCC's optimizers sometimes discard @code{asm} statements if they determine 
7277 there is no need for the output variables. Also, the optimizers may move 
7278 code out of loops if they believe that the code will always return the same 
7279 result (i.e. none of its input values change between calls). Using the 
7280 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
7281 that have no output operands, including @code{asm goto} statements, 
7282 are implicitly volatile.
7284 This i386 code demonstrates a case that does not use (or require) the 
7285 @code{volatile} qualifier. If it is performing assertion checking, this code 
7286 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
7287 unreferenced by any code. As a result, the optimizers can discard the 
7288 @code{asm} statement, which in turn removes the need for the entire 
7289 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
7290 isn't needed you allow the optimizers to produce the most efficient code 
7291 possible.
7293 @example
7294 void DoCheck(uint32_t dwSomeValue)
7296    uint32_t dwRes;
7298    // Assumes dwSomeValue is not zero.
7299    asm ("bsfl %1,%0"
7300      : "=r" (dwRes)
7301      : "r" (dwSomeValue)
7302      : "cc");
7304    assert(dwRes > 3);
7306 @end example
7308 The next example shows a case where the optimizers can recognize that the input 
7309 (@code{dwSomeValue}) never changes during the execution of the function and can 
7310 therefore move the @code{asm} outside the loop to produce more efficient code. 
7311 Again, using @code{volatile} disables this type of optimization.
7313 @example
7314 void do_print(uint32_t dwSomeValue)
7316    uint32_t dwRes;
7318    for (uint32_t x=0; x < 5; x++)
7319    @{
7320       // Assumes dwSomeValue is not zero.
7321       asm ("bsfl %1,%0"
7322         : "=r" (dwRes)
7323         : "r" (dwSomeValue)
7324         : "cc");
7326       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7327    @}
7329 @end example
7331 The following example demonstrates a case where you need to use the 
7332 @code{volatile} qualifier. 
7333 It uses the x86 @code{rdtsc} instruction, which reads 
7334 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
7335 the optimizers might assume that the @code{asm} block will always return the 
7336 same value and therefore optimize away the second call.
7338 @example
7339 uint64_t msr;
7341 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7342         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7343         "or %%rdx, %0"        // 'Or' in the lower bits.
7344         : "=a" (msr)
7345         : 
7346         : "rdx");
7348 printf("msr: %llx\n", msr);
7350 // Do other work...
7352 // Reprint the timestamp
7353 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7354         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7355         "or %%rdx, %0"        // 'Or' in the lower bits.
7356         : "=a" (msr)
7357         : 
7358         : "rdx");
7360 printf("msr: %llx\n", msr);
7361 @end example
7363 GCC's optimizers do not treat this code like the non-volatile code in the 
7364 earlier examples. They do not move it out of loops or omit it on the 
7365 assumption that the result from a previous call is still valid.
7367 Note that the compiler can move even volatile @code{asm} instructions relative 
7368 to other code, including across jump instructions. For example, on many 
7369 targets there is a system register that controls the rounding mode of 
7370 floating-point operations. Setting it with a volatile @code{asm}, as in the 
7371 following PowerPC example, does not work reliably.
7373 @example
7374 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7375 sum = x + y;
7376 @end example
7378 The compiler may move the addition back before the volatile @code{asm}. To 
7379 make it work as expected, add an artificial dependency to the @code{asm} by 
7380 referencing a variable in the subsequent code, for example: 
7382 @example
7383 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7384 sum = x + y;
7385 @end example
7387 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7388 assembly code when optimizing. This can lead to unexpected duplicate symbol 
7389 errors during compilation if your asm code defines symbols or labels. 
7390 Using @samp{%=} 
7391 (@pxref{AssemblerTemplate}) may help resolve this problem.
7393 @anchor{AssemblerTemplate}
7394 @subsubsection Assembler Template
7395 @cindex @code{asm} assembler template
7397 An assembler template is a literal string containing assembler instructions.
7398 The compiler replaces tokens in the template that refer 
7399 to inputs, outputs, and goto labels,
7400 and then outputs the resulting string to the assembler. The 
7401 string can contain any instructions recognized by the assembler, including 
7402 directives. GCC does not parse the assembler instructions 
7403 themselves and does not know what they mean or even whether they are valid 
7404 assembler input. However, it does count the statements 
7405 (@pxref{Size of an asm}).
7407 You may place multiple assembler instructions together in a single @code{asm} 
7408 string, separated by the characters normally used in assembly code for the 
7409 system. A combination that works in most places is a newline to break the 
7410 line, plus a tab character to move to the instruction field (written as 
7411 @samp{\n\t}). 
7412 Some assemblers allow semicolons as a line separator. However, note 
7413 that some assembler dialects use semicolons to start a comment. 
7415 Do not expect a sequence of @code{asm} statements to remain perfectly 
7416 consecutive after compilation, even when you are using the @code{volatile} 
7417 qualifier. If certain instructions need to remain consecutive in the output, 
7418 put them in a single multi-instruction asm statement.
7420 Accessing data from C programs without using input/output operands (such as 
7421 by using global symbols directly from the assembler template) may not work as 
7422 expected. Similarly, calling functions directly from an assembler template 
7423 requires a detailed understanding of the target assembler and ABI.
7425 Since GCC does not parse the assembler template,
7426 it has no visibility of any 
7427 symbols it references. This may result in GCC discarding those symbols as 
7428 unreferenced unless they are also listed as input, output, or goto operands.
7430 @subsubheading Special format strings
7432 In addition to the tokens described by the input, output, and goto operands, 
7433 these tokens have special meanings in the assembler template:
7435 @table @samp
7436 @item %% 
7437 Outputs a single @samp{%} into the assembler code.
7439 @item %= 
7440 Outputs a number that is unique to each instance of the @code{asm} 
7441 statement in the entire compilation. This option is useful when creating local 
7442 labels and referring to them multiple times in a single template that 
7443 generates multiple assembler instructions. 
7445 @item %@{
7446 @itemx %|
7447 @itemx %@}
7448 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7449 into the assembler code.  When unescaped, these characters have special
7450 meaning to indicate multiple assembler dialects, as described below.
7451 @end table
7453 @subsubheading Multiple assembler dialects in @code{asm} templates
7455 On targets such as x86, GCC supports multiple assembler dialects.
7456 The @option{-masm} option controls which dialect GCC uses as its 
7457 default for inline assembler. The target-specific documentation for the 
7458 @option{-masm} option contains the list of supported dialects, as well as the 
7459 default dialect if the option is not specified. This information may be 
7460 important to understand, since assembler code that works correctly when 
7461 compiled using one dialect will likely fail if compiled using another.
7462 @xref{x86 Options}.
7464 If your code needs to support multiple assembler dialects (for example, if 
7465 you are writing public headers that need to support a variety of compilation 
7466 options), use constructs of this form:
7468 @example
7469 @{ dialect0 | dialect1 | dialect2... @}
7470 @end example
7472 This construct outputs @code{dialect0} 
7473 when using dialect #0 to compile the code, 
7474 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
7475 braces than the number of dialects the compiler supports, the construct 
7476 outputs nothing.
7478 For example, if an x86 compiler supports two dialects
7479 (@samp{att}, @samp{intel}), an 
7480 assembler template such as this:
7482 @example
7483 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7484 @end example
7486 @noindent
7487 is equivalent to one of
7489 @example
7490 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
7491 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
7492 @end example
7494 Using that same compiler, this code:
7496 @example
7497 "xchg@{l@}\t@{%%@}ebx, %1"
7498 @end example
7500 @noindent
7501 corresponds to either
7503 @example
7504 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
7505 "xchg\tebx, %1"                    @r{/* intel dialect */}
7506 @end example
7508 There is no support for nesting dialect alternatives.
7510 @anchor{OutputOperands}
7511 @subsubsection Output Operands
7512 @cindex @code{asm} output operands
7514 An @code{asm} statement has zero or more output operands indicating the names
7515 of C variables modified by the assembler code.
7517 In this i386 example, @code{old} (referred to in the template string as 
7518 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
7519 (@code{%2}) is an input:
7521 @example
7522 bool old;
7524 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7525          "sbb %0,%0"      // Use the CF to calculate old.
7526    : "=r" (old), "+rm" (*Base)
7527    : "Ir" (Offset)
7528    : "cc");
7530 return old;
7531 @end example
7533 Operands are separated by commas.  Each operand has this format:
7535 @example
7536 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7537 @end example
7539 @table @var
7540 @item asmSymbolicName
7541 Specifies a symbolic name for the operand.
7542 Reference the name in the assembler template 
7543 by enclosing it in square brackets 
7544 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
7545 that contains the definition. Any valid C variable name is acceptable, 
7546 including names already defined in the surrounding code. No two operands 
7547 within the same @code{asm} statement can use the same symbolic name.
7549 When not using an @var{asmSymbolicName}, use the (zero-based) position
7550 of the operand 
7551 in the list of operands in the assembler template. For example if there are 
7552 three output operands, use @samp{%0} in the template to refer to the first, 
7553 @samp{%1} for the second, and @samp{%2} for the third. 
7555 @item constraint
7556 A string constant specifying constraints on the placement of the operand; 
7557 @xref{Constraints}, for details.
7559 Output constraints must begin with either @samp{=} (a variable overwriting an 
7560 existing value) or @samp{+} (when reading and writing). When using 
7561 @samp{=}, do not assume the location contains the existing value
7562 on entry to the @code{asm}, except 
7563 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7565 After the prefix, there must be one or more additional constraints 
7566 (@pxref{Constraints}) that describe where the value resides. Common 
7567 constraints include @samp{r} for register and @samp{m} for memory. 
7568 When you list more than one possible location (for example, @code{"=rm"}),
7569 the compiler chooses the most efficient one based on the current context. 
7570 If you list as many alternates as the @code{asm} statement allows, you permit 
7571 the optimizers to produce the best possible code. 
7572 If you must use a specific register, but your Machine Constraints do not
7573 provide sufficient control to select the specific register you want, 
7574 local register variables may provide a solution (@pxref{Local Reg Vars}).
7576 @item cvariablename
7577 Specifies a C lvalue expression to hold the output, typically a variable name.
7578 The enclosing parentheses are a required part of the syntax.
7580 @end table
7582 When the compiler selects the registers to use to 
7583 represent the output operands, it does not use any of the clobbered registers 
7584 (@pxref{Clobbers}).
7586 Output operand expressions must be lvalues. The compiler cannot check whether 
7587 the operands have data types that are reasonable for the instruction being 
7588 executed. For output expressions that are not directly addressable (for 
7589 example a bit-field), the constraint must allow a register. In that case, GCC 
7590 uses the register as the output of the @code{asm}, and then stores that 
7591 register into the output. 
7593 Operands using the @samp{+} constraint modifier count as two operands 
7594 (that is, both as input and output) towards the total maximum of 30 operands
7595 per @code{asm} statement.
7597 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7598 operands that must not overlap an input.  Otherwise, 
7599 GCC may allocate the output operand in the same register as an unrelated 
7600 input operand, on the assumption that the assembler code consumes its 
7601 inputs before producing outputs. This assumption may be false if the assembler 
7602 code actually consists of more than one instruction.
7604 The same problem can occur if one output parameter (@var{a}) allows a register 
7605 constraint and another output parameter (@var{b}) allows a memory constraint.
7606 The code generated by GCC to access the memory address in @var{b} can contain
7607 registers which @emph{might} be shared by @var{a}, and GCC considers those 
7608 registers to be inputs to the asm. As above, GCC assumes that such input
7609 registers are consumed before any outputs are written. This assumption may 
7610 result in incorrect behavior if the asm writes to @var{a} before using 
7611 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7612 ensures that modifying @var{a} does not affect the address referenced by 
7613 @var{b}. Otherwise, the location of @var{b} 
7614 is undefined if @var{a} is modified before using @var{b}.
7616 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7617 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7618 dependent. The list of supported modifiers for x86 is found at 
7619 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7621 If the C code that follows the @code{asm} makes no use of any of the output 
7622 operands, use @code{volatile} for the @code{asm} statement to prevent the 
7623 optimizers from discarding the @code{asm} statement as unneeded 
7624 (see @ref{Volatile}).
7626 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
7627 references the first output operand as @code{%0} (were there a second, it 
7628 would be @code{%1}, etc). The number of the first input operand is one greater 
7629 than that of the last output operand. In this i386 example, that makes 
7630 @code{Mask} referenced as @code{%1}:
7632 @example
7633 uint32_t Mask = 1234;
7634 uint32_t Index;
7636   asm ("bsfl %1, %0"
7637      : "=r" (Index)
7638      : "r" (Mask)
7639      : "cc");
7640 @end example
7642 That code overwrites the variable @code{Index} (@samp{=}),
7643 placing the value in a register (@samp{r}).
7644 Using the generic @samp{r} constraint instead of a constraint for a specific 
7645 register allows the compiler to pick the register to use, which can result 
7646 in more efficient code. This may not be possible if an assembler instruction 
7647 requires a specific register.
7649 The following i386 example uses the @var{asmSymbolicName} syntax.
7650 It produces the 
7651 same result as the code above, but some may consider it more readable or more 
7652 maintainable since reordering index numbers is not necessary when adding or 
7653 removing operands. The names @code{aIndex} and @code{aMask}
7654 are only used in this example to emphasize which 
7655 names get used where.
7656 It is acceptable to reuse the names @code{Index} and @code{Mask}.
7658 @example
7659 uint32_t Mask = 1234;
7660 uint32_t Index;
7662   asm ("bsfl %[aMask], %[aIndex]"
7663      : [aIndex] "=r" (Index)
7664      : [aMask] "r" (Mask)
7665      : "cc");
7666 @end example
7668 Here are some more examples of output operands.
7670 @example
7671 uint32_t c = 1;
7672 uint32_t d;
7673 uint32_t *e = &c;
7675 asm ("mov %[e], %[d]"
7676    : [d] "=rm" (d)
7677    : [e] "rm" (*e));
7678 @end example
7680 Here, @code{d} may either be in a register or in memory. Since the compiler 
7681 might already have the current value of the @code{uint32_t} location
7682 pointed to by @code{e}
7683 in a register, you can enable it to choose the best location
7684 for @code{d} by specifying both constraints.
7686 @anchor{FlagOutputOperands}
7687 @subsection Flag Output Operands
7688 @cindex @code{asm} flag output operands
7690 Some targets have a special register that holds the ``flags'' for the
7691 result of an operation or comparison.  Normally, the contents of that
7692 register are either unmodifed by the asm, or the asm is considered to
7693 clobber the contents.
7695 On some targets, a special form of output operand exists by which
7696 conditions in the flags register may be outputs of the asm.  The set of
7697 conditions supported are target specific, but the general rule is that
7698 the output variable must be a scalar integer, and the value will be boolean.
7699 When supported, the target will define the preprocessor symbol
7700 @code{__GCC_ASM_FLAG_OUTPUTS__}.
7702 Because of the special nature of the flag output operands, the constraint
7703 may not include alternatives.
7705 Most often, the target has only one flags register, and thus is an implied
7706 operand of many instructions.  In this case, the operand should not be
7707 referenced within the assembler template via @code{%0} etc, as there's
7708 no corresponding text in the assembly language.
7710 @table @asis
7711 @item x86 family
7712 The flag output constraints for the x86 family are of the form
7713 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
7714 conditions defined in the ISA manual for @code{j@var{cc}} or
7715 @code{set@var{cc}}.
7717 @table @code
7718 @item a
7719 ``above'' or unsigned greater than
7720 @item ae
7721 ``above or equal'' or unsigned greater than or equal
7722 @item b
7723 ``below'' or unsigned less than
7724 @item be
7725 ``below or equal'' or unsigned less than or equal
7726 @item c
7727 carry flag set
7728 @item e
7729 @itemx z
7730 ``equal'' or zero flag set
7731 @item g
7732 signed greater than
7733 @item ge
7734 signed greater than or equal
7735 @item l
7736 signed less than
7737 @item le
7738 signed less than or equal
7739 @item o
7740 overflow flag set
7741 @item p
7742 parity flag set
7743 @item s
7744 sign flag set
7745 @item na
7746 @itemx nae
7747 @itemx nb
7748 @itemx nbe
7749 @itemx nc
7750 @itemx ne
7751 @itemx ng
7752 @itemx nge
7753 @itemx nl
7754 @itemx nle
7755 @itemx no
7756 @itemx np
7757 @itemx ns
7758 @itemx nz
7759 ``not'' @var{flag}, or inverted versions of those above
7760 @end table
7762 @end table
7764 @anchor{InputOperands}
7765 @subsubsection Input Operands
7766 @cindex @code{asm} input operands
7767 @cindex @code{asm} expressions
7769 Input operands make values from C variables and expressions available to the 
7770 assembly code.
7772 Operands are separated by commas.  Each operand has this format:
7774 @example
7775 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
7776 @end example
7778 @table @var
7779 @item asmSymbolicName
7780 Specifies a symbolic name for the operand.
7781 Reference the name in the assembler template 
7782 by enclosing it in square brackets 
7783 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
7784 that contains the definition. Any valid C variable name is acceptable, 
7785 including names already defined in the surrounding code. No two operands 
7786 within the same @code{asm} statement can use the same symbolic name.
7788 When not using an @var{asmSymbolicName}, use the (zero-based) position
7789 of the operand 
7790 in the list of operands in the assembler template. For example if there are
7791 two output operands and three inputs,
7792 use @samp{%2} in the template to refer to the first input operand,
7793 @samp{%3} for the second, and @samp{%4} for the third. 
7795 @item constraint
7796 A string constant specifying constraints on the placement of the operand; 
7797 @xref{Constraints}, for details.
7799 Input constraint strings may not begin with either @samp{=} or @samp{+}.
7800 When you list more than one possible location (for example, @samp{"irm"}), 
7801 the compiler chooses the most efficient one based on the current context.
7802 If you must use a specific register, but your Machine Constraints do not
7803 provide sufficient control to select the specific register you want, 
7804 local register variables may provide a solution (@pxref{Local Reg Vars}).
7806 Input constraints can also be digits (for example, @code{"0"}). This indicates 
7807 that the specified input must be in the same place as the output constraint 
7808 at the (zero-based) index in the output constraint list. 
7809 When using @var{asmSymbolicName} syntax for the output operands,
7810 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
7812 @item cexpression
7813 This is the C variable or expression being passed to the @code{asm} statement 
7814 as input.  The enclosing parentheses are a required part of the syntax.
7816 @end table
7818 When the compiler selects the registers to use to represent the input 
7819 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
7821 If there are no output operands but there are input operands, place two 
7822 consecutive colons where the output operands would go:
7824 @example
7825 __asm__ ("some instructions"
7826    : /* No outputs. */
7827    : "r" (Offset / 8));
7828 @end example
7830 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7831 (except for inputs tied to outputs). The compiler assumes that on exit from 
7832 the @code{asm} statement these operands contain the same values as they 
7833 had before executing the statement. 
7834 It is @emph{not} possible to use clobbers
7835 to inform the compiler that the values in these inputs are changing. One 
7836 common work-around is to tie the changing input variable to an output variable 
7837 that never gets used. Note, however, that if the code that follows the 
7838 @code{asm} statement makes no use of any of the output operands, the GCC 
7839 optimizers may discard the @code{asm} statement as unneeded 
7840 (see @ref{Volatile}).
7842 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7843 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7844 dependent. The list of supported modifiers for x86 is found at 
7845 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7847 In this example using the fictitious @code{combine} instruction, the 
7848 constraint @code{"0"} for input operand 1 says that it must occupy the same 
7849 location as output operand 0. Only input operands may use numbers in 
7850 constraints, and they must each refer to an output operand. Only a number (or 
7851 the symbolic assembler name) in the constraint can guarantee that one operand 
7852 is in the same place as another. The mere fact that @code{foo} is the value of 
7853 both operands is not enough to guarantee that they are in the same place in 
7854 the generated assembler code.
7856 @example
7857 asm ("combine %2, %0" 
7858    : "=r" (foo) 
7859    : "0" (foo), "g" (bar));
7860 @end example
7862 Here is an example using symbolic names.
7864 @example
7865 asm ("cmoveq %1, %2, %[result]" 
7866    : [result] "=r"(result) 
7867    : "r" (test), "r" (new), "[result]" (old));
7868 @end example
7870 @anchor{Clobbers}
7871 @subsubsection Clobbers
7872 @cindex @code{asm} clobbers
7874 While the compiler is aware of changes to entries listed in the output 
7875 operands, the inline @code{asm} code may modify more than just the outputs. For 
7876 example, calculations may require additional registers, or the processor may 
7877 overwrite a register as a side effect of a particular assembler instruction. 
7878 In order to inform the compiler of these changes, list them in the clobber 
7879 list. Clobber list items are either register names or the special clobbers 
7880 (listed below). Each clobber list item is a string constant 
7881 enclosed in double quotes and separated by commas.
7883 Clobber descriptions may not in any way overlap with an input or output 
7884 operand. For example, you may not have an operand describing a register class 
7885 with one member when listing that register in the clobber list. Variables 
7886 declared to live in specific registers (@pxref{Explicit Reg Vars}) and used 
7887 as @code{asm} input or output operands must have no part mentioned in the 
7888 clobber description. In particular, there is no way to specify that input 
7889 operands get modified without also specifying them as output operands.
7891 When the compiler selects which registers to use to represent input and output 
7892 operands, it does not use any of the clobbered registers. As a result, 
7893 clobbered registers are available for any use in the assembler code.
7895 Here is a realistic example for the VAX showing the use of clobbered 
7896 registers: 
7898 @example
7899 asm volatile ("movc3 %0, %1, %2"
7900                    : /* No outputs. */
7901                    : "g" (from), "g" (to), "g" (count)
7902                    : "r0", "r1", "r2", "r3", "r4", "r5");
7903 @end example
7905 Also, there are two special clobber arguments:
7907 @table @code
7908 @item "cc"
7909 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7910 register. On some machines, GCC represents the condition codes as a specific 
7911 hardware register; @code{"cc"} serves to name this register.
7912 On other machines, condition code handling is different, 
7913 and specifying @code{"cc"} has no effect. But 
7914 it is valid no matter what the target.
7916 @item "memory"
7917 The @code{"memory"} clobber tells the compiler that the assembly code
7918 performs memory 
7919 reads or writes to items other than those listed in the input and output 
7920 operands (for example, accessing the memory pointed to by one of the input 
7921 parameters). To ensure memory contains correct values, GCC may need to flush 
7922 specific register values to memory before executing the @code{asm}. Further, 
7923 the compiler does not assume that any values read from memory before an 
7924 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
7925 needed.  
7926 Using the @code{"memory"} clobber effectively forms a read/write
7927 memory barrier for the compiler.
7929 Note that this clobber does not prevent the @emph{processor} from doing 
7930 speculative reads past the @code{asm} statement. To prevent that, you need 
7931 processor-specific fence instructions.
7933 Flushing registers to memory has performance implications and may be an issue 
7934 for time-sensitive code.  You can use a trick to avoid this if the size of 
7935 the memory being accessed is known at compile time. For example, if accessing 
7936 ten bytes of a string, use a memory input like: 
7938 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7940 @end table
7942 @anchor{GotoLabels}
7943 @subsubsection Goto Labels
7944 @cindex @code{asm} goto labels
7946 @code{asm goto} allows assembly code to jump to one or more C labels.  The
7947 @var{GotoLabels} section in an @code{asm goto} statement contains 
7948 a comma-separated 
7949 list of all C labels to which the assembler code may jump. GCC assumes that 
7950 @code{asm} execution falls through to the next statement (if this is not the 
7951 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7952 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7953 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7954 Attributes}).
7956 An @code{asm goto} statement cannot have outputs.
7957 This is due to an internal restriction of 
7958 the compiler: control transfer instructions cannot have outputs. 
7959 If the assembler code does modify anything, use the @code{"memory"} clobber 
7960 to force the 
7961 optimizers to flush all register values to memory and reload them if 
7962 necessary after the @code{asm} statement.
7964 Also note that an @code{asm goto} statement is always implicitly
7965 considered volatile.
7967 To reference a label in the assembler template,
7968 prefix it with @samp{%l} (lowercase @samp{L}) followed 
7969 by its (zero-based) position in @var{GotoLabels} plus the number of input 
7970 operands.  For example, if the @code{asm} has three inputs and references two 
7971 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
7973 Alternately, you can reference labels using the actual C label name enclosed
7974 in brackets.  For example, to reference a label named @code{carry}, you can
7975 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
7976 section when using this approach.
7978 Here is an example of @code{asm goto} for i386:
7980 @example
7981 asm goto (
7982     "btl %1, %0\n\t"
7983     "jc %l2"
7984     : /* No outputs. */
7985     : "r" (p1), "r" (p2) 
7986     : "cc" 
7987     : carry);
7989 return 0;
7991 carry:
7992 return 1;
7993 @end example
7995 The following example shows an @code{asm goto} that uses a memory clobber.
7997 @example
7998 int frob(int x)
8000   int y;
8001   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8002             : /* No outputs. */
8003             : "r"(x), "r"(&y)
8004             : "r5", "memory" 
8005             : error);
8006   return y;
8007 error:
8008   return -1;
8010 @end example
8012 @anchor{x86Operandmodifiers}
8013 @subsubsection x86 Operand Modifiers
8015 References to input, output, and goto operands in the assembler template
8016 of extended @code{asm} statements can use 
8017 modifiers to affect the way the operands are formatted in 
8018 the code output to the assembler. For example, the 
8019 following code uses the @samp{h} and @samp{b} modifiers for x86:
8021 @example
8022 uint16_t  num;
8023 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8024 @end example
8026 @noindent
8027 These modifiers generate this assembler code:
8029 @example
8030 xchg %ah, %al
8031 @end example
8033 The rest of this discussion uses the following code for illustrative purposes.
8035 @example
8036 int main()
8038    int iInt = 1;
8040 top:
8042    asm volatile goto ("some assembler instructions here"
8043    : /* No outputs. */
8044    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8045    : /* No clobbers. */
8046    : top);
8048 @end example
8050 With no modifiers, this is what the output from the operands would be for the 
8051 @samp{att} and @samp{intel} dialects of assembler:
8053 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8054 @headitem Operand @tab masm=att @tab masm=intel
8055 @item @code{%0}
8056 @tab @code{%eax}
8057 @tab @code{eax}
8058 @item @code{%1}
8059 @tab @code{$2}
8060 @tab @code{2}
8061 @item @code{%2}
8062 @tab @code{$.L2}
8063 @tab @code{OFFSET FLAT:.L2}
8064 @end multitable
8066 The table below shows the list of supported modifiers and their effects.
8068 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8069 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8070 @item @code{z}
8071 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8072 @tab @code{%z0}
8073 @tab @code{l}
8074 @tab 
8075 @item @code{b}
8076 @tab Print the QImode name of the register.
8077 @tab @code{%b0}
8078 @tab @code{%al}
8079 @tab @code{al}
8080 @item @code{h}
8081 @tab Print the QImode name for a ``high'' register.
8082 @tab @code{%h0}
8083 @tab @code{%ah}
8084 @tab @code{ah}
8085 @item @code{w}
8086 @tab Print the HImode name of the register.
8087 @tab @code{%w0}
8088 @tab @code{%ax}
8089 @tab @code{ax}
8090 @item @code{k}
8091 @tab Print the SImode name of the register.
8092 @tab @code{%k0}
8093 @tab @code{%eax}
8094 @tab @code{eax}
8095 @item @code{q}
8096 @tab Print the DImode name of the register.
8097 @tab @code{%q0}
8098 @tab @code{%rax}
8099 @tab @code{rax}
8100 @item @code{l}
8101 @tab Print the label name with no punctuation.
8102 @tab @code{%l2}
8103 @tab @code{.L2}
8104 @tab @code{.L2}
8105 @item @code{c}
8106 @tab Require a constant operand and print the constant expression with no punctuation.
8107 @tab @code{%c1}
8108 @tab @code{2}
8109 @tab @code{2}
8110 @end multitable
8112 @anchor{x86floatingpointasmoperands}
8113 @subsubsection x86 Floating-Point @code{asm} Operands
8115 On x86 targets, there are several rules on the usage of stack-like registers
8116 in the operands of an @code{asm}.  These rules apply only to the operands
8117 that are stack-like registers:
8119 @enumerate
8120 @item
8121 Given a set of input registers that die in an @code{asm}, it is
8122 necessary to know which are implicitly popped by the @code{asm}, and
8123 which must be explicitly popped by GCC@.
8125 An input register that is implicitly popped by the @code{asm} must be
8126 explicitly clobbered, unless it is constrained to match an
8127 output operand.
8129 @item
8130 For any input register that is implicitly popped by an @code{asm}, it is
8131 necessary to know how to adjust the stack to compensate for the pop.
8132 If any non-popped input is closer to the top of the reg-stack than
8133 the implicitly popped register, it would not be possible to know what the
8134 stack looked like---it's not clear how the rest of the stack ``slides
8135 up''.
8137 All implicitly popped input registers must be closer to the top of
8138 the reg-stack than any input that is not implicitly popped.
8140 It is possible that if an input dies in an @code{asm}, the compiler might
8141 use the input register for an output reload.  Consider this example:
8143 @smallexample
8144 asm ("foo" : "=t" (a) : "f" (b));
8145 @end smallexample
8147 @noindent
8148 This code says that input @code{b} is not popped by the @code{asm}, and that
8149 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8150 deeper after the @code{asm} than it was before.  But, it is possible that
8151 reload may think that it can use the same register for both the input and
8152 the output.
8154 To prevent this from happening,
8155 if any input operand uses the @samp{f} constraint, all output register
8156 constraints must use the @samp{&} early-clobber modifier.
8158 The example above is correctly written as:
8160 @smallexample
8161 asm ("foo" : "=&t" (a) : "f" (b));
8162 @end smallexample
8164 @item
8165 Some operands need to be in particular places on the stack.  All
8166 output operands fall in this category---GCC has no other way to
8167 know which registers the outputs appear in unless you indicate
8168 this in the constraints.
8170 Output operands must specifically indicate which register an output
8171 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
8172 constraints must select a class with a single register.
8174 @item
8175 Output operands may not be ``inserted'' between existing stack registers.
8176 Since no 387 opcode uses a read/write operand, all output operands
8177 are dead before the @code{asm}, and are pushed by the @code{asm}.
8178 It makes no sense to push anywhere but the top of the reg-stack.
8180 Output operands must start at the top of the reg-stack: output
8181 operands may not ``skip'' a register.
8183 @item
8184 Some @code{asm} statements may need extra stack space for internal
8185 calculations.  This can be guaranteed by clobbering stack registers
8186 unrelated to the inputs and outputs.
8188 @end enumerate
8190 This @code{asm}
8191 takes one input, which is internally popped, and produces two outputs.
8193 @smallexample
8194 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8195 @end smallexample
8197 @noindent
8198 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8199 and replaces them with one output.  The @code{st(1)} clobber is necessary 
8200 for the compiler to know that @code{fyl2xp1} pops both inputs.
8202 @smallexample
8203 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8204 @end smallexample
8206 @lowersections
8207 @include md.texi
8208 @raisesections
8210 @node Asm Labels
8211 @subsection Controlling Names Used in Assembler Code
8212 @cindex assembler names for identifiers
8213 @cindex names used in assembler code
8214 @cindex identifiers, names in assembler code
8216 You can specify the name to be used in the assembler code for a C
8217 function or variable by writing the @code{asm} (or @code{__asm__})
8218 keyword after the declarator as follows:
8220 @smallexample
8221 int foo asm ("myfoo") = 2;
8222 @end smallexample
8224 @noindent
8225 This specifies that the name to be used for the variable @code{foo} in
8226 the assembler code should be @samp{myfoo} rather than the usual
8227 @samp{_foo}.
8229 On systems where an underscore is normally prepended to the name of a C
8230 function or variable, this feature allows you to define names for the
8231 linker that do not start with an underscore.
8233 It does not make sense to use this feature with a non-static local
8234 variable since such variables do not have assembler names.  If you are
8235 trying to put the variable in a particular register, see @ref{Explicit
8236 Reg Vars}.  GCC presently accepts such code with a warning, but will
8237 probably be changed to issue an error, rather than a warning, in the
8238 future.
8240 You cannot use @code{asm} in this way in a function @emph{definition}; but
8241 you can get the same effect by writing a declaration for the function
8242 before its definition and putting @code{asm} there, like this:
8244 @smallexample
8245 extern func () asm ("FUNC");
8247 func (x, y)
8248      int x, y;
8249 /* @r{@dots{}} */
8250 @end smallexample
8252 It is up to you to make sure that the assembler names you choose do not
8253 conflict with any other assembler symbols.  Also, you must not use a
8254 register name; that would produce completely invalid assembler code.  GCC
8255 does not as yet have the ability to store static variables in registers.
8256 Perhaps that will be added.
8258 @node Explicit Reg Vars
8259 @subsection Variables in Specified Registers
8260 @cindex explicit register variables
8261 @cindex variables in specified registers
8262 @cindex specified registers
8263 @cindex registers, global allocation
8265 GNU C allows you to put a few global variables into specified hardware
8266 registers.  You can also specify the register in which an ordinary
8267 register variable should be allocated.
8269 @itemize @bullet
8270 @item
8271 Global register variables reserve registers throughout the program.
8272 This may be useful in programs such as programming language
8273 interpreters that have a couple of global variables that are accessed
8274 very often.
8276 @item
8277 Local register variables in specific registers do not reserve the
8278 registers, except at the point where they are used as input or output
8279 operands in an @code{asm} statement and the @code{asm} statement itself is
8280 not deleted.  The compiler's data flow analysis is capable of determining
8281 where the specified registers contain live values, and where they are
8282 available for other uses.  Stores into local register variables may be deleted
8283 when they appear to be dead according to dataflow analysis.  References
8284 to local register variables may be deleted or moved or simplified.
8286 These local variables are sometimes convenient for use with the extended
8287 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
8288 output of the assembler instruction directly into a particular register.
8289 (This works provided the register you specify fits the constraints
8290 specified for that operand in the @code{asm}.)
8291 @end itemize
8293 @menu
8294 * Global Reg Vars::
8295 * Local Reg Vars::
8296 @end menu
8298 @node Global Reg Vars
8299 @subsubsection Defining Global Register Variables
8300 @cindex global register variables
8301 @cindex registers, global variables in
8303 You can define a global register variable in GNU C like this:
8305 @smallexample
8306 register int *foo asm ("a5");
8307 @end smallexample
8309 @noindent
8310 Here @code{a5} is the name of the register that should be used.  Choose a
8311 register that is normally saved and restored by function calls on your
8312 machine, so that library routines will not clobber it.
8314 Naturally the register name is CPU-dependent, so you need to
8315 conditionalize your program according to CPU type.  The register
8316 @code{a5} is a good choice on a 68000 for a variable of pointer
8317 type.  On machines with register windows, be sure to choose a ``global''
8318 register that is not affected magically by the function call mechanism.
8320 In addition, different operating systems on the same CPU may differ in how they
8321 name the registers; then you need additional conditionals.  For
8322 example, some 68000 operating systems call this register @code{%a5}.
8324 Eventually there may be a way of asking the compiler to choose a register
8325 automatically, but first we need to figure out how it should choose and
8326 how to enable you to guide the choice.  No solution is evident.
8328 Defining a global register variable in a certain register reserves that
8329 register entirely for this use, at least within the current compilation.
8330 The register is not allocated for any other purpose in the functions
8331 in the current compilation, and is not saved and restored by
8332 these functions.  Stores into this register are never deleted even if they
8333 appear to be dead, but references may be deleted or moved or
8334 simplified.
8336 It is not safe to access the global register variables from signal
8337 handlers, or from more than one thread of control, because the system
8338 library routines may temporarily use the register for other things (unless
8339 you recompile them specially for the task at hand).
8341 @cindex @code{qsort}, and global register variables
8342 It is not safe for one function that uses a global register variable to
8343 call another such function @code{foo} by way of a third function
8344 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
8345 different source file in which the variable isn't declared).  This is
8346 because @code{lose} might save the register and put some other value there.
8347 For example, you can't expect a global register variable to be available in
8348 the comparison-function that you pass to @code{qsort}, since @code{qsort}
8349 might have put something else in that register.  (If you are prepared to
8350 recompile @code{qsort} with the same global register variable, you can
8351 solve this problem.)
8353 If you want to recompile @code{qsort} or other source files that do not
8354 actually use your global register variable, so that they do not use that
8355 register for any other purpose, then it suffices to specify the compiler
8356 option @option{-ffixed-@var{reg}}.  You need not actually add a global
8357 register declaration to their source code.
8359 A function that can alter the value of a global register variable cannot
8360 safely be called from a function compiled without this variable, because it
8361 could clobber the value the caller expects to find there on return.
8362 Therefore, the function that is the entry point into the part of the
8363 program that uses the global register variable must explicitly save and
8364 restore the value that belongs to its caller.
8366 @cindex register variable after @code{longjmp}
8367 @cindex global register after @code{longjmp}
8368 @cindex value after @code{longjmp}
8369 @findex longjmp
8370 @findex setjmp
8371 On most machines, @code{longjmp} restores to each global register
8372 variable the value it had at the time of the @code{setjmp}.  On some
8373 machines, however, @code{longjmp} does not change the value of global
8374 register variables.  To be portable, the function that called @code{setjmp}
8375 should make other arrangements to save the values of the global register
8376 variables, and to restore them in a @code{longjmp}.  This way, the same
8377 thing happens regardless of what @code{longjmp} does.
8379 All global register variable declarations must precede all function
8380 definitions.  If such a declaration could appear after function
8381 definitions, the declaration would be too late to prevent the register from
8382 being used for other purposes in the preceding functions.
8384 Global register variables may not have initial values, because an
8385 executable file has no means to supply initial contents for a register.
8387 On the SPARC, there are reports that g3 @dots{} g7 are suitable
8388 registers, but certain library functions, such as @code{getwd}, as well
8389 as the subroutines for division and remainder, modify g3 and g4.  g1 and
8390 g2 are local temporaries.
8392 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
8393 Of course, it does not do to use more than a few of those.
8395 @node Local Reg Vars
8396 @subsubsection Specifying Registers for Local Variables
8397 @cindex local variables, specifying registers
8398 @cindex specifying registers for local variables
8399 @cindex registers for local variables
8401 You can define a local register variable with a specified register
8402 like this:
8404 @smallexample
8405 register int *foo asm ("a5");
8406 @end smallexample
8408 @noindent
8409 Here @code{a5} is the name of the register that should be used.  Note
8410 that this is the same syntax used for defining global register
8411 variables, but for a local variable it appears within a function.
8413 Naturally the register name is CPU-dependent, but this is not a
8414 problem, since specific registers are most often useful with explicit
8415 assembler instructions (@pxref{Extended Asm}).  Both of these things
8416 generally require that you conditionalize your program according to
8417 CPU type.
8419 In addition, operating systems on one type of CPU may differ in how they
8420 name the registers; then you need additional conditionals.  For
8421 example, some 68000 operating systems call this register @code{%a5}.
8423 Defining such a register variable does not reserve the register; it
8424 remains available for other uses in places where flow control determines
8425 the variable's value is not live.
8427 This option does not guarantee that GCC generates code that has
8428 this variable in the register you specify at all times.  You may not
8429 code an explicit reference to this register in the assembler
8430 instruction template part of an @code{asm} statement and assume it
8431 always refers to this variable.
8432 However, using the variable as an input or output operand to the @code{asm}
8433 guarantees that the specified register is used for that operand.  
8434 @xref{Extended Asm}, for more information.
8436 Stores into local register variables may be deleted when they appear to be dead
8437 according to dataflow analysis.  References to local register variables may
8438 be deleted or moved or simplified.
8440 As with global register variables, it is recommended that you choose a
8441 register that is normally saved and restored by function calls on
8442 your machine, so that library routines will not clobber it.  
8444 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
8445 specific register, but there's no matching constraint letter for that 
8446 register. To force the operand into that register, create a local variable 
8447 and specify the register in the variable's declaration. Then use the local 
8448 variable for the asm operand and specify any constraint letter that matches 
8449 the register:
8451 @smallexample
8452 register int *p1 asm ("r0") = @dots{};
8453 register int *p2 asm ("r1") = @dots{};
8454 register int *result asm ("r0");
8455 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8456 @end smallexample
8458 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
8459 call-clobbered by subsequent code, including function calls and library calls 
8460 for arithmetic operators on other variables (for example the initialization 
8461 of p2). In this case, use temporary variables for expressions between the 
8462 register assignments:
8464 @smallexample
8465 int t1 = @dots{};
8466 register int *p1 asm ("r0") = @dots{};
8467 register int *p2 asm ("r1") = t1;
8468 register int *result asm ("r0");
8469 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8470 @end smallexample
8472 @node Size of an asm
8473 @subsection Size of an @code{asm}
8475 Some targets require that GCC track the size of each instruction used
8476 in order to generate correct code.  Because the final length of the
8477 code produced by an @code{asm} statement is only known by the
8478 assembler, GCC must make an estimate as to how big it will be.  It
8479 does this by counting the number of instructions in the pattern of the
8480 @code{asm} and multiplying that by the length of the longest
8481 instruction supported by that processor.  (When working out the number
8482 of instructions, it assumes that any occurrence of a newline or of
8483 whatever statement separator character is supported by the assembler --
8484 typically @samp{;} --- indicates the end of an instruction.)
8486 Normally, GCC's estimate is adequate to ensure that correct
8487 code is generated, but it is possible to confuse the compiler if you use
8488 pseudo instructions or assembler macros that expand into multiple real
8489 instructions, or if you use assembler directives that expand to more
8490 space in the object file than is needed for a single instruction.
8491 If this happens then the assembler may produce a diagnostic saying that
8492 a label is unreachable.
8494 @node Alternate Keywords
8495 @section Alternate Keywords
8496 @cindex alternate keywords
8497 @cindex keywords, alternate
8499 @option{-ansi} and the various @option{-std} options disable certain
8500 keywords.  This causes trouble when you want to use GNU C extensions, or
8501 a general-purpose header file that should be usable by all programs,
8502 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
8503 @code{inline} are not available in programs compiled with
8504 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8505 program compiled with @option{-std=c99} or @option{-std=c11}).  The
8506 ISO C99 keyword
8507 @code{restrict} is only available when @option{-std=gnu99} (which will
8508 eventually be the default) or @option{-std=c99} (or the equivalent
8509 @option{-std=iso9899:1999}), or an option for a later standard
8510 version, is used.
8512 The way to solve these problems is to put @samp{__} at the beginning and
8513 end of each problematical keyword.  For example, use @code{__asm__}
8514 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8516 Other C compilers won't accept these alternative keywords; if you want to
8517 compile with another compiler, you can define the alternate keywords as
8518 macros to replace them with the customary keywords.  It looks like this:
8520 @smallexample
8521 #ifndef __GNUC__
8522 #define __asm__ asm
8523 #endif
8524 @end smallexample
8526 @findex __extension__
8527 @opindex pedantic
8528 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8529 You can
8530 prevent such warnings within one expression by writing
8531 @code{__extension__} before the expression.  @code{__extension__} has no
8532 effect aside from this.
8534 @node Incomplete Enums
8535 @section Incomplete @code{enum} Types
8537 You can define an @code{enum} tag without specifying its possible values.
8538 This results in an incomplete type, much like what you get if you write
8539 @code{struct foo} without describing the elements.  A later declaration
8540 that does specify the possible values completes the type.
8542 You can't allocate variables or storage using the type while it is
8543 incomplete.  However, you can work with pointers to that type.
8545 This extension may not be very useful, but it makes the handling of
8546 @code{enum} more consistent with the way @code{struct} and @code{union}
8547 are handled.
8549 This extension is not supported by GNU C++.
8551 @node Function Names
8552 @section Function Names as Strings
8553 @cindex @code{__func__} identifier
8554 @cindex @code{__FUNCTION__} identifier
8555 @cindex @code{__PRETTY_FUNCTION__} identifier
8557 GCC provides three magic variables that hold the name of the current
8558 function, as a string.  The first of these is @code{__func__}, which
8559 is part of the C99 standard:
8561 The identifier @code{__func__} is implicitly declared by the translator
8562 as if, immediately following the opening brace of each function
8563 definition, the declaration
8565 @smallexample
8566 static const char __func__[] = "function-name";
8567 @end smallexample
8569 @noindent
8570 appeared, where function-name is the name of the lexically-enclosing
8571 function.  This name is the unadorned name of the function.
8573 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8574 backward compatibility with old versions of GCC.
8576 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8577 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
8578 the type signature of the function as well as its bare name.  For
8579 example, this program:
8581 @smallexample
8582 extern "C" @{
8583 extern int printf (char *, ...);
8586 class a @{
8587  public:
8588   void sub (int i)
8589     @{
8590       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8591       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8592     @}
8596 main (void)
8598   a ax;
8599   ax.sub (0);
8600   return 0;
8602 @end smallexample
8604 @noindent
8605 gives this output:
8607 @smallexample
8608 __FUNCTION__ = sub
8609 __PRETTY_FUNCTION__ = void a::sub(int)
8610 @end smallexample
8612 These identifiers are variables, not preprocessor macros, and may not
8613 be used to initialize @code{char} arrays or be concatenated with other string
8614 literals.
8616 @node Return Address
8617 @section Getting the Return or Frame Address of a Function
8619 These functions may be used to get information about the callers of a
8620 function.
8622 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8623 This function returns the return address of the current function, or of
8624 one of its callers.  The @var{level} argument is number of frames to
8625 scan up the call stack.  A value of @code{0} yields the return address
8626 of the current function, a value of @code{1} yields the return address
8627 of the caller of the current function, and so forth.  When inlining
8628 the expected behavior is that the function returns the address of
8629 the function that is returned to.  To work around this behavior use
8630 the @code{noinline} function attribute.
8632 The @var{level} argument must be a constant integer.
8634 On some machines it may be impossible to determine the return address of
8635 any function other than the current one; in such cases, or when the top
8636 of the stack has been reached, this function returns @code{0} or a
8637 random value.  In addition, @code{__builtin_frame_address} may be used
8638 to determine if the top of the stack has been reached.
8640 Additional post-processing of the returned value may be needed, see
8641 @code{__builtin_extract_return_addr}.
8643 This function should only be used with a nonzero argument for debugging
8644 purposes.
8645 @end deftypefn
8647 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
8648 The address as returned by @code{__builtin_return_address} may have to be fed
8649 through this function to get the actual encoded address.  For example, on the
8650 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
8651 platforms an offset has to be added for the true next instruction to be
8652 executed.
8654 If no fixup is needed, this function simply passes through @var{addr}.
8655 @end deftypefn
8657 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
8658 This function does the reverse of @code{__builtin_extract_return_addr}.
8659 @end deftypefn
8661 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
8662 This function is similar to @code{__builtin_return_address}, but it
8663 returns the address of the function frame rather than the return address
8664 of the function.  Calling @code{__builtin_frame_address} with a value of
8665 @code{0} yields the frame address of the current function, a value of
8666 @code{1} yields the frame address of the caller of the current function,
8667 and so forth.
8669 The frame is the area on the stack that holds local variables and saved
8670 registers.  The frame address is normally the address of the first word
8671 pushed on to the stack by the function.  However, the exact definition
8672 depends upon the processor and the calling convention.  If the processor
8673 has a dedicated frame pointer register, and the function has a frame,
8674 then @code{__builtin_frame_address} returns the value of the frame
8675 pointer register.
8677 On some machines it may be impossible to determine the frame address of
8678 any function other than the current one; in such cases, or when the top
8679 of the stack has been reached, this function returns @code{0} if
8680 the first frame pointer is properly initialized by the startup code.
8682 This function should only be used with a nonzero argument for debugging
8683 purposes.
8684 @end deftypefn
8686 @node Vector Extensions
8687 @section Using Vector Instructions through Built-in Functions
8689 On some targets, the instruction set contains SIMD vector instructions which
8690 operate on multiple values contained in one large register at the same time.
8691 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
8692 this way.
8694 The first step in using these extensions is to provide the necessary data
8695 types.  This should be done using an appropriate @code{typedef}:
8697 @smallexample
8698 typedef int v4si __attribute__ ((vector_size (16)));
8699 @end smallexample
8701 @noindent
8702 The @code{int} type specifies the base type, while the attribute specifies
8703 the vector size for the variable, measured in bytes.  For example, the
8704 declaration above causes the compiler to set the mode for the @code{v4si}
8705 type to be 16 bytes wide and divided into @code{int} sized units.  For
8706 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
8707 corresponding mode of @code{foo} is @acronym{V4SI}.
8709 The @code{vector_size} attribute is only applicable to integral and
8710 float scalars, although arrays, pointers, and function return values
8711 are allowed in conjunction with this construct. Only sizes that are
8712 a power of two are currently allowed.
8714 All the basic integer types can be used as base types, both as signed
8715 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
8716 @code{long long}.  In addition, @code{float} and @code{double} can be
8717 used to build floating-point vector types.
8719 Specifying a combination that is not valid for the current architecture
8720 causes GCC to synthesize the instructions using a narrower mode.
8721 For example, if you specify a variable of type @code{V4SI} and your
8722 architecture does not allow for this specific SIMD type, GCC
8723 produces code that uses 4 @code{SIs}.
8725 The types defined in this manner can be used with a subset of normal C
8726 operations.  Currently, GCC allows using the following operators
8727 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
8729 The operations behave like C++ @code{valarrays}.  Addition is defined as
8730 the addition of the corresponding elements of the operands.  For
8731 example, in the code below, each of the 4 elements in @var{a} is
8732 added to the corresponding 4 elements in @var{b} and the resulting
8733 vector is stored in @var{c}.
8735 @smallexample
8736 typedef int v4si __attribute__ ((vector_size (16)));
8738 v4si a, b, c;
8740 c = a + b;
8741 @end smallexample
8743 Subtraction, multiplication, division, and the logical operations
8744 operate in a similar manner.  Likewise, the result of using the unary
8745 minus or complement operators on a vector type is a vector whose
8746 elements are the negative or complemented values of the corresponding
8747 elements in the operand.
8749 It is possible to use shifting operators @code{<<}, @code{>>} on
8750 integer-type vectors. The operation is defined as following: @code{@{a0,
8751 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
8752 @dots{}, an >> bn@}}@. Vector operands must have the same number of
8753 elements. 
8755 For convenience, it is allowed to use a binary vector operation
8756 where one operand is a scalar. In that case the compiler transforms
8757 the scalar operand into a vector where each element is the scalar from
8758 the operation. The transformation happens only if the scalar could be
8759 safely converted to the vector-element type.
8760 Consider the following code.
8762 @smallexample
8763 typedef int v4si __attribute__ ((vector_size (16)));
8765 v4si a, b, c;
8766 long l;
8768 a = b + 1;    /* a = b + @{1,1,1,1@}; */
8769 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
8771 a = l + a;    /* Error, cannot convert long to int. */
8772 @end smallexample
8774 Vectors can be subscripted as if the vector were an array with
8775 the same number of elements and base type.  Out of bound accesses
8776 invoke undefined behavior at run time.  Warnings for out of bound
8777 accesses for vector subscription can be enabled with
8778 @option{-Warray-bounds}.
8780 Vector comparison is supported with standard comparison
8781 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
8782 vector expressions of integer-type or real-type. Comparison between
8783 integer-type vectors and real-type vectors are not supported.  The
8784 result of the comparison is a vector of the same width and number of
8785 elements as the comparison operands with a signed integral element
8786 type.
8788 Vectors are compared element-wise producing 0 when comparison is false
8789 and -1 (constant of the appropriate type where all bits are set)
8790 otherwise. Consider the following example.
8792 @smallexample
8793 typedef int v4si __attribute__ ((vector_size (16)));
8795 v4si a = @{1,2,3,4@};
8796 v4si b = @{3,2,1,4@};
8797 v4si c;
8799 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
8800 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
8801 @end smallexample
8803 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8804 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8805 integer vector with the same number of elements of the same size as @code{b}
8806 and @code{c}, computes all three arguments and creates a vector
8807 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
8808 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8809 As in the case of binary operations, this syntax is also accepted when
8810 one of @code{b} or @code{c} is a scalar that is then transformed into a
8811 vector. If both @code{b} and @code{c} are scalars and the type of
8812 @code{true?b:c} has the same size as the element type of @code{a}, then
8813 @code{b} and @code{c} are converted to a vector type whose elements have
8814 this type and with the same number of elements as @code{a}.
8816 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8817 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8818 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8819 For mixed operations between a scalar @code{s} and a vector @code{v},
8820 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8821 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8823 Vector shuffling is available using functions
8824 @code{__builtin_shuffle (vec, mask)} and
8825 @code{__builtin_shuffle (vec0, vec1, mask)}.
8826 Both functions construct a permutation of elements from one or two
8827 vectors and return a vector of the same type as the input vector(s).
8828 The @var{mask} is an integral vector with the same width (@var{W})
8829 and element count (@var{N}) as the output vector.
8831 The elements of the input vectors are numbered in memory ordering of
8832 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8833 elements of @var{mask} are considered modulo @var{N} in the single-operand
8834 case and modulo @math{2*@var{N}} in the two-operand case.
8836 Consider the following example,
8838 @smallexample
8839 typedef int v4si __attribute__ ((vector_size (16)));
8841 v4si a = @{1,2,3,4@};
8842 v4si b = @{5,6,7,8@};
8843 v4si mask1 = @{0,1,1,3@};
8844 v4si mask2 = @{0,4,2,5@};
8845 v4si res;
8847 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
8848 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
8849 @end smallexample
8851 Note that @code{__builtin_shuffle} is intentionally semantically
8852 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8854 You can declare variables and use them in function calls and returns, as
8855 well as in assignments and some casts.  You can specify a vector type as
8856 a return type for a function.  Vector types can also be used as function
8857 arguments.  It is possible to cast from one vector type to another,
8858 provided they are of the same size (in fact, you can also cast vectors
8859 to and from other datatypes of the same size).
8861 You cannot operate between vectors of different lengths or different
8862 signedness without a cast.
8864 @node Offsetof
8865 @section Support for @code{offsetof}
8866 @findex __builtin_offsetof
8868 GCC implements for both C and C++ a syntactic extension to implement
8869 the @code{offsetof} macro.
8871 @smallexample
8872 primary:
8873         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8875 offsetof_member_designator:
8876           @code{identifier}
8877         | offsetof_member_designator "." @code{identifier}
8878         | offsetof_member_designator "[" @code{expr} "]"
8879 @end smallexample
8881 This extension is sufficient such that
8883 @smallexample
8884 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8885 @end smallexample
8887 @noindent
8888 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8889 may be dependent.  In either case, @var{member} may consist of a single
8890 identifier, or a sequence of member accesses and array references.
8892 @node __sync Builtins
8893 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
8895 The following built-in functions
8896 are intended to be compatible with those described
8897 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8898 section 7.4.  As such, they depart from normal GCC practice by not using
8899 the @samp{__builtin_} prefix and also by being overloaded so that they
8900 work on multiple types.
8902 The definition given in the Intel documentation allows only for the use of
8903 the types @code{int}, @code{long}, @code{long long} or their unsigned
8904 counterparts.  GCC allows any integral scalar or pointer type that is
8905 1, 2, 4 or 8 bytes in length.
8907 These functions are implemented in terms of the @samp{__atomic}
8908 builtins (@pxref{__atomic Builtins}).  They should not be used for new
8909 code which should use the @samp{__atomic} builtins instead.
8911 Not all operations are supported by all target processors.  If a particular
8912 operation cannot be implemented on the target processor, a warning is
8913 generated and a call to an external function is generated.  The external
8914 function carries the same name as the built-in version,
8915 with an additional suffix
8916 @samp{_@var{n}} where @var{n} is the size of the data type.
8918 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8919 @c useful for implementing the operation under the control of an external
8920 @c mutex.
8922 In most cases, these built-in functions are considered a @dfn{full barrier}.
8923 That is,
8924 no memory operand is moved across the operation, either forward or
8925 backward.  Further, instructions are issued as necessary to prevent the
8926 processor from speculating loads across the operation and from queuing stores
8927 after the operation.
8929 All of the routines are described in the Intel documentation to take
8930 ``an optional list of variables protected by the memory barrier''.  It's
8931 not clear what is meant by that; it could mean that @emph{only} the
8932 listed variables are protected, or it could mean a list of additional
8933 variables to be protected.  The list is ignored by GCC which treats it as
8934 empty.  GCC interprets an empty list as meaning that all globally
8935 accessible variables should be protected.
8937 @table @code
8938 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8939 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8940 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8941 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8942 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8943 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8944 @findex __sync_fetch_and_add
8945 @findex __sync_fetch_and_sub
8946 @findex __sync_fetch_and_or
8947 @findex __sync_fetch_and_and
8948 @findex __sync_fetch_and_xor
8949 @findex __sync_fetch_and_nand
8950 These built-in functions perform the operation suggested by the name, and
8951 returns the value that had previously been in memory.  That is,
8953 @smallexample
8954 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8955 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8956 @end smallexample
8958 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8959 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8961 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8962 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8963 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8964 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8965 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8966 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8967 @findex __sync_add_and_fetch
8968 @findex __sync_sub_and_fetch
8969 @findex __sync_or_and_fetch
8970 @findex __sync_and_and_fetch
8971 @findex __sync_xor_and_fetch
8972 @findex __sync_nand_and_fetch
8973 These built-in functions perform the operation suggested by the name, and
8974 return the new value.  That is,
8976 @smallexample
8977 @{ *ptr @var{op}= value; return *ptr; @}
8978 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8979 @end smallexample
8981 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8982 as @code{*ptr = ~(*ptr & value)} instead of
8983 @code{*ptr = ~*ptr & value}.
8985 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8986 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8987 @findex __sync_bool_compare_and_swap
8988 @findex __sync_val_compare_and_swap
8989 These built-in functions perform an atomic compare and swap.
8990 That is, if the current
8991 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8992 @code{*@var{ptr}}.
8994 The ``bool'' version returns true if the comparison is successful and
8995 @var{newval} is written.  The ``val'' version returns the contents
8996 of @code{*@var{ptr}} before the operation.
8998 @item __sync_synchronize (...)
8999 @findex __sync_synchronize
9000 This built-in function issues a full memory barrier.
9002 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9003 @findex __sync_lock_test_and_set
9004 This built-in function, as described by Intel, is not a traditional test-and-set
9005 operation, but rather an atomic exchange operation.  It writes @var{value}
9006 into @code{*@var{ptr}}, and returns the previous contents of
9007 @code{*@var{ptr}}.
9009 Many targets have only minimal support for such locks, and do not support
9010 a full exchange operation.  In this case, a target may support reduced
9011 functionality here by which the @emph{only} valid value to store is the
9012 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
9013 is implementation defined.
9015 This built-in function is not a full barrier,
9016 but rather an @dfn{acquire barrier}.
9017 This means that references after the operation cannot move to (or be
9018 speculated to) before the operation, but previous memory stores may not
9019 be globally visible yet, and previous memory loads may not yet be
9020 satisfied.
9022 @item void __sync_lock_release (@var{type} *ptr, ...)
9023 @findex __sync_lock_release
9024 This built-in function releases the lock acquired by
9025 @code{__sync_lock_test_and_set}.
9026 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9028 This built-in function is not a full barrier,
9029 but rather a @dfn{release barrier}.
9030 This means that all previous memory stores are globally visible, and all
9031 previous memory loads have been satisfied, but following memory reads
9032 are not prevented from being speculated to before the barrier.
9033 @end table
9035 @node __atomic Builtins
9036 @section Built-in Functions for Memory Model Aware Atomic Operations
9038 The following built-in functions approximately match the requirements
9039 for the C++11 memory model.  They are all
9040 identified by being prefixed with @samp{__atomic} and most are
9041 overloaded so that they work with multiple types.
9043 These functions are intended to replace the legacy @samp{__sync}
9044 builtins.  The main difference is that the memory order that is requested
9045 is a parameter to the functions.  New code should always use the
9046 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9048 Note that the @samp{__atomic} builtins assume that programs will
9049 conform to the C++11 memory model.  In particular, they assume
9050 that programs are free of data races.  See the C++11 standard for
9051 detailed requirements.
9053 The @samp{__atomic} builtins can be used with any integral scalar or
9054 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
9055 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9056 supported by the architecture.
9058 The four non-arithmetic functions (load, store, exchange, and 
9059 compare_exchange) all have a generic version as well.  This generic
9060 version works on any data type.  It uses the lock-free built-in function
9061 if the specific data type size makes that possible; otherwise, an
9062 external call is left to be resolved at run time.  This external call is
9063 the same format with the addition of a @samp{size_t} parameter inserted
9064 as the first parameter indicating the size of the object being pointed to.
9065 All objects must be the same size.
9067 There are 6 different memory orders that can be specified.  These map
9068 to the C++11 memory orders with the same names, see the C++11 standard
9069 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9070 on atomic synchronization} for detailed definitions.  Individual
9071 targets may also support additional memory orders for use on specific
9072 architectures.  Refer to the target documentation for details of
9073 these.
9075 An atomic operation can both constrain code motion and
9076 be mapped to hardware instructions for synchronization between threads
9077 (e.g., a fence).  To which extent this happens is controlled by the
9078 memory orders, which are listed here in approximately ascending order of
9079 strength.  The description of each memory order is only meant to roughly
9080 illustrate the effects and is not a specification; see the C++11
9081 memory model for precise semantics.
9083 @table  @code
9084 @item __ATOMIC_RELAXED
9085 Implies no inter-thread ordering constraints.
9086 @item __ATOMIC_CONSUME
9087 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9088 memory order because of a deficiency in C++11's semantics for
9089 @code{memory_order_consume}.
9090 @item __ATOMIC_ACQUIRE
9091 Creates an inter-thread happens-before constraint from the release (or
9092 stronger) semantic store to this acquire load.  Can prevent hoisting
9093 of code to before the operation.
9094 @item __ATOMIC_RELEASE
9095 Creates an inter-thread happens-before constraint to acquire (or stronger)
9096 semantic loads that read from this release store.  Can prevent sinking
9097 of code to after the operation.
9098 @item __ATOMIC_ACQ_REL
9099 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9100 @code{__ATOMIC_RELEASE}.
9101 @item __ATOMIC_SEQ_CST
9102 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9103 @end table
9105 Note that in the C++11 memory model, @emph{fences} (e.g.,
9106 @samp{__atomic_thread_fence}) take effect in combination with other
9107 atomic operations on specific memory locations (e.g., atomic loads);
9108 operations on specific memory locations do not necessarily affect other
9109 operations in the same way.
9111 Target architectures are encouraged to provide their own patterns for
9112 each of the atomic built-in functions.  If no target is provided, the original
9113 non-memory model set of @samp{__sync} atomic built-in functions are
9114 used, along with any required synchronization fences surrounding it in
9115 order to achieve the proper behavior.  Execution in this case is subject
9116 to the same restrictions as those built-in functions.
9118 If there is no pattern or mechanism to provide a lock-free instruction
9119 sequence, a call is made to an external routine with the same parameters
9120 to be resolved at run time.
9122 When implementing patterns for these built-in functions, the memory order
9123 parameter can be ignored as long as the pattern implements the most
9124 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
9125 orders execute correctly with this memory order but they may not execute as
9126 efficiently as they could with a more appropriate implementation of the
9127 relaxed requirements.
9129 Note that the C++11 standard allows for the memory order parameter to be
9130 determined at run time rather than at compile time.  These built-in
9131 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9132 than invoke a runtime library call or inline a switch statement.  This is
9133 standard compliant, safe, and the simplest approach for now.
9135 The memory order parameter is a signed int, but only the lower 16 bits are
9136 reserved for the memory order.  The remainder of the signed int is reserved
9137 for target use and should be 0.  Use of the predefined atomic values
9138 ensures proper usage.
9140 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9141 This built-in function implements an atomic load operation.  It returns the
9142 contents of @code{*@var{ptr}}.
9144 The valid memory order variants are
9145 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9146 and @code{__ATOMIC_CONSUME}.
9148 @end deftypefn
9150 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9151 This is the generic version of an atomic load.  It returns the
9152 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9154 @end deftypefn
9156 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9157 This built-in function implements an atomic store operation.  It writes 
9158 @code{@var{val}} into @code{*@var{ptr}}.  
9160 The valid memory order variants are
9161 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9163 @end deftypefn
9165 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9166 This is the generic version of an atomic store.  It stores the value
9167 of @code{*@var{val}} into @code{*@var{ptr}}.
9169 @end deftypefn
9171 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9172 This built-in function implements an atomic exchange operation.  It writes
9173 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9174 @code{*@var{ptr}}.
9176 The valid memory order variants are
9177 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9178 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9180 @end deftypefn
9182 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9183 This is the generic version of an atomic exchange.  It stores the
9184 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9185 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9187 @end deftypefn
9189 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memorder, int failure_memorder)
9190 This built-in function implements an atomic compare and exchange operation.
9191 This compares the contents of @code{*@var{ptr}} with the contents of
9192 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9193 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
9194 equal, the operation is a @emph{read} and the current contents of
9195 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
9196 for weak compare_exchange, and false for the strong variation.  Many targets 
9197 only offer the strong variation and ignore the parameter.  When in doubt, use
9198 the strong variation.
9200 True is returned if @var{desired} is written into
9201 @code{*@var{ptr}} and the operation is considered to conform to the
9202 memory order specified by @var{success_memorder}.  There are no
9203 restrictions on what memory order can be used here.
9205 False is returned otherwise, and the operation is considered to conform
9206 to @var{failure_memorder}. This memory order cannot be
9207 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
9208 stronger order than that specified by @var{success_memorder}.
9210 @end deftypefn
9212 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memorder, int failure_memorder)
9213 This built-in function implements the generic version of
9214 @code{__atomic_compare_exchange}.  The function is virtually identical to
9215 @code{__atomic_compare_exchange_n}, except the desired value is also a
9216 pointer.
9218 @end deftypefn
9220 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9221 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9222 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9223 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9224 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9225 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9226 These built-in functions perform the operation suggested by the name, and
9227 return the result of the operation. That is,
9229 @smallexample
9230 @{ *ptr @var{op}= val; return *ptr; @}
9231 @end smallexample
9233 All memory orders are valid.
9235 @end deftypefn
9237 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9238 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9239 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9240 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9241 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9242 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9243 These built-in functions perform the operation suggested by the name, and
9244 return the value that had previously been in @code{*@var{ptr}}.  That is,
9246 @smallexample
9247 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9248 @end smallexample
9250 All memory orders are valid.
9252 @end deftypefn
9254 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9256 This built-in function performs an atomic test-and-set operation on
9257 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
9258 defined nonzero ``set'' value and the return value is @code{true} if and only
9259 if the previous contents were ``set''.
9260 It should be only used for operands of type @code{bool} or @code{char}. For 
9261 other types only part of the value may be set.
9263 All memory orders are valid.
9265 @end deftypefn
9267 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9269 This built-in function performs an atomic clear operation on
9270 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
9271 It should be only used for operands of type @code{bool} or @code{char} and 
9272 in conjunction with @code{__atomic_test_and_set}.
9273 For other types it may only clear partially. If the type is not @code{bool}
9274 prefer using @code{__atomic_store}.
9276 The valid memory order variants are
9277 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9278 @code{__ATOMIC_RELEASE}.
9280 @end deftypefn
9282 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9284 This built-in function acts as a synchronization fence between threads
9285 based on the specified memory order.
9287 All memory orders are valid.
9289 @end deftypefn
9291 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9293 This built-in function acts as a synchronization fence between a thread
9294 and signal handlers based in the same thread.
9296 All memory orders are valid.
9298 @end deftypefn
9300 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
9302 This built-in function returns true if objects of @var{size} bytes always
9303 generate lock-free atomic instructions for the target architecture.
9304 @var{size} must resolve to a compile-time constant and the result also
9305 resolves to a compile-time constant.
9307 @var{ptr} is an optional pointer to the object that may be used to determine
9308 alignment.  A value of 0 indicates typical alignment should be used.  The 
9309 compiler may also ignore this parameter.
9311 @smallexample
9312 if (_atomic_always_lock_free (sizeof (long long), 0))
9313 @end smallexample
9315 @end deftypefn
9317 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9319 This built-in function returns true if objects of @var{size} bytes always
9320 generate lock-free atomic instructions for the target architecture.  If
9321 the built-in function is not known to be lock-free, a call is made to a
9322 runtime routine named @code{__atomic_is_lock_free}.
9324 @var{ptr} is an optional pointer to the object that may be used to determine
9325 alignment.  A value of 0 indicates typical alignment should be used.  The 
9326 compiler may also ignore this parameter.
9327 @end deftypefn
9329 @node Integer Overflow Builtins
9330 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9332 The following built-in functions allow performing simple arithmetic operations
9333 together with checking whether the operations overflowed.
9335 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9336 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9337 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9338 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9339 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9340 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9341 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9343 These built-in functions promote the first two operands into infinite precision signed
9344 type and perform addition on those promoted operands.  The result is then
9345 cast to the type the third pointer argument points to and stored there.
9346 If the stored result is equal to the infinite precision result, the built-in
9347 functions return false, otherwise they return true.  As the addition is
9348 performed in infinite signed precision, these built-in functions have fully defined
9349 behavior for all argument values.
9351 The first built-in function allows arbitrary integral types for operands and
9352 the result type must be pointer to some integer type, the rest of the built-in
9353 functions have explicit integer types.
9355 The compiler will attempt to use hardware instructions to implement
9356 these built-in functions where possible, like conditional jump on overflow
9357 after addition, conditional jump on carry etc.
9359 @end deftypefn
9361 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9362 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9363 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9364 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9365 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9366 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9367 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9369 These built-in functions are similar to the add overflow checking built-in
9370 functions above, except they perform subtraction, subtract the second argument
9371 from the first one, instead of addition.
9373 @end deftypefn
9375 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9376 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9377 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9378 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9379 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9380 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9381 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9383 These built-in functions are similar to the add overflow checking built-in
9384 functions above, except they perform multiplication, instead of addition.
9386 @end deftypefn
9388 @node x86 specific memory model extensions for transactional memory
9389 @section x86-Specific Memory Model Extensions for Transactional Memory
9391 The x86 architecture supports additional memory ordering flags
9392 to mark lock critical sections for hardware lock elision. 
9393 These must be specified in addition to an existing memory order to
9394 atomic intrinsics.
9396 @table @code
9397 @item __ATOMIC_HLE_ACQUIRE
9398 Start lock elision on a lock variable.
9399 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9400 @item __ATOMIC_HLE_RELEASE
9401 End lock elision on a lock variable.
9402 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9403 @end table
9405 When a lock acquire fails, it is required for good performance to abort
9406 the transaction quickly. This can be done with a @code{_mm_pause}.
9408 @smallexample
9409 #include <immintrin.h> // For _mm_pause
9411 int lockvar;
9413 /* Acquire lock with lock elision */
9414 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9415     _mm_pause(); /* Abort failed transaction */
9417 /* Free lock with lock elision */
9418 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9419 @end smallexample
9421 @node Object Size Checking
9422 @section Object Size Checking Built-in Functions
9423 @findex __builtin_object_size
9424 @findex __builtin___memcpy_chk
9425 @findex __builtin___mempcpy_chk
9426 @findex __builtin___memmove_chk
9427 @findex __builtin___memset_chk
9428 @findex __builtin___strcpy_chk
9429 @findex __builtin___stpcpy_chk
9430 @findex __builtin___strncpy_chk
9431 @findex __builtin___strcat_chk
9432 @findex __builtin___strncat_chk
9433 @findex __builtin___sprintf_chk
9434 @findex __builtin___snprintf_chk
9435 @findex __builtin___vsprintf_chk
9436 @findex __builtin___vsnprintf_chk
9437 @findex __builtin___printf_chk
9438 @findex __builtin___vprintf_chk
9439 @findex __builtin___fprintf_chk
9440 @findex __builtin___vfprintf_chk
9442 GCC implements a limited buffer overflow protection mechanism
9443 that can prevent some buffer overflow attacks.
9445 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9446 is a built-in construct that returns a constant number of bytes from
9447 @var{ptr} to the end of the object @var{ptr} pointer points to
9448 (if known at compile time).  @code{__builtin_object_size} never evaluates
9449 its arguments for side-effects.  If there are any side-effects in them, it
9450 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9451 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
9452 point to and all of them are known at compile time, the returned number
9453 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9454 0 and minimum if nonzero.  If it is not possible to determine which objects
9455 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9456 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9457 for @var{type} 2 or 3.
9459 @var{type} is an integer constant from 0 to 3.  If the least significant
9460 bit is clear, objects are whole variables, if it is set, a closest
9461 surrounding subobject is considered the object a pointer points to.
9462 The second bit determines if maximum or minimum of remaining bytes
9463 is computed.
9465 @smallexample
9466 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9467 char *p = &var.buf1[1], *q = &var.b;
9469 /* Here the object p points to is var.  */
9470 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9471 /* The subobject p points to is var.buf1.  */
9472 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9473 /* The object q points to is var.  */
9474 assert (__builtin_object_size (q, 0)
9475         == (char *) (&var + 1) - (char *) &var.b);
9476 /* The subobject q points to is var.b.  */
9477 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9478 @end smallexample
9479 @end deftypefn
9481 There are built-in functions added for many common string operation
9482 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9483 built-in is provided.  This built-in has an additional last argument,
9484 which is the number of bytes remaining in object the @var{dest}
9485 argument points to or @code{(size_t) -1} if the size is not known.
9487 The built-in functions are optimized into the normal string functions
9488 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9489 it is known at compile time that the destination object will not
9490 be overflown.  If the compiler can determine at compile time the
9491 object will be always overflown, it issues a warning.
9493 The intended use can be e.g.@:
9495 @smallexample
9496 #undef memcpy
9497 #define bos0(dest) __builtin_object_size (dest, 0)
9498 #define memcpy(dest, src, n) \
9499   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9501 char *volatile p;
9502 char buf[10];
9503 /* It is unknown what object p points to, so this is optimized
9504    into plain memcpy - no checking is possible.  */
9505 memcpy (p, "abcde", n);
9506 /* Destination is known and length too.  It is known at compile
9507    time there will be no overflow.  */
9508 memcpy (&buf[5], "abcde", 5);
9509 /* Destination is known, but the length is not known at compile time.
9510    This will result in __memcpy_chk call that can check for overflow
9511    at run time.  */
9512 memcpy (&buf[5], "abcde", n);
9513 /* Destination is known and it is known at compile time there will
9514    be overflow.  There will be a warning and __memcpy_chk call that
9515    will abort the program at run time.  */
9516 memcpy (&buf[6], "abcde", 5);
9517 @end smallexample
9519 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9520 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9521 @code{strcat} and @code{strncat}.
9523 There are also checking built-in functions for formatted output functions.
9524 @smallexample
9525 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9526 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9527                               const char *fmt, ...);
9528 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9529                               va_list ap);
9530 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9531                                const char *fmt, va_list ap);
9532 @end smallexample
9534 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9535 etc.@: functions and can contain implementation specific flags on what
9536 additional security measures the checking function might take, such as
9537 handling @code{%n} differently.
9539 The @var{os} argument is the object size @var{s} points to, like in the
9540 other built-in functions.  There is a small difference in the behavior
9541 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9542 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9543 the checking function is called with @var{os} argument set to
9544 @code{(size_t) -1}.
9546 In addition to this, there are checking built-in functions
9547 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9548 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9549 These have just one additional argument, @var{flag}, right before
9550 format string @var{fmt}.  If the compiler is able to optimize them to
9551 @code{fputc} etc.@: functions, it does, otherwise the checking function
9552 is called and the @var{flag} argument passed to it.
9554 @node Pointer Bounds Checker builtins
9555 @section Pointer Bounds Checker Built-in Functions
9556 @cindex Pointer Bounds Checker builtins
9557 @findex __builtin___bnd_set_ptr_bounds
9558 @findex __builtin___bnd_narrow_ptr_bounds
9559 @findex __builtin___bnd_copy_ptr_bounds
9560 @findex __builtin___bnd_init_ptr_bounds
9561 @findex __builtin___bnd_null_ptr_bounds
9562 @findex __builtin___bnd_store_ptr_bounds
9563 @findex __builtin___bnd_chk_ptr_lbounds
9564 @findex __builtin___bnd_chk_ptr_ubounds
9565 @findex __builtin___bnd_chk_ptr_bounds
9566 @findex __builtin___bnd_get_ptr_lbound
9567 @findex __builtin___bnd_get_ptr_ubound
9569 GCC provides a set of built-in functions to control Pointer Bounds Checker
9570 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
9571 even if you compile with Pointer Bounds Checker off
9572 (@option{-fno-check-pointer-bounds}).
9573 The behavior may differ in such case as documented below.
9575 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9577 This built-in function returns a new pointer with the value of @var{q}, and
9578 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
9579 Bounds Checker off, the built-in function just returns the first argument.
9581 @smallexample
9582 extern void *__wrap_malloc (size_t n)
9584   void *p = (void *)__real_malloc (n);
9585   if (!p) return __builtin___bnd_null_ptr_bounds (p);
9586   return __builtin___bnd_set_ptr_bounds (p, n);
9588 @end smallexample
9590 @end deftypefn
9592 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
9594 This built-in function returns a new pointer with the value of @var{p}
9595 and associates it with the narrowed bounds formed by the intersection
9596 of bounds associated with @var{q} and the bounds
9597 [@var{p}, @var{p} + @var{size} - 1].
9598 With Pointer Bounds Checker off, the built-in function just returns the first
9599 argument.
9601 @smallexample
9602 void init_objects (object *objs, size_t size)
9604   size_t i;
9605   /* Initialize objects one-by-one passing pointers with bounds of 
9606      an object, not the full array of objects.  */
9607   for (i = 0; i < size; i++)
9608     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
9609                                                     sizeof(object)));
9611 @end smallexample
9613 @end deftypefn
9615 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
9617 This built-in function returns a new pointer with the value of @var{q},
9618 and associates it with the bounds already associated with pointer @var{r}.
9619 With Pointer Bounds Checker off, the built-in function just returns the first
9620 argument.
9622 @smallexample
9623 /* Here is a way to get pointer to object's field but
9624    still with the full object's bounds.  */
9625 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
9626                                                   objptr);
9627 @end smallexample
9629 @end deftypefn
9631 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
9633 This built-in function returns a new pointer with the value of @var{q}, and
9634 associates it with INIT (allowing full memory access) bounds. With Pointer
9635 Bounds Checker off, the built-in function just returns the first argument.
9637 @end deftypefn
9639 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
9641 This built-in function returns a new pointer with the value of @var{q}, and
9642 associates it with NULL (allowing no memory access) bounds. With Pointer
9643 Bounds Checker off, the built-in function just returns the first argument.
9645 @end deftypefn
9647 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
9649 This built-in function stores the bounds associated with pointer @var{ptr_val}
9650 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
9651 bounds from legacy code without touching the associated pointer's memory when
9652 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
9653 function call is ignored.
9655 @end deftypefn
9657 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
9659 This built-in function checks if the pointer @var{q} is within the lower
9660 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
9661 function call is ignored.
9663 @smallexample
9664 extern void *__wrap_memset (void *dst, int c, size_t len)
9666   if (len > 0)
9667     @{
9668       __builtin___bnd_chk_ptr_lbounds (dst);
9669       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
9670       __real_memset (dst, c, len);
9671     @}
9672   return dst;
9674 @end smallexample
9676 @end deftypefn
9678 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
9680 This built-in function checks if the pointer @var{q} is within the upper
9681 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
9682 function call is ignored.
9684 @end deftypefn
9686 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
9688 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
9689 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
9690 off, the built-in function call is ignored.
9692 @smallexample
9693 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
9695   if (n > 0)
9696     @{
9697       __bnd_chk_ptr_bounds (dst, n);
9698       __bnd_chk_ptr_bounds (src, n);
9699       __real_memcpy (dst, src, n);
9700     @}
9701   return dst;
9703 @end smallexample
9705 @end deftypefn
9707 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
9709 This built-in function returns the lower bound associated
9710 with the pointer @var{q}, as a pointer value.  
9711 This is useful for debugging using @code{printf}.
9712 With Pointer Bounds Checker off, the built-in function returns 0.
9714 @smallexample
9715 void *lb = __builtin___bnd_get_ptr_lbound (q);
9716 void *ub = __builtin___bnd_get_ptr_ubound (q);
9717 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
9718 @end smallexample
9720 @end deftypefn
9722 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
9724 This built-in function returns the upper bound (which is a pointer) associated
9725 with the pointer @var{q}.  With Pointer Bounds Checker off,
9726 the built-in function returns -1.
9728 @end deftypefn
9730 @node Cilk Plus Builtins
9731 @section Cilk Plus C/C++ Language Extension Built-in Functions
9733 GCC provides support for the following built-in reduction functions if Cilk Plus
9734 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
9736 @itemize @bullet
9737 @item @code{__sec_implicit_index}
9738 @item @code{__sec_reduce}
9739 @item @code{__sec_reduce_add}
9740 @item @code{__sec_reduce_all_nonzero}
9741 @item @code{__sec_reduce_all_zero}
9742 @item @code{__sec_reduce_any_nonzero}
9743 @item @code{__sec_reduce_any_zero}
9744 @item @code{__sec_reduce_max}
9745 @item @code{__sec_reduce_min}
9746 @item @code{__sec_reduce_max_ind}
9747 @item @code{__sec_reduce_min_ind}
9748 @item @code{__sec_reduce_mul}
9749 @item @code{__sec_reduce_mutating}
9750 @end itemize
9752 Further details and examples about these built-in functions are described 
9753 in the Cilk Plus language manual which can be found at 
9754 @uref{http://www.cilkplus.org}.
9756 @node Other Builtins
9757 @section Other Built-in Functions Provided by GCC
9758 @cindex built-in functions
9759 @findex __builtin_call_with_static_chain
9760 @findex __builtin_fpclassify
9761 @findex __builtin_isfinite
9762 @findex __builtin_isnormal
9763 @findex __builtin_isgreater
9764 @findex __builtin_isgreaterequal
9765 @findex __builtin_isinf_sign
9766 @findex __builtin_isless
9767 @findex __builtin_islessequal
9768 @findex __builtin_islessgreater
9769 @findex __builtin_isunordered
9770 @findex __builtin_powi
9771 @findex __builtin_powif
9772 @findex __builtin_powil
9773 @findex _Exit
9774 @findex _exit
9775 @findex abort
9776 @findex abs
9777 @findex acos
9778 @findex acosf
9779 @findex acosh
9780 @findex acoshf
9781 @findex acoshl
9782 @findex acosl
9783 @findex alloca
9784 @findex asin
9785 @findex asinf
9786 @findex asinh
9787 @findex asinhf
9788 @findex asinhl
9789 @findex asinl
9790 @findex atan
9791 @findex atan2
9792 @findex atan2f
9793 @findex atan2l
9794 @findex atanf
9795 @findex atanh
9796 @findex atanhf
9797 @findex atanhl
9798 @findex atanl
9799 @findex bcmp
9800 @findex bzero
9801 @findex cabs
9802 @findex cabsf
9803 @findex cabsl
9804 @findex cacos
9805 @findex cacosf
9806 @findex cacosh
9807 @findex cacoshf
9808 @findex cacoshl
9809 @findex cacosl
9810 @findex calloc
9811 @findex carg
9812 @findex cargf
9813 @findex cargl
9814 @findex casin
9815 @findex casinf
9816 @findex casinh
9817 @findex casinhf
9818 @findex casinhl
9819 @findex casinl
9820 @findex catan
9821 @findex catanf
9822 @findex catanh
9823 @findex catanhf
9824 @findex catanhl
9825 @findex catanl
9826 @findex cbrt
9827 @findex cbrtf
9828 @findex cbrtl
9829 @findex ccos
9830 @findex ccosf
9831 @findex ccosh
9832 @findex ccoshf
9833 @findex ccoshl
9834 @findex ccosl
9835 @findex ceil
9836 @findex ceilf
9837 @findex ceill
9838 @findex cexp
9839 @findex cexpf
9840 @findex cexpl
9841 @findex cimag
9842 @findex cimagf
9843 @findex cimagl
9844 @findex clog
9845 @findex clogf
9846 @findex clogl
9847 @findex conj
9848 @findex conjf
9849 @findex conjl
9850 @findex copysign
9851 @findex copysignf
9852 @findex copysignl
9853 @findex cos
9854 @findex cosf
9855 @findex cosh
9856 @findex coshf
9857 @findex coshl
9858 @findex cosl
9859 @findex cpow
9860 @findex cpowf
9861 @findex cpowl
9862 @findex cproj
9863 @findex cprojf
9864 @findex cprojl
9865 @findex creal
9866 @findex crealf
9867 @findex creall
9868 @findex csin
9869 @findex csinf
9870 @findex csinh
9871 @findex csinhf
9872 @findex csinhl
9873 @findex csinl
9874 @findex csqrt
9875 @findex csqrtf
9876 @findex csqrtl
9877 @findex ctan
9878 @findex ctanf
9879 @findex ctanh
9880 @findex ctanhf
9881 @findex ctanhl
9882 @findex ctanl
9883 @findex dcgettext
9884 @findex dgettext
9885 @findex drem
9886 @findex dremf
9887 @findex dreml
9888 @findex erf
9889 @findex erfc
9890 @findex erfcf
9891 @findex erfcl
9892 @findex erff
9893 @findex erfl
9894 @findex exit
9895 @findex exp
9896 @findex exp10
9897 @findex exp10f
9898 @findex exp10l
9899 @findex exp2
9900 @findex exp2f
9901 @findex exp2l
9902 @findex expf
9903 @findex expl
9904 @findex expm1
9905 @findex expm1f
9906 @findex expm1l
9907 @findex fabs
9908 @findex fabsf
9909 @findex fabsl
9910 @findex fdim
9911 @findex fdimf
9912 @findex fdiml
9913 @findex ffs
9914 @findex floor
9915 @findex floorf
9916 @findex floorl
9917 @findex fma
9918 @findex fmaf
9919 @findex fmal
9920 @findex fmax
9921 @findex fmaxf
9922 @findex fmaxl
9923 @findex fmin
9924 @findex fminf
9925 @findex fminl
9926 @findex fmod
9927 @findex fmodf
9928 @findex fmodl
9929 @findex fprintf
9930 @findex fprintf_unlocked
9931 @findex fputs
9932 @findex fputs_unlocked
9933 @findex frexp
9934 @findex frexpf
9935 @findex frexpl
9936 @findex fscanf
9937 @findex gamma
9938 @findex gammaf
9939 @findex gammal
9940 @findex gamma_r
9941 @findex gammaf_r
9942 @findex gammal_r
9943 @findex gettext
9944 @findex hypot
9945 @findex hypotf
9946 @findex hypotl
9947 @findex ilogb
9948 @findex ilogbf
9949 @findex ilogbl
9950 @findex imaxabs
9951 @findex index
9952 @findex isalnum
9953 @findex isalpha
9954 @findex isascii
9955 @findex isblank
9956 @findex iscntrl
9957 @findex isdigit
9958 @findex isgraph
9959 @findex islower
9960 @findex isprint
9961 @findex ispunct
9962 @findex isspace
9963 @findex isupper
9964 @findex iswalnum
9965 @findex iswalpha
9966 @findex iswblank
9967 @findex iswcntrl
9968 @findex iswdigit
9969 @findex iswgraph
9970 @findex iswlower
9971 @findex iswprint
9972 @findex iswpunct
9973 @findex iswspace
9974 @findex iswupper
9975 @findex iswxdigit
9976 @findex isxdigit
9977 @findex j0
9978 @findex j0f
9979 @findex j0l
9980 @findex j1
9981 @findex j1f
9982 @findex j1l
9983 @findex jn
9984 @findex jnf
9985 @findex jnl
9986 @findex labs
9987 @findex ldexp
9988 @findex ldexpf
9989 @findex ldexpl
9990 @findex lgamma
9991 @findex lgammaf
9992 @findex lgammal
9993 @findex lgamma_r
9994 @findex lgammaf_r
9995 @findex lgammal_r
9996 @findex llabs
9997 @findex llrint
9998 @findex llrintf
9999 @findex llrintl
10000 @findex llround
10001 @findex llroundf
10002 @findex llroundl
10003 @findex log
10004 @findex log10
10005 @findex log10f
10006 @findex log10l
10007 @findex log1p
10008 @findex log1pf
10009 @findex log1pl
10010 @findex log2
10011 @findex log2f
10012 @findex log2l
10013 @findex logb
10014 @findex logbf
10015 @findex logbl
10016 @findex logf
10017 @findex logl
10018 @findex lrint
10019 @findex lrintf
10020 @findex lrintl
10021 @findex lround
10022 @findex lroundf
10023 @findex lroundl
10024 @findex malloc
10025 @findex memchr
10026 @findex memcmp
10027 @findex memcpy
10028 @findex mempcpy
10029 @findex memset
10030 @findex modf
10031 @findex modff
10032 @findex modfl
10033 @findex nearbyint
10034 @findex nearbyintf
10035 @findex nearbyintl
10036 @findex nextafter
10037 @findex nextafterf
10038 @findex nextafterl
10039 @findex nexttoward
10040 @findex nexttowardf
10041 @findex nexttowardl
10042 @findex pow
10043 @findex pow10
10044 @findex pow10f
10045 @findex pow10l
10046 @findex powf
10047 @findex powl
10048 @findex printf
10049 @findex printf_unlocked
10050 @findex putchar
10051 @findex puts
10052 @findex remainder
10053 @findex remainderf
10054 @findex remainderl
10055 @findex remquo
10056 @findex remquof
10057 @findex remquol
10058 @findex rindex
10059 @findex rint
10060 @findex rintf
10061 @findex rintl
10062 @findex round
10063 @findex roundf
10064 @findex roundl
10065 @findex scalb
10066 @findex scalbf
10067 @findex scalbl
10068 @findex scalbln
10069 @findex scalblnf
10070 @findex scalblnf
10071 @findex scalbn
10072 @findex scalbnf
10073 @findex scanfnl
10074 @findex signbit
10075 @findex signbitf
10076 @findex signbitl
10077 @findex signbitd32
10078 @findex signbitd64
10079 @findex signbitd128
10080 @findex significand
10081 @findex significandf
10082 @findex significandl
10083 @findex sin
10084 @findex sincos
10085 @findex sincosf
10086 @findex sincosl
10087 @findex sinf
10088 @findex sinh
10089 @findex sinhf
10090 @findex sinhl
10091 @findex sinl
10092 @findex snprintf
10093 @findex sprintf
10094 @findex sqrt
10095 @findex sqrtf
10096 @findex sqrtl
10097 @findex sscanf
10098 @findex stpcpy
10099 @findex stpncpy
10100 @findex strcasecmp
10101 @findex strcat
10102 @findex strchr
10103 @findex strcmp
10104 @findex strcpy
10105 @findex strcspn
10106 @findex strdup
10107 @findex strfmon
10108 @findex strftime
10109 @findex strlen
10110 @findex strncasecmp
10111 @findex strncat
10112 @findex strncmp
10113 @findex strncpy
10114 @findex strndup
10115 @findex strpbrk
10116 @findex strrchr
10117 @findex strspn
10118 @findex strstr
10119 @findex tan
10120 @findex tanf
10121 @findex tanh
10122 @findex tanhf
10123 @findex tanhl
10124 @findex tanl
10125 @findex tgamma
10126 @findex tgammaf
10127 @findex tgammal
10128 @findex toascii
10129 @findex tolower
10130 @findex toupper
10131 @findex towlower
10132 @findex towupper
10133 @findex trunc
10134 @findex truncf
10135 @findex truncl
10136 @findex vfprintf
10137 @findex vfscanf
10138 @findex vprintf
10139 @findex vscanf
10140 @findex vsnprintf
10141 @findex vsprintf
10142 @findex vsscanf
10143 @findex y0
10144 @findex y0f
10145 @findex y0l
10146 @findex y1
10147 @findex y1f
10148 @findex y1l
10149 @findex yn
10150 @findex ynf
10151 @findex ynl
10153 GCC provides a large number of built-in functions other than the ones
10154 mentioned above.  Some of these are for internal use in the processing
10155 of exceptions or variable-length argument lists and are not
10156 documented here because they may change from time to time; we do not
10157 recommend general use of these functions.
10159 The remaining functions are provided for optimization purposes.
10161 @opindex fno-builtin
10162 GCC includes built-in versions of many of the functions in the standard
10163 C library.  The versions prefixed with @code{__builtin_} are always
10164 treated as having the same meaning as the C library function even if you
10165 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
10166 Many of these functions are only optimized in certain cases; if they are
10167 not optimized in a particular case, a call to the library function is
10168 emitted.
10170 @opindex ansi
10171 @opindex std
10172 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10173 @option{-std=c99} or @option{-std=c11}), the functions
10174 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10175 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10176 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10177 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10178 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10179 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10180 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10181 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10182 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10183 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10184 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10185 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10186 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10187 @code{significandl}, @code{significand}, @code{sincosf},
10188 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10189 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10190 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10191 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10192 @code{yn}
10193 may be handled as built-in functions.
10194 All these functions have corresponding versions
10195 prefixed with @code{__builtin_}, which may be used even in strict C90
10196 mode.
10198 The ISO C99 functions
10199 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10200 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10201 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10202 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10203 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10204 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10205 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10206 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10207 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10208 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10209 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10210 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10211 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10212 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10213 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10214 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10215 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10216 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10217 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10218 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10219 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10220 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10221 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10222 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10223 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10224 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10225 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10226 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10227 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10228 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10229 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10230 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10231 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10232 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10233 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10234 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10235 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10236 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10237 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10238 are handled as built-in functions
10239 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10241 There are also built-in versions of the ISO C99 functions
10242 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10243 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10244 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10245 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10246 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10247 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10248 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10249 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10250 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10251 that are recognized in any mode since ISO C90 reserves these names for
10252 the purpose to which ISO C99 puts them.  All these functions have
10253 corresponding versions prefixed with @code{__builtin_}.
10255 The ISO C94 functions
10256 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10257 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10258 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10259 @code{towupper}
10260 are handled as built-in functions
10261 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10263 The ISO C90 functions
10264 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10265 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10266 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10267 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10268 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10269 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10270 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10271 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10272 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10273 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10274 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10275 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10276 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10277 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10278 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10279 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10280 are all recognized as built-in functions unless
10281 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10282 is specified for an individual function).  All of these functions have
10283 corresponding versions prefixed with @code{__builtin_}.
10285 GCC provides built-in versions of the ISO C99 floating-point comparison
10286 macros that avoid raising exceptions for unordered operands.  They have
10287 the same names as the standard macros ( @code{isgreater},
10288 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10289 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10290 prefixed.  We intend for a library implementor to be able to simply
10291 @code{#define} each standard macro to its built-in equivalent.
10292 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10293 @code{isinf_sign} and @code{isnormal} built-ins used with
10294 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
10295 built-in functions appear both with and without the @code{__builtin_} prefix.
10297 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10299 You can use the built-in function @code{__builtin_types_compatible_p} to
10300 determine whether two types are the same.
10302 This built-in function returns 1 if the unqualified versions of the
10303 types @var{type1} and @var{type2} (which are types, not expressions) are
10304 compatible, 0 otherwise.  The result of this built-in function can be
10305 used in integer constant expressions.
10307 This built-in function ignores top level qualifiers (e.g., @code{const},
10308 @code{volatile}).  For example, @code{int} is equivalent to @code{const
10309 int}.
10311 The type @code{int[]} and @code{int[5]} are compatible.  On the other
10312 hand, @code{int} and @code{char *} are not compatible, even if the size
10313 of their types, on the particular architecture are the same.  Also, the
10314 amount of pointer indirection is taken into account when determining
10315 similarity.  Consequently, @code{short *} is not similar to
10316 @code{short **}.  Furthermore, two types that are typedefed are
10317 considered compatible if their underlying types are compatible.
10319 An @code{enum} type is not considered to be compatible with another
10320 @code{enum} type even if both are compatible with the same integer
10321 type; this is what the C standard specifies.
10322 For example, @code{enum @{foo, bar@}} is not similar to
10323 @code{enum @{hot, dog@}}.
10325 You typically use this function in code whose execution varies
10326 depending on the arguments' types.  For example:
10328 @smallexample
10329 #define foo(x)                                                  \
10330   (@{                                                           \
10331     typeof (x) tmp = (x);                                       \
10332     if (__builtin_types_compatible_p (typeof (x), long double)) \
10333       tmp = foo_long_double (tmp);                              \
10334     else if (__builtin_types_compatible_p (typeof (x), double)) \
10335       tmp = foo_double (tmp);                                   \
10336     else if (__builtin_types_compatible_p (typeof (x), float))  \
10337       tmp = foo_float (tmp);                                    \
10338     else                                                        \
10339       abort ();                                                 \
10340     tmp;                                                        \
10341   @})
10342 @end smallexample
10344 @emph{Note:} This construct is only available for C@.
10346 @end deftypefn
10348 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10350 The @var{call_exp} expression must be a function call, and the
10351 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
10352 is passed to the function call in the target's static chain location.
10353 The result of builtin is the result of the function call.
10355 @emph{Note:} This builtin is only available for C@.
10356 This builtin can be used to call Go closures from C.
10358 @end deftypefn
10360 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10362 You can use the built-in function @code{__builtin_choose_expr} to
10363 evaluate code depending on the value of a constant expression.  This
10364 built-in function returns @var{exp1} if @var{const_exp}, which is an
10365 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
10367 This built-in function is analogous to the @samp{? :} operator in C,
10368 except that the expression returned has its type unaltered by promotion
10369 rules.  Also, the built-in function does not evaluate the expression
10370 that is not chosen.  For example, if @var{const_exp} evaluates to true,
10371 @var{exp2} is not evaluated even if it has side-effects.
10373 This built-in function can return an lvalue if the chosen argument is an
10374 lvalue.
10376 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10377 type.  Similarly, if @var{exp2} is returned, its return type is the same
10378 as @var{exp2}.
10380 Example:
10382 @smallexample
10383 #define foo(x)                                                    \
10384   __builtin_choose_expr (                                         \
10385     __builtin_types_compatible_p (typeof (x), double),            \
10386     foo_double (x),                                               \
10387     __builtin_choose_expr (                                       \
10388       __builtin_types_compatible_p (typeof (x), float),           \
10389       foo_float (x),                                              \
10390       /* @r{The void expression results in a compile-time error}  \
10391          @r{when assigning the result to something.}  */          \
10392       (void)0))
10393 @end smallexample
10395 @emph{Note:} This construct is only available for C@.  Furthermore, the
10396 unused expression (@var{exp1} or @var{exp2} depending on the value of
10397 @var{const_exp}) may still generate syntax errors.  This may change in
10398 future revisions.
10400 @end deftypefn
10402 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10404 The built-in function @code{__builtin_complex} is provided for use in
10405 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10406 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
10407 real binary floating-point type, and the result has the corresponding
10408 complex type with real and imaginary parts @var{real} and @var{imag}.
10409 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10410 infinities, NaNs and negative zeros are involved.
10412 @end deftypefn
10414 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10415 You can use the built-in function @code{__builtin_constant_p} to
10416 determine if a value is known to be constant at compile time and hence
10417 that GCC can perform constant-folding on expressions involving that
10418 value.  The argument of the function is the value to test.  The function
10419 returns the integer 1 if the argument is known to be a compile-time
10420 constant and 0 if it is not known to be a compile-time constant.  A
10421 return of 0 does not indicate that the value is @emph{not} a constant,
10422 but merely that GCC cannot prove it is a constant with the specified
10423 value of the @option{-O} option.
10425 You typically use this function in an embedded application where
10426 memory is a critical resource.  If you have some complex calculation,
10427 you may want it to be folded if it involves constants, but need to call
10428 a function if it does not.  For example:
10430 @smallexample
10431 #define Scale_Value(X)      \
10432   (__builtin_constant_p (X) \
10433   ? ((X) * SCALE + OFFSET) : Scale (X))
10434 @end smallexample
10436 You may use this built-in function in either a macro or an inline
10437 function.  However, if you use it in an inlined function and pass an
10438 argument of the function as the argument to the built-in, GCC 
10439 never returns 1 when you call the inline function with a string constant
10440 or compound literal (@pxref{Compound Literals}) and does not return 1
10441 when you pass a constant numeric value to the inline function unless you
10442 specify the @option{-O} option.
10444 You may also use @code{__builtin_constant_p} in initializers for static
10445 data.  For instance, you can write
10447 @smallexample
10448 static const int table[] = @{
10449    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10450    /* @r{@dots{}} */
10452 @end smallexample
10454 @noindent
10455 This is an acceptable initializer even if @var{EXPRESSION} is not a
10456 constant expression, including the case where
10457 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10458 folded to a constant but @var{EXPRESSION} contains operands that are
10459 not otherwise permitted in a static initializer (for example,
10460 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
10461 built-in in this case, because it has no opportunity to perform
10462 optimization.
10463 @end deftypefn
10465 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10466 @opindex fprofile-arcs
10467 You may use @code{__builtin_expect} to provide the compiler with
10468 branch prediction information.  In general, you should prefer to
10469 use actual profile feedback for this (@option{-fprofile-arcs}), as
10470 programmers are notoriously bad at predicting how their programs
10471 actually perform.  However, there are applications in which this
10472 data is hard to collect.
10474 The return value is the value of @var{exp}, which should be an integral
10475 expression.  The semantics of the built-in are that it is expected that
10476 @var{exp} == @var{c}.  For example:
10478 @smallexample
10479 if (__builtin_expect (x, 0))
10480   foo ();
10481 @end smallexample
10483 @noindent
10484 indicates that we do not expect to call @code{foo}, since
10485 we expect @code{x} to be zero.  Since you are limited to integral
10486 expressions for @var{exp}, you should use constructions such as
10488 @smallexample
10489 if (__builtin_expect (ptr != NULL, 1))
10490   foo (*ptr);
10491 @end smallexample
10493 @noindent
10494 when testing pointer or floating-point values.
10495 @end deftypefn
10497 @deftypefn {Built-in Function} void __builtin_trap (void)
10498 This function causes the program to exit abnormally.  GCC implements
10499 this function by using a target-dependent mechanism (such as
10500 intentionally executing an illegal instruction) or by calling
10501 @code{abort}.  The mechanism used may vary from release to release so
10502 you should not rely on any particular implementation.
10503 @end deftypefn
10505 @deftypefn {Built-in Function} void __builtin_unreachable (void)
10506 If control flow reaches the point of the @code{__builtin_unreachable},
10507 the program is undefined.  It is useful in situations where the
10508 compiler cannot deduce the unreachability of the code.
10510 One such case is immediately following an @code{asm} statement that
10511 either never terminates, or one that transfers control elsewhere
10512 and never returns.  In this example, without the
10513 @code{__builtin_unreachable}, GCC issues a warning that control
10514 reaches the end of a non-void function.  It also generates code
10515 to return after the @code{asm}.
10517 @smallexample
10518 int f (int c, int v)
10520   if (c)
10521     @{
10522       return v;
10523     @}
10524   else
10525     @{
10526       asm("jmp error_handler");
10527       __builtin_unreachable ();
10528     @}
10530 @end smallexample
10532 @noindent
10533 Because the @code{asm} statement unconditionally transfers control out
10534 of the function, control never reaches the end of the function
10535 body.  The @code{__builtin_unreachable} is in fact unreachable and
10536 communicates this fact to the compiler.
10538 Another use for @code{__builtin_unreachable} is following a call a
10539 function that never returns but that is not declared
10540 @code{__attribute__((noreturn))}, as in this example:
10542 @smallexample
10543 void function_that_never_returns (void);
10545 int g (int c)
10547   if (c)
10548     @{
10549       return 1;
10550     @}
10551   else
10552     @{
10553       function_that_never_returns ();
10554       __builtin_unreachable ();
10555     @}
10557 @end smallexample
10559 @end deftypefn
10561 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
10562 This function returns its first argument, and allows the compiler
10563 to assume that the returned pointer is at least @var{align} bytes
10564 aligned.  This built-in can have either two or three arguments,
10565 if it has three, the third argument should have integer type, and
10566 if it is nonzero means misalignment offset.  For example:
10568 @smallexample
10569 void *x = __builtin_assume_aligned (arg, 16);
10570 @end smallexample
10572 @noindent
10573 means that the compiler can assume @code{x}, set to @code{arg}, is at least
10574 16-byte aligned, while:
10576 @smallexample
10577 void *x = __builtin_assume_aligned (arg, 32, 8);
10578 @end smallexample
10580 @noindent
10581 means that the compiler can assume for @code{x}, set to @code{arg}, that
10582 @code{(char *) x - 8} is 32-byte aligned.
10583 @end deftypefn
10585 @deftypefn {Built-in Function} int __builtin_LINE ()
10586 This function is the equivalent to the preprocessor @code{__LINE__}
10587 macro and returns the line number of the invocation of the built-in.
10588 In a C++ default argument for a function @var{F}, it gets the line number of
10589 the call to @var{F}.
10590 @end deftypefn
10592 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
10593 This function is the equivalent to the preprocessor @code{__FUNCTION__}
10594 macro and returns the function name the invocation of the built-in is in.
10595 @end deftypefn
10597 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
10598 This function is the equivalent to the preprocessor @code{__FILE__}
10599 macro and returns the file name the invocation of the built-in is in.
10600 In a C++ default argument for a function @var{F}, it gets the file name of
10601 the call to @var{F}.
10602 @end deftypefn
10604 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
10605 This function is used to flush the processor's instruction cache for
10606 the region of memory between @var{begin} inclusive and @var{end}
10607 exclusive.  Some targets require that the instruction cache be
10608 flushed, after modifying memory containing code, in order to obtain
10609 deterministic behavior.
10611 If the target does not require instruction cache flushes,
10612 @code{__builtin___clear_cache} has no effect.  Otherwise either
10613 instructions are emitted in-line to clear the instruction cache or a
10614 call to the @code{__clear_cache} function in libgcc is made.
10615 @end deftypefn
10617 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
10618 This function is used to minimize cache-miss latency by moving data into
10619 a cache before it is accessed.
10620 You can insert calls to @code{__builtin_prefetch} into code for which
10621 you know addresses of data in memory that is likely to be accessed soon.
10622 If the target supports them, data prefetch instructions are generated.
10623 If the prefetch is done early enough before the access then the data will
10624 be in the cache by the time it is accessed.
10626 The value of @var{addr} is the address of the memory to prefetch.
10627 There are two optional arguments, @var{rw} and @var{locality}.
10628 The value of @var{rw} is a compile-time constant one or zero; one
10629 means that the prefetch is preparing for a write to the memory address
10630 and zero, the default, means that the prefetch is preparing for a read.
10631 The value @var{locality} must be a compile-time constant integer between
10632 zero and three.  A value of zero means that the data has no temporal
10633 locality, so it need not be left in the cache after the access.  A value
10634 of three means that the data has a high degree of temporal locality and
10635 should be left in all levels of cache possible.  Values of one and two
10636 mean, respectively, a low or moderate degree of temporal locality.  The
10637 default is three.
10639 @smallexample
10640 for (i = 0; i < n; i++)
10641   @{
10642     a[i] = a[i] + b[i];
10643     __builtin_prefetch (&a[i+j], 1, 1);
10644     __builtin_prefetch (&b[i+j], 0, 1);
10645     /* @r{@dots{}} */
10646   @}
10647 @end smallexample
10649 Data prefetch does not generate faults if @var{addr} is invalid, but
10650 the address expression itself must be valid.  For example, a prefetch
10651 of @code{p->next} does not fault if @code{p->next} is not a valid
10652 address, but evaluation faults if @code{p} is not a valid address.
10654 If the target does not support data prefetch, the address expression
10655 is evaluated if it includes side effects but no other code is generated
10656 and GCC does not issue a warning.
10657 @end deftypefn
10659 @deftypefn {Built-in Function} double __builtin_huge_val (void)
10660 Returns a positive infinity, if supported by the floating-point format,
10661 else @code{DBL_MAX}.  This function is suitable for implementing the
10662 ISO C macro @code{HUGE_VAL}.
10663 @end deftypefn
10665 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
10666 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
10667 @end deftypefn
10669 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
10670 Similar to @code{__builtin_huge_val}, except the return
10671 type is @code{long double}.
10672 @end deftypefn
10674 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
10675 This built-in implements the C99 fpclassify functionality.  The first
10676 five int arguments should be the target library's notion of the
10677 possible FP classes and are used for return values.  They must be
10678 constant values and they must appear in this order: @code{FP_NAN},
10679 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
10680 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
10681 to classify.  GCC treats the last argument as type-generic, which
10682 means it does not do default promotion from float to double.
10683 @end deftypefn
10685 @deftypefn {Built-in Function} double __builtin_inf (void)
10686 Similar to @code{__builtin_huge_val}, except a warning is generated
10687 if the target floating-point format does not support infinities.
10688 @end deftypefn
10690 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
10691 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
10692 @end deftypefn
10694 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
10695 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
10696 @end deftypefn
10698 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
10699 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
10700 @end deftypefn
10702 @deftypefn {Built-in Function} float __builtin_inff (void)
10703 Similar to @code{__builtin_inf}, except the return type is @code{float}.
10704 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
10705 @end deftypefn
10707 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
10708 Similar to @code{__builtin_inf}, except the return
10709 type is @code{long double}.
10710 @end deftypefn
10712 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
10713 Similar to @code{isinf}, except the return value is -1 for
10714 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
10715 Note while the parameter list is an
10716 ellipsis, this function only accepts exactly one floating-point
10717 argument.  GCC treats this parameter as type-generic, which means it
10718 does not do default promotion from float to double.
10719 @end deftypefn
10721 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
10722 This is an implementation of the ISO C99 function @code{nan}.
10724 Since ISO C99 defines this function in terms of @code{strtod}, which we
10725 do not implement, a description of the parsing is in order.  The string
10726 is parsed as by @code{strtol}; that is, the base is recognized by
10727 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
10728 in the significand such that the least significant bit of the number
10729 is at the least significant bit of the significand.  The number is
10730 truncated to fit the significand field provided.  The significand is
10731 forced to be a quiet NaN@.
10733 This function, if given a string literal all of which would have been
10734 consumed by @code{strtol}, is evaluated early enough that it is considered a
10735 compile-time constant.
10736 @end deftypefn
10738 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
10739 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
10740 @end deftypefn
10742 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
10743 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
10744 @end deftypefn
10746 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
10747 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
10748 @end deftypefn
10750 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
10751 Similar to @code{__builtin_nan}, except the return type is @code{float}.
10752 @end deftypefn
10754 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
10755 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
10756 @end deftypefn
10758 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
10759 Similar to @code{__builtin_nan}, except the significand is forced
10760 to be a signaling NaN@.  The @code{nans} function is proposed by
10761 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
10762 @end deftypefn
10764 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
10765 Similar to @code{__builtin_nans}, except the return type is @code{float}.
10766 @end deftypefn
10768 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
10769 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
10770 @end deftypefn
10772 @deftypefn {Built-in Function} int __builtin_ffs (int x)
10773 Returns one plus the index of the least significant 1-bit of @var{x}, or
10774 if @var{x} is zero, returns zero.
10775 @end deftypefn
10777 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
10778 Returns the number of leading 0-bits in @var{x}, starting at the most
10779 significant bit position.  If @var{x} is 0, the result is undefined.
10780 @end deftypefn
10782 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
10783 Returns the number of trailing 0-bits in @var{x}, starting at the least
10784 significant bit position.  If @var{x} is 0, the result is undefined.
10785 @end deftypefn
10787 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
10788 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
10789 number of bits following the most significant bit that are identical
10790 to it.  There are no special cases for 0 or other values. 
10791 @end deftypefn
10793 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
10794 Returns the number of 1-bits in @var{x}.
10795 @end deftypefn
10797 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
10798 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
10799 modulo 2.
10800 @end deftypefn
10802 @deftypefn {Built-in Function} int __builtin_ffsl (long)
10803 Similar to @code{__builtin_ffs}, except the argument type is
10804 @code{long}.
10805 @end deftypefn
10807 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
10808 Similar to @code{__builtin_clz}, except the argument type is
10809 @code{unsigned long}.
10810 @end deftypefn
10812 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
10813 Similar to @code{__builtin_ctz}, except the argument type is
10814 @code{unsigned long}.
10815 @end deftypefn
10817 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
10818 Similar to @code{__builtin_clrsb}, except the argument type is
10819 @code{long}.
10820 @end deftypefn
10822 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
10823 Similar to @code{__builtin_popcount}, except the argument type is
10824 @code{unsigned long}.
10825 @end deftypefn
10827 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
10828 Similar to @code{__builtin_parity}, except the argument type is
10829 @code{unsigned long}.
10830 @end deftypefn
10832 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
10833 Similar to @code{__builtin_ffs}, except the argument type is
10834 @code{long long}.
10835 @end deftypefn
10837 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
10838 Similar to @code{__builtin_clz}, except the argument type is
10839 @code{unsigned long long}.
10840 @end deftypefn
10842 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
10843 Similar to @code{__builtin_ctz}, except the argument type is
10844 @code{unsigned long long}.
10845 @end deftypefn
10847 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
10848 Similar to @code{__builtin_clrsb}, except the argument type is
10849 @code{long long}.
10850 @end deftypefn
10852 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10853 Similar to @code{__builtin_popcount}, except the argument type is
10854 @code{unsigned long long}.
10855 @end deftypefn
10857 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10858 Similar to @code{__builtin_parity}, except the argument type is
10859 @code{unsigned long long}.
10860 @end deftypefn
10862 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10863 Returns the first argument raised to the power of the second.  Unlike the
10864 @code{pow} function no guarantees about precision and rounding are made.
10865 @end deftypefn
10867 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10868 Similar to @code{__builtin_powi}, except the argument and return types
10869 are @code{float}.
10870 @end deftypefn
10872 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10873 Similar to @code{__builtin_powi}, except the argument and return types
10874 are @code{long double}.
10875 @end deftypefn
10877 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10878 Returns @var{x} with the order of the bytes reversed; for example,
10879 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
10880 exactly 8 bits.
10881 @end deftypefn
10883 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10884 Similar to @code{__builtin_bswap16}, except the argument and return types
10885 are 32 bit.
10886 @end deftypefn
10888 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10889 Similar to @code{__builtin_bswap32}, except the argument and return types
10890 are 64 bit.
10891 @end deftypefn
10893 @node Target Builtins
10894 @section Built-in Functions Specific to Particular Target Machines
10896 On some target machines, GCC supports many built-in functions specific
10897 to those machines.  Generally these generate calls to specific machine
10898 instructions, but allow the compiler to schedule those calls.
10900 @menu
10901 * AArch64 Built-in Functions::
10902 * Alpha Built-in Functions::
10903 * Altera Nios II Built-in Functions::
10904 * ARC Built-in Functions::
10905 * ARC SIMD Built-in Functions::
10906 * ARM iWMMXt Built-in Functions::
10907 * ARM C Language Extensions (ACLE)::
10908 * ARM Floating Point Status and Control Intrinsics::
10909 * AVR Built-in Functions::
10910 * Blackfin Built-in Functions::
10911 * FR-V Built-in Functions::
10912 * MIPS DSP Built-in Functions::
10913 * MIPS Paired-Single Support::
10914 * MIPS Loongson Built-in Functions::
10915 * Other MIPS Built-in Functions::
10916 * MSP430 Built-in Functions::
10917 * NDS32 Built-in Functions::
10918 * picoChip Built-in Functions::
10919 * PowerPC Built-in Functions::
10920 * PowerPC AltiVec/VSX Built-in Functions::
10921 * PowerPC Hardware Transactional Memory Built-in Functions::
10922 * RX Built-in Functions::
10923 * S/390 System z Built-in Functions::
10924 * SH Built-in Functions::
10925 * SPARC VIS Built-in Functions::
10926 * SPU Built-in Functions::
10927 * TI C6X Built-in Functions::
10928 * TILE-Gx Built-in Functions::
10929 * TILEPro Built-in Functions::
10930 * x86 Built-in Functions::
10931 * x86 transactional memory intrinsics::
10932 @end menu
10934 @node AArch64 Built-in Functions
10935 @subsection AArch64 Built-in Functions
10937 These built-in functions are available for the AArch64 family of
10938 processors.
10939 @smallexample
10940 unsigned int __builtin_aarch64_get_fpcr ()
10941 void __builtin_aarch64_set_fpcr (unsigned int)
10942 unsigned int __builtin_aarch64_get_fpsr ()
10943 void __builtin_aarch64_set_fpsr (unsigned int)
10944 @end smallexample
10946 @node Alpha Built-in Functions
10947 @subsection Alpha Built-in Functions
10949 These built-in functions are available for the Alpha family of
10950 processors, depending on the command-line switches used.
10952 The following built-in functions are always available.  They
10953 all generate the machine instruction that is part of the name.
10955 @smallexample
10956 long __builtin_alpha_implver (void)
10957 long __builtin_alpha_rpcc (void)
10958 long __builtin_alpha_amask (long)
10959 long __builtin_alpha_cmpbge (long, long)
10960 long __builtin_alpha_extbl (long, long)
10961 long __builtin_alpha_extwl (long, long)
10962 long __builtin_alpha_extll (long, long)
10963 long __builtin_alpha_extql (long, long)
10964 long __builtin_alpha_extwh (long, long)
10965 long __builtin_alpha_extlh (long, long)
10966 long __builtin_alpha_extqh (long, long)
10967 long __builtin_alpha_insbl (long, long)
10968 long __builtin_alpha_inswl (long, long)
10969 long __builtin_alpha_insll (long, long)
10970 long __builtin_alpha_insql (long, long)
10971 long __builtin_alpha_inswh (long, long)
10972 long __builtin_alpha_inslh (long, long)
10973 long __builtin_alpha_insqh (long, long)
10974 long __builtin_alpha_mskbl (long, long)
10975 long __builtin_alpha_mskwl (long, long)
10976 long __builtin_alpha_mskll (long, long)
10977 long __builtin_alpha_mskql (long, long)
10978 long __builtin_alpha_mskwh (long, long)
10979 long __builtin_alpha_msklh (long, long)
10980 long __builtin_alpha_mskqh (long, long)
10981 long __builtin_alpha_umulh (long, long)
10982 long __builtin_alpha_zap (long, long)
10983 long __builtin_alpha_zapnot (long, long)
10984 @end smallexample
10986 The following built-in functions are always with @option{-mmax}
10987 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10988 later.  They all generate the machine instruction that is part
10989 of the name.
10991 @smallexample
10992 long __builtin_alpha_pklb (long)
10993 long __builtin_alpha_pkwb (long)
10994 long __builtin_alpha_unpkbl (long)
10995 long __builtin_alpha_unpkbw (long)
10996 long __builtin_alpha_minub8 (long, long)
10997 long __builtin_alpha_minsb8 (long, long)
10998 long __builtin_alpha_minuw4 (long, long)
10999 long __builtin_alpha_minsw4 (long, long)
11000 long __builtin_alpha_maxub8 (long, long)
11001 long __builtin_alpha_maxsb8 (long, long)
11002 long __builtin_alpha_maxuw4 (long, long)
11003 long __builtin_alpha_maxsw4 (long, long)
11004 long __builtin_alpha_perr (long, long)
11005 @end smallexample
11007 The following built-in functions are always with @option{-mcix}
11008 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11009 later.  They all generate the machine instruction that is part
11010 of the name.
11012 @smallexample
11013 long __builtin_alpha_cttz (long)
11014 long __builtin_alpha_ctlz (long)
11015 long __builtin_alpha_ctpop (long)
11016 @end smallexample
11018 The following built-in functions are available on systems that use the OSF/1
11019 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
11020 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11021 @code{rdval} and @code{wrval}.
11023 @smallexample
11024 void *__builtin_thread_pointer (void)
11025 void __builtin_set_thread_pointer (void *)
11026 @end smallexample
11028 @node Altera Nios II Built-in Functions
11029 @subsection Altera Nios II Built-in Functions
11031 These built-in functions are available for the Altera Nios II
11032 family of processors.
11034 The following built-in functions are always available.  They
11035 all generate the machine instruction that is part of the name.
11037 @example
11038 int __builtin_ldbio (volatile const void *)
11039 int __builtin_ldbuio (volatile const void *)
11040 int __builtin_ldhio (volatile const void *)
11041 int __builtin_ldhuio (volatile const void *)
11042 int __builtin_ldwio (volatile const void *)
11043 void __builtin_stbio (volatile void *, int)
11044 void __builtin_sthio (volatile void *, int)
11045 void __builtin_stwio (volatile void *, int)
11046 void __builtin_sync (void)
11047 int __builtin_rdctl (int) 
11048 void __builtin_wrctl (int, int)
11049 @end example
11051 The following built-in functions are always available.  They
11052 all generate a Nios II Custom Instruction. The name of the
11053 function represents the types that the function takes and
11054 returns. The letter before the @code{n} is the return type
11055 or void if absent. The @code{n} represents the first parameter
11056 to all the custom instructions, the custom instruction number.
11057 The two letters after the @code{n} represent the up to two
11058 parameters to the function.
11060 The letters represent the following data types:
11061 @table @code
11062 @item <no letter>
11063 @code{void} for return type and no parameter for parameter types.
11065 @item i
11066 @code{int} for return type and parameter type
11068 @item f
11069 @code{float} for return type and parameter type
11071 @item p
11072 @code{void *} for return type and parameter type
11074 @end table
11076 And the function names are:
11077 @example
11078 void __builtin_custom_n (void)
11079 void __builtin_custom_ni (int)
11080 void __builtin_custom_nf (float)
11081 void __builtin_custom_np (void *)
11082 void __builtin_custom_nii (int, int)
11083 void __builtin_custom_nif (int, float)
11084 void __builtin_custom_nip (int, void *)
11085 void __builtin_custom_nfi (float, int)
11086 void __builtin_custom_nff (float, float)
11087 void __builtin_custom_nfp (float, void *)
11088 void __builtin_custom_npi (void *, int)
11089 void __builtin_custom_npf (void *, float)
11090 void __builtin_custom_npp (void *, void *)
11091 int __builtin_custom_in (void)
11092 int __builtin_custom_ini (int)
11093 int __builtin_custom_inf (float)
11094 int __builtin_custom_inp (void *)
11095 int __builtin_custom_inii (int, int)
11096 int __builtin_custom_inif (int, float)
11097 int __builtin_custom_inip (int, void *)
11098 int __builtin_custom_infi (float, int)
11099 int __builtin_custom_inff (float, float)
11100 int __builtin_custom_infp (float, void *)
11101 int __builtin_custom_inpi (void *, int)
11102 int __builtin_custom_inpf (void *, float)
11103 int __builtin_custom_inpp (void *, void *)
11104 float __builtin_custom_fn (void)
11105 float __builtin_custom_fni (int)
11106 float __builtin_custom_fnf (float)
11107 float __builtin_custom_fnp (void *)
11108 float __builtin_custom_fnii (int, int)
11109 float __builtin_custom_fnif (int, float)
11110 float __builtin_custom_fnip (int, void *)
11111 float __builtin_custom_fnfi (float, int)
11112 float __builtin_custom_fnff (float, float)
11113 float __builtin_custom_fnfp (float, void *)
11114 float __builtin_custom_fnpi (void *, int)
11115 float __builtin_custom_fnpf (void *, float)
11116 float __builtin_custom_fnpp (void *, void *)
11117 void * __builtin_custom_pn (void)
11118 void * __builtin_custom_pni (int)
11119 void * __builtin_custom_pnf (float)
11120 void * __builtin_custom_pnp (void *)
11121 void * __builtin_custom_pnii (int, int)
11122 void * __builtin_custom_pnif (int, float)
11123 void * __builtin_custom_pnip (int, void *)
11124 void * __builtin_custom_pnfi (float, int)
11125 void * __builtin_custom_pnff (float, float)
11126 void * __builtin_custom_pnfp (float, void *)
11127 void * __builtin_custom_pnpi (void *, int)
11128 void * __builtin_custom_pnpf (void *, float)
11129 void * __builtin_custom_pnpp (void *, void *)
11130 @end example
11132 @node ARC Built-in Functions
11133 @subsection ARC Built-in Functions
11135 The following built-in functions are provided for ARC targets.  The
11136 built-ins generate the corresponding assembly instructions.  In the
11137 examples given below, the generated code often requires an operand or
11138 result to be in a register.  Where necessary further code will be
11139 generated to ensure this is true, but for brevity this is not
11140 described in each case.
11142 @emph{Note:} Using a built-in to generate an instruction not supported
11143 by a target may cause problems. At present the compiler is not
11144 guaranteed to detect such misuse, and as a result an internal compiler
11145 error may be generated.
11147 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11148 Return 1 if @var{val} is known to have the byte alignment given
11149 by @var{alignval}, otherwise return 0.
11150 Note that this is different from
11151 @smallexample
11152 __alignof__(*(char *)@var{val}) >= alignval
11153 @end smallexample
11154 because __alignof__ sees only the type of the dereference, whereas
11155 __builtin_arc_align uses alignment information from the pointer
11156 as well as from the pointed-to type.
11157 The information available will depend on optimization level.
11158 @end deftypefn
11160 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11161 Generates
11162 @example
11164 @end example
11165 @end deftypefn
11167 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11168 The operand is the number of a register to be read.  Generates:
11169 @example
11170 mov  @var{dest}, r@var{regno}
11171 @end example
11172 where the value in @var{dest} will be the result returned from the
11173 built-in.
11174 @end deftypefn
11176 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11177 The first operand is the number of a register to be written, the
11178 second operand is a compile time constant to write into that
11179 register.  Generates:
11180 @example
11181 mov  r@var{regno}, @var{val}
11182 @end example
11183 @end deftypefn
11185 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11186 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11187 Generates:
11188 @example
11189 divaw  @var{dest}, @var{a}, @var{b}
11190 @end example
11191 where the value in @var{dest} will be the result returned from the
11192 built-in.
11193 @end deftypefn
11195 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11196 Generates
11197 @example
11198 flag  @var{a}
11199 @end example
11200 @end deftypefn
11202 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11203 The operand, @var{auxv}, is the address of an auxiliary register and
11204 must be a compile time constant.  Generates:
11205 @example
11206 lr  @var{dest}, [@var{auxr}]
11207 @end example
11208 Where the value in @var{dest} will be the result returned from the
11209 built-in.
11210 @end deftypefn
11212 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11213 Only available with @option{-mmul64}.  Generates:
11214 @example
11215 mul64  @var{a}, @var{b}
11216 @end example
11217 @end deftypefn
11219 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11220 Only available with @option{-mmul64}.  Generates:
11221 @example
11222 mulu64  @var{a}, @var{b}
11223 @end example
11224 @end deftypefn
11226 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11227 Generates:
11228 @example
11230 @end example
11231 @end deftypefn
11233 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11234 Only valid if the @samp{norm} instruction is available through the
11235 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11236 Generates:
11237 @example
11238 norm  @var{dest}, @var{src}
11239 @end example
11240 Where the value in @var{dest} will be the result returned from the
11241 built-in.
11242 @end deftypefn
11244 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
11245 Only valid if the @samp{normw} instruction is available through the
11246 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11247 Generates:
11248 @example
11249 normw  @var{dest}, @var{src}
11250 @end example
11251 Where the value in @var{dest} will be the result returned from the
11252 built-in.
11253 @end deftypefn
11255 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
11256 Generates:
11257 @example
11258 rtie
11259 @end example
11260 @end deftypefn
11262 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
11263 Generates:
11264 @example
11265 sleep  @var{a}
11266 @end example
11267 @end deftypefn
11269 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11270 The first argument, @var{auxv}, is the address of an auxiliary
11271 register, the second argument, @var{val}, is a compile time constant
11272 to be written to the register.  Generates:
11273 @example
11274 sr  @var{auxr}, [@var{val}]
11275 @end example
11276 @end deftypefn
11278 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
11279 Only valid with @option{-mswap}.  Generates:
11280 @example
11281 swap  @var{dest}, @var{src}
11282 @end example
11283 Where the value in @var{dest} will be the result returned from the
11284 built-in.
11285 @end deftypefn
11287 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
11288 Generates:
11289 @example
11291 @end example
11292 @end deftypefn
11294 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
11295 Only available with @option{-mcpu=ARC700}.  Generates:
11296 @example
11297 sync
11298 @end example
11299 @end deftypefn
11301 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
11302 Only available with @option{-mcpu=ARC700}.  Generates:
11303 @example
11304 trap_s  @var{c}
11305 @end example
11306 @end deftypefn
11308 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
11309 Only available with @option{-mcpu=ARC700}.  Generates:
11310 @example
11311 unimp_s
11312 @end example
11313 @end deftypefn
11315 The instructions generated by the following builtins are not
11316 considered as candidates for scheduling.  They are not moved around by
11317 the compiler during scheduling, and thus can be expected to appear
11318 where they are put in the C code:
11319 @example
11320 __builtin_arc_brk()
11321 __builtin_arc_core_read()
11322 __builtin_arc_core_write()
11323 __builtin_arc_flag()
11324 __builtin_arc_lr()
11325 __builtin_arc_sleep()
11326 __builtin_arc_sr()
11327 __builtin_arc_swi()
11328 @end example
11330 @node ARC SIMD Built-in Functions
11331 @subsection ARC SIMD Built-in Functions
11333 SIMD builtins provided by the compiler can be used to generate the
11334 vector instructions.  This section describes the available builtins
11335 and their usage in programs.  With the @option{-msimd} option, the
11336 compiler provides 128-bit vector types, which can be specified using
11337 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
11338 can be included to use the following predefined types:
11339 @example
11340 typedef int __v4si   __attribute__((vector_size(16)));
11341 typedef short __v8hi __attribute__((vector_size(16)));
11342 @end example
11344 These types can be used to define 128-bit variables.  The built-in
11345 functions listed in the following section can be used on these
11346 variables to generate the vector operations.
11348 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11349 @file{arc-simd.h} also provides equivalent macros called
11350 @code{_@var{someinsn}} that can be used for programming ease and
11351 improved readability.  The following macros for DMA control are also
11352 provided:
11353 @example
11354 #define _setup_dma_in_channel_reg _vdiwr
11355 #define _setup_dma_out_channel_reg _vdowr
11356 @end example
11358 The following is a complete list of all the SIMD built-ins provided
11359 for ARC, grouped by calling signature.
11361 The following take two @code{__v8hi} arguments and return a
11362 @code{__v8hi} result:
11363 @example
11364 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11365 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11366 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11367 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11368 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11369 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11370 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11371 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11372 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11373 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11374 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11375 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11376 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11377 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11378 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11379 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11380 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11381 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11382 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11383 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11384 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11385 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11386 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11387 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11388 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11389 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11390 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11391 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11392 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11393 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11394 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11395 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11396 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11397 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11398 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11399 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11400 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11401 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11402 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11403 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11404 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11405 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11406 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11407 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11408 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11409 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11410 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11411 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11412 @end example
11414 The following take one @code{__v8hi} and one @code{int} argument and return a
11415 @code{__v8hi} result:
11417 @example
11418 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11419 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11420 __v8hi __builtin_arc_vbminw (__v8hi, int)
11421 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11422 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11423 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11424 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11425 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11426 @end example
11428 The following take one @code{__v8hi} argument and one @code{int} argument which
11429 must be a 3-bit compile time constant indicating a register number
11430 I0-I7.  They return a @code{__v8hi} result.
11431 @example
11432 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11433 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11434 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11435 @end example
11437 The following take one @code{__v8hi} argument and one @code{int}
11438 argument which must be a 6-bit compile time constant.  They return a
11439 @code{__v8hi} result.
11440 @example
11441 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11442 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11443 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11444 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11445 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11446 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11447 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11448 @end example
11450 The following take one @code{__v8hi} argument and one @code{int} argument which
11451 must be a 8-bit compile time constant.  They return a @code{__v8hi}
11452 result.
11453 @example
11454 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11455 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11456 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11457 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11458 @end example
11460 The following take two @code{int} arguments, the second of which which
11461 must be a 8-bit compile time constant.  They return a @code{__v8hi}
11462 result:
11463 @example
11464 __v8hi __builtin_arc_vmovaw (int, const int)
11465 __v8hi __builtin_arc_vmovw (int, const int)
11466 __v8hi __builtin_arc_vmovzw (int, const int)
11467 @end example
11469 The following take a single @code{__v8hi} argument and return a
11470 @code{__v8hi} result:
11471 @example
11472 __v8hi __builtin_arc_vabsaw (__v8hi)
11473 __v8hi __builtin_arc_vabsw (__v8hi)
11474 __v8hi __builtin_arc_vaddsuw (__v8hi)
11475 __v8hi __builtin_arc_vexch1 (__v8hi)
11476 __v8hi __builtin_arc_vexch2 (__v8hi)
11477 __v8hi __builtin_arc_vexch4 (__v8hi)
11478 __v8hi __builtin_arc_vsignw (__v8hi)
11479 __v8hi __builtin_arc_vupbaw (__v8hi)
11480 __v8hi __builtin_arc_vupbw (__v8hi)
11481 __v8hi __builtin_arc_vupsbaw (__v8hi)
11482 __v8hi __builtin_arc_vupsbw (__v8hi)
11483 @end example
11485 The following take two @code{int} arguments and return no result:
11486 @example
11487 void __builtin_arc_vdirun (int, int)
11488 void __builtin_arc_vdorun (int, int)
11489 @end example
11491 The following take two @code{int} arguments and return no result.  The
11492 first argument must a 3-bit compile time constant indicating one of
11493 the DR0-DR7 DMA setup channels:
11494 @example
11495 void __builtin_arc_vdiwr (const int, int)
11496 void __builtin_arc_vdowr (const int, int)
11497 @end example
11499 The following take an @code{int} argument and return no result:
11500 @example
11501 void __builtin_arc_vendrec (int)
11502 void __builtin_arc_vrec (int)
11503 void __builtin_arc_vrecrun (int)
11504 void __builtin_arc_vrun (int)
11505 @end example
11507 The following take a @code{__v8hi} argument and two @code{int}
11508 arguments and return a @code{__v8hi} result.  The second argument must
11509 be a 3-bit compile time constants, indicating one the registers I0-I7,
11510 and the third argument must be an 8-bit compile time constant.
11512 @emph{Note:} Although the equivalent hardware instructions do not take
11513 an SIMD register as an operand, these builtins overwrite the relevant
11514 bits of the @code{__v8hi} register provided as the first argument with
11515 the value loaded from the @code{[Ib, u8]} location in the SDM.
11517 @example
11518 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
11519 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
11520 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
11521 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
11522 @end example
11524 The following take two @code{int} arguments and return a @code{__v8hi}
11525 result.  The first argument must be a 3-bit compile time constants,
11526 indicating one the registers I0-I7, and the second argument must be an
11527 8-bit compile time constant.
11529 @example
11530 __v8hi __builtin_arc_vld128 (const int, const int)
11531 __v8hi __builtin_arc_vld64w (const int, const int)
11532 @end example
11534 The following take a @code{__v8hi} argument and two @code{int}
11535 arguments and return no result.  The second argument must be a 3-bit
11536 compile time constants, indicating one the registers I0-I7, and the
11537 third argument must be an 8-bit compile time constant.
11539 @example
11540 void __builtin_arc_vst128 (__v8hi, const int, const int)
11541 void __builtin_arc_vst64 (__v8hi, const int, const int)
11542 @end example
11544 The following take a @code{__v8hi} argument and three @code{int}
11545 arguments and return no result.  The second argument must be a 3-bit
11546 compile-time constant, identifying the 16-bit sub-register to be
11547 stored, the third argument must be a 3-bit compile time constants,
11548 indicating one the registers I0-I7, and the fourth argument must be an
11549 8-bit compile time constant.
11551 @example
11552 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
11553 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
11554 @end example
11556 @node ARM iWMMXt Built-in Functions
11557 @subsection ARM iWMMXt Built-in Functions
11559 These built-in functions are available for the ARM family of
11560 processors when the @option{-mcpu=iwmmxt} switch is used:
11562 @smallexample
11563 typedef int v2si __attribute__ ((vector_size (8)));
11564 typedef short v4hi __attribute__ ((vector_size (8)));
11565 typedef char v8qi __attribute__ ((vector_size (8)));
11567 int __builtin_arm_getwcgr0 (void)
11568 void __builtin_arm_setwcgr0 (int)
11569 int __builtin_arm_getwcgr1 (void)
11570 void __builtin_arm_setwcgr1 (int)
11571 int __builtin_arm_getwcgr2 (void)
11572 void __builtin_arm_setwcgr2 (int)
11573 int __builtin_arm_getwcgr3 (void)
11574 void __builtin_arm_setwcgr3 (int)
11575 int __builtin_arm_textrmsb (v8qi, int)
11576 int __builtin_arm_textrmsh (v4hi, int)
11577 int __builtin_arm_textrmsw (v2si, int)
11578 int __builtin_arm_textrmub (v8qi, int)
11579 int __builtin_arm_textrmuh (v4hi, int)
11580 int __builtin_arm_textrmuw (v2si, int)
11581 v8qi __builtin_arm_tinsrb (v8qi, int, int)
11582 v4hi __builtin_arm_tinsrh (v4hi, int, int)
11583 v2si __builtin_arm_tinsrw (v2si, int, int)
11584 long long __builtin_arm_tmia (long long, int, int)
11585 long long __builtin_arm_tmiabb (long long, int, int)
11586 long long __builtin_arm_tmiabt (long long, int, int)
11587 long long __builtin_arm_tmiaph (long long, int, int)
11588 long long __builtin_arm_tmiatb (long long, int, int)
11589 long long __builtin_arm_tmiatt (long long, int, int)
11590 int __builtin_arm_tmovmskb (v8qi)
11591 int __builtin_arm_tmovmskh (v4hi)
11592 int __builtin_arm_tmovmskw (v2si)
11593 long long __builtin_arm_waccb (v8qi)
11594 long long __builtin_arm_wacch (v4hi)
11595 long long __builtin_arm_waccw (v2si)
11596 v8qi __builtin_arm_waddb (v8qi, v8qi)
11597 v8qi __builtin_arm_waddbss (v8qi, v8qi)
11598 v8qi __builtin_arm_waddbus (v8qi, v8qi)
11599 v4hi __builtin_arm_waddh (v4hi, v4hi)
11600 v4hi __builtin_arm_waddhss (v4hi, v4hi)
11601 v4hi __builtin_arm_waddhus (v4hi, v4hi)
11602 v2si __builtin_arm_waddw (v2si, v2si)
11603 v2si __builtin_arm_waddwss (v2si, v2si)
11604 v2si __builtin_arm_waddwus (v2si, v2si)
11605 v8qi __builtin_arm_walign (v8qi, v8qi, int)
11606 long long __builtin_arm_wand(long long, long long)
11607 long long __builtin_arm_wandn (long long, long long)
11608 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
11609 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
11610 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
11611 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
11612 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
11613 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
11614 v2si __builtin_arm_wcmpeqw (v2si, v2si)
11615 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
11616 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
11617 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
11618 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
11619 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
11620 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
11621 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
11622 long long __builtin_arm_wmacsz (v4hi, v4hi)
11623 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
11624 long long __builtin_arm_wmacuz (v4hi, v4hi)
11625 v4hi __builtin_arm_wmadds (v4hi, v4hi)
11626 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
11627 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
11628 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
11629 v2si __builtin_arm_wmaxsw (v2si, v2si)
11630 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
11631 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
11632 v2si __builtin_arm_wmaxuw (v2si, v2si)
11633 v8qi __builtin_arm_wminsb (v8qi, v8qi)
11634 v4hi __builtin_arm_wminsh (v4hi, v4hi)
11635 v2si __builtin_arm_wminsw (v2si, v2si)
11636 v8qi __builtin_arm_wminub (v8qi, v8qi)
11637 v4hi __builtin_arm_wminuh (v4hi, v4hi)
11638 v2si __builtin_arm_wminuw (v2si, v2si)
11639 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
11640 v4hi __builtin_arm_wmulul (v4hi, v4hi)
11641 v4hi __builtin_arm_wmulum (v4hi, v4hi)
11642 long long __builtin_arm_wor (long long, long long)
11643 v2si __builtin_arm_wpackdss (long long, long long)
11644 v2si __builtin_arm_wpackdus (long long, long long)
11645 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
11646 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
11647 v4hi __builtin_arm_wpackwss (v2si, v2si)
11648 v4hi __builtin_arm_wpackwus (v2si, v2si)
11649 long long __builtin_arm_wrord (long long, long long)
11650 long long __builtin_arm_wrordi (long long, int)
11651 v4hi __builtin_arm_wrorh (v4hi, long long)
11652 v4hi __builtin_arm_wrorhi (v4hi, int)
11653 v2si __builtin_arm_wrorw (v2si, long long)
11654 v2si __builtin_arm_wrorwi (v2si, int)
11655 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
11656 v2si __builtin_arm_wsadbz (v8qi, v8qi)
11657 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
11658 v2si __builtin_arm_wsadhz (v4hi, v4hi)
11659 v4hi __builtin_arm_wshufh (v4hi, int)
11660 long long __builtin_arm_wslld (long long, long long)
11661 long long __builtin_arm_wslldi (long long, int)
11662 v4hi __builtin_arm_wsllh (v4hi, long long)
11663 v4hi __builtin_arm_wsllhi (v4hi, int)
11664 v2si __builtin_arm_wsllw (v2si, long long)
11665 v2si __builtin_arm_wsllwi (v2si, int)
11666 long long __builtin_arm_wsrad (long long, long long)
11667 long long __builtin_arm_wsradi (long long, int)
11668 v4hi __builtin_arm_wsrah (v4hi, long long)
11669 v4hi __builtin_arm_wsrahi (v4hi, int)
11670 v2si __builtin_arm_wsraw (v2si, long long)
11671 v2si __builtin_arm_wsrawi (v2si, int)
11672 long long __builtin_arm_wsrld (long long, long long)
11673 long long __builtin_arm_wsrldi (long long, int)
11674 v4hi __builtin_arm_wsrlh (v4hi, long long)
11675 v4hi __builtin_arm_wsrlhi (v4hi, int)
11676 v2si __builtin_arm_wsrlw (v2si, long long)
11677 v2si __builtin_arm_wsrlwi (v2si, int)
11678 v8qi __builtin_arm_wsubb (v8qi, v8qi)
11679 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
11680 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
11681 v4hi __builtin_arm_wsubh (v4hi, v4hi)
11682 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
11683 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
11684 v2si __builtin_arm_wsubw (v2si, v2si)
11685 v2si __builtin_arm_wsubwss (v2si, v2si)
11686 v2si __builtin_arm_wsubwus (v2si, v2si)
11687 v4hi __builtin_arm_wunpckehsb (v8qi)
11688 v2si __builtin_arm_wunpckehsh (v4hi)
11689 long long __builtin_arm_wunpckehsw (v2si)
11690 v4hi __builtin_arm_wunpckehub (v8qi)
11691 v2si __builtin_arm_wunpckehuh (v4hi)
11692 long long __builtin_arm_wunpckehuw (v2si)
11693 v4hi __builtin_arm_wunpckelsb (v8qi)
11694 v2si __builtin_arm_wunpckelsh (v4hi)
11695 long long __builtin_arm_wunpckelsw (v2si)
11696 v4hi __builtin_arm_wunpckelub (v8qi)
11697 v2si __builtin_arm_wunpckeluh (v4hi)
11698 long long __builtin_arm_wunpckeluw (v2si)
11699 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
11700 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
11701 v2si __builtin_arm_wunpckihw (v2si, v2si)
11702 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
11703 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
11704 v2si __builtin_arm_wunpckilw (v2si, v2si)
11705 long long __builtin_arm_wxor (long long, long long)
11706 long long __builtin_arm_wzero ()
11707 @end smallexample
11710 @node ARM C Language Extensions (ACLE)
11711 @subsection ARM C Language Extensions (ACLE)
11713 GCC implements extensions for C as described in the ARM C Language
11714 Extensions (ACLE) specification, which can be found at
11715 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
11717 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
11718 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
11719 intrinsics can be found at
11720 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
11721 The built-in intrinsics for the Advanced SIMD extension are available when
11722 NEON is enabled.
11724 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
11725 back ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM back end's
11726 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
11727 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
11728 intrinsics yet.
11730 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
11731 availability of extensions.
11733 @node ARM Floating Point Status and Control Intrinsics
11734 @subsection ARM Floating Point Status and Control Intrinsics
11736 These built-in functions are available for the ARM family of
11737 processors with floating-point unit.
11739 @smallexample
11740 unsigned int __builtin_arm_get_fpscr ()
11741 void __builtin_arm_set_fpscr (unsigned int)
11742 @end smallexample
11744 @node AVR Built-in Functions
11745 @subsection AVR Built-in Functions
11747 For each built-in function for AVR, there is an equally named,
11748 uppercase built-in macro defined. That way users can easily query if
11749 or if not a specific built-in is implemented or not. For example, if
11750 @code{__builtin_avr_nop} is available the macro
11751 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
11753 The following built-in functions map to the respective machine
11754 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
11755 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
11756 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
11757 as library call if no hardware multiplier is available.
11759 @smallexample
11760 void __builtin_avr_nop (void)
11761 void __builtin_avr_sei (void)
11762 void __builtin_avr_cli (void)
11763 void __builtin_avr_sleep (void)
11764 void __builtin_avr_wdr (void)
11765 unsigned char __builtin_avr_swap (unsigned char)
11766 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
11767 int __builtin_avr_fmuls (char, char)
11768 int __builtin_avr_fmulsu (char, unsigned char)
11769 @end smallexample
11771 In order to delay execution for a specific number of cycles, GCC
11772 implements
11773 @smallexample
11774 void __builtin_avr_delay_cycles (unsigned long ticks)
11775 @end smallexample
11777 @noindent
11778 @code{ticks} is the number of ticks to delay execution. Note that this
11779 built-in does not take into account the effect of interrupts that
11780 might increase delay time. @code{ticks} must be a compile-time
11781 integer constant; delays with a variable number of cycles are not supported.
11783 @smallexample
11784 char __builtin_avr_flash_segment (const __memx void*)
11785 @end smallexample
11787 @noindent
11788 This built-in takes a byte address to the 24-bit
11789 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
11790 the number of the flash segment (the 64 KiB chunk) where the address
11791 points to.  Counting starts at @code{0}.
11792 If the address does not point to flash memory, return @code{-1}.
11794 @smallexample
11795 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
11796 @end smallexample
11798 @noindent
11799 Insert bits from @var{bits} into @var{val} and return the resulting
11800 value. The nibbles of @var{map} determine how the insertion is
11801 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
11802 @enumerate
11803 @item If @var{X} is @code{0xf},
11804 then the @var{n}-th bit of @var{val} is returned unaltered.
11806 @item If X is in the range 0@dots{}7,
11807 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
11809 @item If X is in the range 8@dots{}@code{0xe},
11810 then the @var{n}-th result bit is undefined.
11811 @end enumerate
11813 @noindent
11814 One typical use case for this built-in is adjusting input and
11815 output values to non-contiguous port layouts. Some examples:
11817 @smallexample
11818 // same as val, bits is unused
11819 __builtin_avr_insert_bits (0xffffffff, bits, val)
11820 @end smallexample
11822 @smallexample
11823 // same as bits, val is unused
11824 __builtin_avr_insert_bits (0x76543210, bits, val)
11825 @end smallexample
11827 @smallexample
11828 // same as rotating bits by 4
11829 __builtin_avr_insert_bits (0x32107654, bits, 0)
11830 @end smallexample
11832 @smallexample
11833 // high nibble of result is the high nibble of val
11834 // low nibble of result is the low nibble of bits
11835 __builtin_avr_insert_bits (0xffff3210, bits, val)
11836 @end smallexample
11838 @smallexample
11839 // reverse the bit order of bits
11840 __builtin_avr_insert_bits (0x01234567, bits, 0)
11841 @end smallexample
11843 @node Blackfin Built-in Functions
11844 @subsection Blackfin Built-in Functions
11846 Currently, there are two Blackfin-specific built-in functions.  These are
11847 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
11848 using inline assembly; by using these built-in functions the compiler can
11849 automatically add workarounds for hardware errata involving these
11850 instructions.  These functions are named as follows:
11852 @smallexample
11853 void __builtin_bfin_csync (void)
11854 void __builtin_bfin_ssync (void)
11855 @end smallexample
11857 @node FR-V Built-in Functions
11858 @subsection FR-V Built-in Functions
11860 GCC provides many FR-V-specific built-in functions.  In general,
11861 these functions are intended to be compatible with those described
11862 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11863 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
11864 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11865 pointer rather than by value.
11867 Most of the functions are named after specific FR-V instructions.
11868 Such functions are said to be ``directly mapped'' and are summarized
11869 here in tabular form.
11871 @menu
11872 * Argument Types::
11873 * Directly-mapped Integer Functions::
11874 * Directly-mapped Media Functions::
11875 * Raw read/write Functions::
11876 * Other Built-in Functions::
11877 @end menu
11879 @node Argument Types
11880 @subsubsection Argument Types
11882 The arguments to the built-in functions can be divided into three groups:
11883 register numbers, compile-time constants and run-time values.  In order
11884 to make this classification clear at a glance, the arguments and return
11885 values are given the following pseudo types:
11887 @multitable @columnfractions .20 .30 .15 .35
11888 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11889 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11890 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11891 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11892 @item @code{uw2} @tab @code{unsigned long long} @tab No
11893 @tab an unsigned doubleword
11894 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11895 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11896 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11897 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11898 @end multitable
11900 These pseudo types are not defined by GCC, they are simply a notational
11901 convenience used in this manual.
11903 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11904 and @code{sw2} are evaluated at run time.  They correspond to
11905 register operands in the underlying FR-V instructions.
11907 @code{const} arguments represent immediate operands in the underlying
11908 FR-V instructions.  They must be compile-time constants.
11910 @code{acc} arguments are evaluated at compile time and specify the number
11911 of an accumulator register.  For example, an @code{acc} argument of 2
11912 selects the ACC2 register.
11914 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11915 number of an IACC register.  See @pxref{Other Built-in Functions}
11916 for more details.
11918 @node Directly-mapped Integer Functions
11919 @subsubsection Directly-Mapped Integer Functions
11921 The functions listed below map directly to FR-V I-type instructions.
11923 @multitable @columnfractions .45 .32 .23
11924 @item Function prototype @tab Example usage @tab Assembly output
11925 @item @code{sw1 __ADDSS (sw1, sw1)}
11926 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11927 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11928 @item @code{sw1 __SCAN (sw1, sw1)}
11929 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11930 @tab @code{SCAN @var{a},@var{b},@var{c}}
11931 @item @code{sw1 __SCUTSS (sw1)}
11932 @tab @code{@var{b} = __SCUTSS (@var{a})}
11933 @tab @code{SCUTSS @var{a},@var{b}}
11934 @item @code{sw1 __SLASS (sw1, sw1)}
11935 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11936 @tab @code{SLASS @var{a},@var{b},@var{c}}
11937 @item @code{void __SMASS (sw1, sw1)}
11938 @tab @code{__SMASS (@var{a}, @var{b})}
11939 @tab @code{SMASS @var{a},@var{b}}
11940 @item @code{void __SMSSS (sw1, sw1)}
11941 @tab @code{__SMSSS (@var{a}, @var{b})}
11942 @tab @code{SMSSS @var{a},@var{b}}
11943 @item @code{void __SMU (sw1, sw1)}
11944 @tab @code{__SMU (@var{a}, @var{b})}
11945 @tab @code{SMU @var{a},@var{b}}
11946 @item @code{sw2 __SMUL (sw1, sw1)}
11947 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11948 @tab @code{SMUL @var{a},@var{b},@var{c}}
11949 @item @code{sw1 __SUBSS (sw1, sw1)}
11950 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11951 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11952 @item @code{uw2 __UMUL (uw1, uw1)}
11953 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11954 @tab @code{UMUL @var{a},@var{b},@var{c}}
11955 @end multitable
11957 @node Directly-mapped Media Functions
11958 @subsubsection Directly-Mapped Media Functions
11960 The functions listed below map directly to FR-V M-type instructions.
11962 @multitable @columnfractions .45 .32 .23
11963 @item Function prototype @tab Example usage @tab Assembly output
11964 @item @code{uw1 __MABSHS (sw1)}
11965 @tab @code{@var{b} = __MABSHS (@var{a})}
11966 @tab @code{MABSHS @var{a},@var{b}}
11967 @item @code{void __MADDACCS (acc, acc)}
11968 @tab @code{__MADDACCS (@var{b}, @var{a})}
11969 @tab @code{MADDACCS @var{a},@var{b}}
11970 @item @code{sw1 __MADDHSS (sw1, sw1)}
11971 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11972 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11973 @item @code{uw1 __MADDHUS (uw1, uw1)}
11974 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11975 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11976 @item @code{uw1 __MAND (uw1, uw1)}
11977 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11978 @tab @code{MAND @var{a},@var{b},@var{c}}
11979 @item @code{void __MASACCS (acc, acc)}
11980 @tab @code{__MASACCS (@var{b}, @var{a})}
11981 @tab @code{MASACCS @var{a},@var{b}}
11982 @item @code{uw1 __MAVEH (uw1, uw1)}
11983 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11984 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11985 @item @code{uw2 __MBTOH (uw1)}
11986 @tab @code{@var{b} = __MBTOH (@var{a})}
11987 @tab @code{MBTOH @var{a},@var{b}}
11988 @item @code{void __MBTOHE (uw1 *, uw1)}
11989 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11990 @tab @code{MBTOHE @var{a},@var{b}}
11991 @item @code{void __MCLRACC (acc)}
11992 @tab @code{__MCLRACC (@var{a})}
11993 @tab @code{MCLRACC @var{a}}
11994 @item @code{void __MCLRACCA (void)}
11995 @tab @code{__MCLRACCA ()}
11996 @tab @code{MCLRACCA}
11997 @item @code{uw1 __Mcop1 (uw1, uw1)}
11998 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11999 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12000 @item @code{uw1 __Mcop2 (uw1, uw1)}
12001 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12002 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12003 @item @code{uw1 __MCPLHI (uw2, const)}
12004 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12005 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12006 @item @code{uw1 __MCPLI (uw2, const)}
12007 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12008 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12009 @item @code{void __MCPXIS (acc, sw1, sw1)}
12010 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12011 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12012 @item @code{void __MCPXIU (acc, uw1, uw1)}
12013 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12014 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12015 @item @code{void __MCPXRS (acc, sw1, sw1)}
12016 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12017 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12018 @item @code{void __MCPXRU (acc, uw1, uw1)}
12019 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12020 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12021 @item @code{uw1 __MCUT (acc, uw1)}
12022 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12023 @tab @code{MCUT @var{a},@var{b},@var{c}}
12024 @item @code{uw1 __MCUTSS (acc, sw1)}
12025 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12026 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12027 @item @code{void __MDADDACCS (acc, acc)}
12028 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12029 @tab @code{MDADDACCS @var{a},@var{b}}
12030 @item @code{void __MDASACCS (acc, acc)}
12031 @tab @code{__MDASACCS (@var{b}, @var{a})}
12032 @tab @code{MDASACCS @var{a},@var{b}}
12033 @item @code{uw2 __MDCUTSSI (acc, const)}
12034 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12035 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12036 @item @code{uw2 __MDPACKH (uw2, uw2)}
12037 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12038 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12039 @item @code{uw2 __MDROTLI (uw2, const)}
12040 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12041 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12042 @item @code{void __MDSUBACCS (acc, acc)}
12043 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12044 @tab @code{MDSUBACCS @var{a},@var{b}}
12045 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12046 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12047 @tab @code{MDUNPACKH @var{a},@var{b}}
12048 @item @code{uw2 __MEXPDHD (uw1, const)}
12049 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12050 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12051 @item @code{uw1 __MEXPDHW (uw1, const)}
12052 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12053 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12054 @item @code{uw1 __MHDSETH (uw1, const)}
12055 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12056 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12057 @item @code{sw1 __MHDSETS (const)}
12058 @tab @code{@var{b} = __MHDSETS (@var{a})}
12059 @tab @code{MHDSETS #@var{a},@var{b}}
12060 @item @code{uw1 __MHSETHIH (uw1, const)}
12061 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12062 @tab @code{MHSETHIH #@var{a},@var{b}}
12063 @item @code{sw1 __MHSETHIS (sw1, const)}
12064 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12065 @tab @code{MHSETHIS #@var{a},@var{b}}
12066 @item @code{uw1 __MHSETLOH (uw1, const)}
12067 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12068 @tab @code{MHSETLOH #@var{a},@var{b}}
12069 @item @code{sw1 __MHSETLOS (sw1, const)}
12070 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12071 @tab @code{MHSETLOS #@var{a},@var{b}}
12072 @item @code{uw1 __MHTOB (uw2)}
12073 @tab @code{@var{b} = __MHTOB (@var{a})}
12074 @tab @code{MHTOB @var{a},@var{b}}
12075 @item @code{void __MMACHS (acc, sw1, sw1)}
12076 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12077 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12078 @item @code{void __MMACHU (acc, uw1, uw1)}
12079 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12080 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12081 @item @code{void __MMRDHS (acc, sw1, sw1)}
12082 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12083 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12084 @item @code{void __MMRDHU (acc, uw1, uw1)}
12085 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12086 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12087 @item @code{void __MMULHS (acc, sw1, sw1)}
12088 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12089 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12090 @item @code{void __MMULHU (acc, uw1, uw1)}
12091 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12092 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12093 @item @code{void __MMULXHS (acc, sw1, sw1)}
12094 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12095 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12096 @item @code{void __MMULXHU (acc, uw1, uw1)}
12097 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12098 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12099 @item @code{uw1 __MNOT (uw1)}
12100 @tab @code{@var{b} = __MNOT (@var{a})}
12101 @tab @code{MNOT @var{a},@var{b}}
12102 @item @code{uw1 __MOR (uw1, uw1)}
12103 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12104 @tab @code{MOR @var{a},@var{b},@var{c}}
12105 @item @code{uw1 __MPACKH (uh, uh)}
12106 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12107 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12108 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12109 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12110 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12111 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12112 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12113 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12114 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12115 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12116 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12117 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12118 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12119 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12120 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12121 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12122 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12123 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12124 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12125 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12126 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12127 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12128 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12129 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12130 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12131 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12132 @item @code{void __MQMACHS (acc, sw2, sw2)}
12133 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12134 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12135 @item @code{void __MQMACHU (acc, uw2, uw2)}
12136 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12137 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12138 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12139 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12140 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12141 @item @code{void __MQMULHS (acc, sw2, sw2)}
12142 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12143 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12144 @item @code{void __MQMULHU (acc, uw2, uw2)}
12145 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12146 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12147 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12148 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12149 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12150 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12151 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12152 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12153 @item @code{sw2 __MQSATHS (sw2, sw2)}
12154 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12155 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12156 @item @code{uw2 __MQSLLHI (uw2, int)}
12157 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12158 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12159 @item @code{sw2 __MQSRAHI (sw2, int)}
12160 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12161 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12162 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12163 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12164 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12165 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12166 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12167 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12168 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12169 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12170 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12171 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12172 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12173 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12174 @item @code{uw1 __MRDACC (acc)}
12175 @tab @code{@var{b} = __MRDACC (@var{a})}
12176 @tab @code{MRDACC @var{a},@var{b}}
12177 @item @code{uw1 __MRDACCG (acc)}
12178 @tab @code{@var{b} = __MRDACCG (@var{a})}
12179 @tab @code{MRDACCG @var{a},@var{b}}
12180 @item @code{uw1 __MROTLI (uw1, const)}
12181 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12182 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12183 @item @code{uw1 __MROTRI (uw1, const)}
12184 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12185 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12186 @item @code{sw1 __MSATHS (sw1, sw1)}
12187 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12188 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12189 @item @code{uw1 __MSATHU (uw1, uw1)}
12190 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12191 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12192 @item @code{uw1 __MSLLHI (uw1, const)}
12193 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12194 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12195 @item @code{sw1 __MSRAHI (sw1, const)}
12196 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12197 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12198 @item @code{uw1 __MSRLHI (uw1, const)}
12199 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12200 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12201 @item @code{void __MSUBACCS (acc, acc)}
12202 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12203 @tab @code{MSUBACCS @var{a},@var{b}}
12204 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12205 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12206 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12207 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12208 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12209 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12210 @item @code{void __MTRAP (void)}
12211 @tab @code{__MTRAP ()}
12212 @tab @code{MTRAP}
12213 @item @code{uw2 __MUNPACKH (uw1)}
12214 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12215 @tab @code{MUNPACKH @var{a},@var{b}}
12216 @item @code{uw1 __MWCUT (uw2, uw1)}
12217 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12218 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12219 @item @code{void __MWTACC (acc, uw1)}
12220 @tab @code{__MWTACC (@var{b}, @var{a})}
12221 @tab @code{MWTACC @var{a},@var{b}}
12222 @item @code{void __MWTACCG (acc, uw1)}
12223 @tab @code{__MWTACCG (@var{b}, @var{a})}
12224 @tab @code{MWTACCG @var{a},@var{b}}
12225 @item @code{uw1 __MXOR (uw1, uw1)}
12226 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12227 @tab @code{MXOR @var{a},@var{b},@var{c}}
12228 @end multitable
12230 @node Raw read/write Functions
12231 @subsubsection Raw Read/Write Functions
12233 This sections describes built-in functions related to read and write
12234 instructions to access memory.  These functions generate
12235 @code{membar} instructions to flush the I/O load and stores where
12236 appropriate, as described in Fujitsu's manual described above.
12238 @table @code
12240 @item unsigned char __builtin_read8 (void *@var{data})
12241 @item unsigned short __builtin_read16 (void *@var{data})
12242 @item unsigned long __builtin_read32 (void *@var{data})
12243 @item unsigned long long __builtin_read64 (void *@var{data})
12245 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12246 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12247 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12248 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12249 @end table
12251 @node Other Built-in Functions
12252 @subsubsection Other Built-in Functions
12254 This section describes built-in functions that are not named after
12255 a specific FR-V instruction.
12257 @table @code
12258 @item sw2 __IACCreadll (iacc @var{reg})
12259 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
12260 for future expansion and must be 0.
12262 @item sw1 __IACCreadl (iacc @var{reg})
12263 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12264 Other values of @var{reg} are rejected as invalid.
12266 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12267 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
12268 is reserved for future expansion and must be 0.
12270 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12271 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12272 is 1.  Other values of @var{reg} are rejected as invalid.
12274 @item void __data_prefetch0 (const void *@var{x})
12275 Use the @code{dcpl} instruction to load the contents of address @var{x}
12276 into the data cache.
12278 @item void __data_prefetch (const void *@var{x})
12279 Use the @code{nldub} instruction to load the contents of address @var{x}
12280 into the data cache.  The instruction is issued in slot I1@.
12281 @end table
12283 @node MIPS DSP Built-in Functions
12284 @subsection MIPS DSP Built-in Functions
12286 The MIPS DSP Application-Specific Extension (ASE) includes new
12287 instructions that are designed to improve the performance of DSP and
12288 media applications.  It provides instructions that operate on packed
12289 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12291 GCC supports MIPS DSP operations using both the generic
12292 vector extensions (@pxref{Vector Extensions}) and a collection of
12293 MIPS-specific built-in functions.  Both kinds of support are
12294 enabled by the @option{-mdsp} command-line option.
12296 Revision 2 of the ASE was introduced in the second half of 2006.
12297 This revision adds extra instructions to the original ASE, but is
12298 otherwise backwards-compatible with it.  You can select revision 2
12299 using the command-line option @option{-mdspr2}; this option implies
12300 @option{-mdsp}.
12302 The SCOUNT and POS bits of the DSP control register are global.  The
12303 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12304 POS bits.  During optimization, the compiler does not delete these
12305 instructions and it does not delete calls to functions containing
12306 these instructions.
12308 At present, GCC only provides support for operations on 32-bit
12309 vectors.  The vector type associated with 8-bit integer data is
12310 usually called @code{v4i8}, the vector type associated with Q7
12311 is usually called @code{v4q7}, the vector type associated with 16-bit
12312 integer data is usually called @code{v2i16}, and the vector type
12313 associated with Q15 is usually called @code{v2q15}.  They can be
12314 defined in C as follows:
12316 @smallexample
12317 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12318 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12319 typedef short v2i16 __attribute__ ((vector_size(4)));
12320 typedef short v2q15 __attribute__ ((vector_size(4)));
12321 @end smallexample
12323 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12324 initialized in the same way as aggregates.  For example:
12326 @smallexample
12327 v4i8 a = @{1, 2, 3, 4@};
12328 v4i8 b;
12329 b = (v4i8) @{5, 6, 7, 8@};
12331 v2q15 c = @{0x0fcb, 0x3a75@};
12332 v2q15 d;
12333 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12334 @end smallexample
12336 @emph{Note:} The CPU's endianness determines the order in which values
12337 are packed.  On little-endian targets, the first value is the least
12338 significant and the last value is the most significant.  The opposite
12339 order applies to big-endian targets.  For example, the code above
12340 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12341 and @code{4} on big-endian targets.
12343 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12344 representation.  As shown in this example, the integer representation
12345 of a Q7 value can be obtained by multiplying the fractional value by
12346 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
12347 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
12348 @code{0x1.0p31}.
12350 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12351 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
12352 and @code{c} and @code{d} are @code{v2q15} values.
12354 @multitable @columnfractions .50 .50
12355 @item C code @tab MIPS instruction
12356 @item @code{a + b} @tab @code{addu.qb}
12357 @item @code{c + d} @tab @code{addq.ph}
12358 @item @code{a - b} @tab @code{subu.qb}
12359 @item @code{c - d} @tab @code{subq.ph}
12360 @end multitable
12362 The table below lists the @code{v2i16} operation for which
12363 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
12364 @code{v2i16} values.
12366 @multitable @columnfractions .50 .50
12367 @item C code @tab MIPS instruction
12368 @item @code{e * f} @tab @code{mul.ph}
12369 @end multitable
12371 It is easier to describe the DSP built-in functions if we first define
12372 the following types:
12374 @smallexample
12375 typedef int q31;
12376 typedef int i32;
12377 typedef unsigned int ui32;
12378 typedef long long a64;
12379 @end smallexample
12381 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12382 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12383 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
12384 @code{long long}, but we use @code{a64} to indicate values that are
12385 placed in one of the four DSP accumulators (@code{$ac0},
12386 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12388 Also, some built-in functions prefer or require immediate numbers as
12389 parameters, because the corresponding DSP instructions accept both immediate
12390 numbers and register operands, or accept immediate numbers only.  The
12391 immediate parameters are listed as follows.
12393 @smallexample
12394 imm0_3: 0 to 3.
12395 imm0_7: 0 to 7.
12396 imm0_15: 0 to 15.
12397 imm0_31: 0 to 31.
12398 imm0_63: 0 to 63.
12399 imm0_255: 0 to 255.
12400 imm_n32_31: -32 to 31.
12401 imm_n512_511: -512 to 511.
12402 @end smallexample
12404 The following built-in functions map directly to a particular MIPS DSP
12405 instruction.  Please refer to the architecture specification
12406 for details on what each instruction does.
12408 @smallexample
12409 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12410 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12411 q31 __builtin_mips_addq_s_w (q31, q31)
12412 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12413 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12414 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12415 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12416 q31 __builtin_mips_subq_s_w (q31, q31)
12417 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12418 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12419 i32 __builtin_mips_addsc (i32, i32)
12420 i32 __builtin_mips_addwc (i32, i32)
12421 i32 __builtin_mips_modsub (i32, i32)
12422 i32 __builtin_mips_raddu_w_qb (v4i8)
12423 v2q15 __builtin_mips_absq_s_ph (v2q15)
12424 q31 __builtin_mips_absq_s_w (q31)
12425 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12426 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12427 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12428 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12429 q31 __builtin_mips_preceq_w_phl (v2q15)
12430 q31 __builtin_mips_preceq_w_phr (v2q15)
12431 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12432 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12433 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12434 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12435 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12436 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12437 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12438 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12439 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12440 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12441 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12442 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12443 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12444 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12445 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12446 q31 __builtin_mips_shll_s_w (q31, i32)
12447 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12448 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12449 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12450 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12451 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12452 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12453 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12454 q31 __builtin_mips_shra_r_w (q31, i32)
12455 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12456 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12457 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12458 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12459 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12460 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12461 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12462 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12463 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12464 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12465 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12466 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12467 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12468 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12469 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12470 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12471 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12472 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12473 i32 __builtin_mips_bitrev (i32)
12474 i32 __builtin_mips_insv (i32, i32)
12475 v4i8 __builtin_mips_repl_qb (imm0_255)
12476 v4i8 __builtin_mips_repl_qb (i32)
12477 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12478 v2q15 __builtin_mips_repl_ph (i32)
12479 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12480 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12481 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12482 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12483 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12484 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12485 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12486 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12487 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12488 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12489 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12490 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12491 i32 __builtin_mips_extr_w (a64, imm0_31)
12492 i32 __builtin_mips_extr_w (a64, i32)
12493 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12494 i32 __builtin_mips_extr_s_h (a64, i32)
12495 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12496 i32 __builtin_mips_extr_rs_w (a64, i32)
12497 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12498 i32 __builtin_mips_extr_r_w (a64, i32)
12499 i32 __builtin_mips_extp (a64, imm0_31)
12500 i32 __builtin_mips_extp (a64, i32)
12501 i32 __builtin_mips_extpdp (a64, imm0_31)
12502 i32 __builtin_mips_extpdp (a64, i32)
12503 a64 __builtin_mips_shilo (a64, imm_n32_31)
12504 a64 __builtin_mips_shilo (a64, i32)
12505 a64 __builtin_mips_mthlip (a64, i32)
12506 void __builtin_mips_wrdsp (i32, imm0_63)
12507 i32 __builtin_mips_rddsp (imm0_63)
12508 i32 __builtin_mips_lbux (void *, i32)
12509 i32 __builtin_mips_lhx (void *, i32)
12510 i32 __builtin_mips_lwx (void *, i32)
12511 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12512 i32 __builtin_mips_bposge32 (void)
12513 a64 __builtin_mips_madd (a64, i32, i32);
12514 a64 __builtin_mips_maddu (a64, ui32, ui32);
12515 a64 __builtin_mips_msub (a64, i32, i32);
12516 a64 __builtin_mips_msubu (a64, ui32, ui32);
12517 a64 __builtin_mips_mult (i32, i32);
12518 a64 __builtin_mips_multu (ui32, ui32);
12519 @end smallexample
12521 The following built-in functions map directly to a particular MIPS DSP REV 2
12522 instruction.  Please refer to the architecture specification
12523 for details on what each instruction does.
12525 @smallexample
12526 v4q7 __builtin_mips_absq_s_qb (v4q7);
12527 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12528 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12529 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12530 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12531 i32 __builtin_mips_append (i32, i32, imm0_31);
12532 i32 __builtin_mips_balign (i32, i32, imm0_3);
12533 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12534 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12535 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12536 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12537 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12538 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12539 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12540 q31 __builtin_mips_mulq_rs_w (q31, q31);
12541 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12542 q31 __builtin_mips_mulq_s_w (q31, q31);
12543 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12544 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12545 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12546 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12547 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12548 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12549 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12550 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12551 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12552 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12553 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12554 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12555 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12556 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12557 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12558 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12559 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12560 q31 __builtin_mips_addqh_w (q31, q31);
12561 q31 __builtin_mips_addqh_r_w (q31, q31);
12562 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12563 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12564 q31 __builtin_mips_subqh_w (q31, q31);
12565 q31 __builtin_mips_subqh_r_w (q31, q31);
12566 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12567 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12568 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12569 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12570 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12571 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12572 @end smallexample
12575 @node MIPS Paired-Single Support
12576 @subsection MIPS Paired-Single Support
12578 The MIPS64 architecture includes a number of instructions that
12579 operate on pairs of single-precision floating-point values.
12580 Each pair is packed into a 64-bit floating-point register,
12581 with one element being designated the ``upper half'' and
12582 the other being designated the ``lower half''.
12584 GCC supports paired-single operations using both the generic
12585 vector extensions (@pxref{Vector Extensions}) and a collection of
12586 MIPS-specific built-in functions.  Both kinds of support are
12587 enabled by the @option{-mpaired-single} command-line option.
12589 The vector type associated with paired-single values is usually
12590 called @code{v2sf}.  It can be defined in C as follows:
12592 @smallexample
12593 typedef float v2sf __attribute__ ((vector_size (8)));
12594 @end smallexample
12596 @code{v2sf} values are initialized in the same way as aggregates.
12597 For example:
12599 @smallexample
12600 v2sf a = @{1.5, 9.1@};
12601 v2sf b;
12602 float e, f;
12603 b = (v2sf) @{e, f@};
12604 @end smallexample
12606 @emph{Note:} The CPU's endianness determines which value is stored in
12607 the upper half of a register and which value is stored in the lower half.
12608 On little-endian targets, the first value is the lower one and the second
12609 value is the upper one.  The opposite order applies to big-endian targets.
12610 For example, the code above sets the lower half of @code{a} to
12611 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12613 @node MIPS Loongson Built-in Functions
12614 @subsection MIPS Loongson Built-in Functions
12616 GCC provides intrinsics to access the SIMD instructions provided by the
12617 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
12618 available after inclusion of the @code{loongson.h} header file,
12619 operate on the following 64-bit vector types:
12621 @itemize
12622 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12623 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12624 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12625 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12626 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12627 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12628 @end itemize
12630 The intrinsics provided are listed below; each is named after the
12631 machine instruction to which it corresponds, with suffixes added as
12632 appropriate to distinguish intrinsics that expand to the same machine
12633 instruction yet have different argument types.  Refer to the architecture
12634 documentation for a description of the functionality of each
12635 instruction.
12637 @smallexample
12638 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12639 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12640 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12641 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12642 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12643 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12644 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12645 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12646 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12647 uint64_t paddd_u (uint64_t s, uint64_t t);
12648 int64_t paddd_s (int64_t s, int64_t t);
12649 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12650 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12651 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12652 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12653 uint64_t pandn_ud (uint64_t s, uint64_t t);
12654 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12655 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12656 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12657 int64_t pandn_sd (int64_t s, int64_t t);
12658 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12659 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12660 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12661 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12662 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12663 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12664 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12665 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12666 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12667 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12668 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12669 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12670 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12671 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12672 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12673 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12674 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12675 uint16x4_t pextrh_u (uint16x4_t s, int field);
12676 int16x4_t pextrh_s (int16x4_t s, int field);
12677 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12678 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12679 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12680 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12681 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12682 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12683 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12684 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12685 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12686 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12687 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12688 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12689 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12690 uint8x8_t pmovmskb_u (uint8x8_t s);
12691 int8x8_t pmovmskb_s (int8x8_t s);
12692 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12693 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12694 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12695 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12696 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12697 uint16x4_t biadd (uint8x8_t s);
12698 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12699 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12700 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12701 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12702 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12703 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12704 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12705 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12706 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12707 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12708 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12709 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12710 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12711 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12712 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12713 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12714 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12715 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12716 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12717 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12718 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12719 uint64_t psubd_u (uint64_t s, uint64_t t);
12720 int64_t psubd_s (int64_t s, int64_t t);
12721 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12722 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12723 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12724 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12725 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12726 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12727 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12728 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12729 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12730 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12731 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12732 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12733 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12734 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12735 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12736 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12737 @end smallexample
12739 @menu
12740 * Paired-Single Arithmetic::
12741 * Paired-Single Built-in Functions::
12742 * MIPS-3D Built-in Functions::
12743 @end menu
12745 @node Paired-Single Arithmetic
12746 @subsubsection Paired-Single Arithmetic
12748 The table below lists the @code{v2sf} operations for which hardware
12749 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
12750 values and @code{x} is an integral value.
12752 @multitable @columnfractions .50 .50
12753 @item C code @tab MIPS instruction
12754 @item @code{a + b} @tab @code{add.ps}
12755 @item @code{a - b} @tab @code{sub.ps}
12756 @item @code{-a} @tab @code{neg.ps}
12757 @item @code{a * b} @tab @code{mul.ps}
12758 @item @code{a * b + c} @tab @code{madd.ps}
12759 @item @code{a * b - c} @tab @code{msub.ps}
12760 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
12761 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
12762 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
12763 @end multitable
12765 Note that the multiply-accumulate instructions can be disabled
12766 using the command-line option @code{-mno-fused-madd}.
12768 @node Paired-Single Built-in Functions
12769 @subsubsection Paired-Single Built-in Functions
12771 The following paired-single functions map directly to a particular
12772 MIPS instruction.  Please refer to the architecture specification
12773 for details on what each instruction does.
12775 @table @code
12776 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
12777 Pair lower lower (@code{pll.ps}).
12779 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
12780 Pair upper lower (@code{pul.ps}).
12782 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
12783 Pair lower upper (@code{plu.ps}).
12785 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
12786 Pair upper upper (@code{puu.ps}).
12788 @item v2sf __builtin_mips_cvt_ps_s (float, float)
12789 Convert pair to paired single (@code{cvt.ps.s}).
12791 @item float __builtin_mips_cvt_s_pl (v2sf)
12792 Convert pair lower to single (@code{cvt.s.pl}).
12794 @item float __builtin_mips_cvt_s_pu (v2sf)
12795 Convert pair upper to single (@code{cvt.s.pu}).
12797 @item v2sf __builtin_mips_abs_ps (v2sf)
12798 Absolute value (@code{abs.ps}).
12800 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12801 Align variable (@code{alnv.ps}).
12803 @emph{Note:} The value of the third parameter must be 0 or 4
12804 modulo 8, otherwise the result is unpredictable.  Please read the
12805 instruction description for details.
12806 @end table
12808 The following multi-instruction functions are also available.
12809 In each case, @var{cond} can be any of the 16 floating-point conditions:
12810 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12811 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12812 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12814 @table @code
12815 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12816 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12817 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12818 @code{movt.ps}/@code{movf.ps}).
12820 The @code{movt} functions return the value @var{x} computed by:
12822 @smallexample
12823 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12824 mov.ps @var{x},@var{c}
12825 movt.ps @var{x},@var{d},@var{cc}
12826 @end smallexample
12828 The @code{movf} functions are similar but use @code{movf.ps} instead
12829 of @code{movt.ps}.
12831 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12832 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12833 Comparison of two paired-single values (@code{c.@var{cond}.ps},
12834 @code{bc1t}/@code{bc1f}).
12836 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12837 and return either the upper or lower half of the result.  For example:
12839 @smallexample
12840 v2sf a, b;
12841 if (__builtin_mips_upper_c_eq_ps (a, b))
12842   upper_halves_are_equal ();
12843 else
12844   upper_halves_are_unequal ();
12846 if (__builtin_mips_lower_c_eq_ps (a, b))
12847   lower_halves_are_equal ();
12848 else
12849   lower_halves_are_unequal ();
12850 @end smallexample
12851 @end table
12853 @node MIPS-3D Built-in Functions
12854 @subsubsection MIPS-3D Built-in Functions
12856 The MIPS-3D Application-Specific Extension (ASE) includes additional
12857 paired-single instructions that are designed to improve the performance
12858 of 3D graphics operations.  Support for these instructions is controlled
12859 by the @option{-mips3d} command-line option.
12861 The functions listed below map directly to a particular MIPS-3D
12862 instruction.  Please refer to the architecture specification for
12863 more details on what each instruction does.
12865 @table @code
12866 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
12867 Reduction add (@code{addr.ps}).
12869 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
12870 Reduction multiply (@code{mulr.ps}).
12872 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
12873 Convert paired single to paired word (@code{cvt.pw.ps}).
12875 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
12876 Convert paired word to paired single (@code{cvt.ps.pw}).
12878 @item float __builtin_mips_recip1_s (float)
12879 @itemx double __builtin_mips_recip1_d (double)
12880 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
12881 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
12883 @item float __builtin_mips_recip2_s (float, float)
12884 @itemx double __builtin_mips_recip2_d (double, double)
12885 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
12886 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
12888 @item float __builtin_mips_rsqrt1_s (float)
12889 @itemx double __builtin_mips_rsqrt1_d (double)
12890 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
12891 Reduced-precision reciprocal square root (sequence step 1)
12892 (@code{rsqrt1.@var{fmt}}).
12894 @item float __builtin_mips_rsqrt2_s (float, float)
12895 @itemx double __builtin_mips_rsqrt2_d (double, double)
12896 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
12897 Reduced-precision reciprocal square root (sequence step 2)
12898 (@code{rsqrt2.@var{fmt}}).
12899 @end table
12901 The following multi-instruction functions are also available.
12902 In each case, @var{cond} can be any of the 16 floating-point conditions:
12903 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12904 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
12905 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12907 @table @code
12908 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
12909 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
12910 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
12911 @code{bc1t}/@code{bc1f}).
12913 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
12914 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
12915 For example:
12917 @smallexample
12918 float a, b;
12919 if (__builtin_mips_cabs_eq_s (a, b))
12920   true ();
12921 else
12922   false ();
12923 @end smallexample
12925 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12926 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12927 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
12928 @code{bc1t}/@code{bc1f}).
12930 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
12931 and return either the upper or lower half of the result.  For example:
12933 @smallexample
12934 v2sf a, b;
12935 if (__builtin_mips_upper_cabs_eq_ps (a, b))
12936   upper_halves_are_equal ();
12937 else
12938   upper_halves_are_unequal ();
12940 if (__builtin_mips_lower_cabs_eq_ps (a, b))
12941   lower_halves_are_equal ();
12942 else
12943   lower_halves_are_unequal ();
12944 @end smallexample
12946 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12947 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12948 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
12949 @code{movt.ps}/@code{movf.ps}).
12951 The @code{movt} functions return the value @var{x} computed by:
12953 @smallexample
12954 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
12955 mov.ps @var{x},@var{c}
12956 movt.ps @var{x},@var{d},@var{cc}
12957 @end smallexample
12959 The @code{movf} functions are similar but use @code{movf.ps} instead
12960 of @code{movt.ps}.
12962 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12963 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12964 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12965 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12966 Comparison of two paired-single values
12967 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12968 @code{bc1any2t}/@code{bc1any2f}).
12970 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12971 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
12972 result is true and the @code{all} forms return true if both results are true.
12973 For example:
12975 @smallexample
12976 v2sf a, b;
12977 if (__builtin_mips_any_c_eq_ps (a, b))
12978   one_is_true ();
12979 else
12980   both_are_false ();
12982 if (__builtin_mips_all_c_eq_ps (a, b))
12983   both_are_true ();
12984 else
12985   one_is_false ();
12986 @end smallexample
12988 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12989 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12990 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12991 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12992 Comparison of four paired-single values
12993 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12994 @code{bc1any4t}/@code{bc1any4f}).
12996 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
12997 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
12998 The @code{any} forms return true if any of the four results are true
12999 and the @code{all} forms return true if all four results are true.
13000 For example:
13002 @smallexample
13003 v2sf a, b, c, d;
13004 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13005   some_are_true ();
13006 else
13007   all_are_false ();
13009 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13010   all_are_true ();
13011 else
13012   some_are_false ();
13013 @end smallexample
13014 @end table
13016 @node Other MIPS Built-in Functions
13017 @subsection Other MIPS Built-in Functions
13019 GCC provides other MIPS-specific built-in functions:
13021 @table @code
13022 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13023 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13024 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13025 when this function is available.
13027 @item unsigned int __builtin_mips_get_fcsr (void)
13028 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13029 Get and set the contents of the floating-point control and status register
13030 (FPU control register 31).  These functions are only available in hard-float
13031 code but can be called in both MIPS16 and non-MIPS16 contexts.
13033 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13034 register except the condition codes, which GCC assumes are preserved.
13035 @end table
13037 @node MSP430 Built-in Functions
13038 @subsection MSP430 Built-in Functions
13040 GCC provides a couple of special builtin functions to aid in the
13041 writing of interrupt handlers in C.
13043 @table @code
13044 @item __bic_SR_register_on_exit (int @var{mask})
13045 This clears the indicated bits in the saved copy of the status register
13046 currently residing on the stack.  This only works inside interrupt
13047 handlers and the changes to the status register will only take affect
13048 once the handler returns.
13050 @item __bis_SR_register_on_exit (int @var{mask})
13051 This sets the indicated bits in the saved copy of the status register
13052 currently residing on the stack.  This only works inside interrupt
13053 handlers and the changes to the status register will only take affect
13054 once the handler returns.
13056 @item __delay_cycles (long long @var{cycles})
13057 This inserts an instruction sequence that takes exactly @var{cycles}
13058 cycles (between 0 and about 17E9) to complete.  The inserted sequence
13059 may use jumps, loops, or no-ops, and does not interfere with any other
13060 instructions.  Note that @var{cycles} must be a compile-time constant
13061 integer - that is, you must pass a number, not a variable that may be
13062 optimized to a constant later.  The number of cycles delayed by this
13063 builtin is exact.
13064 @end table
13066 @node NDS32 Built-in Functions
13067 @subsection NDS32 Built-in Functions
13069 These built-in functions are available for the NDS32 target:
13071 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13072 Insert an ISYNC instruction into the instruction stream where
13073 @var{addr} is an instruction address for serialization.
13074 @end deftypefn
13076 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13077 Insert an ISB instruction into the instruction stream.
13078 @end deftypefn
13080 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13081 Return the content of a system register which is mapped by @var{sr}.
13082 @end deftypefn
13084 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13085 Return the content of a user space register which is mapped by @var{usr}.
13086 @end deftypefn
13088 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13089 Move the @var{value} to a system register which is mapped by @var{sr}.
13090 @end deftypefn
13092 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13093 Move the @var{value} to a user space register which is mapped by @var{usr}.
13094 @end deftypefn
13096 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13097 Enable global interrupt.
13098 @end deftypefn
13100 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13101 Disable global interrupt.
13102 @end deftypefn
13104 @node picoChip Built-in Functions
13105 @subsection picoChip Built-in Functions
13107 GCC provides an interface to selected machine instructions from the
13108 picoChip instruction set.
13110 @table @code
13111 @item int __builtin_sbc (int @var{value})
13112 Sign bit count.  Return the number of consecutive bits in @var{value}
13113 that have the same value as the sign bit.  The result is the number of
13114 leading sign bits minus one, giving the number of redundant sign bits in
13115 @var{value}.
13117 @item int __builtin_byteswap (int @var{value})
13118 Byte swap.  Return the result of swapping the upper and lower bytes of
13119 @var{value}.
13121 @item int __builtin_brev (int @var{value})
13122 Bit reversal.  Return the result of reversing the bits in
13123 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13124 and so on.
13126 @item int __builtin_adds (int @var{x}, int @var{y})
13127 Saturating addition.  Return the result of adding @var{x} and @var{y},
13128 storing the value 32767 if the result overflows.
13130 @item int __builtin_subs (int @var{x}, int @var{y})
13131 Saturating subtraction.  Return the result of subtracting @var{y} from
13132 @var{x}, storing the value @minus{}32768 if the result overflows.
13134 @item void __builtin_halt (void)
13135 Halt.  The processor stops execution.  This built-in is useful for
13136 implementing assertions.
13138 @end table
13140 @node PowerPC Built-in Functions
13141 @subsection PowerPC Built-in Functions
13143 These built-in functions are available for the PowerPC family of
13144 processors:
13145 @smallexample
13146 float __builtin_recipdivf (float, float);
13147 float __builtin_rsqrtf (float);
13148 double __builtin_recipdiv (double, double);
13149 double __builtin_rsqrt (double);
13150 uint64_t __builtin_ppc_get_timebase ();
13151 unsigned long __builtin_ppc_mftb ();
13152 double __builtin_unpack_longdouble (long double, int);
13153 long double __builtin_pack_longdouble (double, double);
13154 @end smallexample
13156 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13157 @code{__builtin_rsqrtf} functions generate multiple instructions to
13158 implement the reciprocal sqrt functionality using reciprocal sqrt
13159 estimate instructions.
13161 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13162 functions generate multiple instructions to implement division using
13163 the reciprocal estimate instructions.
13165 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13166 functions generate instructions to read the Time Base Register.  The
13167 @code{__builtin_ppc_get_timebase} function may generate multiple
13168 instructions and always returns the 64 bits of the Time Base Register.
13169 The @code{__builtin_ppc_mftb} function always generates one instruction and
13170 returns the Time Base Register value as an unsigned long, throwing away
13171 the most significant word on 32-bit environments.
13173 The following built-in functions are available for the PowerPC family
13174 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13175 or @option{-mpopcntd}):
13176 @smallexample
13177 long __builtin_bpermd (long, long);
13178 int __builtin_divwe (int, int);
13179 int __builtin_divweo (int, int);
13180 unsigned int __builtin_divweu (unsigned int, unsigned int);
13181 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13182 long __builtin_divde (long, long);
13183 long __builtin_divdeo (long, long);
13184 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13185 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13186 unsigned int cdtbcd (unsigned int);
13187 unsigned int cbcdtd (unsigned int);
13188 unsigned int addg6s (unsigned int, unsigned int);
13189 @end smallexample
13191 The @code{__builtin_divde}, @code{__builtin_divdeo},
13192 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13193 64-bit environment support ISA 2.06 or later.
13195 The following built-in functions are available for the PowerPC family
13196 of processors when hardware decimal floating point
13197 (@option{-mhard-dfp}) is available:
13198 @smallexample
13199 _Decimal64 __builtin_dxex (_Decimal64);
13200 _Decimal128 __builtin_dxexq (_Decimal128);
13201 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13202 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13203 _Decimal64 __builtin_denbcd (int, _Decimal64);
13204 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13205 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13206 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13207 _Decimal64 __builtin_dscli (_Decimal64, int);
13208 _Decimal128 __builtin_dscliq (_Decimal128, int);
13209 _Decimal64 __builtin_dscri (_Decimal64, int);
13210 _Decimal128 __builtin_dscriq (_Decimal128, int);
13211 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13212 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13213 @end smallexample
13215 The following built-in functions are available for the PowerPC family
13216 of processors when the Vector Scalar (vsx) instruction set is
13217 available:
13218 @smallexample
13219 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13220 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13221                                                 unsigned long long);
13222 @end smallexample
13224 @node PowerPC AltiVec/VSX Built-in Functions
13225 @subsection PowerPC AltiVec Built-in Functions
13227 GCC provides an interface for the PowerPC family of processors to access
13228 the AltiVec operations described in Motorola's AltiVec Programming
13229 Interface Manual.  The interface is made available by including
13230 @code{<altivec.h>} and using @option{-maltivec} and
13231 @option{-mabi=altivec}.  The interface supports the following vector
13232 types.
13234 @smallexample
13235 vector unsigned char
13236 vector signed char
13237 vector bool char
13239 vector unsigned short
13240 vector signed short
13241 vector bool short
13242 vector pixel
13244 vector unsigned int
13245 vector signed int
13246 vector bool int
13247 vector float
13248 @end smallexample
13250 If @option{-mvsx} is used the following additional vector types are
13251 implemented.
13253 @smallexample
13254 vector unsigned long
13255 vector signed long
13256 vector double
13257 @end smallexample
13259 The long types are only implemented for 64-bit code generation, and
13260 the long type is only used in the floating point/integer conversion
13261 instructions.
13263 GCC's implementation of the high-level language interface available from
13264 C and C++ code differs from Motorola's documentation in several ways.
13266 @itemize @bullet
13268 @item
13269 A vector constant is a list of constant expressions within curly braces.
13271 @item
13272 A vector initializer requires no cast if the vector constant is of the
13273 same type as the variable it is initializing.
13275 @item
13276 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13277 vector type is the default signedness of the base type.  The default
13278 varies depending on the operating system, so a portable program should
13279 always specify the signedness.
13281 @item
13282 Compiling with @option{-maltivec} adds keywords @code{__vector},
13283 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13284 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13285 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13286 disabled.  To use them, you must include @code{<altivec.h>} instead.
13288 @item
13289 GCC allows using a @code{typedef} name as the type specifier for a
13290 vector type.
13292 @item
13293 For C, overloaded functions are implemented with macros so the following
13294 does not work:
13296 @smallexample
13297   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13298 @end smallexample
13300 @noindent
13301 Since @code{vec_add} is a macro, the vector constant in the example
13302 is treated as four separate arguments.  Wrap the entire argument in
13303 parentheses for this to work.
13304 @end itemize
13306 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13307 Internally, GCC uses built-in functions to achieve the functionality in
13308 the aforementioned header file, but they are not supported and are
13309 subject to change without notice.
13311 The following interfaces are supported for the generic and specific
13312 AltiVec operations and the AltiVec predicates.  In cases where there
13313 is a direct mapping between generic and specific operations, only the
13314 generic names are shown here, although the specific operations can also
13315 be used.
13317 Arguments that are documented as @code{const int} require literal
13318 integral values within the range required for that operation.
13320 @smallexample
13321 vector signed char vec_abs (vector signed char);
13322 vector signed short vec_abs (vector signed short);
13323 vector signed int vec_abs (vector signed int);
13324 vector float vec_abs (vector float);
13326 vector signed char vec_abss (vector signed char);
13327 vector signed short vec_abss (vector signed short);
13328 vector signed int vec_abss (vector signed int);
13330 vector signed char vec_add (vector bool char, vector signed char);
13331 vector signed char vec_add (vector signed char, vector bool char);
13332 vector signed char vec_add (vector signed char, vector signed char);
13333 vector unsigned char vec_add (vector bool char, vector unsigned char);
13334 vector unsigned char vec_add (vector unsigned char, vector bool char);
13335 vector unsigned char vec_add (vector unsigned char,
13336                               vector unsigned char);
13337 vector signed short vec_add (vector bool short, vector signed short);
13338 vector signed short vec_add (vector signed short, vector bool short);
13339 vector signed short vec_add (vector signed short, vector signed short);
13340 vector unsigned short vec_add (vector bool short,
13341                                vector unsigned short);
13342 vector unsigned short vec_add (vector unsigned short,
13343                                vector bool short);
13344 vector unsigned short vec_add (vector unsigned short,
13345                                vector unsigned short);
13346 vector signed int vec_add (vector bool int, vector signed int);
13347 vector signed int vec_add (vector signed int, vector bool int);
13348 vector signed int vec_add (vector signed int, vector signed int);
13349 vector unsigned int vec_add (vector bool int, vector unsigned int);
13350 vector unsigned int vec_add (vector unsigned int, vector bool int);
13351 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13352 vector float vec_add (vector float, vector float);
13354 vector float vec_vaddfp (vector float, vector float);
13356 vector signed int vec_vadduwm (vector bool int, vector signed int);
13357 vector signed int vec_vadduwm (vector signed int, vector bool int);
13358 vector signed int vec_vadduwm (vector signed int, vector signed int);
13359 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13360 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13361 vector unsigned int vec_vadduwm (vector unsigned int,
13362                                  vector unsigned int);
13364 vector signed short vec_vadduhm (vector bool short,
13365                                  vector signed short);
13366 vector signed short vec_vadduhm (vector signed short,
13367                                  vector bool short);
13368 vector signed short vec_vadduhm (vector signed short,
13369                                  vector signed short);
13370 vector unsigned short vec_vadduhm (vector bool short,
13371                                    vector unsigned short);
13372 vector unsigned short vec_vadduhm (vector unsigned short,
13373                                    vector bool short);
13374 vector unsigned short vec_vadduhm (vector unsigned short,
13375                                    vector unsigned short);
13377 vector signed char vec_vaddubm (vector bool char, vector signed char);
13378 vector signed char vec_vaddubm (vector signed char, vector bool char);
13379 vector signed char vec_vaddubm (vector signed char, vector signed char);
13380 vector unsigned char vec_vaddubm (vector bool char,
13381                                   vector unsigned char);
13382 vector unsigned char vec_vaddubm (vector unsigned char,
13383                                   vector bool char);
13384 vector unsigned char vec_vaddubm (vector unsigned char,
13385                                   vector unsigned char);
13387 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13389 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13390 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13391 vector unsigned char vec_adds (vector unsigned char,
13392                                vector unsigned char);
13393 vector signed char vec_adds (vector bool char, vector signed char);
13394 vector signed char vec_adds (vector signed char, vector bool char);
13395 vector signed char vec_adds (vector signed char, vector signed char);
13396 vector unsigned short vec_adds (vector bool short,
13397                                 vector unsigned short);
13398 vector unsigned short vec_adds (vector unsigned short,
13399                                 vector bool short);
13400 vector unsigned short vec_adds (vector unsigned short,
13401                                 vector unsigned short);
13402 vector signed short vec_adds (vector bool short, vector signed short);
13403 vector signed short vec_adds (vector signed short, vector bool short);
13404 vector signed short vec_adds (vector signed short, vector signed short);
13405 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13406 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13407 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13408 vector signed int vec_adds (vector bool int, vector signed int);
13409 vector signed int vec_adds (vector signed int, vector bool int);
13410 vector signed int vec_adds (vector signed int, vector signed int);
13412 vector signed int vec_vaddsws (vector bool int, vector signed int);
13413 vector signed int vec_vaddsws (vector signed int, vector bool int);
13414 vector signed int vec_vaddsws (vector signed int, vector signed int);
13416 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13417 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13418 vector unsigned int vec_vadduws (vector unsigned int,
13419                                  vector unsigned int);
13421 vector signed short vec_vaddshs (vector bool short,
13422                                  vector signed short);
13423 vector signed short vec_vaddshs (vector signed short,
13424                                  vector bool short);
13425 vector signed short vec_vaddshs (vector signed short,
13426                                  vector signed short);
13428 vector unsigned short vec_vadduhs (vector bool short,
13429                                    vector unsigned short);
13430 vector unsigned short vec_vadduhs (vector unsigned short,
13431                                    vector bool short);
13432 vector unsigned short vec_vadduhs (vector unsigned short,
13433                                    vector unsigned short);
13435 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13436 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13437 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13439 vector unsigned char vec_vaddubs (vector bool char,
13440                                   vector unsigned char);
13441 vector unsigned char vec_vaddubs (vector unsigned char,
13442                                   vector bool char);
13443 vector unsigned char vec_vaddubs (vector unsigned char,
13444                                   vector unsigned char);
13446 vector float vec_and (vector float, vector float);
13447 vector float vec_and (vector float, vector bool int);
13448 vector float vec_and (vector bool int, vector float);
13449 vector bool int vec_and (vector bool int, vector bool int);
13450 vector signed int vec_and (vector bool int, vector signed int);
13451 vector signed int vec_and (vector signed int, vector bool int);
13452 vector signed int vec_and (vector signed int, vector signed int);
13453 vector unsigned int vec_and (vector bool int, vector unsigned int);
13454 vector unsigned int vec_and (vector unsigned int, vector bool int);
13455 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13456 vector bool short vec_and (vector bool short, vector bool short);
13457 vector signed short vec_and (vector bool short, vector signed short);
13458 vector signed short vec_and (vector signed short, vector bool short);
13459 vector signed short vec_and (vector signed short, vector signed short);
13460 vector unsigned short vec_and (vector bool short,
13461                                vector unsigned short);
13462 vector unsigned short vec_and (vector unsigned short,
13463                                vector bool short);
13464 vector unsigned short vec_and (vector unsigned short,
13465                                vector unsigned short);
13466 vector signed char vec_and (vector bool char, vector signed char);
13467 vector bool char vec_and (vector bool char, vector bool char);
13468 vector signed char vec_and (vector signed char, vector bool char);
13469 vector signed char vec_and (vector signed char, vector signed char);
13470 vector unsigned char vec_and (vector bool char, vector unsigned char);
13471 vector unsigned char vec_and (vector unsigned char, vector bool char);
13472 vector unsigned char vec_and (vector unsigned char,
13473                               vector unsigned char);
13475 vector float vec_andc (vector float, vector float);
13476 vector float vec_andc (vector float, vector bool int);
13477 vector float vec_andc (vector bool int, vector float);
13478 vector bool int vec_andc (vector bool int, vector bool int);
13479 vector signed int vec_andc (vector bool int, vector signed int);
13480 vector signed int vec_andc (vector signed int, vector bool int);
13481 vector signed int vec_andc (vector signed int, vector signed int);
13482 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13483 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13484 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13485 vector bool short vec_andc (vector bool short, vector bool short);
13486 vector signed short vec_andc (vector bool short, vector signed short);
13487 vector signed short vec_andc (vector signed short, vector bool short);
13488 vector signed short vec_andc (vector signed short, vector signed short);
13489 vector unsigned short vec_andc (vector bool short,
13490                                 vector unsigned short);
13491 vector unsigned short vec_andc (vector unsigned short,
13492                                 vector bool short);
13493 vector unsigned short vec_andc (vector unsigned short,
13494                                 vector unsigned short);
13495 vector signed char vec_andc (vector bool char, vector signed char);
13496 vector bool char vec_andc (vector bool char, vector bool char);
13497 vector signed char vec_andc (vector signed char, vector bool char);
13498 vector signed char vec_andc (vector signed char, vector signed char);
13499 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13500 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13501 vector unsigned char vec_andc (vector unsigned char,
13502                                vector unsigned char);
13504 vector unsigned char vec_avg (vector unsigned char,
13505                               vector unsigned char);
13506 vector signed char vec_avg (vector signed char, vector signed char);
13507 vector unsigned short vec_avg (vector unsigned short,
13508                                vector unsigned short);
13509 vector signed short vec_avg (vector signed short, vector signed short);
13510 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13511 vector signed int vec_avg (vector signed int, vector signed int);
13513 vector signed int vec_vavgsw (vector signed int, vector signed int);
13515 vector unsigned int vec_vavguw (vector unsigned int,
13516                                 vector unsigned int);
13518 vector signed short vec_vavgsh (vector signed short,
13519                                 vector signed short);
13521 vector unsigned short vec_vavguh (vector unsigned short,
13522                                   vector unsigned short);
13524 vector signed char vec_vavgsb (vector signed char, vector signed char);
13526 vector unsigned char vec_vavgub (vector unsigned char,
13527                                  vector unsigned char);
13529 vector float vec_copysign (vector float);
13531 vector float vec_ceil (vector float);
13533 vector signed int vec_cmpb (vector float, vector float);
13535 vector bool char vec_cmpeq (vector signed char, vector signed char);
13536 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13537 vector bool short vec_cmpeq (vector signed short, vector signed short);
13538 vector bool short vec_cmpeq (vector unsigned short,
13539                              vector unsigned short);
13540 vector bool int vec_cmpeq (vector signed int, vector signed int);
13541 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13542 vector bool int vec_cmpeq (vector float, vector float);
13544 vector bool int vec_vcmpeqfp (vector float, vector float);
13546 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13547 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13549 vector bool short vec_vcmpequh (vector signed short,
13550                                 vector signed short);
13551 vector bool short vec_vcmpequh (vector unsigned short,
13552                                 vector unsigned short);
13554 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13555 vector bool char vec_vcmpequb (vector unsigned char,
13556                                vector unsigned char);
13558 vector bool int vec_cmpge (vector float, vector float);
13560 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13561 vector bool char vec_cmpgt (vector signed char, vector signed char);
13562 vector bool short vec_cmpgt (vector unsigned short,
13563                              vector unsigned short);
13564 vector bool short vec_cmpgt (vector signed short, vector signed short);
13565 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13566 vector bool int vec_cmpgt (vector signed int, vector signed int);
13567 vector bool int vec_cmpgt (vector float, vector float);
13569 vector bool int vec_vcmpgtfp (vector float, vector float);
13571 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13573 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13575 vector bool short vec_vcmpgtsh (vector signed short,
13576                                 vector signed short);
13578 vector bool short vec_vcmpgtuh (vector unsigned short,
13579                                 vector unsigned short);
13581 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13583 vector bool char vec_vcmpgtub (vector unsigned char,
13584                                vector unsigned char);
13586 vector bool int vec_cmple (vector float, vector float);
13588 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13589 vector bool char vec_cmplt (vector signed char, vector signed char);
13590 vector bool short vec_cmplt (vector unsigned short,
13591                              vector unsigned short);
13592 vector bool short vec_cmplt (vector signed short, vector signed short);
13593 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13594 vector bool int vec_cmplt (vector signed int, vector signed int);
13595 vector bool int vec_cmplt (vector float, vector float);
13597 vector float vec_cpsgn (vector float, vector float);
13599 vector float vec_ctf (vector unsigned int, const int);
13600 vector float vec_ctf (vector signed int, const int);
13601 vector double vec_ctf (vector unsigned long, const int);
13602 vector double vec_ctf (vector signed long, const int);
13604 vector float vec_vcfsx (vector signed int, const int);
13606 vector float vec_vcfux (vector unsigned int, const int);
13608 vector signed int vec_cts (vector float, const int);
13609 vector signed long vec_cts (vector double, const int);
13611 vector unsigned int vec_ctu (vector float, const int);
13612 vector unsigned long vec_ctu (vector double, const int);
13614 void vec_dss (const int);
13616 void vec_dssall (void);
13618 void vec_dst (const vector unsigned char *, int, const int);
13619 void vec_dst (const vector signed char *, int, const int);
13620 void vec_dst (const vector bool char *, int, const int);
13621 void vec_dst (const vector unsigned short *, int, const int);
13622 void vec_dst (const vector signed short *, int, const int);
13623 void vec_dst (const vector bool short *, int, const int);
13624 void vec_dst (const vector pixel *, int, const int);
13625 void vec_dst (const vector unsigned int *, int, const int);
13626 void vec_dst (const vector signed int *, int, const int);
13627 void vec_dst (const vector bool int *, int, const int);
13628 void vec_dst (const vector float *, int, const int);
13629 void vec_dst (const unsigned char *, int, const int);
13630 void vec_dst (const signed char *, int, const int);
13631 void vec_dst (const unsigned short *, int, const int);
13632 void vec_dst (const short *, int, const int);
13633 void vec_dst (const unsigned int *, int, const int);
13634 void vec_dst (const int *, int, const int);
13635 void vec_dst (const unsigned long *, int, const int);
13636 void vec_dst (const long *, int, const int);
13637 void vec_dst (const float *, int, const int);
13639 void vec_dstst (const vector unsigned char *, int, const int);
13640 void vec_dstst (const vector signed char *, int, const int);
13641 void vec_dstst (const vector bool char *, int, const int);
13642 void vec_dstst (const vector unsigned short *, int, const int);
13643 void vec_dstst (const vector signed short *, int, const int);
13644 void vec_dstst (const vector bool short *, int, const int);
13645 void vec_dstst (const vector pixel *, int, const int);
13646 void vec_dstst (const vector unsigned int *, int, const int);
13647 void vec_dstst (const vector signed int *, int, const int);
13648 void vec_dstst (const vector bool int *, int, const int);
13649 void vec_dstst (const vector float *, int, const int);
13650 void vec_dstst (const unsigned char *, int, const int);
13651 void vec_dstst (const signed char *, int, const int);
13652 void vec_dstst (const unsigned short *, int, const int);
13653 void vec_dstst (const short *, int, const int);
13654 void vec_dstst (const unsigned int *, int, const int);
13655 void vec_dstst (const int *, int, const int);
13656 void vec_dstst (const unsigned long *, int, const int);
13657 void vec_dstst (const long *, int, const int);
13658 void vec_dstst (const float *, int, const int);
13660 void vec_dststt (const vector unsigned char *, int, const int);
13661 void vec_dststt (const vector signed char *, int, const int);
13662 void vec_dststt (const vector bool char *, int, const int);
13663 void vec_dststt (const vector unsigned short *, int, const int);
13664 void vec_dststt (const vector signed short *, int, const int);
13665 void vec_dststt (const vector bool short *, int, const int);
13666 void vec_dststt (const vector pixel *, int, const int);
13667 void vec_dststt (const vector unsigned int *, int, const int);
13668 void vec_dststt (const vector signed int *, int, const int);
13669 void vec_dststt (const vector bool int *, int, const int);
13670 void vec_dststt (const vector float *, int, const int);
13671 void vec_dststt (const unsigned char *, int, const int);
13672 void vec_dststt (const signed char *, int, const int);
13673 void vec_dststt (const unsigned short *, int, const int);
13674 void vec_dststt (const short *, int, const int);
13675 void vec_dststt (const unsigned int *, int, const int);
13676 void vec_dststt (const int *, int, const int);
13677 void vec_dststt (const unsigned long *, int, const int);
13678 void vec_dststt (const long *, int, const int);
13679 void vec_dststt (const float *, int, const int);
13681 void vec_dstt (const vector unsigned char *, int, const int);
13682 void vec_dstt (const vector signed char *, int, const int);
13683 void vec_dstt (const vector bool char *, int, const int);
13684 void vec_dstt (const vector unsigned short *, int, const int);
13685 void vec_dstt (const vector signed short *, int, const int);
13686 void vec_dstt (const vector bool short *, int, const int);
13687 void vec_dstt (const vector pixel *, int, const int);
13688 void vec_dstt (const vector unsigned int *, int, const int);
13689 void vec_dstt (const vector signed int *, int, const int);
13690 void vec_dstt (const vector bool int *, int, const int);
13691 void vec_dstt (const vector float *, int, const int);
13692 void vec_dstt (const unsigned char *, int, const int);
13693 void vec_dstt (const signed char *, int, const int);
13694 void vec_dstt (const unsigned short *, int, const int);
13695 void vec_dstt (const short *, int, const int);
13696 void vec_dstt (const unsigned int *, int, const int);
13697 void vec_dstt (const int *, int, const int);
13698 void vec_dstt (const unsigned long *, int, const int);
13699 void vec_dstt (const long *, int, const int);
13700 void vec_dstt (const float *, int, const int);
13702 vector float vec_expte (vector float);
13704 vector float vec_floor (vector float);
13706 vector float vec_ld (int, const vector float *);
13707 vector float vec_ld (int, const float *);
13708 vector bool int vec_ld (int, const vector bool int *);
13709 vector signed int vec_ld (int, const vector signed int *);
13710 vector signed int vec_ld (int, const int *);
13711 vector signed int vec_ld (int, const long *);
13712 vector unsigned int vec_ld (int, const vector unsigned int *);
13713 vector unsigned int vec_ld (int, const unsigned int *);
13714 vector unsigned int vec_ld (int, const unsigned long *);
13715 vector bool short vec_ld (int, const vector bool short *);
13716 vector pixel vec_ld (int, const vector pixel *);
13717 vector signed short vec_ld (int, const vector signed short *);
13718 vector signed short vec_ld (int, const short *);
13719 vector unsigned short vec_ld (int, const vector unsigned short *);
13720 vector unsigned short vec_ld (int, const unsigned short *);
13721 vector bool char vec_ld (int, const vector bool char *);
13722 vector signed char vec_ld (int, const vector signed char *);
13723 vector signed char vec_ld (int, const signed char *);
13724 vector unsigned char vec_ld (int, const vector unsigned char *);
13725 vector unsigned char vec_ld (int, const unsigned char *);
13727 vector signed char vec_lde (int, const signed char *);
13728 vector unsigned char vec_lde (int, const unsigned char *);
13729 vector signed short vec_lde (int, const short *);
13730 vector unsigned short vec_lde (int, const unsigned short *);
13731 vector float vec_lde (int, const float *);
13732 vector signed int vec_lde (int, const int *);
13733 vector unsigned int vec_lde (int, const unsigned int *);
13734 vector signed int vec_lde (int, const long *);
13735 vector unsigned int vec_lde (int, const unsigned long *);
13737 vector float vec_lvewx (int, float *);
13738 vector signed int vec_lvewx (int, int *);
13739 vector unsigned int vec_lvewx (int, unsigned int *);
13740 vector signed int vec_lvewx (int, long *);
13741 vector unsigned int vec_lvewx (int, unsigned long *);
13743 vector signed short vec_lvehx (int, short *);
13744 vector unsigned short vec_lvehx (int, unsigned short *);
13746 vector signed char vec_lvebx (int, char *);
13747 vector unsigned char vec_lvebx (int, unsigned char *);
13749 vector float vec_ldl (int, const vector float *);
13750 vector float vec_ldl (int, const float *);
13751 vector bool int vec_ldl (int, const vector bool int *);
13752 vector signed int vec_ldl (int, const vector signed int *);
13753 vector signed int vec_ldl (int, const int *);
13754 vector signed int vec_ldl (int, const long *);
13755 vector unsigned int vec_ldl (int, const vector unsigned int *);
13756 vector unsigned int vec_ldl (int, const unsigned int *);
13757 vector unsigned int vec_ldl (int, const unsigned long *);
13758 vector bool short vec_ldl (int, const vector bool short *);
13759 vector pixel vec_ldl (int, const vector pixel *);
13760 vector signed short vec_ldl (int, const vector signed short *);
13761 vector signed short vec_ldl (int, const short *);
13762 vector unsigned short vec_ldl (int, const vector unsigned short *);
13763 vector unsigned short vec_ldl (int, const unsigned short *);
13764 vector bool char vec_ldl (int, const vector bool char *);
13765 vector signed char vec_ldl (int, const vector signed char *);
13766 vector signed char vec_ldl (int, const signed char *);
13767 vector unsigned char vec_ldl (int, const vector unsigned char *);
13768 vector unsigned char vec_ldl (int, const unsigned char *);
13770 vector float vec_loge (vector float);
13772 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
13773 vector unsigned char vec_lvsl (int, const volatile signed char *);
13774 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
13775 vector unsigned char vec_lvsl (int, const volatile short *);
13776 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
13777 vector unsigned char vec_lvsl (int, const volatile int *);
13778 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
13779 vector unsigned char vec_lvsl (int, const volatile long *);
13780 vector unsigned char vec_lvsl (int, const volatile float *);
13782 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
13783 vector unsigned char vec_lvsr (int, const volatile signed char *);
13784 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
13785 vector unsigned char vec_lvsr (int, const volatile short *);
13786 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
13787 vector unsigned char vec_lvsr (int, const volatile int *);
13788 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
13789 vector unsigned char vec_lvsr (int, const volatile long *);
13790 vector unsigned char vec_lvsr (int, const volatile float *);
13792 vector float vec_madd (vector float, vector float, vector float);
13794 vector signed short vec_madds (vector signed short,
13795                                vector signed short,
13796                                vector signed short);
13798 vector unsigned char vec_max (vector bool char, vector unsigned char);
13799 vector unsigned char vec_max (vector unsigned char, vector bool char);
13800 vector unsigned char vec_max (vector unsigned char,
13801                               vector unsigned char);
13802 vector signed char vec_max (vector bool char, vector signed char);
13803 vector signed char vec_max (vector signed char, vector bool char);
13804 vector signed char vec_max (vector signed char, vector signed char);
13805 vector unsigned short vec_max (vector bool short,
13806                                vector unsigned short);
13807 vector unsigned short vec_max (vector unsigned short,
13808                                vector bool short);
13809 vector unsigned short vec_max (vector unsigned short,
13810                                vector unsigned short);
13811 vector signed short vec_max (vector bool short, vector signed short);
13812 vector signed short vec_max (vector signed short, vector bool short);
13813 vector signed short vec_max (vector signed short, vector signed short);
13814 vector unsigned int vec_max (vector bool int, vector unsigned int);
13815 vector unsigned int vec_max (vector unsigned int, vector bool int);
13816 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13817 vector signed int vec_max (vector bool int, vector signed int);
13818 vector signed int vec_max (vector signed int, vector bool int);
13819 vector signed int vec_max (vector signed int, vector signed int);
13820 vector float vec_max (vector float, vector float);
13822 vector float vec_vmaxfp (vector float, vector float);
13824 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13825 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13826 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13828 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13829 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13830 vector unsigned int vec_vmaxuw (vector unsigned int,
13831                                 vector unsigned int);
13833 vector signed short vec_vmaxsh (vector bool short, vector signed short);
13834 vector signed short vec_vmaxsh (vector signed short, vector bool short);
13835 vector signed short vec_vmaxsh (vector signed short,
13836                                 vector signed short);
13838 vector unsigned short vec_vmaxuh (vector bool short,
13839                                   vector unsigned short);
13840 vector unsigned short vec_vmaxuh (vector unsigned short,
13841                                   vector bool short);
13842 vector unsigned short vec_vmaxuh (vector unsigned short,
13843                                   vector unsigned short);
13845 vector signed char vec_vmaxsb (vector bool char, vector signed char);
13846 vector signed char vec_vmaxsb (vector signed char, vector bool char);
13847 vector signed char vec_vmaxsb (vector signed char, vector signed char);
13849 vector unsigned char vec_vmaxub (vector bool char,
13850                                  vector unsigned char);
13851 vector unsigned char vec_vmaxub (vector unsigned char,
13852                                  vector bool char);
13853 vector unsigned char vec_vmaxub (vector unsigned char,
13854                                  vector unsigned char);
13856 vector bool char vec_mergeh (vector bool char, vector bool char);
13857 vector signed char vec_mergeh (vector signed char, vector signed char);
13858 vector unsigned char vec_mergeh (vector unsigned char,
13859                                  vector unsigned char);
13860 vector bool short vec_mergeh (vector bool short, vector bool short);
13861 vector pixel vec_mergeh (vector pixel, vector pixel);
13862 vector signed short vec_mergeh (vector signed short,
13863                                 vector signed short);
13864 vector unsigned short vec_mergeh (vector unsigned short,
13865                                   vector unsigned short);
13866 vector float vec_mergeh (vector float, vector float);
13867 vector bool int vec_mergeh (vector bool int, vector bool int);
13868 vector signed int vec_mergeh (vector signed int, vector signed int);
13869 vector unsigned int vec_mergeh (vector unsigned int,
13870                                 vector unsigned int);
13872 vector float vec_vmrghw (vector float, vector float);
13873 vector bool int vec_vmrghw (vector bool int, vector bool int);
13874 vector signed int vec_vmrghw (vector signed int, vector signed int);
13875 vector unsigned int vec_vmrghw (vector unsigned int,
13876                                 vector unsigned int);
13878 vector bool short vec_vmrghh (vector bool short, vector bool short);
13879 vector signed short vec_vmrghh (vector signed short,
13880                                 vector signed short);
13881 vector unsigned short vec_vmrghh (vector unsigned short,
13882                                   vector unsigned short);
13883 vector pixel vec_vmrghh (vector pixel, vector pixel);
13885 vector bool char vec_vmrghb (vector bool char, vector bool char);
13886 vector signed char vec_vmrghb (vector signed char, vector signed char);
13887 vector unsigned char vec_vmrghb (vector unsigned char,
13888                                  vector unsigned char);
13890 vector bool char vec_mergel (vector bool char, vector bool char);
13891 vector signed char vec_mergel (vector signed char, vector signed char);
13892 vector unsigned char vec_mergel (vector unsigned char,
13893                                  vector unsigned char);
13894 vector bool short vec_mergel (vector bool short, vector bool short);
13895 vector pixel vec_mergel (vector pixel, vector pixel);
13896 vector signed short vec_mergel (vector signed short,
13897                                 vector signed short);
13898 vector unsigned short vec_mergel (vector unsigned short,
13899                                   vector unsigned short);
13900 vector float vec_mergel (vector float, vector float);
13901 vector bool int vec_mergel (vector bool int, vector bool int);
13902 vector signed int vec_mergel (vector signed int, vector signed int);
13903 vector unsigned int vec_mergel (vector unsigned int,
13904                                 vector unsigned int);
13906 vector float vec_vmrglw (vector float, vector float);
13907 vector signed int vec_vmrglw (vector signed int, vector signed int);
13908 vector unsigned int vec_vmrglw (vector unsigned int,
13909                                 vector unsigned int);
13910 vector bool int vec_vmrglw (vector bool int, vector bool int);
13912 vector bool short vec_vmrglh (vector bool short, vector bool short);
13913 vector signed short vec_vmrglh (vector signed short,
13914                                 vector signed short);
13915 vector unsigned short vec_vmrglh (vector unsigned short,
13916                                   vector unsigned short);
13917 vector pixel vec_vmrglh (vector pixel, vector pixel);
13919 vector bool char vec_vmrglb (vector bool char, vector bool char);
13920 vector signed char vec_vmrglb (vector signed char, vector signed char);
13921 vector unsigned char vec_vmrglb (vector unsigned char,
13922                                  vector unsigned char);
13924 vector unsigned short vec_mfvscr (void);
13926 vector unsigned char vec_min (vector bool char, vector unsigned char);
13927 vector unsigned char vec_min (vector unsigned char, vector bool char);
13928 vector unsigned char vec_min (vector unsigned char,
13929                               vector unsigned char);
13930 vector signed char vec_min (vector bool char, vector signed char);
13931 vector signed char vec_min (vector signed char, vector bool char);
13932 vector signed char vec_min (vector signed char, vector signed char);
13933 vector unsigned short vec_min (vector bool short,
13934                                vector unsigned short);
13935 vector unsigned short vec_min (vector unsigned short,
13936                                vector bool short);
13937 vector unsigned short vec_min (vector unsigned short,
13938                                vector unsigned short);
13939 vector signed short vec_min (vector bool short, vector signed short);
13940 vector signed short vec_min (vector signed short, vector bool short);
13941 vector signed short vec_min (vector signed short, vector signed short);
13942 vector unsigned int vec_min (vector bool int, vector unsigned int);
13943 vector unsigned int vec_min (vector unsigned int, vector bool int);
13944 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
13945 vector signed int vec_min (vector bool int, vector signed int);
13946 vector signed int vec_min (vector signed int, vector bool int);
13947 vector signed int vec_min (vector signed int, vector signed int);
13948 vector float vec_min (vector float, vector float);
13950 vector float vec_vminfp (vector float, vector float);
13952 vector signed int vec_vminsw (vector bool int, vector signed int);
13953 vector signed int vec_vminsw (vector signed int, vector bool int);
13954 vector signed int vec_vminsw (vector signed int, vector signed int);
13956 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
13957 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
13958 vector unsigned int vec_vminuw (vector unsigned int,
13959                                 vector unsigned int);
13961 vector signed short vec_vminsh (vector bool short, vector signed short);
13962 vector signed short vec_vminsh (vector signed short, vector bool short);
13963 vector signed short vec_vminsh (vector signed short,
13964                                 vector signed short);
13966 vector unsigned short vec_vminuh (vector bool short,
13967                                   vector unsigned short);
13968 vector unsigned short vec_vminuh (vector unsigned short,
13969                                   vector bool short);
13970 vector unsigned short vec_vminuh (vector unsigned short,
13971                                   vector unsigned short);
13973 vector signed char vec_vminsb (vector bool char, vector signed char);
13974 vector signed char vec_vminsb (vector signed char, vector bool char);
13975 vector signed char vec_vminsb (vector signed char, vector signed char);
13977 vector unsigned char vec_vminub (vector bool char,
13978                                  vector unsigned char);
13979 vector unsigned char vec_vminub (vector unsigned char,
13980                                  vector bool char);
13981 vector unsigned char vec_vminub (vector unsigned char,
13982                                  vector unsigned char);
13984 vector signed short vec_mladd (vector signed short,
13985                                vector signed short,
13986                                vector signed short);
13987 vector signed short vec_mladd (vector signed short,
13988                                vector unsigned short,
13989                                vector unsigned short);
13990 vector signed short vec_mladd (vector unsigned short,
13991                                vector signed short,
13992                                vector signed short);
13993 vector unsigned short vec_mladd (vector unsigned short,
13994                                  vector unsigned short,
13995                                  vector unsigned short);
13997 vector signed short vec_mradds (vector signed short,
13998                                 vector signed short,
13999                                 vector signed short);
14001 vector unsigned int vec_msum (vector unsigned char,
14002                               vector unsigned char,
14003                               vector unsigned int);
14004 vector signed int vec_msum (vector signed char,
14005                             vector unsigned char,
14006                             vector signed int);
14007 vector unsigned int vec_msum (vector unsigned short,
14008                               vector unsigned short,
14009                               vector unsigned int);
14010 vector signed int vec_msum (vector signed short,
14011                             vector signed short,
14012                             vector signed int);
14014 vector signed int vec_vmsumshm (vector signed short,
14015                                 vector signed short,
14016                                 vector signed int);
14018 vector unsigned int vec_vmsumuhm (vector unsigned short,
14019                                   vector unsigned short,
14020                                   vector unsigned int);
14022 vector signed int vec_vmsummbm (vector signed char,
14023                                 vector unsigned char,
14024                                 vector signed int);
14026 vector unsigned int vec_vmsumubm (vector unsigned char,
14027                                   vector unsigned char,
14028                                   vector unsigned int);
14030 vector unsigned int vec_msums (vector unsigned short,
14031                                vector unsigned short,
14032                                vector unsigned int);
14033 vector signed int vec_msums (vector signed short,
14034                              vector signed short,
14035                              vector signed int);
14037 vector signed int vec_vmsumshs (vector signed short,
14038                                 vector signed short,
14039                                 vector signed int);
14041 vector unsigned int vec_vmsumuhs (vector unsigned short,
14042                                   vector unsigned short,
14043                                   vector unsigned int);
14045 void vec_mtvscr (vector signed int);
14046 void vec_mtvscr (vector unsigned int);
14047 void vec_mtvscr (vector bool int);
14048 void vec_mtvscr (vector signed short);
14049 void vec_mtvscr (vector unsigned short);
14050 void vec_mtvscr (vector bool short);
14051 void vec_mtvscr (vector pixel);
14052 void vec_mtvscr (vector signed char);
14053 void vec_mtvscr (vector unsigned char);
14054 void vec_mtvscr (vector bool char);
14056 vector unsigned short vec_mule (vector unsigned char,
14057                                 vector unsigned char);
14058 vector signed short vec_mule (vector signed char,
14059                               vector signed char);
14060 vector unsigned int vec_mule (vector unsigned short,
14061                               vector unsigned short);
14062 vector signed int vec_mule (vector signed short, vector signed short);
14064 vector signed int vec_vmulesh (vector signed short,
14065                                vector signed short);
14067 vector unsigned int vec_vmuleuh (vector unsigned short,
14068                                  vector unsigned short);
14070 vector signed short vec_vmulesb (vector signed char,
14071                                  vector signed char);
14073 vector unsigned short vec_vmuleub (vector unsigned char,
14074                                   vector unsigned char);
14076 vector unsigned short vec_mulo (vector unsigned char,
14077                                 vector unsigned char);
14078 vector signed short vec_mulo (vector signed char, vector signed char);
14079 vector unsigned int vec_mulo (vector unsigned short,
14080                               vector unsigned short);
14081 vector signed int vec_mulo (vector signed short, vector signed short);
14083 vector signed int vec_vmulosh (vector signed short,
14084                                vector signed short);
14086 vector unsigned int vec_vmulouh (vector unsigned short,
14087                                  vector unsigned short);
14089 vector signed short vec_vmulosb (vector signed char,
14090                                  vector signed char);
14092 vector unsigned short vec_vmuloub (vector unsigned char,
14093                                    vector unsigned char);
14095 vector float vec_nmsub (vector float, vector float, vector float);
14097 vector float vec_nor (vector float, vector float);
14098 vector signed int vec_nor (vector signed int, vector signed int);
14099 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14100 vector bool int vec_nor (vector bool int, vector bool int);
14101 vector signed short vec_nor (vector signed short, vector signed short);
14102 vector unsigned short vec_nor (vector unsigned short,
14103                                vector unsigned short);
14104 vector bool short vec_nor (vector bool short, vector bool short);
14105 vector signed char vec_nor (vector signed char, vector signed char);
14106 vector unsigned char vec_nor (vector unsigned char,
14107                               vector unsigned char);
14108 vector bool char vec_nor (vector bool char, vector bool char);
14110 vector float vec_or (vector float, vector float);
14111 vector float vec_or (vector float, vector bool int);
14112 vector float vec_or (vector bool int, vector float);
14113 vector bool int vec_or (vector bool int, vector bool int);
14114 vector signed int vec_or (vector bool int, vector signed int);
14115 vector signed int vec_or (vector signed int, vector bool int);
14116 vector signed int vec_or (vector signed int, vector signed int);
14117 vector unsigned int vec_or (vector bool int, vector unsigned int);
14118 vector unsigned int vec_or (vector unsigned int, vector bool int);
14119 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14120 vector bool short vec_or (vector bool short, vector bool short);
14121 vector signed short vec_or (vector bool short, vector signed short);
14122 vector signed short vec_or (vector signed short, vector bool short);
14123 vector signed short vec_or (vector signed short, vector signed short);
14124 vector unsigned short vec_or (vector bool short, vector unsigned short);
14125 vector unsigned short vec_or (vector unsigned short, vector bool short);
14126 vector unsigned short vec_or (vector unsigned short,
14127                               vector unsigned short);
14128 vector signed char vec_or (vector bool char, vector signed char);
14129 vector bool char vec_or (vector bool char, vector bool char);
14130 vector signed char vec_or (vector signed char, vector bool char);
14131 vector signed char vec_or (vector signed char, vector signed char);
14132 vector unsigned char vec_or (vector bool char, vector unsigned char);
14133 vector unsigned char vec_or (vector unsigned char, vector bool char);
14134 vector unsigned char vec_or (vector unsigned char,
14135                              vector unsigned char);
14137 vector signed char vec_pack (vector signed short, vector signed short);
14138 vector unsigned char vec_pack (vector unsigned short,
14139                                vector unsigned short);
14140 vector bool char vec_pack (vector bool short, vector bool short);
14141 vector signed short vec_pack (vector signed int, vector signed int);
14142 vector unsigned short vec_pack (vector unsigned int,
14143                                 vector unsigned int);
14144 vector bool short vec_pack (vector bool int, vector bool int);
14146 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14147 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14148 vector unsigned short vec_vpkuwum (vector unsigned int,
14149                                    vector unsigned int);
14151 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14152 vector signed char vec_vpkuhum (vector signed short,
14153                                 vector signed short);
14154 vector unsigned char vec_vpkuhum (vector unsigned short,
14155                                   vector unsigned short);
14157 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14159 vector unsigned char vec_packs (vector unsigned short,
14160                                 vector unsigned short);
14161 vector signed char vec_packs (vector signed short, vector signed short);
14162 vector unsigned short vec_packs (vector unsigned int,
14163                                  vector unsigned int);
14164 vector signed short vec_packs (vector signed int, vector signed int);
14166 vector signed short vec_vpkswss (vector signed int, vector signed int);
14168 vector unsigned short vec_vpkuwus (vector unsigned int,
14169                                    vector unsigned int);
14171 vector signed char vec_vpkshss (vector signed short,
14172                                 vector signed short);
14174 vector unsigned char vec_vpkuhus (vector unsigned short,
14175                                   vector unsigned short);
14177 vector unsigned char vec_packsu (vector unsigned short,
14178                                  vector unsigned short);
14179 vector unsigned char vec_packsu (vector signed short,
14180                                  vector signed short);
14181 vector unsigned short vec_packsu (vector unsigned int,
14182                                   vector unsigned int);
14183 vector unsigned short vec_packsu (vector signed int, vector signed int);
14185 vector unsigned short vec_vpkswus (vector signed int,
14186                                    vector signed int);
14188 vector unsigned char vec_vpkshus (vector signed short,
14189                                   vector signed short);
14191 vector float vec_perm (vector float,
14192                        vector float,
14193                        vector unsigned char);
14194 vector signed int vec_perm (vector signed int,
14195                             vector signed int,
14196                             vector unsigned char);
14197 vector unsigned int vec_perm (vector unsigned int,
14198                               vector unsigned int,
14199                               vector unsigned char);
14200 vector bool int vec_perm (vector bool int,
14201                           vector bool int,
14202                           vector unsigned char);
14203 vector signed short vec_perm (vector signed short,
14204                               vector signed short,
14205                               vector unsigned char);
14206 vector unsigned short vec_perm (vector unsigned short,
14207                                 vector unsigned short,
14208                                 vector unsigned char);
14209 vector bool short vec_perm (vector bool short,
14210                             vector bool short,
14211                             vector unsigned char);
14212 vector pixel vec_perm (vector pixel,
14213                        vector pixel,
14214                        vector unsigned char);
14215 vector signed char vec_perm (vector signed char,
14216                              vector signed char,
14217                              vector unsigned char);
14218 vector unsigned char vec_perm (vector unsigned char,
14219                                vector unsigned char,
14220                                vector unsigned char);
14221 vector bool char vec_perm (vector bool char,
14222                            vector bool char,
14223                            vector unsigned char);
14225 vector float vec_re (vector float);
14227 vector signed char vec_rl (vector signed char,
14228                            vector unsigned char);
14229 vector unsigned char vec_rl (vector unsigned char,
14230                              vector unsigned char);
14231 vector signed short vec_rl (vector signed short, vector unsigned short);
14232 vector unsigned short vec_rl (vector unsigned short,
14233                               vector unsigned short);
14234 vector signed int vec_rl (vector signed int, vector unsigned int);
14235 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14237 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14238 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14240 vector signed short vec_vrlh (vector signed short,
14241                               vector unsigned short);
14242 vector unsigned short vec_vrlh (vector unsigned short,
14243                                 vector unsigned short);
14245 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14246 vector unsigned char vec_vrlb (vector unsigned char,
14247                                vector unsigned char);
14249 vector float vec_round (vector float);
14251 vector float vec_recip (vector float, vector float);
14253 vector float vec_rsqrt (vector float);
14255 vector float vec_rsqrte (vector float);
14257 vector float vec_sel (vector float, vector float, vector bool int);
14258 vector float vec_sel (vector float, vector float, vector unsigned int);
14259 vector signed int vec_sel (vector signed int,
14260                            vector signed int,
14261                            vector bool int);
14262 vector signed int vec_sel (vector signed int,
14263                            vector signed int,
14264                            vector unsigned int);
14265 vector unsigned int vec_sel (vector unsigned int,
14266                              vector unsigned int,
14267                              vector bool int);
14268 vector unsigned int vec_sel (vector unsigned int,
14269                              vector unsigned int,
14270                              vector unsigned int);
14271 vector bool int vec_sel (vector bool int,
14272                          vector bool int,
14273                          vector bool int);
14274 vector bool int vec_sel (vector bool int,
14275                          vector bool int,
14276                          vector unsigned int);
14277 vector signed short vec_sel (vector signed short,
14278                              vector signed short,
14279                              vector bool short);
14280 vector signed short vec_sel (vector signed short,
14281                              vector signed short,
14282                              vector unsigned short);
14283 vector unsigned short vec_sel (vector unsigned short,
14284                                vector unsigned short,
14285                                vector bool short);
14286 vector unsigned short vec_sel (vector unsigned short,
14287                                vector unsigned short,
14288                                vector unsigned short);
14289 vector bool short vec_sel (vector bool short,
14290                            vector bool short,
14291                            vector bool short);
14292 vector bool short vec_sel (vector bool short,
14293                            vector bool short,
14294                            vector unsigned short);
14295 vector signed char vec_sel (vector signed char,
14296                             vector signed char,
14297                             vector bool char);
14298 vector signed char vec_sel (vector signed char,
14299                             vector signed char,
14300                             vector unsigned char);
14301 vector unsigned char vec_sel (vector unsigned char,
14302                               vector unsigned char,
14303                               vector bool char);
14304 vector unsigned char vec_sel (vector unsigned char,
14305                               vector unsigned char,
14306                               vector unsigned char);
14307 vector bool char vec_sel (vector bool char,
14308                           vector bool char,
14309                           vector bool char);
14310 vector bool char vec_sel (vector bool char,
14311                           vector bool char,
14312                           vector unsigned char);
14314 vector signed char vec_sl (vector signed char,
14315                            vector unsigned char);
14316 vector unsigned char vec_sl (vector unsigned char,
14317                              vector unsigned char);
14318 vector signed short vec_sl (vector signed short, vector unsigned short);
14319 vector unsigned short vec_sl (vector unsigned short,
14320                               vector unsigned short);
14321 vector signed int vec_sl (vector signed int, vector unsigned int);
14322 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14324 vector signed int vec_vslw (vector signed int, vector unsigned int);
14325 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14327 vector signed short vec_vslh (vector signed short,
14328                               vector unsigned short);
14329 vector unsigned short vec_vslh (vector unsigned short,
14330                                 vector unsigned short);
14332 vector signed char vec_vslb (vector signed char, vector unsigned char);
14333 vector unsigned char vec_vslb (vector unsigned char,
14334                                vector unsigned char);
14336 vector float vec_sld (vector float, vector float, const int);
14337 vector signed int vec_sld (vector signed int,
14338                            vector signed int,
14339                            const int);
14340 vector unsigned int vec_sld (vector unsigned int,
14341                              vector unsigned int,
14342                              const int);
14343 vector bool int vec_sld (vector bool int,
14344                          vector bool int,
14345                          const int);
14346 vector signed short vec_sld (vector signed short,
14347                              vector signed short,
14348                              const int);
14349 vector unsigned short vec_sld (vector unsigned short,
14350                                vector unsigned short,
14351                                const int);
14352 vector bool short vec_sld (vector bool short,
14353                            vector bool short,
14354                            const int);
14355 vector pixel vec_sld (vector pixel,
14356                       vector pixel,
14357                       const int);
14358 vector signed char vec_sld (vector signed char,
14359                             vector signed char,
14360                             const int);
14361 vector unsigned char vec_sld (vector unsigned char,
14362                               vector unsigned char,
14363                               const int);
14364 vector bool char vec_sld (vector bool char,
14365                           vector bool char,
14366                           const int);
14368 vector signed int vec_sll (vector signed int,
14369                            vector unsigned int);
14370 vector signed int vec_sll (vector signed int,
14371                            vector unsigned short);
14372 vector signed int vec_sll (vector signed int,
14373                            vector unsigned char);
14374 vector unsigned int vec_sll (vector unsigned int,
14375                              vector unsigned int);
14376 vector unsigned int vec_sll (vector unsigned int,
14377                              vector unsigned short);
14378 vector unsigned int vec_sll (vector unsigned int,
14379                              vector unsigned char);
14380 vector bool int vec_sll (vector bool int,
14381                          vector unsigned int);
14382 vector bool int vec_sll (vector bool int,
14383                          vector unsigned short);
14384 vector bool int vec_sll (vector bool int,
14385                          vector unsigned char);
14386 vector signed short vec_sll (vector signed short,
14387                              vector unsigned int);
14388 vector signed short vec_sll (vector signed short,
14389                              vector unsigned short);
14390 vector signed short vec_sll (vector signed short,
14391                              vector unsigned char);
14392 vector unsigned short vec_sll (vector unsigned short,
14393                                vector unsigned int);
14394 vector unsigned short vec_sll (vector unsigned short,
14395                                vector unsigned short);
14396 vector unsigned short vec_sll (vector unsigned short,
14397                                vector unsigned char);
14398 vector bool short vec_sll (vector bool short, vector unsigned int);
14399 vector bool short vec_sll (vector bool short, vector unsigned short);
14400 vector bool short vec_sll (vector bool short, vector unsigned char);
14401 vector pixel vec_sll (vector pixel, vector unsigned int);
14402 vector pixel vec_sll (vector pixel, vector unsigned short);
14403 vector pixel vec_sll (vector pixel, vector unsigned char);
14404 vector signed char vec_sll (vector signed char, vector unsigned int);
14405 vector signed char vec_sll (vector signed char, vector unsigned short);
14406 vector signed char vec_sll (vector signed char, vector unsigned char);
14407 vector unsigned char vec_sll (vector unsigned char,
14408                               vector unsigned int);
14409 vector unsigned char vec_sll (vector unsigned char,
14410                               vector unsigned short);
14411 vector unsigned char vec_sll (vector unsigned char,
14412                               vector unsigned char);
14413 vector bool char vec_sll (vector bool char, vector unsigned int);
14414 vector bool char vec_sll (vector bool char, vector unsigned short);
14415 vector bool char vec_sll (vector bool char, vector unsigned char);
14417 vector float vec_slo (vector float, vector signed char);
14418 vector float vec_slo (vector float, vector unsigned char);
14419 vector signed int vec_slo (vector signed int, vector signed char);
14420 vector signed int vec_slo (vector signed int, vector unsigned char);
14421 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14422 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14423 vector signed short vec_slo (vector signed short, vector signed char);
14424 vector signed short vec_slo (vector signed short, vector unsigned char);
14425 vector unsigned short vec_slo (vector unsigned short,
14426                                vector signed char);
14427 vector unsigned short vec_slo (vector unsigned short,
14428                                vector unsigned char);
14429 vector pixel vec_slo (vector pixel, vector signed char);
14430 vector pixel vec_slo (vector pixel, vector unsigned char);
14431 vector signed char vec_slo (vector signed char, vector signed char);
14432 vector signed char vec_slo (vector signed char, vector unsigned char);
14433 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14434 vector unsigned char vec_slo (vector unsigned char,
14435                               vector unsigned char);
14437 vector signed char vec_splat (vector signed char, const int);
14438 vector unsigned char vec_splat (vector unsigned char, const int);
14439 vector bool char vec_splat (vector bool char, const int);
14440 vector signed short vec_splat (vector signed short, const int);
14441 vector unsigned short vec_splat (vector unsigned short, const int);
14442 vector bool short vec_splat (vector bool short, const int);
14443 vector pixel vec_splat (vector pixel, const int);
14444 vector float vec_splat (vector float, const int);
14445 vector signed int vec_splat (vector signed int, const int);
14446 vector unsigned int vec_splat (vector unsigned int, const int);
14447 vector bool int vec_splat (vector bool int, const int);
14448 vector signed long vec_splat (vector signed long, const int);
14449 vector unsigned long vec_splat (vector unsigned long, const int);
14451 vector signed char vec_splats (signed char);
14452 vector unsigned char vec_splats (unsigned char);
14453 vector signed short vec_splats (signed short);
14454 vector unsigned short vec_splats (unsigned short);
14455 vector signed int vec_splats (signed int);
14456 vector unsigned int vec_splats (unsigned int);
14457 vector float vec_splats (float);
14459 vector float vec_vspltw (vector float, const int);
14460 vector signed int vec_vspltw (vector signed int, const int);
14461 vector unsigned int vec_vspltw (vector unsigned int, const int);
14462 vector bool int vec_vspltw (vector bool int, const int);
14464 vector bool short vec_vsplth (vector bool short, const int);
14465 vector signed short vec_vsplth (vector signed short, const int);
14466 vector unsigned short vec_vsplth (vector unsigned short, const int);
14467 vector pixel vec_vsplth (vector pixel, const int);
14469 vector signed char vec_vspltb (vector signed char, const int);
14470 vector unsigned char vec_vspltb (vector unsigned char, const int);
14471 vector bool char vec_vspltb (vector bool char, const int);
14473 vector signed char vec_splat_s8 (const int);
14475 vector signed short vec_splat_s16 (const int);
14477 vector signed int vec_splat_s32 (const int);
14479 vector unsigned char vec_splat_u8 (const int);
14481 vector unsigned short vec_splat_u16 (const int);
14483 vector unsigned int vec_splat_u32 (const int);
14485 vector signed char vec_sr (vector signed char, vector unsigned char);
14486 vector unsigned char vec_sr (vector unsigned char,
14487                              vector unsigned char);
14488 vector signed short vec_sr (vector signed short,
14489                             vector unsigned short);
14490 vector unsigned short vec_sr (vector unsigned short,
14491                               vector unsigned short);
14492 vector signed int vec_sr (vector signed int, vector unsigned int);
14493 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14495 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14496 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14498 vector signed short vec_vsrh (vector signed short,
14499                               vector unsigned short);
14500 vector unsigned short vec_vsrh (vector unsigned short,
14501                                 vector unsigned short);
14503 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14504 vector unsigned char vec_vsrb (vector unsigned char,
14505                                vector unsigned char);
14507 vector signed char vec_sra (vector signed char, vector unsigned char);
14508 vector unsigned char vec_sra (vector unsigned char,
14509                               vector unsigned char);
14510 vector signed short vec_sra (vector signed short,
14511                              vector unsigned short);
14512 vector unsigned short vec_sra (vector unsigned short,
14513                                vector unsigned short);
14514 vector signed int vec_sra (vector signed int, vector unsigned int);
14515 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14517 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14518 vector unsigned int vec_vsraw (vector unsigned int,
14519                                vector unsigned int);
14521 vector signed short vec_vsrah (vector signed short,
14522                                vector unsigned short);
14523 vector unsigned short vec_vsrah (vector unsigned short,
14524                                  vector unsigned short);
14526 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14527 vector unsigned char vec_vsrab (vector unsigned char,
14528                                 vector unsigned char);
14530 vector signed int vec_srl (vector signed int, vector unsigned int);
14531 vector signed int vec_srl (vector signed int, vector unsigned short);
14532 vector signed int vec_srl (vector signed int, vector unsigned char);
14533 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14534 vector unsigned int vec_srl (vector unsigned int,
14535                              vector unsigned short);
14536 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14537 vector bool int vec_srl (vector bool int, vector unsigned int);
14538 vector bool int vec_srl (vector bool int, vector unsigned short);
14539 vector bool int vec_srl (vector bool int, vector unsigned char);
14540 vector signed short vec_srl (vector signed short, vector unsigned int);
14541 vector signed short vec_srl (vector signed short,
14542                              vector unsigned short);
14543 vector signed short vec_srl (vector signed short, vector unsigned char);
14544 vector unsigned short vec_srl (vector unsigned short,
14545                                vector unsigned int);
14546 vector unsigned short vec_srl (vector unsigned short,
14547                                vector unsigned short);
14548 vector unsigned short vec_srl (vector unsigned short,
14549                                vector unsigned char);
14550 vector bool short vec_srl (vector bool short, vector unsigned int);
14551 vector bool short vec_srl (vector bool short, vector unsigned short);
14552 vector bool short vec_srl (vector bool short, vector unsigned char);
14553 vector pixel vec_srl (vector pixel, vector unsigned int);
14554 vector pixel vec_srl (vector pixel, vector unsigned short);
14555 vector pixel vec_srl (vector pixel, vector unsigned char);
14556 vector signed char vec_srl (vector signed char, vector unsigned int);
14557 vector signed char vec_srl (vector signed char, vector unsigned short);
14558 vector signed char vec_srl (vector signed char, vector unsigned char);
14559 vector unsigned char vec_srl (vector unsigned char,
14560                               vector unsigned int);
14561 vector unsigned char vec_srl (vector unsigned char,
14562                               vector unsigned short);
14563 vector unsigned char vec_srl (vector unsigned char,
14564                               vector unsigned char);
14565 vector bool char vec_srl (vector bool char, vector unsigned int);
14566 vector bool char vec_srl (vector bool char, vector unsigned short);
14567 vector bool char vec_srl (vector bool char, vector unsigned char);
14569 vector float vec_sro (vector float, vector signed char);
14570 vector float vec_sro (vector float, vector unsigned char);
14571 vector signed int vec_sro (vector signed int, vector signed char);
14572 vector signed int vec_sro (vector signed int, vector unsigned char);
14573 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14574 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14575 vector signed short vec_sro (vector signed short, vector signed char);
14576 vector signed short vec_sro (vector signed short, vector unsigned char);
14577 vector unsigned short vec_sro (vector unsigned short,
14578                                vector signed char);
14579 vector unsigned short vec_sro (vector unsigned short,
14580                                vector unsigned char);
14581 vector pixel vec_sro (vector pixel, vector signed char);
14582 vector pixel vec_sro (vector pixel, vector unsigned char);
14583 vector signed char vec_sro (vector signed char, vector signed char);
14584 vector signed char vec_sro (vector signed char, vector unsigned char);
14585 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14586 vector unsigned char vec_sro (vector unsigned char,
14587                               vector unsigned char);
14589 void vec_st (vector float, int, vector float *);
14590 void vec_st (vector float, int, float *);
14591 void vec_st (vector signed int, int, vector signed int *);
14592 void vec_st (vector signed int, int, int *);
14593 void vec_st (vector unsigned int, int, vector unsigned int *);
14594 void vec_st (vector unsigned int, int, unsigned int *);
14595 void vec_st (vector bool int, int, vector bool int *);
14596 void vec_st (vector bool int, int, unsigned int *);
14597 void vec_st (vector bool int, int, int *);
14598 void vec_st (vector signed short, int, vector signed short *);
14599 void vec_st (vector signed short, int, short *);
14600 void vec_st (vector unsigned short, int, vector unsigned short *);
14601 void vec_st (vector unsigned short, int, unsigned short *);
14602 void vec_st (vector bool short, int, vector bool short *);
14603 void vec_st (vector bool short, int, unsigned short *);
14604 void vec_st (vector pixel, int, vector pixel *);
14605 void vec_st (vector pixel, int, unsigned short *);
14606 void vec_st (vector pixel, int, short *);
14607 void vec_st (vector bool short, int, short *);
14608 void vec_st (vector signed char, int, vector signed char *);
14609 void vec_st (vector signed char, int, signed char *);
14610 void vec_st (vector unsigned char, int, vector unsigned char *);
14611 void vec_st (vector unsigned char, int, unsigned char *);
14612 void vec_st (vector bool char, int, vector bool char *);
14613 void vec_st (vector bool char, int, unsigned char *);
14614 void vec_st (vector bool char, int, signed char *);
14616 void vec_ste (vector signed char, int, signed char *);
14617 void vec_ste (vector unsigned char, int, unsigned char *);
14618 void vec_ste (vector bool char, int, signed char *);
14619 void vec_ste (vector bool char, int, unsigned char *);
14620 void vec_ste (vector signed short, int, short *);
14621 void vec_ste (vector unsigned short, int, unsigned short *);
14622 void vec_ste (vector bool short, int, short *);
14623 void vec_ste (vector bool short, int, unsigned short *);
14624 void vec_ste (vector pixel, int, short *);
14625 void vec_ste (vector pixel, int, unsigned short *);
14626 void vec_ste (vector float, int, float *);
14627 void vec_ste (vector signed int, int, int *);
14628 void vec_ste (vector unsigned int, int, unsigned int *);
14629 void vec_ste (vector bool int, int, int *);
14630 void vec_ste (vector bool int, int, unsigned int *);
14632 void vec_stvewx (vector float, int, float *);
14633 void vec_stvewx (vector signed int, int, int *);
14634 void vec_stvewx (vector unsigned int, int, unsigned int *);
14635 void vec_stvewx (vector bool int, int, int *);
14636 void vec_stvewx (vector bool int, int, unsigned int *);
14638 void vec_stvehx (vector signed short, int, short *);
14639 void vec_stvehx (vector unsigned short, int, unsigned short *);
14640 void vec_stvehx (vector bool short, int, short *);
14641 void vec_stvehx (vector bool short, int, unsigned short *);
14642 void vec_stvehx (vector pixel, int, short *);
14643 void vec_stvehx (vector pixel, int, unsigned short *);
14645 void vec_stvebx (vector signed char, int, signed char *);
14646 void vec_stvebx (vector unsigned char, int, unsigned char *);
14647 void vec_stvebx (vector bool char, int, signed char *);
14648 void vec_stvebx (vector bool char, int, unsigned char *);
14650 void vec_stl (vector float, int, vector float *);
14651 void vec_stl (vector float, int, float *);
14652 void vec_stl (vector signed int, int, vector signed int *);
14653 void vec_stl (vector signed int, int, int *);
14654 void vec_stl (vector unsigned int, int, vector unsigned int *);
14655 void vec_stl (vector unsigned int, int, unsigned int *);
14656 void vec_stl (vector bool int, int, vector bool int *);
14657 void vec_stl (vector bool int, int, unsigned int *);
14658 void vec_stl (vector bool int, int, int *);
14659 void vec_stl (vector signed short, int, vector signed short *);
14660 void vec_stl (vector signed short, int, short *);
14661 void vec_stl (vector unsigned short, int, vector unsigned short *);
14662 void vec_stl (vector unsigned short, int, unsigned short *);
14663 void vec_stl (vector bool short, int, vector bool short *);
14664 void vec_stl (vector bool short, int, unsigned short *);
14665 void vec_stl (vector bool short, int, short *);
14666 void vec_stl (vector pixel, int, vector pixel *);
14667 void vec_stl (vector pixel, int, unsigned short *);
14668 void vec_stl (vector pixel, int, short *);
14669 void vec_stl (vector signed char, int, vector signed char *);
14670 void vec_stl (vector signed char, int, signed char *);
14671 void vec_stl (vector unsigned char, int, vector unsigned char *);
14672 void vec_stl (vector unsigned char, int, unsigned char *);
14673 void vec_stl (vector bool char, int, vector bool char *);
14674 void vec_stl (vector bool char, int, unsigned char *);
14675 void vec_stl (vector bool char, int, signed char *);
14677 vector signed char vec_sub (vector bool char, vector signed char);
14678 vector signed char vec_sub (vector signed char, vector bool char);
14679 vector signed char vec_sub (vector signed char, vector signed char);
14680 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14681 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14682 vector unsigned char vec_sub (vector unsigned char,
14683                               vector unsigned char);
14684 vector signed short vec_sub (vector bool short, vector signed short);
14685 vector signed short vec_sub (vector signed short, vector bool short);
14686 vector signed short vec_sub (vector signed short, vector signed short);
14687 vector unsigned short vec_sub (vector bool short,
14688                                vector unsigned short);
14689 vector unsigned short vec_sub (vector unsigned short,
14690                                vector bool short);
14691 vector unsigned short vec_sub (vector unsigned short,
14692                                vector unsigned short);
14693 vector signed int vec_sub (vector bool int, vector signed int);
14694 vector signed int vec_sub (vector signed int, vector bool int);
14695 vector signed int vec_sub (vector signed int, vector signed int);
14696 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14697 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14698 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14699 vector float vec_sub (vector float, vector float);
14701 vector float vec_vsubfp (vector float, vector float);
14703 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14704 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14705 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14706 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14707 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14708 vector unsigned int vec_vsubuwm (vector unsigned int,
14709                                  vector unsigned int);
14711 vector signed short vec_vsubuhm (vector bool short,
14712                                  vector signed short);
14713 vector signed short vec_vsubuhm (vector signed short,
14714                                  vector bool short);
14715 vector signed short vec_vsubuhm (vector signed short,
14716                                  vector signed short);
14717 vector unsigned short vec_vsubuhm (vector bool short,
14718                                    vector unsigned short);
14719 vector unsigned short vec_vsubuhm (vector unsigned short,
14720                                    vector bool short);
14721 vector unsigned short vec_vsubuhm (vector unsigned short,
14722                                    vector unsigned short);
14724 vector signed char vec_vsububm (vector bool char, vector signed char);
14725 vector signed char vec_vsububm (vector signed char, vector bool char);
14726 vector signed char vec_vsububm (vector signed char, vector signed char);
14727 vector unsigned char vec_vsububm (vector bool char,
14728                                   vector unsigned char);
14729 vector unsigned char vec_vsububm (vector unsigned char,
14730                                   vector bool char);
14731 vector unsigned char vec_vsububm (vector unsigned char,
14732                                   vector unsigned char);
14734 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14736 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14737 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14738 vector unsigned char vec_subs (vector unsigned char,
14739                                vector unsigned char);
14740 vector signed char vec_subs (vector bool char, vector signed char);
14741 vector signed char vec_subs (vector signed char, vector bool char);
14742 vector signed char vec_subs (vector signed char, vector signed char);
14743 vector unsigned short vec_subs (vector bool short,
14744                                 vector unsigned short);
14745 vector unsigned short vec_subs (vector unsigned short,
14746                                 vector bool short);
14747 vector unsigned short vec_subs (vector unsigned short,
14748                                 vector unsigned short);
14749 vector signed short vec_subs (vector bool short, vector signed short);
14750 vector signed short vec_subs (vector signed short, vector bool short);
14751 vector signed short vec_subs (vector signed short, vector signed short);
14752 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14753 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14754 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14755 vector signed int vec_subs (vector bool int, vector signed int);
14756 vector signed int vec_subs (vector signed int, vector bool int);
14757 vector signed int vec_subs (vector signed int, vector signed int);
14759 vector signed int vec_vsubsws (vector bool int, vector signed int);
14760 vector signed int vec_vsubsws (vector signed int, vector bool int);
14761 vector signed int vec_vsubsws (vector signed int, vector signed int);
14763 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14764 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
14765 vector unsigned int vec_vsubuws (vector unsigned int,
14766                                  vector unsigned int);
14768 vector signed short vec_vsubshs (vector bool short,
14769                                  vector signed short);
14770 vector signed short vec_vsubshs (vector signed short,
14771                                  vector bool short);
14772 vector signed short vec_vsubshs (vector signed short,
14773                                  vector signed short);
14775 vector unsigned short vec_vsubuhs (vector bool short,
14776                                    vector unsigned short);
14777 vector unsigned short vec_vsubuhs (vector unsigned short,
14778                                    vector bool short);
14779 vector unsigned short vec_vsubuhs (vector unsigned short,
14780                                    vector unsigned short);
14782 vector signed char vec_vsubsbs (vector bool char, vector signed char);
14783 vector signed char vec_vsubsbs (vector signed char, vector bool char);
14784 vector signed char vec_vsubsbs (vector signed char, vector signed char);
14786 vector unsigned char vec_vsububs (vector bool char,
14787                                   vector unsigned char);
14788 vector unsigned char vec_vsububs (vector unsigned char,
14789                                   vector bool char);
14790 vector unsigned char vec_vsububs (vector unsigned char,
14791                                   vector unsigned char);
14793 vector unsigned int vec_sum4s (vector unsigned char,
14794                                vector unsigned int);
14795 vector signed int vec_sum4s (vector signed char, vector signed int);
14796 vector signed int vec_sum4s (vector signed short, vector signed int);
14798 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14800 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14802 vector unsigned int vec_vsum4ubs (vector unsigned char,
14803                                   vector unsigned int);
14805 vector signed int vec_sum2s (vector signed int, vector signed int);
14807 vector signed int vec_sums (vector signed int, vector signed int);
14809 vector float vec_trunc (vector float);
14811 vector signed short vec_unpackh (vector signed char);
14812 vector bool short vec_unpackh (vector bool char);
14813 vector signed int vec_unpackh (vector signed short);
14814 vector bool int vec_unpackh (vector bool short);
14815 vector unsigned int vec_unpackh (vector pixel);
14817 vector bool int vec_vupkhsh (vector bool short);
14818 vector signed int vec_vupkhsh (vector signed short);
14820 vector unsigned int vec_vupkhpx (vector pixel);
14822 vector bool short vec_vupkhsb (vector bool char);
14823 vector signed short vec_vupkhsb (vector signed char);
14825 vector signed short vec_unpackl (vector signed char);
14826 vector bool short vec_unpackl (vector bool char);
14827 vector unsigned int vec_unpackl (vector pixel);
14828 vector signed int vec_unpackl (vector signed short);
14829 vector bool int vec_unpackl (vector bool short);
14831 vector unsigned int vec_vupklpx (vector pixel);
14833 vector bool int vec_vupklsh (vector bool short);
14834 vector signed int vec_vupklsh (vector signed short);
14836 vector bool short vec_vupklsb (vector bool char);
14837 vector signed short vec_vupklsb (vector signed char);
14839 vector float vec_xor (vector float, vector float);
14840 vector float vec_xor (vector float, vector bool int);
14841 vector float vec_xor (vector bool int, vector float);
14842 vector bool int vec_xor (vector bool int, vector bool int);
14843 vector signed int vec_xor (vector bool int, vector signed int);
14844 vector signed int vec_xor (vector signed int, vector bool int);
14845 vector signed int vec_xor (vector signed int, vector signed int);
14846 vector unsigned int vec_xor (vector bool int, vector unsigned int);
14847 vector unsigned int vec_xor (vector unsigned int, vector bool int);
14848 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
14849 vector bool short vec_xor (vector bool short, vector bool short);
14850 vector signed short vec_xor (vector bool short, vector signed short);
14851 vector signed short vec_xor (vector signed short, vector bool short);
14852 vector signed short vec_xor (vector signed short, vector signed short);
14853 vector unsigned short vec_xor (vector bool short,
14854                                vector unsigned short);
14855 vector unsigned short vec_xor (vector unsigned short,
14856                                vector bool short);
14857 vector unsigned short vec_xor (vector unsigned short,
14858                                vector unsigned short);
14859 vector signed char vec_xor (vector bool char, vector signed char);
14860 vector bool char vec_xor (vector bool char, vector bool char);
14861 vector signed char vec_xor (vector signed char, vector bool char);
14862 vector signed char vec_xor (vector signed char, vector signed char);
14863 vector unsigned char vec_xor (vector bool char, vector unsigned char);
14864 vector unsigned char vec_xor (vector unsigned char, vector bool char);
14865 vector unsigned char vec_xor (vector unsigned char,
14866                               vector unsigned char);
14868 int vec_all_eq (vector signed char, vector bool char);
14869 int vec_all_eq (vector signed char, vector signed char);
14870 int vec_all_eq (vector unsigned char, vector bool char);
14871 int vec_all_eq (vector unsigned char, vector unsigned char);
14872 int vec_all_eq (vector bool char, vector bool char);
14873 int vec_all_eq (vector bool char, vector unsigned char);
14874 int vec_all_eq (vector bool char, vector signed char);
14875 int vec_all_eq (vector signed short, vector bool short);
14876 int vec_all_eq (vector signed short, vector signed short);
14877 int vec_all_eq (vector unsigned short, vector bool short);
14878 int vec_all_eq (vector unsigned short, vector unsigned short);
14879 int vec_all_eq (vector bool short, vector bool short);
14880 int vec_all_eq (vector bool short, vector unsigned short);
14881 int vec_all_eq (vector bool short, vector signed short);
14882 int vec_all_eq (vector pixel, vector pixel);
14883 int vec_all_eq (vector signed int, vector bool int);
14884 int vec_all_eq (vector signed int, vector signed int);
14885 int vec_all_eq (vector unsigned int, vector bool int);
14886 int vec_all_eq (vector unsigned int, vector unsigned int);
14887 int vec_all_eq (vector bool int, vector bool int);
14888 int vec_all_eq (vector bool int, vector unsigned int);
14889 int vec_all_eq (vector bool int, vector signed int);
14890 int vec_all_eq (vector float, vector float);
14892 int vec_all_ge (vector bool char, vector unsigned char);
14893 int vec_all_ge (vector unsigned char, vector bool char);
14894 int vec_all_ge (vector unsigned char, vector unsigned char);
14895 int vec_all_ge (vector bool char, vector signed char);
14896 int vec_all_ge (vector signed char, vector bool char);
14897 int vec_all_ge (vector signed char, vector signed char);
14898 int vec_all_ge (vector bool short, vector unsigned short);
14899 int vec_all_ge (vector unsigned short, vector bool short);
14900 int vec_all_ge (vector unsigned short, vector unsigned short);
14901 int vec_all_ge (vector signed short, vector signed short);
14902 int vec_all_ge (vector bool short, vector signed short);
14903 int vec_all_ge (vector signed short, vector bool short);
14904 int vec_all_ge (vector bool int, vector unsigned int);
14905 int vec_all_ge (vector unsigned int, vector bool int);
14906 int vec_all_ge (vector unsigned int, vector unsigned int);
14907 int vec_all_ge (vector bool int, vector signed int);
14908 int vec_all_ge (vector signed int, vector bool int);
14909 int vec_all_ge (vector signed int, vector signed int);
14910 int vec_all_ge (vector float, vector float);
14912 int vec_all_gt (vector bool char, vector unsigned char);
14913 int vec_all_gt (vector unsigned char, vector bool char);
14914 int vec_all_gt (vector unsigned char, vector unsigned char);
14915 int vec_all_gt (vector bool char, vector signed char);
14916 int vec_all_gt (vector signed char, vector bool char);
14917 int vec_all_gt (vector signed char, vector signed char);
14918 int vec_all_gt (vector bool short, vector unsigned short);
14919 int vec_all_gt (vector unsigned short, vector bool short);
14920 int vec_all_gt (vector unsigned short, vector unsigned short);
14921 int vec_all_gt (vector bool short, vector signed short);
14922 int vec_all_gt (vector signed short, vector bool short);
14923 int vec_all_gt (vector signed short, vector signed short);
14924 int vec_all_gt (vector bool int, vector unsigned int);
14925 int vec_all_gt (vector unsigned int, vector bool int);
14926 int vec_all_gt (vector unsigned int, vector unsigned int);
14927 int vec_all_gt (vector bool int, vector signed int);
14928 int vec_all_gt (vector signed int, vector bool int);
14929 int vec_all_gt (vector signed int, vector signed int);
14930 int vec_all_gt (vector float, vector float);
14932 int vec_all_in (vector float, vector float);
14934 int vec_all_le (vector bool char, vector unsigned char);
14935 int vec_all_le (vector unsigned char, vector bool char);
14936 int vec_all_le (vector unsigned char, vector unsigned char);
14937 int vec_all_le (vector bool char, vector signed char);
14938 int vec_all_le (vector signed char, vector bool char);
14939 int vec_all_le (vector signed char, vector signed char);
14940 int vec_all_le (vector bool short, vector unsigned short);
14941 int vec_all_le (vector unsigned short, vector bool short);
14942 int vec_all_le (vector unsigned short, vector unsigned short);
14943 int vec_all_le (vector bool short, vector signed short);
14944 int vec_all_le (vector signed short, vector bool short);
14945 int vec_all_le (vector signed short, vector signed short);
14946 int vec_all_le (vector bool int, vector unsigned int);
14947 int vec_all_le (vector unsigned int, vector bool int);
14948 int vec_all_le (vector unsigned int, vector unsigned int);
14949 int vec_all_le (vector bool int, vector signed int);
14950 int vec_all_le (vector signed int, vector bool int);
14951 int vec_all_le (vector signed int, vector signed int);
14952 int vec_all_le (vector float, vector float);
14954 int vec_all_lt (vector bool char, vector unsigned char);
14955 int vec_all_lt (vector unsigned char, vector bool char);
14956 int vec_all_lt (vector unsigned char, vector unsigned char);
14957 int vec_all_lt (vector bool char, vector signed char);
14958 int vec_all_lt (vector signed char, vector bool char);
14959 int vec_all_lt (vector signed char, vector signed char);
14960 int vec_all_lt (vector bool short, vector unsigned short);
14961 int vec_all_lt (vector unsigned short, vector bool short);
14962 int vec_all_lt (vector unsigned short, vector unsigned short);
14963 int vec_all_lt (vector bool short, vector signed short);
14964 int vec_all_lt (vector signed short, vector bool short);
14965 int vec_all_lt (vector signed short, vector signed short);
14966 int vec_all_lt (vector bool int, vector unsigned int);
14967 int vec_all_lt (vector unsigned int, vector bool int);
14968 int vec_all_lt (vector unsigned int, vector unsigned int);
14969 int vec_all_lt (vector bool int, vector signed int);
14970 int vec_all_lt (vector signed int, vector bool int);
14971 int vec_all_lt (vector signed int, vector signed int);
14972 int vec_all_lt (vector float, vector float);
14974 int vec_all_nan (vector float);
14976 int vec_all_ne (vector signed char, vector bool char);
14977 int vec_all_ne (vector signed char, vector signed char);
14978 int vec_all_ne (vector unsigned char, vector bool char);
14979 int vec_all_ne (vector unsigned char, vector unsigned char);
14980 int vec_all_ne (vector bool char, vector bool char);
14981 int vec_all_ne (vector bool char, vector unsigned char);
14982 int vec_all_ne (vector bool char, vector signed char);
14983 int vec_all_ne (vector signed short, vector bool short);
14984 int vec_all_ne (vector signed short, vector signed short);
14985 int vec_all_ne (vector unsigned short, vector bool short);
14986 int vec_all_ne (vector unsigned short, vector unsigned short);
14987 int vec_all_ne (vector bool short, vector bool short);
14988 int vec_all_ne (vector bool short, vector unsigned short);
14989 int vec_all_ne (vector bool short, vector signed short);
14990 int vec_all_ne (vector pixel, vector pixel);
14991 int vec_all_ne (vector signed int, vector bool int);
14992 int vec_all_ne (vector signed int, vector signed int);
14993 int vec_all_ne (vector unsigned int, vector bool int);
14994 int vec_all_ne (vector unsigned int, vector unsigned int);
14995 int vec_all_ne (vector bool int, vector bool int);
14996 int vec_all_ne (vector bool int, vector unsigned int);
14997 int vec_all_ne (vector bool int, vector signed int);
14998 int vec_all_ne (vector float, vector float);
15000 int vec_all_nge (vector float, vector float);
15002 int vec_all_ngt (vector float, vector float);
15004 int vec_all_nle (vector float, vector float);
15006 int vec_all_nlt (vector float, vector float);
15008 int vec_all_numeric (vector float);
15010 int vec_any_eq (vector signed char, vector bool char);
15011 int vec_any_eq (vector signed char, vector signed char);
15012 int vec_any_eq (vector unsigned char, vector bool char);
15013 int vec_any_eq (vector unsigned char, vector unsigned char);
15014 int vec_any_eq (vector bool char, vector bool char);
15015 int vec_any_eq (vector bool char, vector unsigned char);
15016 int vec_any_eq (vector bool char, vector signed char);
15017 int vec_any_eq (vector signed short, vector bool short);
15018 int vec_any_eq (vector signed short, vector signed short);
15019 int vec_any_eq (vector unsigned short, vector bool short);
15020 int vec_any_eq (vector unsigned short, vector unsigned short);
15021 int vec_any_eq (vector bool short, vector bool short);
15022 int vec_any_eq (vector bool short, vector unsigned short);
15023 int vec_any_eq (vector bool short, vector signed short);
15024 int vec_any_eq (vector pixel, vector pixel);
15025 int vec_any_eq (vector signed int, vector bool int);
15026 int vec_any_eq (vector signed int, vector signed int);
15027 int vec_any_eq (vector unsigned int, vector bool int);
15028 int vec_any_eq (vector unsigned int, vector unsigned int);
15029 int vec_any_eq (vector bool int, vector bool int);
15030 int vec_any_eq (vector bool int, vector unsigned int);
15031 int vec_any_eq (vector bool int, vector signed int);
15032 int vec_any_eq (vector float, vector float);
15034 int vec_any_ge (vector signed char, vector bool char);
15035 int vec_any_ge (vector unsigned char, vector bool char);
15036 int vec_any_ge (vector unsigned char, vector unsigned char);
15037 int vec_any_ge (vector signed char, vector signed char);
15038 int vec_any_ge (vector bool char, vector unsigned char);
15039 int vec_any_ge (vector bool char, vector signed char);
15040 int vec_any_ge (vector unsigned short, vector bool short);
15041 int vec_any_ge (vector unsigned short, vector unsigned short);
15042 int vec_any_ge (vector signed short, vector signed short);
15043 int vec_any_ge (vector signed short, vector bool short);
15044 int vec_any_ge (vector bool short, vector unsigned short);
15045 int vec_any_ge (vector bool short, vector signed short);
15046 int vec_any_ge (vector signed int, vector bool int);
15047 int vec_any_ge (vector unsigned int, vector bool int);
15048 int vec_any_ge (vector unsigned int, vector unsigned int);
15049 int vec_any_ge (vector signed int, vector signed int);
15050 int vec_any_ge (vector bool int, vector unsigned int);
15051 int vec_any_ge (vector bool int, vector signed int);
15052 int vec_any_ge (vector float, vector float);
15054 int vec_any_gt (vector bool char, vector unsigned char);
15055 int vec_any_gt (vector unsigned char, vector bool char);
15056 int vec_any_gt (vector unsigned char, vector unsigned char);
15057 int vec_any_gt (vector bool char, vector signed char);
15058 int vec_any_gt (vector signed char, vector bool char);
15059 int vec_any_gt (vector signed char, vector signed char);
15060 int vec_any_gt (vector bool short, vector unsigned short);
15061 int vec_any_gt (vector unsigned short, vector bool short);
15062 int vec_any_gt (vector unsigned short, vector unsigned short);
15063 int vec_any_gt (vector bool short, vector signed short);
15064 int vec_any_gt (vector signed short, vector bool short);
15065 int vec_any_gt (vector signed short, vector signed short);
15066 int vec_any_gt (vector bool int, vector unsigned int);
15067 int vec_any_gt (vector unsigned int, vector bool int);
15068 int vec_any_gt (vector unsigned int, vector unsigned int);
15069 int vec_any_gt (vector bool int, vector signed int);
15070 int vec_any_gt (vector signed int, vector bool int);
15071 int vec_any_gt (vector signed int, vector signed int);
15072 int vec_any_gt (vector float, vector float);
15074 int vec_any_le (vector bool char, vector unsigned char);
15075 int vec_any_le (vector unsigned char, vector bool char);
15076 int vec_any_le (vector unsigned char, vector unsigned char);
15077 int vec_any_le (vector bool char, vector signed char);
15078 int vec_any_le (vector signed char, vector bool char);
15079 int vec_any_le (vector signed char, vector signed char);
15080 int vec_any_le (vector bool short, vector unsigned short);
15081 int vec_any_le (vector unsigned short, vector bool short);
15082 int vec_any_le (vector unsigned short, vector unsigned short);
15083 int vec_any_le (vector bool short, vector signed short);
15084 int vec_any_le (vector signed short, vector bool short);
15085 int vec_any_le (vector signed short, vector signed short);
15086 int vec_any_le (vector bool int, vector unsigned int);
15087 int vec_any_le (vector unsigned int, vector bool int);
15088 int vec_any_le (vector unsigned int, vector unsigned int);
15089 int vec_any_le (vector bool int, vector signed int);
15090 int vec_any_le (vector signed int, vector bool int);
15091 int vec_any_le (vector signed int, vector signed int);
15092 int vec_any_le (vector float, vector float);
15094 int vec_any_lt (vector bool char, vector unsigned char);
15095 int vec_any_lt (vector unsigned char, vector bool char);
15096 int vec_any_lt (vector unsigned char, vector unsigned char);
15097 int vec_any_lt (vector bool char, vector signed char);
15098 int vec_any_lt (vector signed char, vector bool char);
15099 int vec_any_lt (vector signed char, vector signed char);
15100 int vec_any_lt (vector bool short, vector unsigned short);
15101 int vec_any_lt (vector unsigned short, vector bool short);
15102 int vec_any_lt (vector unsigned short, vector unsigned short);
15103 int vec_any_lt (vector bool short, vector signed short);
15104 int vec_any_lt (vector signed short, vector bool short);
15105 int vec_any_lt (vector signed short, vector signed short);
15106 int vec_any_lt (vector bool int, vector unsigned int);
15107 int vec_any_lt (vector unsigned int, vector bool int);
15108 int vec_any_lt (vector unsigned int, vector unsigned int);
15109 int vec_any_lt (vector bool int, vector signed int);
15110 int vec_any_lt (vector signed int, vector bool int);
15111 int vec_any_lt (vector signed int, vector signed int);
15112 int vec_any_lt (vector float, vector float);
15114 int vec_any_nan (vector float);
15116 int vec_any_ne (vector signed char, vector bool char);
15117 int vec_any_ne (vector signed char, vector signed char);
15118 int vec_any_ne (vector unsigned char, vector bool char);
15119 int vec_any_ne (vector unsigned char, vector unsigned char);
15120 int vec_any_ne (vector bool char, vector bool char);
15121 int vec_any_ne (vector bool char, vector unsigned char);
15122 int vec_any_ne (vector bool char, vector signed char);
15123 int vec_any_ne (vector signed short, vector bool short);
15124 int vec_any_ne (vector signed short, vector signed short);
15125 int vec_any_ne (vector unsigned short, vector bool short);
15126 int vec_any_ne (vector unsigned short, vector unsigned short);
15127 int vec_any_ne (vector bool short, vector bool short);
15128 int vec_any_ne (vector bool short, vector unsigned short);
15129 int vec_any_ne (vector bool short, vector signed short);
15130 int vec_any_ne (vector pixel, vector pixel);
15131 int vec_any_ne (vector signed int, vector bool int);
15132 int vec_any_ne (vector signed int, vector signed int);
15133 int vec_any_ne (vector unsigned int, vector bool int);
15134 int vec_any_ne (vector unsigned int, vector unsigned int);
15135 int vec_any_ne (vector bool int, vector bool int);
15136 int vec_any_ne (vector bool int, vector unsigned int);
15137 int vec_any_ne (vector bool int, vector signed int);
15138 int vec_any_ne (vector float, vector float);
15140 int vec_any_nge (vector float, vector float);
15142 int vec_any_ngt (vector float, vector float);
15144 int vec_any_nle (vector float, vector float);
15146 int vec_any_nlt (vector float, vector float);
15148 int vec_any_numeric (vector float);
15150 int vec_any_out (vector float, vector float);
15151 @end smallexample
15153 If the vector/scalar (VSX) instruction set is available, the following
15154 additional functions are available:
15156 @smallexample
15157 vector double vec_abs (vector double);
15158 vector double vec_add (vector double, vector double);
15159 vector double vec_and (vector double, vector double);
15160 vector double vec_and (vector double, vector bool long);
15161 vector double vec_and (vector bool long, vector double);
15162 vector long vec_and (vector long, vector long);
15163 vector long vec_and (vector long, vector bool long);
15164 vector long vec_and (vector bool long, vector long);
15165 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15166 vector unsigned long vec_and (vector unsigned long, vector bool long);
15167 vector unsigned long vec_and (vector bool long, vector unsigned long);
15168 vector double vec_andc (vector double, vector double);
15169 vector double vec_andc (vector double, vector bool long);
15170 vector double vec_andc (vector bool long, vector double);
15171 vector long vec_andc (vector long, vector long);
15172 vector long vec_andc (vector long, vector bool long);
15173 vector long vec_andc (vector bool long, vector long);
15174 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15175 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15176 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15177 vector double vec_ceil (vector double);
15178 vector bool long vec_cmpeq (vector double, vector double);
15179 vector bool long vec_cmpge (vector double, vector double);
15180 vector bool long vec_cmpgt (vector double, vector double);
15181 vector bool long vec_cmple (vector double, vector double);
15182 vector bool long vec_cmplt (vector double, vector double);
15183 vector double vec_cpsgn (vector double, vector double);
15184 vector float vec_div (vector float, vector float);
15185 vector double vec_div (vector double, vector double);
15186 vector long vec_div (vector long, vector long);
15187 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15188 vector double vec_floor (vector double);
15189 vector double vec_ld (int, const vector double *);
15190 vector double vec_ld (int, const double *);
15191 vector double vec_ldl (int, const vector double *);
15192 vector double vec_ldl (int, const double *);
15193 vector unsigned char vec_lvsl (int, const volatile double *);
15194 vector unsigned char vec_lvsr (int, const volatile double *);
15195 vector double vec_madd (vector double, vector double, vector double);
15196 vector double vec_max (vector double, vector double);
15197 vector signed long vec_mergeh (vector signed long, vector signed long);
15198 vector signed long vec_mergeh (vector signed long, vector bool long);
15199 vector signed long vec_mergeh (vector bool long, vector signed long);
15200 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15201 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15202 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15203 vector signed long vec_mergel (vector signed long, vector signed long);
15204 vector signed long vec_mergel (vector signed long, vector bool long);
15205 vector signed long vec_mergel (vector bool long, vector signed long);
15206 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15207 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15208 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15209 vector double vec_min (vector double, vector double);
15210 vector float vec_msub (vector float, vector float, vector float);
15211 vector double vec_msub (vector double, vector double, vector double);
15212 vector float vec_mul (vector float, vector float);
15213 vector double vec_mul (vector double, vector double);
15214 vector long vec_mul (vector long, vector long);
15215 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15216 vector float vec_nearbyint (vector float);
15217 vector double vec_nearbyint (vector double);
15218 vector float vec_nmadd (vector float, vector float, vector float);
15219 vector double vec_nmadd (vector double, vector double, vector double);
15220 vector double vec_nmsub (vector double, vector double, vector double);
15221 vector double vec_nor (vector double, vector double);
15222 vector long vec_nor (vector long, vector long);
15223 vector long vec_nor (vector long, vector bool long);
15224 vector long vec_nor (vector bool long, vector long);
15225 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15226 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15227 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15228 vector double vec_or (vector double, vector double);
15229 vector double vec_or (vector double, vector bool long);
15230 vector double vec_or (vector bool long, vector double);
15231 vector long vec_or (vector long, vector long);
15232 vector long vec_or (vector long, vector bool long);
15233 vector long vec_or (vector bool long, vector long);
15234 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15235 vector unsigned long vec_or (vector unsigned long, vector bool long);
15236 vector unsigned long vec_or (vector bool long, vector unsigned long);
15237 vector double vec_perm (vector double, vector double, vector unsigned char);
15238 vector long vec_perm (vector long, vector long, vector unsigned char);
15239 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15240                                vector unsigned char);
15241 vector double vec_rint (vector double);
15242 vector double vec_recip (vector double, vector double);
15243 vector double vec_rsqrt (vector double);
15244 vector double vec_rsqrte (vector double);
15245 vector double vec_sel (vector double, vector double, vector bool long);
15246 vector double vec_sel (vector double, vector double, vector unsigned long);
15247 vector long vec_sel (vector long, vector long, vector long);
15248 vector long vec_sel (vector long, vector long, vector unsigned long);
15249 vector long vec_sel (vector long, vector long, vector bool long);
15250 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15251                               vector long);
15252 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15253                               vector unsigned long);
15254 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15255                               vector bool long);
15256 vector double vec_splats (double);
15257 vector signed long vec_splats (signed long);
15258 vector unsigned long vec_splats (unsigned long);
15259 vector float vec_sqrt (vector float);
15260 vector double vec_sqrt (vector double);
15261 void vec_st (vector double, int, vector double *);
15262 void vec_st (vector double, int, double *);
15263 vector double vec_sub (vector double, vector double);
15264 vector double vec_trunc (vector double);
15265 vector double vec_xor (vector double, vector double);
15266 vector double vec_xor (vector double, vector bool long);
15267 vector double vec_xor (vector bool long, vector double);
15268 vector long vec_xor (vector long, vector long);
15269 vector long vec_xor (vector long, vector bool long);
15270 vector long vec_xor (vector bool long, vector long);
15271 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15272 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15273 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15274 int vec_all_eq (vector double, vector double);
15275 int vec_all_ge (vector double, vector double);
15276 int vec_all_gt (vector double, vector double);
15277 int vec_all_le (vector double, vector double);
15278 int vec_all_lt (vector double, vector double);
15279 int vec_all_nan (vector double);
15280 int vec_all_ne (vector double, vector double);
15281 int vec_all_nge (vector double, vector double);
15282 int vec_all_ngt (vector double, vector double);
15283 int vec_all_nle (vector double, vector double);
15284 int vec_all_nlt (vector double, vector double);
15285 int vec_all_numeric (vector double);
15286 int vec_any_eq (vector double, vector double);
15287 int vec_any_ge (vector double, vector double);
15288 int vec_any_gt (vector double, vector double);
15289 int vec_any_le (vector double, vector double);
15290 int vec_any_lt (vector double, vector double);
15291 int vec_any_nan (vector double);
15292 int vec_any_ne (vector double, vector double);
15293 int vec_any_nge (vector double, vector double);
15294 int vec_any_ngt (vector double, vector double);
15295 int vec_any_nle (vector double, vector double);
15296 int vec_any_nlt (vector double, vector double);
15297 int vec_any_numeric (vector double);
15299 vector double vec_vsx_ld (int, const vector double *);
15300 vector double vec_vsx_ld (int, const double *);
15301 vector float vec_vsx_ld (int, const vector float *);
15302 vector float vec_vsx_ld (int, const float *);
15303 vector bool int vec_vsx_ld (int, const vector bool int *);
15304 vector signed int vec_vsx_ld (int, const vector signed int *);
15305 vector signed int vec_vsx_ld (int, const int *);
15306 vector signed int vec_vsx_ld (int, const long *);
15307 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15308 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15309 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15310 vector bool short vec_vsx_ld (int, const vector bool short *);
15311 vector pixel vec_vsx_ld (int, const vector pixel *);
15312 vector signed short vec_vsx_ld (int, const vector signed short *);
15313 vector signed short vec_vsx_ld (int, const short *);
15314 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15315 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15316 vector bool char vec_vsx_ld (int, const vector bool char *);
15317 vector signed char vec_vsx_ld (int, const vector signed char *);
15318 vector signed char vec_vsx_ld (int, const signed char *);
15319 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15320 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15322 void vec_vsx_st (vector double, int, vector double *);
15323 void vec_vsx_st (vector double, int, double *);
15324 void vec_vsx_st (vector float, int, vector float *);
15325 void vec_vsx_st (vector float, int, float *);
15326 void vec_vsx_st (vector signed int, int, vector signed int *);
15327 void vec_vsx_st (vector signed int, int, int *);
15328 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15329 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15330 void vec_vsx_st (vector bool int, int, vector bool int *);
15331 void vec_vsx_st (vector bool int, int, unsigned int *);
15332 void vec_vsx_st (vector bool int, int, int *);
15333 void vec_vsx_st (vector signed short, int, vector signed short *);
15334 void vec_vsx_st (vector signed short, int, short *);
15335 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15336 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15337 void vec_vsx_st (vector bool short, int, vector bool short *);
15338 void vec_vsx_st (vector bool short, int, unsigned short *);
15339 void vec_vsx_st (vector pixel, int, vector pixel *);
15340 void vec_vsx_st (vector pixel, int, unsigned short *);
15341 void vec_vsx_st (vector pixel, int, short *);
15342 void vec_vsx_st (vector bool short, int, short *);
15343 void vec_vsx_st (vector signed char, int, vector signed char *);
15344 void vec_vsx_st (vector signed char, int, signed char *);
15345 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15346 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15347 void vec_vsx_st (vector bool char, int, vector bool char *);
15348 void vec_vsx_st (vector bool char, int, unsigned char *);
15349 void vec_vsx_st (vector bool char, int, signed char *);
15351 vector double vec_xxpermdi (vector double, vector double, int);
15352 vector float vec_xxpermdi (vector float, vector float, int);
15353 vector long long vec_xxpermdi (vector long long, vector long long, int);
15354 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15355                                         vector unsigned long long, int);
15356 vector int vec_xxpermdi (vector int, vector int, int);
15357 vector unsigned int vec_xxpermdi (vector unsigned int,
15358                                   vector unsigned int, int);
15359 vector short vec_xxpermdi (vector short, vector short, int);
15360 vector unsigned short vec_xxpermdi (vector unsigned short,
15361                                     vector unsigned short, int);
15362 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15363 vector unsigned char vec_xxpermdi (vector unsigned char,
15364                                    vector unsigned char, int);
15366 vector double vec_xxsldi (vector double, vector double, int);
15367 vector float vec_xxsldi (vector float, vector float, int);
15368 vector long long vec_xxsldi (vector long long, vector long long, int);
15369 vector unsigned long long vec_xxsldi (vector unsigned long long,
15370                                       vector unsigned long long, int);
15371 vector int vec_xxsldi (vector int, vector int, int);
15372 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15373 vector short vec_xxsldi (vector short, vector short, int);
15374 vector unsigned short vec_xxsldi (vector unsigned short,
15375                                   vector unsigned short, int);
15376 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15377 vector unsigned char vec_xxsldi (vector unsigned char,
15378                                  vector unsigned char, int);
15379 @end smallexample
15381 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15382 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15383 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
15384 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15385 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15387 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15388 instruction set is available, the following additional functions are
15389 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
15390 can use @var{vector long} instead of @var{vector long long},
15391 @var{vector bool long} instead of @var{vector bool long long}, and
15392 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15394 @smallexample
15395 vector long long vec_abs (vector long long);
15397 vector long long vec_add (vector long long, vector long long);
15398 vector unsigned long long vec_add (vector unsigned long long,
15399                                    vector unsigned long long);
15401 int vec_all_eq (vector long long, vector long long);
15402 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15403 int vec_all_ge (vector long long, vector long long);
15404 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15405 int vec_all_gt (vector long long, vector long long);
15406 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15407 int vec_all_le (vector long long, vector long long);
15408 int vec_all_le (vector unsigned long long, vector unsigned long long);
15409 int vec_all_lt (vector long long, vector long long);
15410 int vec_all_lt (vector unsigned long long, vector unsigned long long);
15411 int vec_all_ne (vector long long, vector long long);
15412 int vec_all_ne (vector unsigned long long, vector unsigned long long);
15414 int vec_any_eq (vector long long, vector long long);
15415 int vec_any_eq (vector unsigned long long, vector unsigned long long);
15416 int vec_any_ge (vector long long, vector long long);
15417 int vec_any_ge (vector unsigned long long, vector unsigned long long);
15418 int vec_any_gt (vector long long, vector long long);
15419 int vec_any_gt (vector unsigned long long, vector unsigned long long);
15420 int vec_any_le (vector long long, vector long long);
15421 int vec_any_le (vector unsigned long long, vector unsigned long long);
15422 int vec_any_lt (vector long long, vector long long);
15423 int vec_any_lt (vector unsigned long long, vector unsigned long long);
15424 int vec_any_ne (vector long long, vector long long);
15425 int vec_any_ne (vector unsigned long long, vector unsigned long long);
15427 vector long long vec_eqv (vector long long, vector long long);
15428 vector long long vec_eqv (vector bool long long, vector long long);
15429 vector long long vec_eqv (vector long long, vector bool long long);
15430 vector unsigned long long vec_eqv (vector unsigned long long,
15431                                    vector unsigned long long);
15432 vector unsigned long long vec_eqv (vector bool long long,
15433                                    vector unsigned long long);
15434 vector unsigned long long vec_eqv (vector unsigned long long,
15435                                    vector bool long long);
15436 vector int vec_eqv (vector int, vector int);
15437 vector int vec_eqv (vector bool int, vector int);
15438 vector int vec_eqv (vector int, vector bool int);
15439 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15440 vector unsigned int vec_eqv (vector bool unsigned int,
15441                              vector unsigned int);
15442 vector unsigned int vec_eqv (vector unsigned int,
15443                              vector bool unsigned int);
15444 vector short vec_eqv (vector short, vector short);
15445 vector short vec_eqv (vector bool short, vector short);
15446 vector short vec_eqv (vector short, vector bool short);
15447 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15448 vector unsigned short vec_eqv (vector bool unsigned short,
15449                                vector unsigned short);
15450 vector unsigned short vec_eqv (vector unsigned short,
15451                                vector bool unsigned short);
15452 vector signed char vec_eqv (vector signed char, vector signed char);
15453 vector signed char vec_eqv (vector bool signed char, vector signed char);
15454 vector signed char vec_eqv (vector signed char, vector bool signed char);
15455 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15456 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15457 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15459 vector long long vec_max (vector long long, vector long long);
15460 vector unsigned long long vec_max (vector unsigned long long,
15461                                    vector unsigned long long);
15463 vector signed int vec_mergee (vector signed int, vector signed int);
15464 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
15465 vector bool int vec_mergee (vector bool int, vector bool int);
15467 vector signed int vec_mergeo (vector signed int, vector signed int);
15468 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
15469 vector bool int vec_mergeo (vector bool int, vector bool int);
15471 vector long long vec_min (vector long long, vector long long);
15472 vector unsigned long long vec_min (vector unsigned long long,
15473                                    vector unsigned long long);
15475 vector long long vec_nand (vector long long, vector long long);
15476 vector long long vec_nand (vector bool long long, vector long long);
15477 vector long long vec_nand (vector long long, vector bool long long);
15478 vector unsigned long long vec_nand (vector unsigned long long,
15479                                     vector unsigned long long);
15480 vector unsigned long long vec_nand (vector bool long long,
15481                                    vector unsigned long long);
15482 vector unsigned long long vec_nand (vector unsigned long long,
15483                                     vector bool long long);
15484 vector int vec_nand (vector int, vector int);
15485 vector int vec_nand (vector bool int, vector int);
15486 vector int vec_nand (vector int, vector bool int);
15487 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15488 vector unsigned int vec_nand (vector bool unsigned int,
15489                               vector unsigned int);
15490 vector unsigned int vec_nand (vector unsigned int,
15491                               vector bool unsigned int);
15492 vector short vec_nand (vector short, vector short);
15493 vector short vec_nand (vector bool short, vector short);
15494 vector short vec_nand (vector short, vector bool short);
15495 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15496 vector unsigned short vec_nand (vector bool unsigned short,
15497                                 vector unsigned short);
15498 vector unsigned short vec_nand (vector unsigned short,
15499                                 vector bool unsigned short);
15500 vector signed char vec_nand (vector signed char, vector signed char);
15501 vector signed char vec_nand (vector bool signed char, vector signed char);
15502 vector signed char vec_nand (vector signed char, vector bool signed char);
15503 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15504 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15505 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15507 vector long long vec_orc (vector long long, vector long long);
15508 vector long long vec_orc (vector bool long long, vector long long);
15509 vector long long vec_orc (vector long long, vector bool long long);
15510 vector unsigned long long vec_orc (vector unsigned long long,
15511                                    vector unsigned long long);
15512 vector unsigned long long vec_orc (vector bool long long,
15513                                    vector unsigned long long);
15514 vector unsigned long long vec_orc (vector unsigned long long,
15515                                    vector bool long long);
15516 vector int vec_orc (vector int, vector int);
15517 vector int vec_orc (vector bool int, vector int);
15518 vector int vec_orc (vector int, vector bool int);
15519 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15520 vector unsigned int vec_orc (vector bool unsigned int,
15521                              vector unsigned int);
15522 vector unsigned int vec_orc (vector unsigned int,
15523                              vector bool unsigned int);
15524 vector short vec_orc (vector short, vector short);
15525 vector short vec_orc (vector bool short, vector short);
15526 vector short vec_orc (vector short, vector bool short);
15527 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15528 vector unsigned short vec_orc (vector bool unsigned short,
15529                                vector unsigned short);
15530 vector unsigned short vec_orc (vector unsigned short,
15531                                vector bool unsigned short);
15532 vector signed char vec_orc (vector signed char, vector signed char);
15533 vector signed char vec_orc (vector bool signed char, vector signed char);
15534 vector signed char vec_orc (vector signed char, vector bool signed char);
15535 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15536 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15537 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15539 vector int vec_pack (vector long long, vector long long);
15540 vector unsigned int vec_pack (vector unsigned long long,
15541                               vector unsigned long long);
15542 vector bool int vec_pack (vector bool long long, vector bool long long);
15544 vector int vec_packs (vector long long, vector long long);
15545 vector unsigned int vec_packs (vector unsigned long long,
15546                                vector unsigned long long);
15548 vector unsigned int vec_packsu (vector long long, vector long long);
15549 vector unsigned int vec_packsu (vector unsigned long long,
15550                                 vector unsigned long long);
15552 vector long long vec_rl (vector long long,
15553                          vector unsigned long long);
15554 vector long long vec_rl (vector unsigned long long,
15555                          vector unsigned long long);
15557 vector long long vec_sl (vector long long, vector unsigned long long);
15558 vector long long vec_sl (vector unsigned long long,
15559                          vector unsigned long long);
15561 vector long long vec_sr (vector long long, vector unsigned long long);
15562 vector unsigned long long char vec_sr (vector unsigned long long,
15563                                        vector unsigned long long);
15565 vector long long vec_sra (vector long long, vector unsigned long long);
15566 vector unsigned long long vec_sra (vector unsigned long long,
15567                                    vector unsigned long long);
15569 vector long long vec_sub (vector long long, vector long long);
15570 vector unsigned long long vec_sub (vector unsigned long long,
15571                                    vector unsigned long long);
15573 vector long long vec_unpackh (vector int);
15574 vector unsigned long long vec_unpackh (vector unsigned int);
15576 vector long long vec_unpackl (vector int);
15577 vector unsigned long long vec_unpackl (vector unsigned int);
15579 vector long long vec_vaddudm (vector long long, vector long long);
15580 vector long long vec_vaddudm (vector bool long long, vector long long);
15581 vector long long vec_vaddudm (vector long long, vector bool long long);
15582 vector unsigned long long vec_vaddudm (vector unsigned long long,
15583                                        vector unsigned long long);
15584 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15585                                        vector unsigned long long);
15586 vector unsigned long long vec_vaddudm (vector unsigned long long,
15587                                        vector bool unsigned long long);
15589 vector long long vec_vbpermq (vector signed char, vector signed char);
15590 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15592 vector long long vec_cntlz (vector long long);
15593 vector unsigned long long vec_cntlz (vector unsigned long long);
15594 vector int vec_cntlz (vector int);
15595 vector unsigned int vec_cntlz (vector int);
15596 vector short vec_cntlz (vector short);
15597 vector unsigned short vec_cntlz (vector unsigned short);
15598 vector signed char vec_cntlz (vector signed char);
15599 vector unsigned char vec_cntlz (vector unsigned char);
15601 vector long long vec_vclz (vector long long);
15602 vector unsigned long long vec_vclz (vector unsigned long long);
15603 vector int vec_vclz (vector int);
15604 vector unsigned int vec_vclz (vector int);
15605 vector short vec_vclz (vector short);
15606 vector unsigned short vec_vclz (vector unsigned short);
15607 vector signed char vec_vclz (vector signed char);
15608 vector unsigned char vec_vclz (vector unsigned char);
15610 vector signed char vec_vclzb (vector signed char);
15611 vector unsigned char vec_vclzb (vector unsigned char);
15613 vector long long vec_vclzd (vector long long);
15614 vector unsigned long long vec_vclzd (vector unsigned long long);
15616 vector short vec_vclzh (vector short);
15617 vector unsigned short vec_vclzh (vector unsigned short);
15619 vector int vec_vclzw (vector int);
15620 vector unsigned int vec_vclzw (vector int);
15622 vector signed char vec_vgbbd (vector signed char);
15623 vector unsigned char vec_vgbbd (vector unsigned char);
15625 vector long long vec_vmaxsd (vector long long, vector long long);
15627 vector unsigned long long vec_vmaxud (vector unsigned long long,
15628                                       unsigned vector long long);
15630 vector long long vec_vminsd (vector long long, vector long long);
15632 vector unsigned long long vec_vminud (vector long long,
15633                                       vector long long);
15635 vector int vec_vpksdss (vector long long, vector long long);
15636 vector unsigned int vec_vpksdss (vector long long, vector long long);
15638 vector unsigned int vec_vpkudus (vector unsigned long long,
15639                                  vector unsigned long long);
15641 vector int vec_vpkudum (vector long long, vector long long);
15642 vector unsigned int vec_vpkudum (vector unsigned long long,
15643                                  vector unsigned long long);
15644 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15646 vector long long vec_vpopcnt (vector long long);
15647 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15648 vector int vec_vpopcnt (vector int);
15649 vector unsigned int vec_vpopcnt (vector int);
15650 vector short vec_vpopcnt (vector short);
15651 vector unsigned short vec_vpopcnt (vector unsigned short);
15652 vector signed char vec_vpopcnt (vector signed char);
15653 vector unsigned char vec_vpopcnt (vector unsigned char);
15655 vector signed char vec_vpopcntb (vector signed char);
15656 vector unsigned char vec_vpopcntb (vector unsigned char);
15658 vector long long vec_vpopcntd (vector long long);
15659 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15661 vector short vec_vpopcnth (vector short);
15662 vector unsigned short vec_vpopcnth (vector unsigned short);
15664 vector int vec_vpopcntw (vector int);
15665 vector unsigned int vec_vpopcntw (vector int);
15667 vector long long vec_vrld (vector long long, vector unsigned long long);
15668 vector unsigned long long vec_vrld (vector unsigned long long,
15669                                     vector unsigned long long);
15671 vector long long vec_vsld (vector long long, vector unsigned long long);
15672 vector long long vec_vsld (vector unsigned long long,
15673                            vector unsigned long long);
15675 vector long long vec_vsrad (vector long long, vector unsigned long long);
15676 vector unsigned long long vec_vsrad (vector unsigned long long,
15677                                      vector unsigned long long);
15679 vector long long vec_vsrd (vector long long, vector unsigned long long);
15680 vector unsigned long long char vec_vsrd (vector unsigned long long,
15681                                          vector unsigned long long);
15683 vector long long vec_vsubudm (vector long long, vector long long);
15684 vector long long vec_vsubudm (vector bool long long, vector long long);
15685 vector long long vec_vsubudm (vector long long, vector bool long long);
15686 vector unsigned long long vec_vsubudm (vector unsigned long long,
15687                                        vector unsigned long long);
15688 vector unsigned long long vec_vsubudm (vector bool long long,
15689                                        vector unsigned long long);
15690 vector unsigned long long vec_vsubudm (vector unsigned long long,
15691                                        vector bool long long);
15693 vector long long vec_vupkhsw (vector int);
15694 vector unsigned long long vec_vupkhsw (vector unsigned int);
15696 vector long long vec_vupklsw (vector int);
15697 vector unsigned long long vec_vupklsw (vector int);
15698 @end smallexample
15700 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15701 instruction set is available, the following additional functions are
15702 available for 64-bit targets.  New vector types
15703 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
15704 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
15705 builtins.
15707 The normal vector extract, and set operations work on
15708 @var{vector __int128_t} and @var{vector __uint128_t} types,
15709 but the index value must be 0.
15711 @smallexample
15712 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15713 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15715 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
15716 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
15718 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
15719                                 vector __int128_t);
15720 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
15721                                  vector __uint128_t);
15723 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
15724                                 vector __int128_t);
15725 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
15726                                  vector __uint128_t);
15728 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
15729                                 vector __int128_t);
15730 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
15731                                  vector __uint128_t);
15733 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
15734                                 vector __int128_t);
15735 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
15736                                  vector __uint128_t);
15738 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
15739 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
15741 __int128_t vec_vsubuqm (__int128_t, __int128_t);
15742 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
15744 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
15745 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
15746 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
15747 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
15748 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
15749 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
15750 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
15751 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
15752 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
15753 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
15754 @end smallexample
15756 If the cryptographic instructions are enabled (@option{-mcrypto} or
15757 @option{-mcpu=power8}), the following builtins are enabled.
15759 @smallexample
15760 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
15762 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
15763                                                     vector unsigned long long);
15765 vector unsigned long long __builtin_crypto_vcipherlast
15766                                      (vector unsigned long long,
15767                                       vector unsigned long long);
15769 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
15770                                                      vector unsigned long long);
15772 vector unsigned long long __builtin_crypto_vncipherlast
15773                                      (vector unsigned long long,
15774                                       vector unsigned long long);
15776 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
15777                                                 vector unsigned char,
15778                                                 vector unsigned char);
15780 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
15781                                                  vector unsigned short,
15782                                                  vector unsigned short);
15784 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
15785                                                vector unsigned int,
15786                                                vector unsigned int);
15788 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
15789                                                      vector unsigned long long,
15790                                                      vector unsigned long long);
15792 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
15793                                                vector unsigned char);
15795 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15796                                                 vector unsigned short);
15798 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15799                                               vector unsigned int);
15801 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15802                                                     vector unsigned long long);
15804 vector unsigned long long __builtin_crypto_vshasigmad
15805                                (vector unsigned long long, int, int);
15807 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15808                                                  int, int);
15809 @end smallexample
15811 The second argument to the @var{__builtin_crypto_vshasigmad} and
15812 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15813 integer that is 0 or 1.  The third argument to these builtin functions
15814 must be a constant integer in the range of 0 to 15.
15816 @node PowerPC Hardware Transactional Memory Built-in Functions
15817 @subsection PowerPC Hardware Transactional Memory Built-in Functions
15818 GCC provides two interfaces for accessing the Hardware Transactional
15819 Memory (HTM) instructions available on some of the PowerPC family
15820 of processors (eg, POWER8).  The two interfaces come in a low level
15821 interface, consisting of built-in functions specific to PowerPC and a
15822 higher level interface consisting of inline functions that are common
15823 between PowerPC and S/390.
15825 @subsubsection PowerPC HTM Low Level Built-in Functions
15827 The following low level built-in functions are available with
15828 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
15829 They all generate the machine instruction that is part of the name.
15831 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
15832 the full 4-bit condition register value set by their associated hardware
15833 instruction.  The header file @code{htmintrin.h} defines some macros that can
15834 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
15835 returns a simple true or false value depending on whether a transaction was
15836 successfully started or not.  The arguments of the builtins match exactly the
15837 type and order of the associated hardware instruction's operands, except for
15838 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
15839 Refer to the ISA manual for a description of each instruction's operands.
15841 @smallexample
15842 unsigned int __builtin_tbegin (unsigned int)
15843 unsigned int __builtin_tend (unsigned int)
15845 unsigned int __builtin_tabort (unsigned int)
15846 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
15847 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
15848 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
15849 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
15851 unsigned int __builtin_tcheck (void)
15852 unsigned int __builtin_treclaim (unsigned int)
15853 unsigned int __builtin_trechkpt (void)
15854 unsigned int __builtin_tsr (unsigned int)
15855 @end smallexample
15857 In addition to the above HTM built-ins, we have added built-ins for
15858 some common extended mnemonics of the HTM instructions:
15860 @smallexample
15861 unsigned int __builtin_tendall (void)
15862 unsigned int __builtin_tresume (void)
15863 unsigned int __builtin_tsuspend (void)
15864 @end smallexample
15866 The following set of built-in functions are available to gain access
15867 to the HTM specific special purpose registers.
15869 @smallexample
15870 unsigned long __builtin_get_texasr (void)
15871 unsigned long __builtin_get_texasru (void)
15872 unsigned long __builtin_get_tfhar (void)
15873 unsigned long __builtin_get_tfiar (void)
15875 void __builtin_set_texasr (unsigned long);
15876 void __builtin_set_texasru (unsigned long);
15877 void __builtin_set_tfhar (unsigned long);
15878 void __builtin_set_tfiar (unsigned long);
15879 @end smallexample
15881 Example usage of these low level built-in functions may look like:
15883 @smallexample
15884 #include <htmintrin.h>
15886 int num_retries = 10;
15888 while (1)
15889   @{
15890     if (__builtin_tbegin (0))
15891       @{
15892         /* Transaction State Initiated.  */
15893         if (is_locked (lock))
15894           __builtin_tabort (0);
15895         ... transaction code...
15896         __builtin_tend (0);
15897         break;
15898       @}
15899     else
15900       @{
15901         /* Transaction State Failed.  Use locks if the transaction
15902            failure is "persistent" or we've tried too many times.  */
15903         if (num_retries-- <= 0
15904             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
15905           @{
15906             acquire_lock (lock);
15907             ... non transactional fallback path...
15908             release_lock (lock);
15909             break;
15910           @}
15911       @}
15912   @}
15913 @end smallexample
15915 One final built-in function has been added that returns the value of
15916 the 2-bit Transaction State field of the Machine Status Register (MSR)
15917 as stored in @code{CR0}.
15919 @smallexample
15920 unsigned long __builtin_ttest (void)
15921 @end smallexample
15923 This built-in can be used to determine the current transaction state
15924 using the following code example:
15926 @smallexample
15927 #include <htmintrin.h>
15929 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
15931 if (tx_state == _HTM_TRANSACTIONAL)
15932   @{
15933     /* Code to use in transactional state.  */
15934   @}
15935 else if (tx_state == _HTM_NONTRANSACTIONAL)
15936   @{
15937     /* Code to use in non-transactional state.  */
15938   @}
15939 else if (tx_state == _HTM_SUSPENDED)
15940   @{
15941     /* Code to use in transaction suspended state.  */
15942   @}
15943 @end smallexample
15945 @subsubsection PowerPC HTM High Level Inline Functions
15947 The following high level HTM interface is made available by including
15948 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
15949 where CPU is `power8' or later.  This interface is common between PowerPC
15950 and S/390, allowing users to write one HTM source implementation that
15951 can be compiled and executed on either system.
15953 @smallexample
15954 long __TM_simple_begin (void)
15955 long __TM_begin (void* const TM_buff)
15956 long __TM_end (void)
15957 void __TM_abort (void)
15958 void __TM_named_abort (unsigned char const code)
15959 void __TM_resume (void)
15960 void __TM_suspend (void)
15962 long __TM_is_user_abort (void* const TM_buff)
15963 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
15964 long __TM_is_illegal (void* const TM_buff)
15965 long __TM_is_footprint_exceeded (void* const TM_buff)
15966 long __TM_nesting_depth (void* const TM_buff)
15967 long __TM_is_nested_too_deep(void* const TM_buff)
15968 long __TM_is_conflict(void* const TM_buff)
15969 long __TM_is_failure_persistent(void* const TM_buff)
15970 long __TM_failure_address(void* const TM_buff)
15971 long long __TM_failure_code(void* const TM_buff)
15972 @end smallexample
15974 Using these common set of HTM inline functions, we can create
15975 a more portable version of the HTM example in the previous
15976 section that will work on either PowerPC or S/390:
15978 @smallexample
15979 #include <htmxlintrin.h>
15981 int num_retries = 10;
15982 TM_buff_type TM_buff;
15984 while (1)
15985   @{
15986     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
15987       @{
15988         /* Transaction State Initiated.  */
15989         if (is_locked (lock))
15990           __TM_abort ();
15991         ... transaction code...
15992         __TM_end ();
15993         break;
15994       @}
15995     else
15996       @{
15997         /* Transaction State Failed.  Use locks if the transaction
15998            failure is "persistent" or we've tried too many times.  */
15999         if (num_retries-- <= 0
16000             || __TM_is_failure_persistent (TM_buff))
16001           @{
16002             acquire_lock (lock);
16003             ... non transactional fallback path...
16004             release_lock (lock);
16005             break;
16006           @}
16007       @}
16008   @}
16009 @end smallexample
16011 @node RX Built-in Functions
16012 @subsection RX Built-in Functions
16013 GCC supports some of the RX instructions which cannot be expressed in
16014 the C programming language via the use of built-in functions.  The
16015 following functions are supported:
16017 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
16018 Generates the @code{brk} machine instruction.
16019 @end deftypefn
16021 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
16022 Generates the @code{clrpsw} machine instruction to clear the specified
16023 bit in the processor status word.
16024 @end deftypefn
16026 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
16027 Generates the @code{int} machine instruction to generate an interrupt
16028 with the specified value.
16029 @end deftypefn
16031 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
16032 Generates the @code{machi} machine instruction to add the result of
16033 multiplying the top 16 bits of the two arguments into the
16034 accumulator.
16035 @end deftypefn
16037 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
16038 Generates the @code{maclo} machine instruction to add the result of
16039 multiplying the bottom 16 bits of the two arguments into the
16040 accumulator.
16041 @end deftypefn
16043 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
16044 Generates the @code{mulhi} machine instruction to place the result of
16045 multiplying the top 16 bits of the two arguments into the
16046 accumulator.
16047 @end deftypefn
16049 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
16050 Generates the @code{mullo} machine instruction to place the result of
16051 multiplying the bottom 16 bits of the two arguments into the
16052 accumulator.
16053 @end deftypefn
16055 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
16056 Generates the @code{mvfachi} machine instruction to read the top
16057 32 bits of the accumulator.
16058 @end deftypefn
16060 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
16061 Generates the @code{mvfacmi} machine instruction to read the middle
16062 32 bits of the accumulator.
16063 @end deftypefn
16065 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
16066 Generates the @code{mvfc} machine instruction which reads the control
16067 register specified in its argument and returns its value.
16068 @end deftypefn
16070 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
16071 Generates the @code{mvtachi} machine instruction to set the top
16072 32 bits of the accumulator.
16073 @end deftypefn
16075 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
16076 Generates the @code{mvtaclo} machine instruction to set the bottom
16077 32 bits of the accumulator.
16078 @end deftypefn
16080 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
16081 Generates the @code{mvtc} machine instruction which sets control
16082 register number @code{reg} to @code{val}.
16083 @end deftypefn
16085 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
16086 Generates the @code{mvtipl} machine instruction set the interrupt
16087 priority level.
16088 @end deftypefn
16090 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
16091 Generates the @code{racw} machine instruction to round the accumulator
16092 according to the specified mode.
16093 @end deftypefn
16095 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
16096 Generates the @code{revw} machine instruction which swaps the bytes in
16097 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16098 and also bits 16--23 occupy bits 24--31 and vice versa.
16099 @end deftypefn
16101 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
16102 Generates the @code{rmpa} machine instruction which initiates a
16103 repeated multiply and accumulate sequence.
16104 @end deftypefn
16106 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
16107 Generates the @code{round} machine instruction which returns the
16108 floating-point argument rounded according to the current rounding mode
16109 set in the floating-point status word register.
16110 @end deftypefn
16112 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
16113 Generates the @code{sat} machine instruction which returns the
16114 saturated value of the argument.
16115 @end deftypefn
16117 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
16118 Generates the @code{setpsw} machine instruction to set the specified
16119 bit in the processor status word.
16120 @end deftypefn
16122 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
16123 Generates the @code{wait} machine instruction.
16124 @end deftypefn
16126 @node S/390 System z Built-in Functions
16127 @subsection S/390 System z Built-in Functions
16128 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16129 Generates the @code{tbegin} machine instruction starting a
16130 non-constraint hardware transaction.  If the parameter is non-NULL the
16131 memory area is used to store the transaction diagnostic buffer and
16132 will be passed as first operand to @code{tbegin}.  This buffer can be
16133 defined using the @code{struct __htm_tdb} C struct defined in
16134 @code{htmintrin.h} and must reside on a double-word boundary.  The
16135 second tbegin operand is set to @code{0xff0c}. This enables
16136 save/restore of all GPRs and disables aborts for FPR and AR
16137 manipulations inside the transaction body.  The condition code set by
16138 the tbegin instruction is returned as integer value.  The tbegin
16139 instruction by definition overwrites the content of all FPRs.  The
16140 compiler will generate code which saves and restores the FPRs.  For
16141 soft-float code it is recommended to used the @code{*_nofloat}
16142 variant.  In order to prevent a TDB from being written it is required
16143 to pass an constant zero value as parameter.  Passing the zero value
16144 through a variable is not sufficient.  Although modifications of
16145 access registers inside the transaction will not trigger an
16146 transaction abort it is not supported to actually modify them.  Access
16147 registers do not get saved when entering a transaction. They will have
16148 undefined state when reaching the abort code.
16149 @end deftypefn
16151 Macros for the possible return codes of tbegin are defined in the
16152 @code{htmintrin.h} header file:
16154 @table @code
16155 @item _HTM_TBEGIN_STARTED
16156 @code{tbegin} has been executed as part of normal processing.  The
16157 transaction body is supposed to be executed.
16158 @item _HTM_TBEGIN_INDETERMINATE
16159 The transaction was aborted due to an indeterminate condition which
16160 might be persistent.
16161 @item _HTM_TBEGIN_TRANSIENT
16162 The transaction aborted due to a transient failure.  The transaction
16163 should be re-executed in that case.
16164 @item _HTM_TBEGIN_PERSISTENT
16165 The transaction aborted due to a persistent failure.  Re-execution
16166 under same circumstances will not be productive.
16167 @end table
16169 @defmac _HTM_FIRST_USER_ABORT_CODE
16170 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16171 specifies the first abort code which can be used for
16172 @code{__builtin_tabort}.  Values below this threshold are reserved for
16173 machine use.
16174 @end defmac
16176 @deftp {Data type} {struct __htm_tdb}
16177 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16178 the structure of the transaction diagnostic block as specified in the
16179 Principles of Operation manual chapter 5-91.
16180 @end deftp
16182 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16183 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16184 Using this variant in code making use of FPRs will leave the FPRs in
16185 undefined state when entering the transaction abort handler code.
16186 @end deftypefn
16188 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16189 In addition to @code{__builtin_tbegin} a loop for transient failures
16190 is generated.  If tbegin returns a condition code of 2 the transaction
16191 will be retried as often as specified in the second argument.  The
16192 perform processor assist instruction is used to tell the CPU about the
16193 number of fails so far.
16194 @end deftypefn
16196 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16197 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16198 restores.  Using this variant in code making use of FPRs will leave
16199 the FPRs in undefined state when entering the transaction abort
16200 handler code.
16201 @end deftypefn
16203 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16204 Generates the @code{tbeginc} machine instruction starting a constraint
16205 hardware transaction.  The second operand is set to @code{0xff08}.
16206 @end deftypefn
16208 @deftypefn {Built-in Function} int __builtin_tend (void)
16209 Generates the @code{tend} machine instruction finishing a transaction
16210 and making the changes visible to other threads.  The condition code
16211 generated by tend is returned as integer value.
16212 @end deftypefn
16214 @deftypefn {Built-in Function} void __builtin_tabort (int)
16215 Generates the @code{tabort} machine instruction with the specified
16216 abort code.  Abort codes from 0 through 255 are reserved and will
16217 result in an error message.
16218 @end deftypefn
16220 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16221 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16222 integer parameter is loaded into rX and a value of zero is loaded into
16223 rY.  The integer parameter specifies the number of times the
16224 transaction repeatedly aborted.
16225 @end deftypefn
16227 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16228 Generates the @code{etnd} machine instruction.  The current nesting
16229 depth is returned as integer value.  For a nesting depth of 0 the code
16230 is not executed as part of an transaction.
16231 @end deftypefn
16233 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16235 Generates the @code{ntstg} machine instruction.  The second argument
16236 is written to the first arguments location.  The store operation will
16237 not be rolled-back in case of an transaction abort.
16238 @end deftypefn
16240 @node SH Built-in Functions
16241 @subsection SH Built-in Functions
16242 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16243 families of processors:
16245 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16246 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16247 used by system code that manages threads and execution contexts.  The compiler
16248 normally does not generate code that modifies the contents of @samp{GBR} and
16249 thus the value is preserved across function calls.  Changing the @samp{GBR}
16250 value in user code must be done with caution, since the compiler might use
16251 @samp{GBR} in order to access thread local variables.
16253 @end deftypefn
16255 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16256 Returns the value that is currently set in the @samp{GBR} register.
16257 Memory loads and stores that use the thread pointer as a base address are
16258 turned into @samp{GBR} based displacement loads and stores, if possible.
16259 For example:
16260 @smallexample
16261 struct my_tcb
16263    int a, b, c, d, e;
16266 int get_tcb_value (void)
16268   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16269   return ((my_tcb*)__builtin_thread_pointer ())->c;
16272 @end smallexample
16273 @end deftypefn
16275 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16276 Returns the value that is currently set in the @samp{FPSCR} register.
16277 @end deftypefn
16279 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16280 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16281 preserving the current values of the FR, SZ and PR bits.
16282 @end deftypefn
16284 @node SPARC VIS Built-in Functions
16285 @subsection SPARC VIS Built-in Functions
16287 GCC supports SIMD operations on the SPARC using both the generic vector
16288 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16289 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16290 switch, the VIS extension is exposed as the following built-in functions:
16292 @smallexample
16293 typedef int v1si __attribute__ ((vector_size (4)));
16294 typedef int v2si __attribute__ ((vector_size (8)));
16295 typedef short v4hi __attribute__ ((vector_size (8)));
16296 typedef short v2hi __attribute__ ((vector_size (4)));
16297 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16298 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16300 void __builtin_vis_write_gsr (int64_t);
16301 int64_t __builtin_vis_read_gsr (void);
16303 void * __builtin_vis_alignaddr (void *, long);
16304 void * __builtin_vis_alignaddrl (void *, long);
16305 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16306 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16307 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16308 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16310 v4hi __builtin_vis_fexpand (v4qi);
16312 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16313 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16314 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16315 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16316 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16317 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16318 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16320 v4qi __builtin_vis_fpack16 (v4hi);
16321 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16322 v2hi __builtin_vis_fpackfix (v2si);
16323 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16325 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16327 long __builtin_vis_edge8 (void *, void *);
16328 long __builtin_vis_edge8l (void *, void *);
16329 long __builtin_vis_edge16 (void *, void *);
16330 long __builtin_vis_edge16l (void *, void *);
16331 long __builtin_vis_edge32 (void *, void *);
16332 long __builtin_vis_edge32l (void *, void *);
16334 long __builtin_vis_fcmple16 (v4hi, v4hi);
16335 long __builtin_vis_fcmple32 (v2si, v2si);
16336 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16337 long __builtin_vis_fcmpne32 (v2si, v2si);
16338 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16339 long __builtin_vis_fcmpgt32 (v2si, v2si);
16340 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16341 long __builtin_vis_fcmpeq32 (v2si, v2si);
16343 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16344 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16345 v2si __builtin_vis_fpadd32 (v2si, v2si);
16346 v1si __builtin_vis_fpadd32s (v1si, v1si);
16347 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16348 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16349 v2si __builtin_vis_fpsub32 (v2si, v2si);
16350 v1si __builtin_vis_fpsub32s (v1si, v1si);
16352 long __builtin_vis_array8 (long, long);
16353 long __builtin_vis_array16 (long, long);
16354 long __builtin_vis_array32 (long, long);
16355 @end smallexample
16357 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16358 functions also become available:
16360 @smallexample
16361 long __builtin_vis_bmask (long, long);
16362 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16363 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16364 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16365 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16367 long __builtin_vis_edge8n (void *, void *);
16368 long __builtin_vis_edge8ln (void *, void *);
16369 long __builtin_vis_edge16n (void *, void *);
16370 long __builtin_vis_edge16ln (void *, void *);
16371 long __builtin_vis_edge32n (void *, void *);
16372 long __builtin_vis_edge32ln (void *, void *);
16373 @end smallexample
16375 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16376 functions also become available:
16378 @smallexample
16379 void __builtin_vis_cmask8 (long);
16380 void __builtin_vis_cmask16 (long);
16381 void __builtin_vis_cmask32 (long);
16383 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16385 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16386 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16387 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16388 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16389 v2si __builtin_vis_fsll16 (v2si, v2si);
16390 v2si __builtin_vis_fslas16 (v2si, v2si);
16391 v2si __builtin_vis_fsrl16 (v2si, v2si);
16392 v2si __builtin_vis_fsra16 (v2si, v2si);
16394 long __builtin_vis_pdistn (v8qi, v8qi);
16396 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16398 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16399 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16401 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16402 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16403 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16404 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16405 v2si __builtin_vis_fpadds32 (v2si, v2si);
16406 v1si __builtin_vis_fpadds32s (v1si, v1si);
16407 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16408 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16410 long __builtin_vis_fucmple8 (v8qi, v8qi);
16411 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16412 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16413 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16415 float __builtin_vis_fhadds (float, float);
16416 double __builtin_vis_fhaddd (double, double);
16417 float __builtin_vis_fhsubs (float, float);
16418 double __builtin_vis_fhsubd (double, double);
16419 float __builtin_vis_fnhadds (float, float);
16420 double __builtin_vis_fnhaddd (double, double);
16422 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16423 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16424 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16425 @end smallexample
16427 @node SPU Built-in Functions
16428 @subsection SPU Built-in Functions
16430 GCC provides extensions for the SPU processor as described in the
16431 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16432 found at @uref{http://cell.scei.co.jp/} or
16433 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
16434 implementation differs in several ways.
16436 @itemize @bullet
16438 @item
16439 The optional extension of specifying vector constants in parentheses is
16440 not supported.
16442 @item
16443 A vector initializer requires no cast if the vector constant is of the
16444 same type as the variable it is initializing.
16446 @item
16447 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16448 vector type is the default signedness of the base type.  The default
16449 varies depending on the operating system, so a portable program should
16450 always specify the signedness.
16452 @item
16453 By default, the keyword @code{__vector} is added. The macro
16454 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16455 undefined.
16457 @item
16458 GCC allows using a @code{typedef} name as the type specifier for a
16459 vector type.
16461 @item
16462 For C, overloaded functions are implemented with macros so the following
16463 does not work:
16465 @smallexample
16466   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16467 @end smallexample
16469 @noindent
16470 Since @code{spu_add} is a macro, the vector constant in the example
16471 is treated as four separate arguments.  Wrap the entire argument in
16472 parentheses for this to work.
16474 @item
16475 The extended version of @code{__builtin_expect} is not supported.
16477 @end itemize
16479 @emph{Note:} Only the interface described in the aforementioned
16480 specification is supported. Internally, GCC uses built-in functions to
16481 implement the required functionality, but these are not supported and
16482 are subject to change without notice.
16484 @node TI C6X Built-in Functions
16485 @subsection TI C6X Built-in Functions
16487 GCC provides intrinsics to access certain instructions of the TI C6X
16488 processors.  These intrinsics, listed below, are available after
16489 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
16490 to C6X instructions.
16492 @smallexample
16494 int _sadd (int, int)
16495 int _ssub (int, int)
16496 int _sadd2 (int, int)
16497 int _ssub2 (int, int)
16498 long long _mpy2 (int, int)
16499 long long _smpy2 (int, int)
16500 int _add4 (int, int)
16501 int _sub4 (int, int)
16502 int _saddu4 (int, int)
16504 int _smpy (int, int)
16505 int _smpyh (int, int)
16506 int _smpyhl (int, int)
16507 int _smpylh (int, int)
16509 int _sshl (int, int)
16510 int _subc (int, int)
16512 int _avg2 (int, int)
16513 int _avgu4 (int, int)
16515 int _clrr (int, int)
16516 int _extr (int, int)
16517 int _extru (int, int)
16518 int _abs (int)
16519 int _abs2 (int)
16521 @end smallexample
16523 @node TILE-Gx Built-in Functions
16524 @subsection TILE-Gx Built-in Functions
16526 GCC provides intrinsics to access every instruction of the TILE-Gx
16527 processor.  The intrinsics are of the form:
16529 @smallexample
16531 unsigned long long __insn_@var{op} (...)
16533 @end smallexample
16535 Where @var{op} is the name of the instruction.  Refer to the ISA manual
16536 for the complete list of instructions.
16538 GCC also provides intrinsics to directly access the network registers.
16539 The intrinsics are:
16541 @smallexample
16543 unsigned long long __tile_idn0_receive (void)
16544 unsigned long long __tile_idn1_receive (void)
16545 unsigned long long __tile_udn0_receive (void)
16546 unsigned long long __tile_udn1_receive (void)
16547 unsigned long long __tile_udn2_receive (void)
16548 unsigned long long __tile_udn3_receive (void)
16549 void __tile_idn_send (unsigned long long)
16550 void __tile_udn_send (unsigned long long)
16552 @end smallexample
16554 The intrinsic @code{void __tile_network_barrier (void)} is used to
16555 guarantee that no network operations before it are reordered with
16556 those after it.
16558 @node TILEPro Built-in Functions
16559 @subsection TILEPro Built-in Functions
16561 GCC provides intrinsics to access every instruction of the TILEPro
16562 processor.  The intrinsics are of the form:
16564 @smallexample
16566 unsigned __insn_@var{op} (...)
16568 @end smallexample
16570 @noindent
16571 where @var{op} is the name of the instruction.  Refer to the ISA manual
16572 for the complete list of instructions.
16574 GCC also provides intrinsics to directly access the network registers.
16575 The intrinsics are:
16577 @smallexample
16579 unsigned __tile_idn0_receive (void)
16580 unsigned __tile_idn1_receive (void)
16581 unsigned __tile_sn_receive (void)
16582 unsigned __tile_udn0_receive (void)
16583 unsigned __tile_udn1_receive (void)
16584 unsigned __tile_udn2_receive (void)
16585 unsigned __tile_udn3_receive (void)
16586 void __tile_idn_send (unsigned)
16587 void __tile_sn_send (unsigned)
16588 void __tile_udn_send (unsigned)
16590 @end smallexample
16592 The intrinsic @code{void __tile_network_barrier (void)} is used to
16593 guarantee that no network operations before it are reordered with
16594 those after it.
16596 @node x86 Built-in Functions
16597 @subsection x86 Built-in Functions
16599 These built-in functions are available for the x86-32 and x86-64 family
16600 of computers, depending on the command-line switches used.
16602 If you specify command-line switches such as @option{-msse},
16603 the compiler could use the extended instruction sets even if the built-ins
16604 are not used explicitly in the program.  For this reason, applications
16605 that perform run-time CPU detection must compile separate files for each
16606 supported architecture, using the appropriate flags.  In particular,
16607 the file containing the CPU detection code should be compiled without
16608 these options.
16610 The following machine modes are available for use with MMX built-in functions
16611 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
16612 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
16613 vector of eight 8-bit integers.  Some of the built-in functions operate on
16614 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
16616 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
16617 of two 32-bit floating-point values.
16619 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
16620 floating-point values.  Some instructions use a vector of four 32-bit
16621 integers, these use @code{V4SI}.  Finally, some instructions operate on an
16622 entire vector register, interpreting it as a 128-bit integer, these use mode
16623 @code{TI}.
16625 In 64-bit mode, the x86-64 family of processors uses additional built-in
16626 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
16627 floating point and @code{TC} 128-bit complex floating-point values.
16629 The following floating-point built-in functions are available in 64-bit
16630 mode.  All of them implement the function that is part of the name.
16632 @smallexample
16633 __float128 __builtin_fabsq (__float128)
16634 __float128 __builtin_copysignq (__float128, __float128)
16635 @end smallexample
16637 The following built-in function is always available.
16639 @table @code
16640 @item void __builtin_ia32_pause (void)
16641 Generates the @code{pause} machine instruction with a compiler memory
16642 barrier.
16643 @end table
16645 The following floating-point built-in functions are made available in the
16646 64-bit mode.
16648 @table @code
16649 @item __float128 __builtin_infq (void)
16650 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
16651 @findex __builtin_infq
16653 @item __float128 __builtin_huge_valq (void)
16654 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
16655 @findex __builtin_huge_valq
16656 @end table
16658 The following built-in functions are always available and can be used to
16659 check the target platform type.
16661 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
16662 This function runs the CPU detection code to check the type of CPU and the
16663 features supported.  This built-in function needs to be invoked along with the built-in functions
16664 to check CPU type and features, @code{__builtin_cpu_is} and
16665 @code{__builtin_cpu_supports}, only when used in a function that is
16666 executed before any constructors are called.  The CPU detection code is
16667 automatically executed in a very high priority constructor.
16669 For example, this function has to be used in @code{ifunc} resolvers that
16670 check for CPU type using the built-in functions @code{__builtin_cpu_is}
16671 and @code{__builtin_cpu_supports}, or in constructors on targets that
16672 don't support constructor priority.
16673 @smallexample
16675 static void (*resolve_memcpy (void)) (void)
16677   // ifunc resolvers fire before constructors, explicitly call the init
16678   // function.
16679   __builtin_cpu_init ();
16680   if (__builtin_cpu_supports ("ssse3"))
16681     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
16682   else
16683     return default_memcpy;
16686 void *memcpy (void *, const void *, size_t)
16687      __attribute__ ((ifunc ("resolve_memcpy")));
16688 @end smallexample
16690 @end deftypefn
16692 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
16693 This function returns a positive integer if the run-time CPU
16694 is of type @var{cpuname}
16695 and returns @code{0} otherwise. The following CPU names can be detected:
16697 @table @samp
16698 @item intel
16699 Intel CPU.
16701 @item atom
16702 Intel Atom CPU.
16704 @item core2
16705 Intel Core 2 CPU.
16707 @item corei7
16708 Intel Core i7 CPU.
16710 @item nehalem
16711 Intel Core i7 Nehalem CPU.
16713 @item westmere
16714 Intel Core i7 Westmere CPU.
16716 @item sandybridge
16717 Intel Core i7 Sandy Bridge CPU.
16719 @item amd
16720 AMD CPU.
16722 @item amdfam10h
16723 AMD Family 10h CPU.
16725 @item barcelona
16726 AMD Family 10h Barcelona CPU.
16728 @item shanghai
16729 AMD Family 10h Shanghai CPU.
16731 @item istanbul
16732 AMD Family 10h Istanbul CPU.
16734 @item btver1
16735 AMD Family 14h CPU.
16737 @item amdfam15h
16738 AMD Family 15h CPU.
16740 @item bdver1
16741 AMD Family 15h Bulldozer version 1.
16743 @item bdver2
16744 AMD Family 15h Bulldozer version 2.
16746 @item bdver3
16747 AMD Family 15h Bulldozer version 3.
16749 @item bdver4
16750 AMD Family 15h Bulldozer version 4.
16752 @item btver2
16753 AMD Family 16h CPU.
16754 @end table
16756 Here is an example:
16757 @smallexample
16758 if (__builtin_cpu_is ("corei7"))
16759   @{
16760      do_corei7 (); // Core i7 specific implementation.
16761   @}
16762 else
16763   @{
16764      do_generic (); // Generic implementation.
16765   @}
16766 @end smallexample
16767 @end deftypefn
16769 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
16770 This function returns a positive integer if the run-time CPU
16771 supports @var{feature}
16772 and returns @code{0} otherwise. The following features can be detected:
16774 @table @samp
16775 @item cmov
16776 CMOV instruction.
16777 @item mmx
16778 MMX instructions.
16779 @item popcnt
16780 POPCNT instruction.
16781 @item sse
16782 SSE instructions.
16783 @item sse2
16784 SSE2 instructions.
16785 @item sse3
16786 SSE3 instructions.
16787 @item ssse3
16788 SSSE3 instructions.
16789 @item sse4.1
16790 SSE4.1 instructions.
16791 @item sse4.2
16792 SSE4.2 instructions.
16793 @item avx
16794 AVX instructions.
16795 @item avx2
16796 AVX2 instructions.
16797 @item avx512f
16798 AVX512F instructions.
16799 @end table
16801 Here is an example:
16802 @smallexample
16803 if (__builtin_cpu_supports ("popcnt"))
16804   @{
16805      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
16806   @}
16807 else
16808   @{
16809      count = generic_countbits (n); //generic implementation.
16810   @}
16811 @end smallexample
16812 @end deftypefn
16815 The following built-in functions are made available by @option{-mmmx}.
16816 All of them generate the machine instruction that is part of the name.
16818 @smallexample
16819 v8qi __builtin_ia32_paddb (v8qi, v8qi)
16820 v4hi __builtin_ia32_paddw (v4hi, v4hi)
16821 v2si __builtin_ia32_paddd (v2si, v2si)
16822 v8qi __builtin_ia32_psubb (v8qi, v8qi)
16823 v4hi __builtin_ia32_psubw (v4hi, v4hi)
16824 v2si __builtin_ia32_psubd (v2si, v2si)
16825 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
16826 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
16827 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
16828 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
16829 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
16830 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
16831 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
16832 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
16833 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
16834 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
16835 di __builtin_ia32_pand (di, di)
16836 di __builtin_ia32_pandn (di,di)
16837 di __builtin_ia32_por (di, di)
16838 di __builtin_ia32_pxor (di, di)
16839 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
16840 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
16841 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
16842 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
16843 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
16844 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
16845 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
16846 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
16847 v2si __builtin_ia32_punpckhdq (v2si, v2si)
16848 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
16849 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
16850 v2si __builtin_ia32_punpckldq (v2si, v2si)
16851 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
16852 v4hi __builtin_ia32_packssdw (v2si, v2si)
16853 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
16855 v4hi __builtin_ia32_psllw (v4hi, v4hi)
16856 v2si __builtin_ia32_pslld (v2si, v2si)
16857 v1di __builtin_ia32_psllq (v1di, v1di)
16858 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
16859 v2si __builtin_ia32_psrld (v2si, v2si)
16860 v1di __builtin_ia32_psrlq (v1di, v1di)
16861 v4hi __builtin_ia32_psraw (v4hi, v4hi)
16862 v2si __builtin_ia32_psrad (v2si, v2si)
16863 v4hi __builtin_ia32_psllwi (v4hi, int)
16864 v2si __builtin_ia32_pslldi (v2si, int)
16865 v1di __builtin_ia32_psllqi (v1di, int)
16866 v4hi __builtin_ia32_psrlwi (v4hi, int)
16867 v2si __builtin_ia32_psrldi (v2si, int)
16868 v1di __builtin_ia32_psrlqi (v1di, int)
16869 v4hi __builtin_ia32_psrawi (v4hi, int)
16870 v2si __builtin_ia32_psradi (v2si, int)
16872 @end smallexample
16874 The following built-in functions are made available either with
16875 @option{-msse}, or with a combination of @option{-m3dnow} and
16876 @option{-march=athlon}.  All of them generate the machine
16877 instruction that is part of the name.
16879 @smallexample
16880 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
16881 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
16882 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
16883 v1di __builtin_ia32_psadbw (v8qi, v8qi)
16884 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
16885 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
16886 v8qi __builtin_ia32_pminub (v8qi, v8qi)
16887 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
16888 int __builtin_ia32_pmovmskb (v8qi)
16889 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
16890 void __builtin_ia32_movntq (di *, di)
16891 void __builtin_ia32_sfence (void)
16892 @end smallexample
16894 The following built-in functions are available when @option{-msse} is used.
16895 All of them generate the machine instruction that is part of the name.
16897 @smallexample
16898 int __builtin_ia32_comieq (v4sf, v4sf)
16899 int __builtin_ia32_comineq (v4sf, v4sf)
16900 int __builtin_ia32_comilt (v4sf, v4sf)
16901 int __builtin_ia32_comile (v4sf, v4sf)
16902 int __builtin_ia32_comigt (v4sf, v4sf)
16903 int __builtin_ia32_comige (v4sf, v4sf)
16904 int __builtin_ia32_ucomieq (v4sf, v4sf)
16905 int __builtin_ia32_ucomineq (v4sf, v4sf)
16906 int __builtin_ia32_ucomilt (v4sf, v4sf)
16907 int __builtin_ia32_ucomile (v4sf, v4sf)
16908 int __builtin_ia32_ucomigt (v4sf, v4sf)
16909 int __builtin_ia32_ucomige (v4sf, v4sf)
16910 v4sf __builtin_ia32_addps (v4sf, v4sf)
16911 v4sf __builtin_ia32_subps (v4sf, v4sf)
16912 v4sf __builtin_ia32_mulps (v4sf, v4sf)
16913 v4sf __builtin_ia32_divps (v4sf, v4sf)
16914 v4sf __builtin_ia32_addss (v4sf, v4sf)
16915 v4sf __builtin_ia32_subss (v4sf, v4sf)
16916 v4sf __builtin_ia32_mulss (v4sf, v4sf)
16917 v4sf __builtin_ia32_divss (v4sf, v4sf)
16918 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
16919 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
16920 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
16921 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
16922 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
16923 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
16924 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
16925 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
16926 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
16927 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
16928 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
16929 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
16930 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
16931 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
16932 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
16933 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
16934 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
16935 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
16936 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
16937 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
16938 v4sf __builtin_ia32_maxps (v4sf, v4sf)
16939 v4sf __builtin_ia32_maxss (v4sf, v4sf)
16940 v4sf __builtin_ia32_minps (v4sf, v4sf)
16941 v4sf __builtin_ia32_minss (v4sf, v4sf)
16942 v4sf __builtin_ia32_andps (v4sf, v4sf)
16943 v4sf __builtin_ia32_andnps (v4sf, v4sf)
16944 v4sf __builtin_ia32_orps (v4sf, v4sf)
16945 v4sf __builtin_ia32_xorps (v4sf, v4sf)
16946 v4sf __builtin_ia32_movss (v4sf, v4sf)
16947 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
16948 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
16949 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
16950 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
16951 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
16952 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
16953 v2si __builtin_ia32_cvtps2pi (v4sf)
16954 int __builtin_ia32_cvtss2si (v4sf)
16955 v2si __builtin_ia32_cvttps2pi (v4sf)
16956 int __builtin_ia32_cvttss2si (v4sf)
16957 v4sf __builtin_ia32_rcpps (v4sf)
16958 v4sf __builtin_ia32_rsqrtps (v4sf)
16959 v4sf __builtin_ia32_sqrtps (v4sf)
16960 v4sf __builtin_ia32_rcpss (v4sf)
16961 v4sf __builtin_ia32_rsqrtss (v4sf)
16962 v4sf __builtin_ia32_sqrtss (v4sf)
16963 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
16964 void __builtin_ia32_movntps (float *, v4sf)
16965 int __builtin_ia32_movmskps (v4sf)
16966 @end smallexample
16968 The following built-in functions are available when @option{-msse} is used.
16970 @table @code
16971 @item v4sf __builtin_ia32_loadups (float *)
16972 Generates the @code{movups} machine instruction as a load from memory.
16973 @item void __builtin_ia32_storeups (float *, v4sf)
16974 Generates the @code{movups} machine instruction as a store to memory.
16975 @item v4sf __builtin_ia32_loadss (float *)
16976 Generates the @code{movss} machine instruction as a load from memory.
16977 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
16978 Generates the @code{movhps} machine instruction as a load from memory.
16979 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
16980 Generates the @code{movlps} machine instruction as a load from memory
16981 @item void __builtin_ia32_storehps (v2sf *, v4sf)
16982 Generates the @code{movhps} machine instruction as a store to memory.
16983 @item void __builtin_ia32_storelps (v2sf *, v4sf)
16984 Generates the @code{movlps} machine instruction as a store to memory.
16985 @end table
16987 The following built-in functions are available when @option{-msse2} is used.
16988 All of them generate the machine instruction that is part of the name.
16990 @smallexample
16991 int __builtin_ia32_comisdeq (v2df, v2df)
16992 int __builtin_ia32_comisdlt (v2df, v2df)
16993 int __builtin_ia32_comisdle (v2df, v2df)
16994 int __builtin_ia32_comisdgt (v2df, v2df)
16995 int __builtin_ia32_comisdge (v2df, v2df)
16996 int __builtin_ia32_comisdneq (v2df, v2df)
16997 int __builtin_ia32_ucomisdeq (v2df, v2df)
16998 int __builtin_ia32_ucomisdlt (v2df, v2df)
16999 int __builtin_ia32_ucomisdle (v2df, v2df)
17000 int __builtin_ia32_ucomisdgt (v2df, v2df)
17001 int __builtin_ia32_ucomisdge (v2df, v2df)
17002 int __builtin_ia32_ucomisdneq (v2df, v2df)
17003 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
17004 v2df __builtin_ia32_cmpltpd (v2df, v2df)
17005 v2df __builtin_ia32_cmplepd (v2df, v2df)
17006 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
17007 v2df __builtin_ia32_cmpgepd (v2df, v2df)
17008 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
17009 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
17010 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
17011 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
17012 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
17013 v2df __builtin_ia32_cmpngepd (v2df, v2df)
17014 v2df __builtin_ia32_cmpordpd (v2df, v2df)
17015 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
17016 v2df __builtin_ia32_cmpltsd (v2df, v2df)
17017 v2df __builtin_ia32_cmplesd (v2df, v2df)
17018 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
17019 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
17020 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
17021 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
17022 v2df __builtin_ia32_cmpordsd (v2df, v2df)
17023 v2di __builtin_ia32_paddq (v2di, v2di)
17024 v2di __builtin_ia32_psubq (v2di, v2di)
17025 v2df __builtin_ia32_addpd (v2df, v2df)
17026 v2df __builtin_ia32_subpd (v2df, v2df)
17027 v2df __builtin_ia32_mulpd (v2df, v2df)
17028 v2df __builtin_ia32_divpd (v2df, v2df)
17029 v2df __builtin_ia32_addsd (v2df, v2df)
17030 v2df __builtin_ia32_subsd (v2df, v2df)
17031 v2df __builtin_ia32_mulsd (v2df, v2df)
17032 v2df __builtin_ia32_divsd (v2df, v2df)
17033 v2df __builtin_ia32_minpd (v2df, v2df)
17034 v2df __builtin_ia32_maxpd (v2df, v2df)
17035 v2df __builtin_ia32_minsd (v2df, v2df)
17036 v2df __builtin_ia32_maxsd (v2df, v2df)
17037 v2df __builtin_ia32_andpd (v2df, v2df)
17038 v2df __builtin_ia32_andnpd (v2df, v2df)
17039 v2df __builtin_ia32_orpd (v2df, v2df)
17040 v2df __builtin_ia32_xorpd (v2df, v2df)
17041 v2df __builtin_ia32_movsd (v2df, v2df)
17042 v2df __builtin_ia32_unpckhpd (v2df, v2df)
17043 v2df __builtin_ia32_unpcklpd (v2df, v2df)
17044 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
17045 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
17046 v4si __builtin_ia32_paddd128 (v4si, v4si)
17047 v2di __builtin_ia32_paddq128 (v2di, v2di)
17048 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
17049 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
17050 v4si __builtin_ia32_psubd128 (v4si, v4si)
17051 v2di __builtin_ia32_psubq128 (v2di, v2di)
17052 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
17053 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
17054 v2di __builtin_ia32_pand128 (v2di, v2di)
17055 v2di __builtin_ia32_pandn128 (v2di, v2di)
17056 v2di __builtin_ia32_por128 (v2di, v2di)
17057 v2di __builtin_ia32_pxor128 (v2di, v2di)
17058 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
17059 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
17060 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
17061 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
17062 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
17063 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
17064 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
17065 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
17066 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
17067 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
17068 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
17069 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
17070 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
17071 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
17072 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
17073 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
17074 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
17075 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
17076 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
17077 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
17078 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
17079 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
17080 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
17081 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
17082 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
17083 v2df __builtin_ia32_loadupd (double *)
17084 void __builtin_ia32_storeupd (double *, v2df)
17085 v2df __builtin_ia32_loadhpd (v2df, double const *)
17086 v2df __builtin_ia32_loadlpd (v2df, double const *)
17087 int __builtin_ia32_movmskpd (v2df)
17088 int __builtin_ia32_pmovmskb128 (v16qi)
17089 void __builtin_ia32_movnti (int *, int)
17090 void __builtin_ia32_movnti64 (long long int *, long long int)
17091 void __builtin_ia32_movntpd (double *, v2df)
17092 void __builtin_ia32_movntdq (v2df *, v2df)
17093 v4si __builtin_ia32_pshufd (v4si, int)
17094 v8hi __builtin_ia32_pshuflw (v8hi, int)
17095 v8hi __builtin_ia32_pshufhw (v8hi, int)
17096 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
17097 v2df __builtin_ia32_sqrtpd (v2df)
17098 v2df __builtin_ia32_sqrtsd (v2df)
17099 v2df __builtin_ia32_shufpd (v2df, v2df, int)
17100 v2df __builtin_ia32_cvtdq2pd (v4si)
17101 v4sf __builtin_ia32_cvtdq2ps (v4si)
17102 v4si __builtin_ia32_cvtpd2dq (v2df)
17103 v2si __builtin_ia32_cvtpd2pi (v2df)
17104 v4sf __builtin_ia32_cvtpd2ps (v2df)
17105 v4si __builtin_ia32_cvttpd2dq (v2df)
17106 v2si __builtin_ia32_cvttpd2pi (v2df)
17107 v2df __builtin_ia32_cvtpi2pd (v2si)
17108 int __builtin_ia32_cvtsd2si (v2df)
17109 int __builtin_ia32_cvttsd2si (v2df)
17110 long long __builtin_ia32_cvtsd2si64 (v2df)
17111 long long __builtin_ia32_cvttsd2si64 (v2df)
17112 v4si __builtin_ia32_cvtps2dq (v4sf)
17113 v2df __builtin_ia32_cvtps2pd (v4sf)
17114 v4si __builtin_ia32_cvttps2dq (v4sf)
17115 v2df __builtin_ia32_cvtsi2sd (v2df, int)
17116 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
17117 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
17118 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
17119 void __builtin_ia32_clflush (const void *)
17120 void __builtin_ia32_lfence (void)
17121 void __builtin_ia32_mfence (void)
17122 v16qi __builtin_ia32_loaddqu (const char *)
17123 void __builtin_ia32_storedqu (char *, v16qi)
17124 v1di __builtin_ia32_pmuludq (v2si, v2si)
17125 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
17126 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
17127 v4si __builtin_ia32_pslld128 (v4si, v4si)
17128 v2di __builtin_ia32_psllq128 (v2di, v2di)
17129 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
17130 v4si __builtin_ia32_psrld128 (v4si, v4si)
17131 v2di __builtin_ia32_psrlq128 (v2di, v2di)
17132 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
17133 v4si __builtin_ia32_psrad128 (v4si, v4si)
17134 v2di __builtin_ia32_pslldqi128 (v2di, int)
17135 v8hi __builtin_ia32_psllwi128 (v8hi, int)
17136 v4si __builtin_ia32_pslldi128 (v4si, int)
17137 v2di __builtin_ia32_psllqi128 (v2di, int)
17138 v2di __builtin_ia32_psrldqi128 (v2di, int)
17139 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
17140 v4si __builtin_ia32_psrldi128 (v4si, int)
17141 v2di __builtin_ia32_psrlqi128 (v2di, int)
17142 v8hi __builtin_ia32_psrawi128 (v8hi, int)
17143 v4si __builtin_ia32_psradi128 (v4si, int)
17144 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
17145 v2di __builtin_ia32_movq128 (v2di)
17146 @end smallexample
17148 The following built-in functions are available when @option{-msse3} is used.
17149 All of them generate the machine instruction that is part of the name.
17151 @smallexample
17152 v2df __builtin_ia32_addsubpd (v2df, v2df)
17153 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
17154 v2df __builtin_ia32_haddpd (v2df, v2df)
17155 v4sf __builtin_ia32_haddps (v4sf, v4sf)
17156 v2df __builtin_ia32_hsubpd (v2df, v2df)
17157 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
17158 v16qi __builtin_ia32_lddqu (char const *)
17159 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
17160 v4sf __builtin_ia32_movshdup (v4sf)
17161 v4sf __builtin_ia32_movsldup (v4sf)
17162 void __builtin_ia32_mwait (unsigned int, unsigned int)
17163 @end smallexample
17165 The following built-in functions are available when @option{-mssse3} is used.
17166 All of them generate the machine instruction that is part of the name.
17168 @smallexample
17169 v2si __builtin_ia32_phaddd (v2si, v2si)
17170 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
17171 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
17172 v2si __builtin_ia32_phsubd (v2si, v2si)
17173 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
17174 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
17175 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
17176 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
17177 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
17178 v8qi __builtin_ia32_psignb (v8qi, v8qi)
17179 v2si __builtin_ia32_psignd (v2si, v2si)
17180 v4hi __builtin_ia32_psignw (v4hi, v4hi)
17181 v1di __builtin_ia32_palignr (v1di, v1di, int)
17182 v8qi __builtin_ia32_pabsb (v8qi)
17183 v2si __builtin_ia32_pabsd (v2si)
17184 v4hi __builtin_ia32_pabsw (v4hi)
17185 @end smallexample
17187 The following built-in functions are available when @option{-mssse3} is used.
17188 All of them generate the machine instruction that is part of the name.
17190 @smallexample
17191 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17192 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17193 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17194 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17195 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17196 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17197 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17198 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17199 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17200 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17201 v4si __builtin_ia32_psignd128 (v4si, v4si)
17202 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17203 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17204 v16qi __builtin_ia32_pabsb128 (v16qi)
17205 v4si __builtin_ia32_pabsd128 (v4si)
17206 v8hi __builtin_ia32_pabsw128 (v8hi)
17207 @end smallexample
17209 The following built-in functions are available when @option{-msse4.1} is
17210 used.  All of them generate the machine instruction that is part of the
17211 name.
17213 @smallexample
17214 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17215 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17216 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17217 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17218 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17219 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17220 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17221 v2di __builtin_ia32_movntdqa (v2di *);
17222 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17223 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17224 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17225 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17226 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17227 v8hi __builtin_ia32_phminposuw128 (v8hi)
17228 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17229 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17230 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17231 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17232 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17233 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17234 v4si __builtin_ia32_pminud128 (v4si, v4si)
17235 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17236 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17237 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17238 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17239 v2di __builtin_ia32_pmovsxdq128 (v4si)
17240 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17241 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17242 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17243 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17244 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17245 v2di __builtin_ia32_pmovzxdq128 (v4si)
17246 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17247 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17248 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17249 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17250 int __builtin_ia32_ptestc128 (v2di, v2di)
17251 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17252 int __builtin_ia32_ptestz128 (v2di, v2di)
17253 v2df __builtin_ia32_roundpd (v2df, const int)
17254 v4sf __builtin_ia32_roundps (v4sf, const int)
17255 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17256 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17257 @end smallexample
17259 The following built-in functions are available when @option{-msse4.1} is
17260 used.
17262 @table @code
17263 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17264 Generates the @code{insertps} machine instruction.
17265 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17266 Generates the @code{pextrb} machine instruction.
17267 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17268 Generates the @code{pinsrb} machine instruction.
17269 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17270 Generates the @code{pinsrd} machine instruction.
17271 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
17272 Generates the @code{pinsrq} machine instruction in 64bit mode.
17273 @end table
17275 The following built-in functions are changed to generate new SSE4.1
17276 instructions when @option{-msse4.1} is used.
17278 @table @code
17279 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
17280 Generates the @code{extractps} machine instruction.
17281 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
17282 Generates the @code{pextrd} machine instruction.
17283 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
17284 Generates the @code{pextrq} machine instruction in 64bit mode.
17285 @end table
17287 The following built-in functions are available when @option{-msse4.2} is
17288 used.  All of them generate the machine instruction that is part of the
17289 name.
17291 @smallexample
17292 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
17293 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
17294 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
17295 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
17296 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
17297 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
17298 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
17299 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
17300 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
17301 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
17302 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
17303 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
17304 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
17305 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
17306 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
17307 @end smallexample
17309 The following built-in functions are available when @option{-msse4.2} is
17310 used.
17312 @table @code
17313 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
17314 Generates the @code{crc32b} machine instruction.
17315 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
17316 Generates the @code{crc32w} machine instruction.
17317 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
17318 Generates the @code{crc32l} machine instruction.
17319 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
17320 Generates the @code{crc32q} machine instruction.
17321 @end table
17323 The following built-in functions are changed to generate new SSE4.2
17324 instructions when @option{-msse4.2} is used.
17326 @table @code
17327 @item int __builtin_popcount (unsigned int)
17328 Generates the @code{popcntl} machine instruction.
17329 @item int __builtin_popcountl (unsigned long)
17330 Generates the @code{popcntl} or @code{popcntq} machine instruction,
17331 depending on the size of @code{unsigned long}.
17332 @item int __builtin_popcountll (unsigned long long)
17333 Generates the @code{popcntq} machine instruction.
17334 @end table
17336 The following built-in functions are available when @option{-mavx} is
17337 used. All of them generate the machine instruction that is part of the
17338 name.
17340 @smallexample
17341 v4df __builtin_ia32_addpd256 (v4df,v4df)
17342 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
17343 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
17344 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
17345 v4df __builtin_ia32_andnpd256 (v4df,v4df)
17346 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
17347 v4df __builtin_ia32_andpd256 (v4df,v4df)
17348 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
17349 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
17350 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
17351 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
17352 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
17353 v2df __builtin_ia32_cmppd (v2df,v2df,int)
17354 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
17355 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
17356 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
17357 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
17358 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
17359 v4df __builtin_ia32_cvtdq2pd256 (v4si)
17360 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
17361 v4si __builtin_ia32_cvtpd2dq256 (v4df)
17362 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
17363 v8si __builtin_ia32_cvtps2dq256 (v8sf)
17364 v4df __builtin_ia32_cvtps2pd256 (v4sf)
17365 v4si __builtin_ia32_cvttpd2dq256 (v4df)
17366 v8si __builtin_ia32_cvttps2dq256 (v8sf)
17367 v4df __builtin_ia32_divpd256 (v4df,v4df)
17368 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
17369 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
17370 v4df __builtin_ia32_haddpd256 (v4df,v4df)
17371 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
17372 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
17373 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
17374 v32qi __builtin_ia32_lddqu256 (pcchar)
17375 v32qi __builtin_ia32_loaddqu256 (pcchar)
17376 v4df __builtin_ia32_loadupd256 (pcdouble)
17377 v8sf __builtin_ia32_loadups256 (pcfloat)
17378 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
17379 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
17380 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
17381 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
17382 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
17383 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
17384 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
17385 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
17386 v4df __builtin_ia32_maxpd256 (v4df,v4df)
17387 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
17388 v4df __builtin_ia32_minpd256 (v4df,v4df)
17389 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
17390 v4df __builtin_ia32_movddup256 (v4df)
17391 int __builtin_ia32_movmskpd256 (v4df)
17392 int __builtin_ia32_movmskps256 (v8sf)
17393 v8sf __builtin_ia32_movshdup256 (v8sf)
17394 v8sf __builtin_ia32_movsldup256 (v8sf)
17395 v4df __builtin_ia32_mulpd256 (v4df,v4df)
17396 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
17397 v4df __builtin_ia32_orpd256 (v4df,v4df)
17398 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
17399 v2df __builtin_ia32_pd_pd256 (v4df)
17400 v4df __builtin_ia32_pd256_pd (v2df)
17401 v4sf __builtin_ia32_ps_ps256 (v8sf)
17402 v8sf __builtin_ia32_ps256_ps (v4sf)
17403 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
17404 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
17405 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
17406 v8sf __builtin_ia32_rcpps256 (v8sf)
17407 v4df __builtin_ia32_roundpd256 (v4df,int)
17408 v8sf __builtin_ia32_roundps256 (v8sf,int)
17409 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
17410 v8sf __builtin_ia32_rsqrtps256 (v8sf)
17411 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
17412 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
17413 v4si __builtin_ia32_si_si256 (v8si)
17414 v8si __builtin_ia32_si256_si (v4si)
17415 v4df __builtin_ia32_sqrtpd256 (v4df)
17416 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
17417 v8sf __builtin_ia32_sqrtps256 (v8sf)
17418 void __builtin_ia32_storedqu256 (pchar,v32qi)
17419 void __builtin_ia32_storeupd256 (pdouble,v4df)
17420 void __builtin_ia32_storeups256 (pfloat,v8sf)
17421 v4df __builtin_ia32_subpd256 (v4df,v4df)
17422 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
17423 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
17424 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
17425 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
17426 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
17427 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
17428 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
17429 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
17430 v4sf __builtin_ia32_vbroadcastss (pcfloat)
17431 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
17432 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
17433 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
17434 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
17435 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
17436 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
17437 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
17438 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
17439 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
17440 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
17441 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
17442 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
17443 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
17444 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
17445 v2df __builtin_ia32_vpermilpd (v2df,int)
17446 v4df __builtin_ia32_vpermilpd256 (v4df,int)
17447 v4sf __builtin_ia32_vpermilps (v4sf,int)
17448 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
17449 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
17450 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
17451 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
17452 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
17453 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
17454 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
17455 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
17456 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
17457 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
17458 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
17459 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
17460 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
17461 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
17462 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
17463 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
17464 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
17465 void __builtin_ia32_vzeroall (void)
17466 void __builtin_ia32_vzeroupper (void)
17467 v4df __builtin_ia32_xorpd256 (v4df,v4df)
17468 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
17469 @end smallexample
17471 The following built-in functions are available when @option{-mavx2} is
17472 used. All of them generate the machine instruction that is part of the
17473 name.
17475 @smallexample
17476 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
17477 v32qi __builtin_ia32_pabsb256 (v32qi)
17478 v16hi __builtin_ia32_pabsw256 (v16hi)
17479 v8si __builtin_ia32_pabsd256 (v8si)
17480 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
17481 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
17482 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
17483 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
17484 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
17485 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
17486 v8si __builtin_ia32_paddd256 (v8si,v8si)
17487 v4di __builtin_ia32_paddq256 (v4di,v4di)
17488 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
17489 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
17490 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
17491 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
17492 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
17493 v4di __builtin_ia32_andsi256 (v4di,v4di)
17494 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
17495 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
17496 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
17497 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
17498 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
17499 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
17500 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
17501 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
17502 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
17503 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
17504 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
17505 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
17506 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
17507 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
17508 v8si __builtin_ia32_phaddd256 (v8si,v8si)
17509 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
17510 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
17511 v8si __builtin_ia32_phsubd256 (v8si,v8si)
17512 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
17513 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
17514 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
17515 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
17516 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
17517 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
17518 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
17519 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
17520 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
17521 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
17522 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
17523 v8si __builtin_ia32_pminsd256 (v8si,v8si)
17524 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
17525 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
17526 v8si __builtin_ia32_pminud256 (v8si,v8si)
17527 int __builtin_ia32_pmovmskb256 (v32qi)
17528 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
17529 v8si __builtin_ia32_pmovsxbd256 (v16qi)
17530 v4di __builtin_ia32_pmovsxbq256 (v16qi)
17531 v8si __builtin_ia32_pmovsxwd256 (v8hi)
17532 v4di __builtin_ia32_pmovsxwq256 (v8hi)
17533 v4di __builtin_ia32_pmovsxdq256 (v4si)
17534 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
17535 v8si __builtin_ia32_pmovzxbd256 (v16qi)
17536 v4di __builtin_ia32_pmovzxbq256 (v16qi)
17537 v8si __builtin_ia32_pmovzxwd256 (v8hi)
17538 v4di __builtin_ia32_pmovzxwq256 (v8hi)
17539 v4di __builtin_ia32_pmovzxdq256 (v4si)
17540 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
17541 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
17542 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
17543 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
17544 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
17545 v8si __builtin_ia32_pmulld256 (v8si,v8si)
17546 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
17547 v4di __builtin_ia32_por256 (v4di,v4di)
17548 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
17549 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
17550 v8si __builtin_ia32_pshufd256 (v8si,int)
17551 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
17552 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
17553 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
17554 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
17555 v8si __builtin_ia32_psignd256 (v8si,v8si)
17556 v4di __builtin_ia32_pslldqi256 (v4di,int)
17557 v16hi __builtin_ia32_psllwi256 (16hi,int)
17558 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
17559 v8si __builtin_ia32_pslldi256 (v8si,int)
17560 v8si __builtin_ia32_pslld256(v8si,v4si)
17561 v4di __builtin_ia32_psllqi256 (v4di,int)
17562 v4di __builtin_ia32_psllq256(v4di,v2di)
17563 v16hi __builtin_ia32_psrawi256 (v16hi,int)
17564 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
17565 v8si __builtin_ia32_psradi256 (v8si,int)
17566 v8si __builtin_ia32_psrad256 (v8si,v4si)
17567 v4di __builtin_ia32_psrldqi256 (v4di, int)
17568 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
17569 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
17570 v8si __builtin_ia32_psrldi256 (v8si,int)
17571 v8si __builtin_ia32_psrld256 (v8si,v4si)
17572 v4di __builtin_ia32_psrlqi256 (v4di,int)
17573 v4di __builtin_ia32_psrlq256(v4di,v2di)
17574 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
17575 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
17576 v8si __builtin_ia32_psubd256 (v8si,v8si)
17577 v4di __builtin_ia32_psubq256 (v4di,v4di)
17578 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
17579 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
17580 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
17581 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
17582 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
17583 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
17584 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
17585 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
17586 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
17587 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
17588 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
17589 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
17590 v4di __builtin_ia32_pxor256 (v4di,v4di)
17591 v4di __builtin_ia32_movntdqa256 (pv4di)
17592 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
17593 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
17594 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
17595 v4di __builtin_ia32_vbroadcastsi256 (v2di)
17596 v4si __builtin_ia32_pblendd128 (v4si,v4si)
17597 v8si __builtin_ia32_pblendd256 (v8si,v8si)
17598 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
17599 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
17600 v8si __builtin_ia32_pbroadcastd256 (v4si)
17601 v4di __builtin_ia32_pbroadcastq256 (v2di)
17602 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
17603 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
17604 v4si __builtin_ia32_pbroadcastd128 (v4si)
17605 v2di __builtin_ia32_pbroadcastq128 (v2di)
17606 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
17607 v4df __builtin_ia32_permdf256 (v4df,int)
17608 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
17609 v4di __builtin_ia32_permdi256 (v4di,int)
17610 v4di __builtin_ia32_permti256 (v4di,v4di,int)
17611 v4di __builtin_ia32_extract128i256 (v4di,int)
17612 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
17613 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
17614 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
17615 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
17616 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
17617 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
17618 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
17619 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
17620 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
17621 v8si __builtin_ia32_psllv8si (v8si,v8si)
17622 v4si __builtin_ia32_psllv4si (v4si,v4si)
17623 v4di __builtin_ia32_psllv4di (v4di,v4di)
17624 v2di __builtin_ia32_psllv2di (v2di,v2di)
17625 v8si __builtin_ia32_psrav8si (v8si,v8si)
17626 v4si __builtin_ia32_psrav4si (v4si,v4si)
17627 v8si __builtin_ia32_psrlv8si (v8si,v8si)
17628 v4si __builtin_ia32_psrlv4si (v4si,v4si)
17629 v4di __builtin_ia32_psrlv4di (v4di,v4di)
17630 v2di __builtin_ia32_psrlv2di (v2di,v2di)
17631 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
17632 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
17633 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
17634 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
17635 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
17636 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
17637 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
17638 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
17639 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
17640 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
17641 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
17642 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
17643 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
17644 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
17645 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
17646 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
17647 @end smallexample
17649 The following built-in functions are available when @option{-maes} is
17650 used.  All of them generate the machine instruction that is part of the
17651 name.
17653 @smallexample
17654 v2di __builtin_ia32_aesenc128 (v2di, v2di)
17655 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
17656 v2di __builtin_ia32_aesdec128 (v2di, v2di)
17657 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
17658 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
17659 v2di __builtin_ia32_aesimc128 (v2di)
17660 @end smallexample
17662 The following built-in function is available when @option{-mpclmul} is
17663 used.
17665 @table @code
17666 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
17667 Generates the @code{pclmulqdq} machine instruction.
17668 @end table
17670 The following built-in function is available when @option{-mfsgsbase} is
17671 used.  All of them generate the machine instruction that is part of the
17672 name.
17674 @smallexample
17675 unsigned int __builtin_ia32_rdfsbase32 (void)
17676 unsigned long long __builtin_ia32_rdfsbase64 (void)
17677 unsigned int __builtin_ia32_rdgsbase32 (void)
17678 unsigned long long __builtin_ia32_rdgsbase64 (void)
17679 void _writefsbase_u32 (unsigned int)
17680 void _writefsbase_u64 (unsigned long long)
17681 void _writegsbase_u32 (unsigned int)
17682 void _writegsbase_u64 (unsigned long long)
17683 @end smallexample
17685 The following built-in function is available when @option{-mrdrnd} is
17686 used.  All of them generate the machine instruction that is part of the
17687 name.
17689 @smallexample
17690 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
17691 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
17692 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
17693 @end smallexample
17695 The following built-in functions are available when @option{-msse4a} is used.
17696 All of them generate the machine instruction that is part of the name.
17698 @smallexample
17699 void __builtin_ia32_movntsd (double *, v2df)
17700 void __builtin_ia32_movntss (float *, v4sf)
17701 v2di __builtin_ia32_extrq  (v2di, v16qi)
17702 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
17703 v2di __builtin_ia32_insertq (v2di, v2di)
17704 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
17705 @end smallexample
17707 The following built-in functions are available when @option{-mxop} is used.
17708 @smallexample
17709 v2df __builtin_ia32_vfrczpd (v2df)
17710 v4sf __builtin_ia32_vfrczps (v4sf)
17711 v2df __builtin_ia32_vfrczsd (v2df)
17712 v4sf __builtin_ia32_vfrczss (v4sf)
17713 v4df __builtin_ia32_vfrczpd256 (v4df)
17714 v8sf __builtin_ia32_vfrczps256 (v8sf)
17715 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
17716 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
17717 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
17718 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
17719 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
17720 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
17721 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
17722 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
17723 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
17724 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
17725 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
17726 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
17727 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
17728 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
17729 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17730 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
17731 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
17732 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
17733 v4si __builtin_ia32_vpcomequd (v4si, v4si)
17734 v2di __builtin_ia32_vpcomequq (v2di, v2di)
17735 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
17736 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17737 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
17738 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
17739 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
17740 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
17741 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
17742 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
17743 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
17744 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
17745 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
17746 v4si __builtin_ia32_vpcomged (v4si, v4si)
17747 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
17748 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
17749 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
17750 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
17751 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
17752 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
17753 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
17754 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
17755 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
17756 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
17757 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
17758 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
17759 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
17760 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
17761 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
17762 v4si __builtin_ia32_vpcomled (v4si, v4si)
17763 v2di __builtin_ia32_vpcomleq (v2di, v2di)
17764 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
17765 v4si __builtin_ia32_vpcomleud (v4si, v4si)
17766 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
17767 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
17768 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
17769 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
17770 v4si __builtin_ia32_vpcomltd (v4si, v4si)
17771 v2di __builtin_ia32_vpcomltq (v2di, v2di)
17772 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
17773 v4si __builtin_ia32_vpcomltud (v4si, v4si)
17774 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
17775 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
17776 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
17777 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
17778 v4si __builtin_ia32_vpcomned (v4si, v4si)
17779 v2di __builtin_ia32_vpcomneq (v2di, v2di)
17780 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
17781 v4si __builtin_ia32_vpcomneud (v4si, v4si)
17782 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
17783 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
17784 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
17785 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
17786 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
17787 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
17788 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
17789 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
17790 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
17791 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
17792 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
17793 v4si __builtin_ia32_vphaddbd (v16qi)
17794 v2di __builtin_ia32_vphaddbq (v16qi)
17795 v8hi __builtin_ia32_vphaddbw (v16qi)
17796 v2di __builtin_ia32_vphadddq (v4si)
17797 v4si __builtin_ia32_vphaddubd (v16qi)
17798 v2di __builtin_ia32_vphaddubq (v16qi)
17799 v8hi __builtin_ia32_vphaddubw (v16qi)
17800 v2di __builtin_ia32_vphaddudq (v4si)
17801 v4si __builtin_ia32_vphadduwd (v8hi)
17802 v2di __builtin_ia32_vphadduwq (v8hi)
17803 v4si __builtin_ia32_vphaddwd (v8hi)
17804 v2di __builtin_ia32_vphaddwq (v8hi)
17805 v8hi __builtin_ia32_vphsubbw (v16qi)
17806 v2di __builtin_ia32_vphsubdq (v4si)
17807 v4si __builtin_ia32_vphsubwd (v8hi)
17808 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
17809 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
17810 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
17811 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
17812 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
17813 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
17814 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
17815 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
17816 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
17817 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
17818 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
17819 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
17820 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
17821 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
17822 v4si __builtin_ia32_vprotd (v4si, v4si)
17823 v2di __builtin_ia32_vprotq (v2di, v2di)
17824 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
17825 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
17826 v4si __builtin_ia32_vpshad (v4si, v4si)
17827 v2di __builtin_ia32_vpshaq (v2di, v2di)
17828 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
17829 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
17830 v4si __builtin_ia32_vpshld (v4si, v4si)
17831 v2di __builtin_ia32_vpshlq (v2di, v2di)
17832 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
17833 @end smallexample
17835 The following built-in functions are available when @option{-mfma4} is used.
17836 All of them generate the machine instruction that is part of the name.
17838 @smallexample
17839 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
17840 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
17841 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
17842 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
17843 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
17844 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
17845 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
17846 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
17847 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
17848 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
17849 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
17850 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
17851 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
17852 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
17853 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
17854 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
17855 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
17856 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
17857 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
17858 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
17859 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
17860 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
17861 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
17862 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
17863 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
17864 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
17865 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
17866 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
17867 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
17868 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
17869 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
17870 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
17872 @end smallexample
17874 The following built-in functions are available when @option{-mlwp} is used.
17876 @smallexample
17877 void __builtin_ia32_llwpcb16 (void *);
17878 void __builtin_ia32_llwpcb32 (void *);
17879 void __builtin_ia32_llwpcb64 (void *);
17880 void * __builtin_ia32_llwpcb16 (void);
17881 void * __builtin_ia32_llwpcb32 (void);
17882 void * __builtin_ia32_llwpcb64 (void);
17883 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
17884 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
17885 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
17886 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
17887 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
17888 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
17889 @end smallexample
17891 The following built-in functions are available when @option{-mbmi} is used.
17892 All of them generate the machine instruction that is part of the name.
17893 @smallexample
17894 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
17895 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
17896 @end smallexample
17898 The following built-in functions are available when @option{-mbmi2} is used.
17899 All of them generate the machine instruction that is part of the name.
17900 @smallexample
17901 unsigned int _bzhi_u32 (unsigned int, unsigned int)
17902 unsigned int _pdep_u32 (unsigned int, unsigned int)
17903 unsigned int _pext_u32 (unsigned int, unsigned int)
17904 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
17905 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
17906 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
17907 @end smallexample
17909 The following built-in functions are available when @option{-mlzcnt} is used.
17910 All of them generate the machine instruction that is part of the name.
17911 @smallexample
17912 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
17913 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
17914 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
17915 @end smallexample
17917 The following built-in functions are available when @option{-mfxsr} is used.
17918 All of them generate the machine instruction that is part of the name.
17919 @smallexample
17920 void __builtin_ia32_fxsave (void *)
17921 void __builtin_ia32_fxrstor (void *)
17922 void __builtin_ia32_fxsave64 (void *)
17923 void __builtin_ia32_fxrstor64 (void *)
17924 @end smallexample
17926 The following built-in functions are available when @option{-mxsave} is used.
17927 All of them generate the machine instruction that is part of the name.
17928 @smallexample
17929 void __builtin_ia32_xsave (void *, long long)
17930 void __builtin_ia32_xrstor (void *, long long)
17931 void __builtin_ia32_xsave64 (void *, long long)
17932 void __builtin_ia32_xrstor64 (void *, long long)
17933 @end smallexample
17935 The following built-in functions are available when @option{-mxsaveopt} is used.
17936 All of them generate the machine instruction that is part of the name.
17937 @smallexample
17938 void __builtin_ia32_xsaveopt (void *, long long)
17939 void __builtin_ia32_xsaveopt64 (void *, long long)
17940 @end smallexample
17942 The following built-in functions are available when @option{-mtbm} is used.
17943 Both of them generate the immediate form of the bextr machine instruction.
17944 @smallexample
17945 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
17946 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
17947 @end smallexample
17950 The following built-in functions are available when @option{-m3dnow} is used.
17951 All of them generate the machine instruction that is part of the name.
17953 @smallexample
17954 void __builtin_ia32_femms (void)
17955 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
17956 v2si __builtin_ia32_pf2id (v2sf)
17957 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
17958 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
17959 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
17960 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
17961 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
17962 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
17963 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
17964 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
17965 v2sf __builtin_ia32_pfrcp (v2sf)
17966 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
17967 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
17968 v2sf __builtin_ia32_pfrsqrt (v2sf)
17969 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
17970 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
17971 v2sf __builtin_ia32_pi2fd (v2si)
17972 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
17973 @end smallexample
17975 The following built-in functions are available when both @option{-m3dnow}
17976 and @option{-march=athlon} are used.  All of them generate the machine
17977 instruction that is part of the name.
17979 @smallexample
17980 v2si __builtin_ia32_pf2iw (v2sf)
17981 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
17982 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
17983 v2sf __builtin_ia32_pi2fw (v2si)
17984 v2sf __builtin_ia32_pswapdsf (v2sf)
17985 v2si __builtin_ia32_pswapdsi (v2si)
17986 @end smallexample
17988 The following built-in functions are available when @option{-mrtm} is used
17989 They are used for restricted transactional memory. These are the internal
17990 low level functions. Normally the functions in 
17991 @ref{x86 transactional memory intrinsics} should be used instead.
17993 @smallexample
17994 int __builtin_ia32_xbegin ()
17995 void __builtin_ia32_xend ()
17996 void __builtin_ia32_xabort (status)
17997 int __builtin_ia32_xtest ()
17998 @end smallexample
18000 The following built-in functions are available when @option{-mmwaitx} is used.
18001 All of them generate the machine instruction that is part of the name.
18002 @smallexample
18003 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
18004 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
18005 @end smallexample
18007 @node x86 transactional memory intrinsics
18008 @subsection x86 Transactional Memory Intrinsics
18010 These hardware transactional memory intrinsics for x86 allow you to use
18011 memory transactions with RTM (Restricted Transactional Memory).
18012 This support is enabled with the @option{-mrtm} option.
18013 For using HLE (Hardware Lock Elision) see 
18014 @ref{x86 specific memory model extensions for transactional memory} instead.
18016 A memory transaction commits all changes to memory in an atomic way,
18017 as visible to other threads. If the transaction fails it is rolled back
18018 and all side effects discarded.
18020 Generally there is no guarantee that a memory transaction ever succeeds
18021 and suitable fallback code always needs to be supplied.
18023 @deftypefn {RTM Function} {unsigned} _xbegin ()
18024 Start a RTM (Restricted Transactional Memory) transaction. 
18025 Returns @code{_XBEGIN_STARTED} when the transaction
18026 started successfully (note this is not 0, so the constant has to be 
18027 explicitly tested).  
18029 If the transaction aborts, all side-effects 
18030 are undone and an abort code encoded as a bit mask is returned.
18031 The following macros are defined:
18033 @table @code
18034 @item _XABORT_EXPLICIT
18035 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
18036 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
18037 @item _XABORT_RETRY
18038 Transaction retry is possible.
18039 @item _XABORT_CONFLICT
18040 Transaction abort due to a memory conflict with another thread.
18041 @item _XABORT_CAPACITY
18042 Transaction abort due to the transaction using too much memory.
18043 @item _XABORT_DEBUG
18044 Transaction abort due to a debug trap.
18045 @item _XABORT_NESTED
18046 Transaction abort in an inner nested transaction.
18047 @end table
18049 There is no guarantee
18050 any transaction ever succeeds, so there always needs to be a valid
18051 fallback path.
18052 @end deftypefn
18054 @deftypefn {RTM Function} {void} _xend ()
18055 Commit the current transaction. When no transaction is active this faults.
18056 All memory side-effects of the transaction become visible
18057 to other threads in an atomic manner.
18058 @end deftypefn
18060 @deftypefn {RTM Function} {int} _xtest ()
18061 Return a nonzero value if a transaction is currently active, otherwise 0.
18062 @end deftypefn
18064 @deftypefn {RTM Function} {void} _xabort (status)
18065 Abort the current transaction. When no transaction is active this is a no-op.
18066 The @var{status} is an 8-bit constant; its value is encoded in the return 
18067 value from @code{_xbegin}.
18068 @end deftypefn
18070 Here is an example showing handling for @code{_XABORT_RETRY}
18071 and a fallback path for other failures:
18073 @smallexample
18074 #include <immintrin.h>
18076 int n_tries, max_tries;
18077 unsigned status = _XABORT_EXPLICIT;
18080 for (n_tries = 0; n_tries < max_tries; n_tries++) 
18081   @{
18082     status = _xbegin ();
18083     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
18084       break;
18085   @}
18086 if (status == _XBEGIN_STARTED) 
18087   @{
18088     ... transaction code...
18089     _xend ();
18090   @} 
18091 else 
18092   @{
18093     ... non-transactional fallback path...
18094   @}
18095 @end smallexample
18097 @noindent
18098 Note that, in most cases, the transactional and non-transactional code
18099 must synchronize together to ensure consistency.
18101 @node Target Format Checks
18102 @section Format Checks Specific to Particular Target Machines
18104 For some target machines, GCC supports additional options to the
18105 format attribute
18106 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
18108 @menu
18109 * Solaris Format Checks::
18110 * Darwin Format Checks::
18111 @end menu
18113 @node Solaris Format Checks
18114 @subsection Solaris Format Checks
18116 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
18117 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
18118 conversions, and the two-argument @code{%b} conversion for displaying
18119 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
18121 @node Darwin Format Checks
18122 @subsection Darwin Format Checks
18124 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
18125 attribute context.  Declarations made with such attribution are parsed for correct syntax
18126 and format argument types.  However, parsing of the format string itself is currently undefined
18127 and is not carried out by this version of the compiler.
18129 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
18130 also be used as format arguments.  Note that the relevant headers are only likely to be
18131 available on Darwin (OSX) installations.  On such installations, the XCode and system
18132 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
18133 associated functions.
18135 @node Pragmas
18136 @section Pragmas Accepted by GCC
18137 @cindex pragmas
18138 @cindex @code{#pragma}
18140 GCC supports several types of pragmas, primarily in order to compile
18141 code originally written for other compilers.  Note that in general
18142 we do not recommend the use of pragmas; @xref{Function Attributes},
18143 for further explanation.
18145 @menu
18146 * ARM Pragmas::
18147 * M32C Pragmas::
18148 * MeP Pragmas::
18149 * RS/6000 and PowerPC Pragmas::
18150 * Darwin Pragmas::
18151 * Solaris Pragmas::
18152 * Symbol-Renaming Pragmas::
18153 * Structure-Packing Pragmas::
18154 * Weak Pragmas::
18155 * Diagnostic Pragmas::
18156 * Visibility Pragmas::
18157 * Push/Pop Macro Pragmas::
18158 * Function Specific Option Pragmas::
18159 * Loop-Specific Pragmas::
18160 @end menu
18162 @node ARM Pragmas
18163 @subsection ARM Pragmas
18165 The ARM target defines pragmas for controlling the default addition of
18166 @code{long_call} and @code{short_call} attributes to functions.
18167 @xref{Function Attributes}, for information about the effects of these
18168 attributes.
18170 @table @code
18171 @item long_calls
18172 @cindex pragma, long_calls
18173 Set all subsequent functions to have the @code{long_call} attribute.
18175 @item no_long_calls
18176 @cindex pragma, no_long_calls
18177 Set all subsequent functions to have the @code{short_call} attribute.
18179 @item long_calls_off
18180 @cindex pragma, long_calls_off
18181 Do not affect the @code{long_call} or @code{short_call} attributes of
18182 subsequent functions.
18183 @end table
18185 @node M32C Pragmas
18186 @subsection M32C Pragmas
18188 @table @code
18189 @item GCC memregs @var{number}
18190 @cindex pragma, memregs
18191 Overrides the command-line option @code{-memregs=} for the current
18192 file.  Use with care!  This pragma must be before any function in the
18193 file, and mixing different memregs values in different objects may
18194 make them incompatible.  This pragma is useful when a
18195 performance-critical function uses a memreg for temporary values,
18196 as it may allow you to reduce the number of memregs used.
18198 @item ADDRESS @var{name} @var{address}
18199 @cindex pragma, address
18200 For any declared symbols matching @var{name}, this does three things
18201 to that symbol: it forces the symbol to be located at the given
18202 address (a number), it forces the symbol to be volatile, and it
18203 changes the symbol's scope to be static.  This pragma exists for
18204 compatibility with other compilers, but note that the common
18205 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18206 instead).  Example:
18208 @smallexample
18209 #pragma ADDRESS port3 0x103
18210 char port3;
18211 @end smallexample
18213 @end table
18215 @node MeP Pragmas
18216 @subsection MeP Pragmas
18218 @table @code
18220 @item custom io_volatile (on|off)
18221 @cindex pragma, custom io_volatile
18222 Overrides the command-line option @code{-mio-volatile} for the current
18223 file.  Note that for compatibility with future GCC releases, this
18224 option should only be used once before any @code{io} variables in each
18225 file.
18227 @item GCC coprocessor available @var{registers}
18228 @cindex pragma, coprocessor available
18229 Specifies which coprocessor registers are available to the register
18230 allocator.  @var{registers} may be a single register, register range
18231 separated by ellipses, or comma-separated list of those.  Example:
18233 @smallexample
18234 #pragma GCC coprocessor available $c0...$c10, $c28
18235 @end smallexample
18237 @item GCC coprocessor call_saved @var{registers}
18238 @cindex pragma, coprocessor call_saved
18239 Specifies which coprocessor registers are to be saved and restored by
18240 any function using them.  @var{registers} may be a single register,
18241 register range separated by ellipses, or comma-separated list of
18242 those.  Example:
18244 @smallexample
18245 #pragma GCC coprocessor call_saved $c4...$c6, $c31
18246 @end smallexample
18248 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
18249 @cindex pragma, coprocessor subclass
18250 Creates and defines a register class.  These register classes can be
18251 used by inline @code{asm} constructs.  @var{registers} may be a single
18252 register, register range separated by ellipses, or comma-separated
18253 list of those.  Example:
18255 @smallexample
18256 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
18258 asm ("cpfoo %0" : "=B" (x));
18259 @end smallexample
18261 @item GCC disinterrupt @var{name} , @var{name} @dots{}
18262 @cindex pragma, disinterrupt
18263 For the named functions, the compiler adds code to disable interrupts
18264 for the duration of those functions.  If any functions so named 
18265 are not encountered in the source, a warning is emitted that the pragma is
18266 not used.  Examples:
18268 @smallexample
18269 #pragma disinterrupt foo
18270 #pragma disinterrupt bar, grill
18271 int foo () @{ @dots{} @}
18272 @end smallexample
18274 @item GCC call @var{name} , @var{name} @dots{}
18275 @cindex pragma, call
18276 For the named functions, the compiler always uses a register-indirect
18277 call model when calling the named functions.  Examples:
18279 @smallexample
18280 extern int foo ();
18281 #pragma call foo
18282 @end smallexample
18284 @end table
18286 @node RS/6000 and PowerPC Pragmas
18287 @subsection RS/6000 and PowerPC Pragmas
18289 The RS/6000 and PowerPC targets define one pragma for controlling
18290 whether or not the @code{longcall} attribute is added to function
18291 declarations by default.  This pragma overrides the @option{-mlongcall}
18292 option, but not the @code{longcall} and @code{shortcall} attributes.
18293 @xref{RS/6000 and PowerPC Options}, for more information about when long
18294 calls are and are not necessary.
18296 @table @code
18297 @item longcall (1)
18298 @cindex pragma, longcall
18299 Apply the @code{longcall} attribute to all subsequent function
18300 declarations.
18302 @item longcall (0)
18303 Do not apply the @code{longcall} attribute to subsequent function
18304 declarations.
18305 @end table
18307 @c Describe h8300 pragmas here.
18308 @c Describe sh pragmas here.
18309 @c Describe v850 pragmas here.
18311 @node Darwin Pragmas
18312 @subsection Darwin Pragmas
18314 The following pragmas are available for all architectures running the
18315 Darwin operating system.  These are useful for compatibility with other
18316 Mac OS compilers.
18318 @table @code
18319 @item mark @var{tokens}@dots{}
18320 @cindex pragma, mark
18321 This pragma is accepted, but has no effect.
18323 @item options align=@var{alignment}
18324 @cindex pragma, options align
18325 This pragma sets the alignment of fields in structures.  The values of
18326 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
18327 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
18328 properly; to restore the previous setting, use @code{reset} for the
18329 @var{alignment}.
18331 @item segment @var{tokens}@dots{}
18332 @cindex pragma, segment
18333 This pragma is accepted, but has no effect.
18335 @item unused (@var{var} [, @var{var}]@dots{})
18336 @cindex pragma, unused
18337 This pragma declares variables to be possibly unused.  GCC does not
18338 produce warnings for the listed variables.  The effect is similar to
18339 that of the @code{unused} attribute, except that this pragma may appear
18340 anywhere within the variables' scopes.
18341 @end table
18343 @node Solaris Pragmas
18344 @subsection Solaris Pragmas
18346 The Solaris target supports @code{#pragma redefine_extname}
18347 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
18348 @code{#pragma} directives for compatibility with the system compiler.
18350 @table @code
18351 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
18352 @cindex pragma, align
18354 Increase the minimum alignment of each @var{variable} to @var{alignment}.
18355 This is the same as GCC's @code{aligned} attribute @pxref{Variable
18356 Attributes}).  Macro expansion occurs on the arguments to this pragma
18357 when compiling C and Objective-C@.  It does not currently occur when
18358 compiling C++, but this is a bug which may be fixed in a future
18359 release.
18361 @item fini (@var{function} [, @var{function}]...)
18362 @cindex pragma, fini
18364 This pragma causes each listed @var{function} to be called after
18365 main, or during shared module unloading, by adding a call to the
18366 @code{.fini} section.
18368 @item init (@var{function} [, @var{function}]...)
18369 @cindex pragma, init
18371 This pragma causes each listed @var{function} to be called during
18372 initialization (before @code{main}) or during shared module loading, by
18373 adding a call to the @code{.init} section.
18375 @end table
18377 @node Symbol-Renaming Pragmas
18378 @subsection Symbol-Renaming Pragmas
18380 GCC supports a @code{#pragma} directive that changes the name used in
18381 assembly for a given declaration. While this pragma is supported on all
18382 platforms, it is intended primarily to provide compatibility with the
18383 Solaris system headers. This effect can also be achieved using the asm
18384 labels extension (@pxref{Asm Labels}).
18386 @table @code
18387 @item redefine_extname @var{oldname} @var{newname}
18388 @cindex pragma, redefine_extname
18390 This pragma gives the C function @var{oldname} the assembly symbol
18391 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
18392 is defined if this pragma is available (currently on all platforms).
18393 @end table
18395 This pragma and the asm labels extension interact in a complicated
18396 manner.  Here are some corner cases you may want to be aware of:
18398 @enumerate
18399 @item This pragma silently applies only to declarations with external
18400 linkage.  Asm labels do not have this restriction.
18402 @item In C++, this pragma silently applies only to declarations with
18403 ``C'' linkage.  Again, asm labels do not have this restriction.
18405 @item If either of the ways of changing the assembly name of a
18406 declaration are applied to a declaration whose assembly name has
18407 already been determined (either by a previous use of one of these
18408 features, or because the compiler needed the assembly name in order to
18409 generate code), and the new name is different, a warning issues and
18410 the name does not change.
18412 @item The @var{oldname} used by @code{#pragma redefine_extname} is
18413 always the C-language name.
18414 @end enumerate
18416 @node Structure-Packing Pragmas
18417 @subsection Structure-Packing Pragmas
18419 For compatibility with Microsoft Windows compilers, GCC supports a
18420 set of @code{#pragma} directives that change the maximum alignment of
18421 members of structures (other than zero-width bit-fields), unions, and
18422 classes subsequently defined. The @var{n} value below always is required
18423 to be a small power of two and specifies the new alignment in bytes.
18425 @enumerate
18426 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
18427 @item @code{#pragma pack()} sets the alignment to the one that was in
18428 effect when compilation started (see also command-line option
18429 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
18430 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
18431 setting on an internal stack and then optionally sets the new alignment.
18432 @item @code{#pragma pack(pop)} restores the alignment setting to the one
18433 saved at the top of the internal stack (and removes that stack entry).
18434 Note that @code{#pragma pack([@var{n}])} does not influence this internal
18435 stack; thus it is possible to have @code{#pragma pack(push)} followed by
18436 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
18437 @code{#pragma pack(pop)}.
18438 @end enumerate
18440 Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct}
18441 @code{#pragma} which lays out a structure as the documented
18442 @code{__attribute__ ((ms_struct))}.
18443 @enumerate
18444 @item @code{#pragma ms_struct on} turns on the layout for structures
18445 declared.
18446 @item @code{#pragma ms_struct off} turns off the layout for structures
18447 declared.
18448 @item @code{#pragma ms_struct reset} goes back to the default layout.
18449 @end enumerate
18451 @node Weak Pragmas
18452 @subsection Weak Pragmas
18454 For compatibility with SVR4, GCC supports a set of @code{#pragma}
18455 directives for declaring symbols to be weak, and defining weak
18456 aliases.
18458 @table @code
18459 @item #pragma weak @var{symbol}
18460 @cindex pragma, weak
18461 This pragma declares @var{symbol} to be weak, as if the declaration
18462 had the attribute of the same name.  The pragma may appear before
18463 or after the declaration of @var{symbol}.  It is not an error for
18464 @var{symbol} to never be defined at all.
18466 @item #pragma weak @var{symbol1} = @var{symbol2}
18467 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
18468 It is an error if @var{symbol2} is not defined in the current
18469 translation unit.
18470 @end table
18472 @node Diagnostic Pragmas
18473 @subsection Diagnostic Pragmas
18475 GCC allows the user to selectively enable or disable certain types of
18476 diagnostics, and change the kind of the diagnostic.  For example, a
18477 project's policy might require that all sources compile with
18478 @option{-Werror} but certain files might have exceptions allowing
18479 specific types of warnings.  Or, a project might selectively enable
18480 diagnostics and treat them as errors depending on which preprocessor
18481 macros are defined.
18483 @table @code
18484 @item #pragma GCC diagnostic @var{kind} @var{option}
18485 @cindex pragma, diagnostic
18487 Modifies the disposition of a diagnostic.  Note that not all
18488 diagnostics are modifiable; at the moment only warnings (normally
18489 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
18490 Use @option{-fdiagnostics-show-option} to determine which diagnostics
18491 are controllable and which option controls them.
18493 @var{kind} is @samp{error} to treat this diagnostic as an error,
18494 @samp{warning} to treat it like a warning (even if @option{-Werror} is
18495 in effect), or @samp{ignored} if the diagnostic is to be ignored.
18496 @var{option} is a double quoted string that matches the command-line
18497 option.
18499 @smallexample
18500 #pragma GCC diagnostic warning "-Wformat"
18501 #pragma GCC diagnostic error "-Wformat"
18502 #pragma GCC diagnostic ignored "-Wformat"
18503 @end smallexample
18505 Note that these pragmas override any command-line options.  GCC keeps
18506 track of the location of each pragma, and issues diagnostics according
18507 to the state as of that point in the source file.  Thus, pragmas occurring
18508 after a line do not affect diagnostics caused by that line.
18510 @item #pragma GCC diagnostic push
18511 @itemx #pragma GCC diagnostic pop
18513 Causes GCC to remember the state of the diagnostics as of each
18514 @code{push}, and restore to that point at each @code{pop}.  If a
18515 @code{pop} has no matching @code{push}, the command-line options are
18516 restored.
18518 @smallexample
18519 #pragma GCC diagnostic error "-Wuninitialized"
18520   foo(a);                       /* error is given for this one */
18521 #pragma GCC diagnostic push
18522 #pragma GCC diagnostic ignored "-Wuninitialized"
18523   foo(b);                       /* no diagnostic for this one */
18524 #pragma GCC diagnostic pop
18525   foo(c);                       /* error is given for this one */
18526 #pragma GCC diagnostic pop
18527   foo(d);                       /* depends on command-line options */
18528 @end smallexample
18530 @end table
18532 GCC also offers a simple mechanism for printing messages during
18533 compilation.
18535 @table @code
18536 @item #pragma message @var{string}
18537 @cindex pragma, diagnostic
18539 Prints @var{string} as a compiler message on compilation.  The message
18540 is informational only, and is neither a compilation warning nor an error.
18542 @smallexample
18543 #pragma message "Compiling " __FILE__ "..."
18544 @end smallexample
18546 @var{string} may be parenthesized, and is printed with location
18547 information.  For example,
18549 @smallexample
18550 #define DO_PRAGMA(x) _Pragma (#x)
18551 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
18553 TODO(Remember to fix this)
18554 @end smallexample
18556 @noindent
18557 prints @samp{/tmp/file.c:4: note: #pragma message:
18558 TODO - Remember to fix this}.
18560 @end table
18562 @node Visibility Pragmas
18563 @subsection Visibility Pragmas
18565 @table @code
18566 @item #pragma GCC visibility push(@var{visibility})
18567 @itemx #pragma GCC visibility pop
18568 @cindex pragma, visibility
18570 This pragma allows the user to set the visibility for multiple
18571 declarations without having to give each a visibility attribute
18572 (@pxref{Function Attributes}).
18574 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
18575 declarations.  Class members and template specializations are not
18576 affected; if you want to override the visibility for a particular
18577 member or instantiation, you must use an attribute.
18579 @end table
18582 @node Push/Pop Macro Pragmas
18583 @subsection Push/Pop Macro Pragmas
18585 For compatibility with Microsoft Windows compilers, GCC supports
18586 @samp{#pragma push_macro(@var{"macro_name"})}
18587 and @samp{#pragma pop_macro(@var{"macro_name"})}.
18589 @table @code
18590 @item #pragma push_macro(@var{"macro_name"})
18591 @cindex pragma, push_macro
18592 This pragma saves the value of the macro named as @var{macro_name} to
18593 the top of the stack for this macro.
18595 @item #pragma pop_macro(@var{"macro_name"})
18596 @cindex pragma, pop_macro
18597 This pragma sets the value of the macro named as @var{macro_name} to
18598 the value on top of the stack for this macro. If the stack for
18599 @var{macro_name} is empty, the value of the macro remains unchanged.
18600 @end table
18602 For example:
18604 @smallexample
18605 #define X  1
18606 #pragma push_macro("X")
18607 #undef X
18608 #define X -1
18609 #pragma pop_macro("X")
18610 int x [X];
18611 @end smallexample
18613 @noindent
18614 In this example, the definition of X as 1 is saved by @code{#pragma
18615 push_macro} and restored by @code{#pragma pop_macro}.
18617 @node Function Specific Option Pragmas
18618 @subsection Function Specific Option Pragmas
18620 @table @code
18621 @item #pragma GCC target (@var{"string"}...)
18622 @cindex pragma GCC target
18624 This pragma allows you to set target specific options for functions
18625 defined later in the source file.  One or more strings can be
18626 specified.  Each function that is defined after this point is as
18627 if @code{attribute((target("STRING")))} was specified for that
18628 function.  The parenthesis around the options is optional.
18629 @xref{Function Attributes}, for more information about the
18630 @code{target} attribute and the attribute syntax.
18632 The @code{#pragma GCC target} pragma is presently implemented for
18633 x86, PowerPC, and Nios II targets only.
18634 @end table
18636 @table @code
18637 @item #pragma GCC optimize (@var{"string"}...)
18638 @cindex pragma GCC optimize
18640 This pragma allows you to set global optimization options for functions
18641 defined later in the source file.  One or more strings can be
18642 specified.  Each function that is defined after this point is as
18643 if @code{attribute((optimize("STRING")))} was specified for that
18644 function.  The parenthesis around the options is optional.
18645 @xref{Function Attributes}, for more information about the
18646 @code{optimize} attribute and the attribute syntax.
18647 @end table
18649 @table @code
18650 @item #pragma GCC push_options
18651 @itemx #pragma GCC pop_options
18652 @cindex pragma GCC push_options
18653 @cindex pragma GCC pop_options
18655 These pragmas maintain a stack of the current target and optimization
18656 options.  It is intended for include files where you temporarily want
18657 to switch to using a different @samp{#pragma GCC target} or
18658 @samp{#pragma GCC optimize} and then to pop back to the previous
18659 options.
18660 @end table
18662 @table @code
18663 @item #pragma GCC reset_options
18664 @cindex pragma GCC reset_options
18666 This pragma clears the current @code{#pragma GCC target} and
18667 @code{#pragma GCC optimize} to use the default switches as specified
18668 on the command line.
18669 @end table
18671 @node Loop-Specific Pragmas
18672 @subsection Loop-Specific Pragmas
18674 @table @code
18675 @item #pragma GCC ivdep
18676 @cindex pragma GCC ivdep
18677 @end table
18679 With this pragma, the programmer asserts that there are no loop-carried
18680 dependencies which would prevent consecutive iterations of
18681 the following loop from executing concurrently with SIMD
18682 (single instruction multiple data) instructions.
18684 For example, the compiler can only unconditionally vectorize the following
18685 loop with the pragma:
18687 @smallexample
18688 void foo (int n, int *a, int *b, int *c)
18690   int i, j;
18691 #pragma GCC ivdep
18692   for (i = 0; i < n; ++i)
18693     a[i] = b[i] + c[i];
18695 @end smallexample
18697 @noindent
18698 In this example, using the @code{restrict} qualifier had the same
18699 effect. In the following example, that would not be possible. Assume
18700 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
18701 that it can unconditionally vectorize the following loop:
18703 @smallexample
18704 void ignore_vec_dep (int *a, int k, int c, int m)
18706 #pragma GCC ivdep
18707   for (int i = 0; i < m; i++)
18708     a[i] = a[i + k] * c;
18710 @end smallexample
18713 @node Unnamed Fields
18714 @section Unnamed Structure and Union Fields
18715 @cindex @code{struct}
18716 @cindex @code{union}
18718 As permitted by ISO C11 and for compatibility with other compilers,
18719 GCC allows you to define
18720 a structure or union that contains, as fields, structures and unions
18721 without names.  For example:
18723 @smallexample
18724 struct @{
18725   int a;
18726   union @{
18727     int b;
18728     float c;
18729   @};
18730   int d;
18731 @} foo;
18732 @end smallexample
18734 @noindent
18735 In this example, you are able to access members of the unnamed
18736 union with code like @samp{foo.b}.  Note that only unnamed structs and
18737 unions are allowed, you may not have, for example, an unnamed
18738 @code{int}.
18740 You must never create such structures that cause ambiguous field definitions.
18741 For example, in this structure:
18743 @smallexample
18744 struct @{
18745   int a;
18746   struct @{
18747     int a;
18748   @};
18749 @} foo;
18750 @end smallexample
18752 @noindent
18753 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
18754 The compiler gives errors for such constructs.
18756 @opindex fms-extensions
18757 Unless @option{-fms-extensions} is used, the unnamed field must be a
18758 structure or union definition without a tag (for example, @samp{struct
18759 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
18760 also be a definition with a tag such as @samp{struct foo @{ int a;
18761 @};}, a reference to a previously defined structure or union such as
18762 @samp{struct foo;}, or a reference to a @code{typedef} name for a
18763 previously defined structure or union type.
18765 @opindex fplan9-extensions
18766 The option @option{-fplan9-extensions} enables
18767 @option{-fms-extensions} as well as two other extensions.  First, a
18768 pointer to a structure is automatically converted to a pointer to an
18769 anonymous field for assignments and function calls.  For example:
18771 @smallexample
18772 struct s1 @{ int a; @};
18773 struct s2 @{ struct s1; @};
18774 extern void f1 (struct s1 *);
18775 void f2 (struct s2 *p) @{ f1 (p); @}
18776 @end smallexample
18778 @noindent
18779 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
18780 converted into a pointer to the anonymous field.
18782 Second, when the type of an anonymous field is a @code{typedef} for a
18783 @code{struct} or @code{union}, code may refer to the field using the
18784 name of the @code{typedef}.
18786 @smallexample
18787 typedef struct @{ int a; @} s1;
18788 struct s2 @{ s1; @};
18789 s1 f1 (struct s2 *p) @{ return p->s1; @}
18790 @end smallexample
18792 These usages are only permitted when they are not ambiguous.
18794 @node Thread-Local
18795 @section Thread-Local Storage
18796 @cindex Thread-Local Storage
18797 @cindex @acronym{TLS}
18798 @cindex @code{__thread}
18800 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
18801 are allocated such that there is one instance of the variable per extant
18802 thread.  The runtime model GCC uses to implement this originates
18803 in the IA-64 processor-specific ABI, but has since been migrated
18804 to other processors as well.  It requires significant support from
18805 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
18806 system libraries (@file{libc.so} and @file{libpthread.so}), so it
18807 is not available everywhere.
18809 At the user level, the extension is visible with a new storage
18810 class keyword: @code{__thread}.  For example:
18812 @smallexample
18813 __thread int i;
18814 extern __thread struct state s;
18815 static __thread char *p;
18816 @end smallexample
18818 The @code{__thread} specifier may be used alone, with the @code{extern}
18819 or @code{static} specifiers, but with no other storage class specifier.
18820 When used with @code{extern} or @code{static}, @code{__thread} must appear
18821 immediately after the other storage class specifier.
18823 The @code{__thread} specifier may be applied to any global, file-scoped
18824 static, function-scoped static, or static data member of a class.  It may
18825 not be applied to block-scoped automatic or non-static data member.
18827 When the address-of operator is applied to a thread-local variable, it is
18828 evaluated at run time and returns the address of the current thread's
18829 instance of that variable.  An address so obtained may be used by any
18830 thread.  When a thread terminates, any pointers to thread-local variables
18831 in that thread become invalid.
18833 No static initialization may refer to the address of a thread-local variable.
18835 In C++, if an initializer is present for a thread-local variable, it must
18836 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
18837 standard.
18839 See @uref{http://www.akkadia.org/drepper/tls.pdf,
18840 ELF Handling For Thread-Local Storage} for a detailed explanation of
18841 the four thread-local storage addressing models, and how the runtime
18842 is expected to function.
18844 @menu
18845 * C99 Thread-Local Edits::
18846 * C++98 Thread-Local Edits::
18847 @end menu
18849 @node C99 Thread-Local Edits
18850 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
18852 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
18853 that document the exact semantics of the language extension.
18855 @itemize @bullet
18856 @item
18857 @cite{5.1.2  Execution environments}
18859 Add new text after paragraph 1
18861 @quotation
18862 Within either execution environment, a @dfn{thread} is a flow of
18863 control within a program.  It is implementation defined whether
18864 or not there may be more than one thread associated with a program.
18865 It is implementation defined how threads beyond the first are
18866 created, the name and type of the function called at thread
18867 startup, and how threads may be terminated.  However, objects
18868 with thread storage duration shall be initialized before thread
18869 startup.
18870 @end quotation
18872 @item
18873 @cite{6.2.4  Storage durations of objects}
18875 Add new text before paragraph 3
18877 @quotation
18878 An object whose identifier is declared with the storage-class
18879 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
18880 Its lifetime is the entire execution of the thread, and its
18881 stored value is initialized only once, prior to thread startup.
18882 @end quotation
18884 @item
18885 @cite{6.4.1  Keywords}
18887 Add @code{__thread}.
18889 @item
18890 @cite{6.7.1  Storage-class specifiers}
18892 Add @code{__thread} to the list of storage class specifiers in
18893 paragraph 1.
18895 Change paragraph 2 to
18897 @quotation
18898 With the exception of @code{__thread}, at most one storage-class
18899 specifier may be given [@dots{}].  The @code{__thread} specifier may
18900 be used alone, or immediately following @code{extern} or
18901 @code{static}.
18902 @end quotation
18904 Add new text after paragraph 6
18906 @quotation
18907 The declaration of an identifier for a variable that has
18908 block scope that specifies @code{__thread} shall also
18909 specify either @code{extern} or @code{static}.
18911 The @code{__thread} specifier shall be used only with
18912 variables.
18913 @end quotation
18914 @end itemize
18916 @node C++98 Thread-Local Edits
18917 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18919 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18920 that document the exact semantics of the language extension.
18922 @itemize @bullet
18923 @item
18924 @b{[intro.execution]}
18926 New text after paragraph 4
18928 @quotation
18929 A @dfn{thread} is a flow of control within the abstract machine.
18930 It is implementation defined whether or not there may be more than
18931 one thread.
18932 @end quotation
18934 New text after paragraph 7
18936 @quotation
18937 It is unspecified whether additional action must be taken to
18938 ensure when and whether side effects are visible to other threads.
18939 @end quotation
18941 @item
18942 @b{[lex.key]}
18944 Add @code{__thread}.
18946 @item
18947 @b{[basic.start.main]}
18949 Add after paragraph 5
18951 @quotation
18952 The thread that begins execution at the @code{main} function is called
18953 the @dfn{main thread}.  It is implementation defined how functions
18954 beginning threads other than the main thread are designated or typed.
18955 A function so designated, as well as the @code{main} function, is called
18956 a @dfn{thread startup function}.  It is implementation defined what
18957 happens if a thread startup function returns.  It is implementation
18958 defined what happens to other threads when any thread calls @code{exit}.
18959 @end quotation
18961 @item
18962 @b{[basic.start.init]}
18964 Add after paragraph 4
18966 @quotation
18967 The storage for an object of thread storage duration shall be
18968 statically initialized before the first statement of the thread startup
18969 function.  An object of thread storage duration shall not require
18970 dynamic initialization.
18971 @end quotation
18973 @item
18974 @b{[basic.start.term]}
18976 Add after paragraph 3
18978 @quotation
18979 The type of an object with thread storage duration shall not have a
18980 non-trivial destructor, nor shall it be an array type whose elements
18981 (directly or indirectly) have non-trivial destructors.
18982 @end quotation
18984 @item
18985 @b{[basic.stc]}
18987 Add ``thread storage duration'' to the list in paragraph 1.
18989 Change paragraph 2
18991 @quotation
18992 Thread, static, and automatic storage durations are associated with
18993 objects introduced by declarations [@dots{}].
18994 @end quotation
18996 Add @code{__thread} to the list of specifiers in paragraph 3.
18998 @item
18999 @b{[basic.stc.thread]}
19001 New section before @b{[basic.stc.static]}
19003 @quotation
19004 The keyword @code{__thread} applied to a non-local object gives the
19005 object thread storage duration.
19007 A local variable or class data member declared both @code{static}
19008 and @code{__thread} gives the variable or member thread storage
19009 duration.
19010 @end quotation
19012 @item
19013 @b{[basic.stc.static]}
19015 Change paragraph 1
19017 @quotation
19018 All objects that have neither thread storage duration, dynamic
19019 storage duration nor are local [@dots{}].
19020 @end quotation
19022 @item
19023 @b{[dcl.stc]}
19025 Add @code{__thread} to the list in paragraph 1.
19027 Change paragraph 1
19029 @quotation
19030 With the exception of @code{__thread}, at most one
19031 @var{storage-class-specifier} shall appear in a given
19032 @var{decl-specifier-seq}.  The @code{__thread} specifier may
19033 be used alone, or immediately following the @code{extern} or
19034 @code{static} specifiers.  [@dots{}]
19035 @end quotation
19037 Add after paragraph 5
19039 @quotation
19040 The @code{__thread} specifier can be applied only to the names of objects
19041 and to anonymous unions.
19042 @end quotation
19044 @item
19045 @b{[class.mem]}
19047 Add after paragraph 6
19049 @quotation
19050 Non-@code{static} members shall not be @code{__thread}.
19051 @end quotation
19052 @end itemize
19054 @node Binary constants
19055 @section Binary Constants using the @samp{0b} Prefix
19056 @cindex Binary constants using the @samp{0b} prefix
19058 Integer constants can be written as binary constants, consisting of a
19059 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
19060 @samp{0B}.  This is particularly useful in environments that operate a
19061 lot on the bit level (like microcontrollers).
19063 The following statements are identical:
19065 @smallexample
19066 i =       42;
19067 i =     0x2a;
19068 i =      052;
19069 i = 0b101010;
19070 @end smallexample
19072 The type of these constants follows the same rules as for octal or
19073 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
19074 can be applied.
19076 @node C++ Extensions
19077 @chapter Extensions to the C++ Language
19078 @cindex extensions, C++ language
19079 @cindex C++ language extensions
19081 The GNU compiler provides these extensions to the C++ language (and you
19082 can also use most of the C language extensions in your C++ programs).  If you
19083 want to write code that checks whether these features are available, you can
19084 test for the GNU compiler the same way as for C programs: check for a
19085 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
19086 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
19087 Predefined Macros,cpp,The GNU C Preprocessor}).
19089 @menu
19090 * C++ Volatiles::       What constitutes an access to a volatile object.
19091 * Restricted Pointers:: C99 restricted pointers and references.
19092 * Vague Linkage::       Where G++ puts inlines, vtables and such.
19093 * C++ Interface::       You can use a single C++ header file for both
19094                         declarations and definitions.
19095 * Template Instantiation:: Methods for ensuring that exactly one copy of
19096                         each needed template instantiation is emitted.
19097 * Bound member functions:: You can extract a function pointer to the
19098                         method denoted by a @samp{->*} or @samp{.*} expression.
19099 * C++ Attributes::      Variable, function, and type attributes for C++ only.
19100 * Function Multiversioning::   Declaring multiple function versions.
19101 * Namespace Association:: Strong using-directives for namespace association.
19102 * Type Traits::         Compiler support for type traits
19103 * Java Exceptions::     Tweaking exception handling to work with Java.
19104 * Deprecated Features:: Things will disappear from G++.
19105 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
19106 @end menu
19108 @node C++ Volatiles
19109 @section When is a Volatile C++ Object Accessed?
19110 @cindex accessing volatiles
19111 @cindex volatile read
19112 @cindex volatile write
19113 @cindex volatile access
19115 The C++ standard differs from the C standard in its treatment of
19116 volatile objects.  It fails to specify what constitutes a volatile
19117 access, except to say that C++ should behave in a similar manner to C
19118 with respect to volatiles, where possible.  However, the different
19119 lvalueness of expressions between C and C++ complicate the behavior.
19120 G++ behaves the same as GCC for volatile access, @xref{C
19121 Extensions,,Volatiles}, for a description of GCC's behavior.
19123 The C and C++ language specifications differ when an object is
19124 accessed in a void context:
19126 @smallexample
19127 volatile int *src = @var{somevalue};
19128 *src;
19129 @end smallexample
19131 The C++ standard specifies that such expressions do not undergo lvalue
19132 to rvalue conversion, and that the type of the dereferenced object may
19133 be incomplete.  The C++ standard does not specify explicitly that it
19134 is lvalue to rvalue conversion that is responsible for causing an
19135 access.  There is reason to believe that it is, because otherwise
19136 certain simple expressions become undefined.  However, because it
19137 would surprise most programmers, G++ treats dereferencing a pointer to
19138 volatile object of complete type as GCC would do for an equivalent
19139 type in C@.  When the object has incomplete type, G++ issues a
19140 warning; if you wish to force an error, you must force a conversion to
19141 rvalue with, for instance, a static cast.
19143 When using a reference to volatile, G++ does not treat equivalent
19144 expressions as accesses to volatiles, but instead issues a warning that
19145 no volatile is accessed.  The rationale for this is that otherwise it
19146 becomes difficult to determine where volatile access occur, and not
19147 possible to ignore the return value from functions returning volatile
19148 references.  Again, if you wish to force a read, cast the reference to
19149 an rvalue.
19151 G++ implements the same behavior as GCC does when assigning to a
19152 volatile object---there is no reread of the assigned-to object, the
19153 assigned rvalue is reused.  Note that in C++ assignment expressions
19154 are lvalues, and if used as an lvalue, the volatile object is
19155 referred to.  For instance, @var{vref} refers to @var{vobj}, as
19156 expected, in the following example:
19158 @smallexample
19159 volatile int vobj;
19160 volatile int &vref = vobj = @var{something};
19161 @end smallexample
19163 @node Restricted Pointers
19164 @section Restricting Pointer Aliasing
19165 @cindex restricted pointers
19166 @cindex restricted references
19167 @cindex restricted this pointer
19169 As with the C front end, G++ understands the C99 feature of restricted pointers,
19170 specified with the @code{__restrict__}, or @code{__restrict} type
19171 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
19172 language flag, @code{restrict} is not a keyword in C++.
19174 In addition to allowing restricted pointers, you can specify restricted
19175 references, which indicate that the reference is not aliased in the local
19176 context.
19178 @smallexample
19179 void fn (int *__restrict__ rptr, int &__restrict__ rref)
19181   /* @r{@dots{}} */
19183 @end smallexample
19185 @noindent
19186 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
19187 @var{rref} refers to a (different) unaliased integer.
19189 You may also specify whether a member function's @var{this} pointer is
19190 unaliased by using @code{__restrict__} as a member function qualifier.
19192 @smallexample
19193 void T::fn () __restrict__
19195   /* @r{@dots{}} */
19197 @end smallexample
19199 @noindent
19200 Within the body of @code{T::fn}, @var{this} has the effective
19201 definition @code{T *__restrict__ const this}.  Notice that the
19202 interpretation of a @code{__restrict__} member function qualifier is
19203 different to that of @code{const} or @code{volatile} qualifier, in that it
19204 is applied to the pointer rather than the object.  This is consistent with
19205 other compilers that implement restricted pointers.
19207 As with all outermost parameter qualifiers, @code{__restrict__} is
19208 ignored in function definition matching.  This means you only need to
19209 specify @code{__restrict__} in a function definition, rather than
19210 in a function prototype as well.
19212 @node Vague Linkage
19213 @section Vague Linkage
19214 @cindex vague linkage
19216 There are several constructs in C++ that require space in the object
19217 file but are not clearly tied to a single translation unit.  We say that
19218 these constructs have ``vague linkage''.  Typically such constructs are
19219 emitted wherever they are needed, though sometimes we can be more
19220 clever.
19222 @table @asis
19223 @item Inline Functions
19224 Inline functions are typically defined in a header file which can be
19225 included in many different compilations.  Hopefully they can usually be
19226 inlined, but sometimes an out-of-line copy is necessary, if the address
19227 of the function is taken or if inlining fails.  In general, we emit an
19228 out-of-line copy in all translation units where one is needed.  As an
19229 exception, we only emit inline virtual functions with the vtable, since
19230 it always requires a copy.
19232 Local static variables and string constants used in an inline function
19233 are also considered to have vague linkage, since they must be shared
19234 between all inlined and out-of-line instances of the function.
19236 @item VTables
19237 @cindex vtable
19238 C++ virtual functions are implemented in most compilers using a lookup
19239 table, known as a vtable.  The vtable contains pointers to the virtual
19240 functions provided by a class, and each object of the class contains a
19241 pointer to its vtable (or vtables, in some multiple-inheritance
19242 situations).  If the class declares any non-inline, non-pure virtual
19243 functions, the first one is chosen as the ``key method'' for the class,
19244 and the vtable is only emitted in the translation unit where the key
19245 method is defined.
19247 @emph{Note:} If the chosen key method is later defined as inline, the
19248 vtable is still emitted in every translation unit that defines it.
19249 Make sure that any inline virtuals are declared inline in the class
19250 body, even if they are not defined there.
19252 @item @code{type_info} objects
19253 @cindex @code{type_info}
19254 @cindex RTTI
19255 C++ requires information about types to be written out in order to
19256 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
19257 For polymorphic classes (classes with virtual functions), the @samp{type_info}
19258 object is written out along with the vtable so that @samp{dynamic_cast}
19259 can determine the dynamic type of a class object at run time.  For all
19260 other types, we write out the @samp{type_info} object when it is used: when
19261 applying @samp{typeid} to an expression, throwing an object, or
19262 referring to a type in a catch clause or exception specification.
19264 @item Template Instantiations
19265 Most everything in this section also applies to template instantiations,
19266 but there are other options as well.
19267 @xref{Template Instantiation,,Where's the Template?}.
19269 @end table
19271 When used with GNU ld version 2.8 or later on an ELF system such as
19272 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
19273 these constructs will be discarded at link time.  This is known as
19274 COMDAT support.
19276 On targets that don't support COMDAT, but do support weak symbols, GCC
19277 uses them.  This way one copy overrides all the others, but
19278 the unused copies still take up space in the executable.
19280 For targets that do not support either COMDAT or weak symbols,
19281 most entities with vague linkage are emitted as local symbols to
19282 avoid duplicate definition errors from the linker.  This does not happen
19283 for local statics in inlines, however, as having multiple copies
19284 almost certainly breaks things.
19286 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
19287 another way to control placement of these constructs.
19289 @node C++ Interface
19290 @section C++ Interface and Implementation Pragmas
19292 @cindex interface and implementation headers, C++
19293 @cindex C++ interface and implementation headers
19294 @cindex pragmas, interface and implementation
19296 @code{#pragma interface} and @code{#pragma implementation} provide the
19297 user with a way of explicitly directing the compiler to emit entities
19298 with vague linkage (and debugging information) in a particular
19299 translation unit.
19301 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
19302 by COMDAT support and the ``key method'' heuristic
19303 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
19304 program to grow due to unnecessary out-of-line copies of inline
19305 functions.
19307 @table @code
19308 @item #pragma interface
19309 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
19310 @kindex #pragma interface
19311 Use this directive in @emph{header files} that define object classes, to save
19312 space in most of the object files that use those classes.  Normally,
19313 local copies of certain information (backup copies of inline member
19314 functions, debugging information, and the internal tables that implement
19315 virtual functions) must be kept in each object file that includes class
19316 definitions.  You can use this pragma to avoid such duplication.  When a
19317 header file containing @samp{#pragma interface} is included in a
19318 compilation, this auxiliary information is not generated (unless
19319 the main input source file itself uses @samp{#pragma implementation}).
19320 Instead, the object files contain references to be resolved at link
19321 time.
19323 The second form of this directive is useful for the case where you have
19324 multiple headers with the same name in different directories.  If you
19325 use this form, you must specify the same string to @samp{#pragma
19326 implementation}.
19328 @item #pragma implementation
19329 @itemx #pragma implementation "@var{objects}.h"
19330 @kindex #pragma implementation
19331 Use this pragma in a @emph{main input file}, when you want full output from
19332 included header files to be generated (and made globally visible).  The
19333 included header file, in turn, should use @samp{#pragma interface}.
19334 Backup copies of inline member functions, debugging information, and the
19335 internal tables used to implement virtual functions are all generated in
19336 implementation files.
19338 @cindex implied @code{#pragma implementation}
19339 @cindex @code{#pragma implementation}, implied
19340 @cindex naming convention, implementation headers
19341 If you use @samp{#pragma implementation} with no argument, it applies to
19342 an include file with the same basename@footnote{A file's @dfn{basename}
19343 is the name stripped of all leading path information and of trailing
19344 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
19345 file.  For example, in @file{allclass.cc}, giving just
19346 @samp{#pragma implementation}
19347 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
19349 Use the string argument if you want a single implementation file to
19350 include code from multiple header files.  (You must also use
19351 @samp{#include} to include the header file; @samp{#pragma
19352 implementation} only specifies how to use the file---it doesn't actually
19353 include it.)
19355 There is no way to split up the contents of a single header file into
19356 multiple implementation files.
19357 @end table
19359 @cindex inlining and C++ pragmas
19360 @cindex C++ pragmas, effect on inlining
19361 @cindex pragmas in C++, effect on inlining
19362 @samp{#pragma implementation} and @samp{#pragma interface} also have an
19363 effect on function inlining.
19365 If you define a class in a header file marked with @samp{#pragma
19366 interface}, the effect on an inline function defined in that class is
19367 similar to an explicit @code{extern} declaration---the compiler emits
19368 no code at all to define an independent version of the function.  Its
19369 definition is used only for inlining with its callers.
19371 @opindex fno-implement-inlines
19372 Conversely, when you include the same header file in a main source file
19373 that declares it as @samp{#pragma implementation}, the compiler emits
19374 code for the function itself; this defines a version of the function
19375 that can be found via pointers (or by callers compiled without
19376 inlining).  If all calls to the function can be inlined, you can avoid
19377 emitting the function by compiling with @option{-fno-implement-inlines}.
19378 If any calls are not inlined, you will get linker errors.
19380 @node Template Instantiation
19381 @section Where's the Template?
19382 @cindex template instantiation
19384 C++ templates are the first language feature to require more
19385 intelligence from the environment than one usually finds on a UNIX
19386 system.  Somehow the compiler and linker have to make sure that each
19387 template instance occurs exactly once in the executable if it is needed,
19388 and not at all otherwise.  There are two basic approaches to this
19389 problem, which are referred to as the Borland model and the Cfront model.
19391 @table @asis
19392 @item Borland model
19393 Borland C++ solved the template instantiation problem by adding the code
19394 equivalent of common blocks to their linker; the compiler emits template
19395 instances in each translation unit that uses them, and the linker
19396 collapses them together.  The advantage of this model is that the linker
19397 only has to consider the object files themselves; there is no external
19398 complexity to worry about.  This disadvantage is that compilation time
19399 is increased because the template code is being compiled repeatedly.
19400 Code written for this model tends to include definitions of all
19401 templates in the header file, since they must be seen to be
19402 instantiated.
19404 @item Cfront model
19405 The AT&T C++ translator, Cfront, solved the template instantiation
19406 problem by creating the notion of a template repository, an
19407 automatically maintained place where template instances are stored.  A
19408 more modern version of the repository works as follows: As individual
19409 object files are built, the compiler places any template definitions and
19410 instantiations encountered in the repository.  At link time, the link
19411 wrapper adds in the objects in the repository and compiles any needed
19412 instances that were not previously emitted.  The advantages of this
19413 model are more optimal compilation speed and the ability to use the
19414 system linker; to implement the Borland model a compiler vendor also
19415 needs to replace the linker.  The disadvantages are vastly increased
19416 complexity, and thus potential for error; for some code this can be
19417 just as transparent, but in practice it can been very difficult to build
19418 multiple programs in one directory and one program in multiple
19419 directories.  Code written for this model tends to separate definitions
19420 of non-inline member templates into a separate file, which should be
19421 compiled separately.
19422 @end table
19424 When used with GNU ld version 2.8 or later on an ELF system such as
19425 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
19426 Borland model.  On other systems, G++ implements neither automatic
19427 model.
19429 You have the following options for dealing with template instantiations:
19431 @enumerate
19432 @item
19433 @opindex frepo
19434 Compile your template-using code with @option{-frepo}.  The compiler
19435 generates files with the extension @samp{.rpo} listing all of the
19436 template instantiations used in the corresponding object files that
19437 could be instantiated there; the link wrapper, @samp{collect2},
19438 then updates the @samp{.rpo} files to tell the compiler where to place
19439 those instantiations and rebuild any affected object files.  The
19440 link-time overhead is negligible after the first pass, as the compiler
19441 continues to place the instantiations in the same files.
19443 This is your best option for application code written for the Borland
19444 model, as it just works.  Code written for the Cfront model 
19445 needs to be modified so that the template definitions are available at
19446 one or more points of instantiation; usually this is as simple as adding
19447 @code{#include <tmethods.cc>} to the end of each template header.
19449 For library code, if you want the library to provide all of the template
19450 instantiations it needs, just try to link all of its object files
19451 together; the link will fail, but cause the instantiations to be
19452 generated as a side effect.  Be warned, however, that this may cause
19453 conflicts if multiple libraries try to provide the same instantiations.
19454 For greater control, use explicit instantiation as described in the next
19455 option.
19457 @item
19458 @opindex fno-implicit-templates
19459 Compile your code with @option{-fno-implicit-templates} to disable the
19460 implicit generation of template instances, and explicitly instantiate
19461 all the ones you use.  This approach requires more knowledge of exactly
19462 which instances you need than do the others, but it's less
19463 mysterious and allows greater control.  You can scatter the explicit
19464 instantiations throughout your program, perhaps putting them in the
19465 translation units where the instances are used or the translation units
19466 that define the templates themselves; you can put all of the explicit
19467 instantiations you need into one big file; or you can create small files
19468 like
19470 @smallexample
19471 #include "Foo.h"
19472 #include "Foo.cc"
19474 template class Foo<int>;
19475 template ostream& operator <<
19476                 (ostream&, const Foo<int>&);
19477 @end smallexample
19479 @noindent
19480 for each of the instances you need, and create a template instantiation
19481 library from those.
19483 If you are using Cfront-model code, you can probably get away with not
19484 using @option{-fno-implicit-templates} when compiling files that don't
19485 @samp{#include} the member template definitions.
19487 If you use one big file to do the instantiations, you may want to
19488 compile it without @option{-fno-implicit-templates} so you get all of the
19489 instances required by your explicit instantiations (but not by any
19490 other files) without having to specify them as well.
19492 The ISO C++ 2011 standard allows forward declaration of explicit
19493 instantiations (with @code{extern}). G++ supports explicit instantiation
19494 declarations in C++98 mode and has extended the template instantiation
19495 syntax to support instantiation of the compiler support data for a
19496 template class (i.e.@: the vtable) without instantiating any of its
19497 members (with @code{inline}), and instantiation of only the static data
19498 members of a template class, without the support data or member
19499 functions (with @code{static}):
19501 @smallexample
19502 extern template int max (int, int);
19503 inline template class Foo<int>;
19504 static template class Foo<int>;
19505 @end smallexample
19507 @item
19508 Do nothing.  Pretend G++ does implement automatic instantiation
19509 management.  Code written for the Borland model works fine, but
19510 each translation unit contains instances of each of the templates it
19511 uses.  In a large program, this can lead to an unacceptable amount of code
19512 duplication.
19513 @end enumerate
19515 @node Bound member functions
19516 @section Extracting the Function Pointer from a Bound Pointer to Member Function
19517 @cindex pmf
19518 @cindex pointer to member function
19519 @cindex bound pointer to member function
19521 In C++, pointer to member functions (PMFs) are implemented using a wide
19522 pointer of sorts to handle all the possible call mechanisms; the PMF
19523 needs to store information about how to adjust the @samp{this} pointer,
19524 and if the function pointed to is virtual, where to find the vtable, and
19525 where in the vtable to look for the member function.  If you are using
19526 PMFs in an inner loop, you should really reconsider that decision.  If
19527 that is not an option, you can extract the pointer to the function that
19528 would be called for a given object/PMF pair and call it directly inside
19529 the inner loop, to save a bit of time.
19531 Note that you still pay the penalty for the call through a
19532 function pointer; on most modern architectures, such a call defeats the
19533 branch prediction features of the CPU@.  This is also true of normal
19534 virtual function calls.
19536 The syntax for this extension is
19538 @smallexample
19539 extern A a;
19540 extern int (A::*fp)();
19541 typedef int (*fptr)(A *);
19543 fptr p = (fptr)(a.*fp);
19544 @end smallexample
19546 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
19547 no object is needed to obtain the address of the function.  They can be
19548 converted to function pointers directly:
19550 @smallexample
19551 fptr p1 = (fptr)(&A::foo);
19552 @end smallexample
19554 @opindex Wno-pmf-conversions
19555 You must specify @option{-Wno-pmf-conversions} to use this extension.
19557 @node C++ Attributes
19558 @section C++-Specific Variable, Function, and Type Attributes
19560 Some attributes only make sense for C++ programs.
19562 @table @code
19563 @item abi_tag ("@var{tag}", ...)
19564 @cindex @code{abi_tag} function attribute
19565 @cindex @code{abi_tag} variable attribute
19566 @cindex @code{abi_tag} type attribute
19567 The @code{abi_tag} attribute can be applied to a function, variable, or class
19568 declaration.  It modifies the mangled name of the entity to
19569 incorporate the tag name, in order to distinguish the function or
19570 class from an earlier version with a different ABI; perhaps the class
19571 has changed size, or the function has a different return type that is
19572 not encoded in the mangled name.
19574 The attribute can also be applied to an inline namespace, but does not
19575 affect the mangled name of the namespace; in this case it is only used
19576 for @option{-Wabi-tag} warnings and automatic tagging of functions and
19577 variables.  Tagging inline namespaces is generally preferable to
19578 tagging individual declarations, but the latter is sometimes
19579 necessary, such as when only certain members of a class need to be
19580 tagged.
19582 The argument can be a list of strings of arbitrary length.  The
19583 strings are sorted on output, so the order of the list is
19584 unimportant.
19586 A redeclaration of an entity must not add new ABI tags,
19587 since doing so would change the mangled name.
19589 The ABI tags apply to a name, so all instantiations and
19590 specializations of a template have the same tags.  The attribute will
19591 be ignored if applied to an explicit specialization or instantiation.
19593 The @option{-Wabi-tag} flag enables a warning about a class which does
19594 not have all the ABI tags used by its subobjects and virtual functions; for users with code
19595 that needs to coexist with an earlier ABI, using this option can help
19596 to find all affected types that need to be tagged.
19598 When a type involving an ABI tag is used as the type of a variable or
19599 return type of a function where that tag is not already present in the
19600 signature of the function, the tag is automatically applied to the
19601 variable or function.  @option{-Wabi-tag} also warns about this
19602 situation; this warning can be avoided by explicitly tagging the
19603 variable or function or moving it into a tagged inline namespace.
19605 @item init_priority (@var{priority})
19606 @cindex @code{init_priority} variable attribute
19608 In Standard C++, objects defined at namespace scope are guaranteed to be
19609 initialized in an order in strict accordance with that of their definitions
19610 @emph{in a given translation unit}.  No guarantee is made for initializations
19611 across translation units.  However, GNU C++ allows users to control the
19612 order of initialization of objects defined at namespace scope with the
19613 @code{init_priority} attribute by specifying a relative @var{priority},
19614 a constant integral expression currently bounded between 101 and 65535
19615 inclusive.  Lower numbers indicate a higher priority.
19617 In the following example, @code{A} would normally be created before
19618 @code{B}, but the @code{init_priority} attribute reverses that order:
19620 @smallexample
19621 Some_Class  A  __attribute__ ((init_priority (2000)));
19622 Some_Class  B  __attribute__ ((init_priority (543)));
19623 @end smallexample
19625 @noindent
19626 Note that the particular values of @var{priority} do not matter; only their
19627 relative ordering.
19629 @item java_interface
19630 @cindex @code{java_interface} type attribute
19632 This type attribute informs C++ that the class is a Java interface.  It may
19633 only be applied to classes declared within an @code{extern "Java"} block.
19634 Calls to methods declared in this interface are dispatched using GCJ's
19635 interface table mechanism, instead of regular virtual table dispatch.
19637 @item warn_unused
19638 @cindex @code{warn_unused} type attribute
19640 For C++ types with non-trivial constructors and/or destructors it is
19641 impossible for the compiler to determine whether a variable of this
19642 type is truly unused if it is not referenced. This type attribute
19643 informs the compiler that variables of this type should be warned
19644 about if they appear to be unused, just like variables of fundamental
19645 types.
19647 This attribute is appropriate for types which just represent a value,
19648 such as @code{std::string}; it is not appropriate for types which
19649 control a resource, such as @code{std::mutex}.
19651 This attribute is also accepted in C, but it is unnecessary because C
19652 does not have constructors or destructors.
19654 @end table
19656 See also @ref{Namespace Association}.
19658 @node Function Multiversioning
19659 @section Function Multiversioning
19660 @cindex function versions
19662 With the GNU C++ front end, for x86 targets, you may specify multiple
19663 versions of a function, where each function is specialized for a
19664 specific target feature.  At runtime, the appropriate version of the
19665 function is automatically executed depending on the characteristics of
19666 the execution platform.  Here is an example.
19668 @smallexample
19669 __attribute__ ((target ("default")))
19670 int foo ()
19672   // The default version of foo.
19673   return 0;
19676 __attribute__ ((target ("sse4.2")))
19677 int foo ()
19679   // foo version for SSE4.2
19680   return 1;
19683 __attribute__ ((target ("arch=atom")))
19684 int foo ()
19686   // foo version for the Intel ATOM processor
19687   return 2;
19690 __attribute__ ((target ("arch=amdfam10")))
19691 int foo ()
19693   // foo version for the AMD Family 0x10 processors.
19694   return 3;
19697 int main ()
19699   int (*p)() = &foo;
19700   assert ((*p) () == foo ());
19701   return 0;
19703 @end smallexample
19705 In the above example, four versions of function foo are created. The
19706 first version of foo with the target attribute "default" is the default
19707 version.  This version gets executed when no other target specific
19708 version qualifies for execution on a particular platform. A new version
19709 of foo is created by using the same function signature but with a
19710 different target string.  Function foo is called or a pointer to it is
19711 taken just like a regular function.  GCC takes care of doing the
19712 dispatching to call the right version at runtime.  Refer to the
19713 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
19714 Function Multiversioning} for more details.
19716 @node Namespace Association
19717 @section Namespace Association
19719 @strong{Caution:} The semantics of this extension are equivalent
19720 to C++ 2011 inline namespaces.  Users should use inline namespaces
19721 instead as this extension will be removed in future versions of G++.
19723 A using-directive with @code{__attribute ((strong))} is stronger
19724 than a normal using-directive in two ways:
19726 @itemize @bullet
19727 @item
19728 Templates from the used namespace can be specialized and explicitly
19729 instantiated as though they were members of the using namespace.
19731 @item
19732 The using namespace is considered an associated namespace of all
19733 templates in the used namespace for purposes of argument-dependent
19734 name lookup.
19735 @end itemize
19737 The used namespace must be nested within the using namespace so that
19738 normal unqualified lookup works properly.
19740 This is useful for composing a namespace transparently from
19741 implementation namespaces.  For example:
19743 @smallexample
19744 namespace std @{
19745   namespace debug @{
19746     template <class T> struct A @{ @};
19747   @}
19748   using namespace debug __attribute ((__strong__));
19749   template <> struct A<int> @{ @};   // @r{OK to specialize}
19751   template <class T> void f (A<T>);
19754 int main()
19756   f (std::A<float>());             // @r{lookup finds} std::f
19757   f (std::A<int>());
19759 @end smallexample
19761 @node Type Traits
19762 @section Type Traits
19764 The C++ front end implements syntactic extensions that allow
19765 compile-time determination of 
19766 various characteristics of a type (or of a
19767 pair of types).
19769 @table @code
19770 @item __has_nothrow_assign (type)
19771 If @code{type} is const qualified or is a reference type then the trait is
19772 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
19773 is true, else if @code{type} is a cv class or union type with copy assignment
19774 operators that are known not to throw an exception then the trait is true,
19775 else it is false.  Requires: @code{type} shall be a complete type,
19776 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19778 @item __has_nothrow_copy (type)
19779 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
19780 @code{type} is a cv class or union type with copy constructors that
19781 are known not to throw an exception then the trait is true, else it is false.
19782 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
19783 @code{void}, or an array of unknown bound.
19785 @item __has_nothrow_constructor (type)
19786 If @code{__has_trivial_constructor (type)} is true then the trait is
19787 true, else if @code{type} is a cv class or union type (or array
19788 thereof) with a default constructor that is known not to throw an
19789 exception then the trait is true, else it is false.  Requires:
19790 @code{type} shall be a complete type, (possibly cv-qualified)
19791 @code{void}, or an array of unknown bound.
19793 @item __has_trivial_assign (type)
19794 If @code{type} is const qualified or is a reference type then the trait is
19795 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
19796 true, else if @code{type} is a cv class or union type with a trivial
19797 copy assignment ([class.copy]) then the trait is true, else it is
19798 false.  Requires: @code{type} shall be a complete type, (possibly
19799 cv-qualified) @code{void}, or an array of unknown bound.
19801 @item __has_trivial_copy (type)
19802 If @code{__is_pod (type)} is true or @code{type} is a reference type
19803 then the trait is true, else if @code{type} is a cv class or union type
19804 with a trivial copy constructor ([class.copy]) then the trait
19805 is true, else it is false.  Requires: @code{type} shall be a complete
19806 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19808 @item __has_trivial_constructor (type)
19809 If @code{__is_pod (type)} is true then the trait is true, else if
19810 @code{type} is a cv class or union type (or array thereof) with a
19811 trivial default constructor ([class.ctor]) then the trait is true,
19812 else it is false.  Requires: @code{type} shall be a complete
19813 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19815 @item __has_trivial_destructor (type)
19816 If @code{__is_pod (type)} is true or @code{type} is a reference type then
19817 the trait is true, else if @code{type} is a cv class or union type (or
19818 array thereof) with a trivial destructor ([class.dtor]) then the trait
19819 is true, else it is false.  Requires: @code{type} shall be a complete
19820 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19822 @item __has_virtual_destructor (type)
19823 If @code{type} is a class type with a virtual destructor
19824 ([class.dtor]) then the trait is true, else it is false.  Requires:
19825 @code{type} shall be a complete type, (possibly cv-qualified)
19826 @code{void}, or an array of unknown bound.
19828 @item __is_abstract (type)
19829 If @code{type} is an abstract class ([class.abstract]) then the trait
19830 is true, else it is false.  Requires: @code{type} shall be a complete
19831 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19833 @item __is_base_of (base_type, derived_type)
19834 If @code{base_type} is a base class of @code{derived_type}
19835 ([class.derived]) then the trait is true, otherwise it is false.
19836 Top-level cv qualifications of @code{base_type} and
19837 @code{derived_type} are ignored.  For the purposes of this trait, a
19838 class type is considered is own base.  Requires: if @code{__is_class
19839 (base_type)} and @code{__is_class (derived_type)} are true and
19840 @code{base_type} and @code{derived_type} are not the same type
19841 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
19842 type.  Diagnostic is produced if this requirement is not met.
19844 @item __is_class (type)
19845 If @code{type} is a cv class type, and not a union type
19846 ([basic.compound]) the trait is true, else it is false.
19848 @item __is_empty (type)
19849 If @code{__is_class (type)} is false then the trait is false.
19850 Otherwise @code{type} is considered empty if and only if: @code{type}
19851 has no non-static data members, or all non-static data members, if
19852 any, are bit-fields of length 0, and @code{type} has no virtual
19853 members, and @code{type} has no virtual base classes, and @code{type}
19854 has no base classes @code{base_type} for which
19855 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
19856 be a complete type, (possibly cv-qualified) @code{void}, or an array
19857 of unknown bound.
19859 @item __is_enum (type)
19860 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
19861 true, else it is false.
19863 @item __is_literal_type (type)
19864 If @code{type} is a literal type ([basic.types]) the trait is
19865 true, else it is false.  Requires: @code{type} shall be a complete type,
19866 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19868 @item __is_pod (type)
19869 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
19870 else it is false.  Requires: @code{type} shall be a complete type,
19871 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19873 @item __is_polymorphic (type)
19874 If @code{type} is a polymorphic class ([class.virtual]) then the trait
19875 is true, else it is false.  Requires: @code{type} shall be a complete
19876 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19878 @item __is_standard_layout (type)
19879 If @code{type} is a standard-layout type ([basic.types]) the trait is
19880 true, else it is false.  Requires: @code{type} shall be a complete
19881 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19883 @item __is_trivial (type)
19884 If @code{type} is a trivial type ([basic.types]) the trait is
19885 true, else it is false.  Requires: @code{type} shall be a complete
19886 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19888 @item __is_union (type)
19889 If @code{type} is a cv union type ([basic.compound]) the trait is
19890 true, else it is false.
19892 @item __underlying_type (type)
19893 The underlying type of @code{type}.  Requires: @code{type} shall be
19894 an enumeration type ([dcl.enum]).
19896 @end table
19898 @node Java Exceptions
19899 @section Java Exceptions
19901 The Java language uses a slightly different exception handling model
19902 from C++.  Normally, GNU C++ automatically detects when you are
19903 writing C++ code that uses Java exceptions, and handle them
19904 appropriately.  However, if C++ code only needs to execute destructors
19905 when Java exceptions are thrown through it, GCC guesses incorrectly.
19906 Sample problematic code is:
19908 @smallexample
19909   struct S @{ ~S(); @};
19910   extern void bar();    // @r{is written in Java, and may throw exceptions}
19911   void foo()
19912   @{
19913     S s;
19914     bar();
19915   @}
19916 @end smallexample
19918 @noindent
19919 The usual effect of an incorrect guess is a link failure, complaining of
19920 a missing routine called @samp{__gxx_personality_v0}.
19922 You can inform the compiler that Java exceptions are to be used in a
19923 translation unit, irrespective of what it might think, by writing
19924 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
19925 @samp{#pragma} must appear before any functions that throw or catch
19926 exceptions, or run destructors when exceptions are thrown through them.
19928 You cannot mix Java and C++ exceptions in the same translation unit.  It
19929 is believed to be safe to throw a C++ exception from one file through
19930 another file compiled for the Java exception model, or vice versa, but
19931 there may be bugs in this area.
19933 @node Deprecated Features
19934 @section Deprecated Features
19936 In the past, the GNU C++ compiler was extended to experiment with new
19937 features, at a time when the C++ language was still evolving.  Now that
19938 the C++ standard is complete, some of those features are superseded by
19939 superior alternatives.  Using the old features might cause a warning in
19940 some cases that the feature will be dropped in the future.  In other
19941 cases, the feature might be gone already.
19943 While the list below is not exhaustive, it documents some of the options
19944 that are now deprecated:
19946 @table @code
19947 @item -fexternal-templates
19948 @itemx -falt-external-templates
19949 These are two of the many ways for G++ to implement template
19950 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
19951 defines how template definitions have to be organized across
19952 implementation units.  G++ has an implicit instantiation mechanism that
19953 should work just fine for standard-conforming code.
19955 @item -fstrict-prototype
19956 @itemx -fno-strict-prototype
19957 Previously it was possible to use an empty prototype parameter list to
19958 indicate an unspecified number of parameters (like C), rather than no
19959 parameters, as C++ demands.  This feature has been removed, except where
19960 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
19961 @end table
19963 G++ allows a virtual function returning @samp{void *} to be overridden
19964 by one returning a different pointer type.  This extension to the
19965 covariant return type rules is now deprecated and will be removed from a
19966 future version.
19968 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19969 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19970 and are now removed from G++.  Code using these operators should be
19971 modified to use @code{std::min} and @code{std::max} instead.
19973 The named return value extension has been deprecated, and is now
19974 removed from G++.
19976 The use of initializer lists with new expressions has been deprecated,
19977 and is now removed from G++.
19979 Floating and complex non-type template parameters have been deprecated,
19980 and are now removed from G++.
19982 The implicit typename extension has been deprecated and is now
19983 removed from G++.
19985 The use of default arguments in function pointers, function typedefs
19986 and other places where they are not permitted by the standard is
19987 deprecated and will be removed from a future version of G++.
19989 G++ allows floating-point literals to appear in integral constant expressions,
19990 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19991 This extension is deprecated and will be removed from a future version.
19993 G++ allows static data members of const floating-point type to be declared
19994 with an initializer in a class definition. The standard only allows
19995 initializers for static members of const integral types and const
19996 enumeration types so this extension has been deprecated and will be removed
19997 from a future version.
19999 @node Backwards Compatibility
20000 @section Backwards Compatibility
20001 @cindex Backwards Compatibility
20002 @cindex ARM [Annotated C++ Reference Manual]
20004 Now that there is a definitive ISO standard C++, G++ has a specification
20005 to adhere to.  The C++ language evolved over time, and features that
20006 used to be acceptable in previous drafts of the standard, such as the ARM
20007 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
20008 compilation of C++ written to such drafts, G++ contains some backwards
20009 compatibilities.  @emph{All such backwards compatibility features are
20010 liable to disappear in future versions of G++.} They should be considered
20011 deprecated.   @xref{Deprecated Features}.
20013 @table @code
20014 @item For scope
20015 If a variable is declared at for scope, it used to remain in scope until
20016 the end of the scope that contained the for statement (rather than just
20017 within the for scope).  G++ retains this, but issues a warning, if such a
20018 variable is accessed outside the for scope.
20020 @item Implicit C language
20021 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
20022 scope to set the language.  On such systems, all header files are
20023 implicitly scoped inside a C language scope.  Also, an empty prototype
20024 @code{()} is treated as an unspecified number of arguments, rather
20025 than no arguments, as C++ demands.
20026 @end table
20028 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
20029 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr