* doc/extend.texi (Size of an asm): Move node text according
[official-gcc.git] / gcc / doc / extend.texi
blobbd2c82915bcb3c9a15bf85b25ce95c1441a77ef7
1 @c Copyright (C) 1988-2014 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Initializers::        Non-constant initializers.
50 * Compound Literals::   Compound literals give structures, unions
51                         or arrays as values.
52 * Designated Inits::    Labeling elements of initializers.
53 * Case Ranges::         `case 1 ... 9' and such.
54 * Cast to Union::       Casting to union type from any member of the union.
55 * Mixed Declarations::  Mixing declarations and code.
56 * Function Attributes:: Declaring that functions have no side effects,
57                         or that they can never return.
58 * Attribute Syntax::    Formal syntax for attributes.
59 * Function Prototypes:: Prototype declarations and old-style definitions.
60 * C++ Comments::        C++ comments are recognized.
61 * Dollar Signs::        Dollar sign is allowed in identifiers.
62 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
63 * Variable Attributes:: Specifying attributes of variables.
64 * Type Attributes::     Specifying attributes of types.
65 * Alignment::           Inquiring about the alignment of a type or variable.
66 * Inline::              Defining inline functions (as fast as macros).
67 * Volatiles::           What constitutes an access to a volatile object.
68 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
69 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
70 * Incomplete Enums::    @code{enum foo;}, with details to follow.
71 * Function Names::      Printable strings which are the name of the current
72                         function.
73 * Return Address::      Getting the return or frame address of a function.
74 * Vector Extensions::   Using vector instructions through built-in functions.
75 * Offsetof::            Special syntax for implementing @code{offsetof}.
76 * __sync Builtins::     Legacy built-in functions for atomic memory access.
77 * __atomic Builtins::   Atomic built-in functions with memory model.
78 * x86 specific memory model extensions for transactional memory:: x86 memory models.
79 * Object Size Checking:: Built-in functions for limited buffer overflow
80                         checking.
81 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
82 * Other Builtins::      Other built-in functions.
83 * Target Builtins::     Built-in functions specific to particular targets.
84 * Target Format Checks:: Format checks specific to particular targets.
85 * Pragmas::             Pragmas accepted by GCC.
86 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
87 * Thread-Local::        Per-thread variables.
88 * Binary constants::    Binary constants using the @samp{0b} prefix.
89 @end menu
91 @node Statement Exprs
92 @section Statements and Declarations in Expressions
93 @cindex statements inside expressions
94 @cindex declarations inside expressions
95 @cindex expressions containing statements
96 @cindex macros, statements in expressions
98 @c the above section title wrapped and causes an underfull hbox.. i
99 @c changed it from "within" to "in". --mew 4feb93
100 A compound statement enclosed in parentheses may appear as an expression
101 in GNU C@.  This allows you to use loops, switches, and local variables
102 within an expression.
104 Recall that a compound statement is a sequence of statements surrounded
105 by braces; in this construct, parentheses go around the braces.  For
106 example:
108 @smallexample
109 (@{ int y = foo (); int z;
110    if (y > 0) z = y;
111    else z = - y;
112    z; @})
113 @end smallexample
115 @noindent
116 is a valid (though slightly more complex than necessary) expression
117 for the absolute value of @code{foo ()}.
119 The last thing in the compound statement should be an expression
120 followed by a semicolon; the value of this subexpression serves as the
121 value of the entire construct.  (If you use some other kind of statement
122 last within the braces, the construct has type @code{void}, and thus
123 effectively no value.)
125 This feature is especially useful in making macro definitions ``safe'' (so
126 that they evaluate each operand exactly once).  For example, the
127 ``maximum'' function is commonly defined as a macro in standard C as
128 follows:
130 @smallexample
131 #define max(a,b) ((a) > (b) ? (a) : (b))
132 @end smallexample
134 @noindent
135 @cindex side effects, macro argument
136 But this definition computes either @var{a} or @var{b} twice, with bad
137 results if the operand has side effects.  In GNU C, if you know the
138 type of the operands (here taken as @code{int}), you can define
139 the macro safely as follows:
141 @smallexample
142 #define maxint(a,b) \
143   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
144 @end smallexample
146 Embedded statements are not allowed in constant expressions, such as
147 the value of an enumeration constant, the width of a bit-field, or
148 the initial value of a static variable.
150 If you don't know the type of the operand, you can still do this, but you
151 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
153 In G++, the result value of a statement expression undergoes array and
154 function pointer decay, and is returned by value to the enclosing
155 expression.  For instance, if @code{A} is a class, then
157 @smallexample
158         A a;
160         (@{a;@}).Foo ()
161 @end smallexample
163 @noindent
164 constructs a temporary @code{A} object to hold the result of the
165 statement expression, and that is used to invoke @code{Foo}.
166 Therefore the @code{this} pointer observed by @code{Foo} is not the
167 address of @code{a}.
169 In a statement expression, any temporaries created within a statement
170 are destroyed at that statement's end.  This makes statement
171 expressions inside macros slightly different from function calls.  In
172 the latter case temporaries introduced during argument evaluation are
173 destroyed at the end of the statement that includes the function
174 call.  In the statement expression case they are destroyed during
175 the statement expression.  For instance,
177 @smallexample
178 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
179 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
181 void foo ()
183   macro (X ());
184   function (X ());
186 @end smallexample
188 @noindent
189 has different places where temporaries are destroyed.  For the
190 @code{macro} case, the temporary @code{X} is destroyed just after
191 the initialization of @code{b}.  In the @code{function} case that
192 temporary is destroyed when the function returns.
194 These considerations mean that it is probably a bad idea to use
195 statement expressions of this form in header files that are designed to
196 work with C++.  (Note that some versions of the GNU C Library contained
197 header files using statement expressions that lead to precisely this
198 bug.)
200 Jumping into a statement expression with @code{goto} or using a
201 @code{switch} statement outside the statement expression with a
202 @code{case} or @code{default} label inside the statement expression is
203 not permitted.  Jumping into a statement expression with a computed
204 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
205 Jumping out of a statement expression is permitted, but if the
206 statement expression is part of a larger expression then it is
207 unspecified which other subexpressions of that expression have been
208 evaluated except where the language definition requires certain
209 subexpressions to be evaluated before or after the statement
210 expression.  In any case, as with a function call, the evaluation of a
211 statement expression is not interleaved with the evaluation of other
212 parts of the containing expression.  For example,
214 @smallexample
215   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
216 @end smallexample
218 @noindent
219 calls @code{foo} and @code{bar1} and does not call @code{baz} but
220 may or may not call @code{bar2}.  If @code{bar2} is called, it is
221 called after @code{foo} and before @code{bar1}.
223 @node Local Labels
224 @section Locally Declared Labels
225 @cindex local labels
226 @cindex macros, local labels
228 GCC allows you to declare @dfn{local labels} in any nested block
229 scope.  A local label is just like an ordinary label, but you can
230 only reference it (with a @code{goto} statement, or by taking its
231 address) within the block in which it is declared.
233 A local label declaration looks like this:
235 @smallexample
236 __label__ @var{label};
237 @end smallexample
239 @noindent
242 @smallexample
243 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
244 @end smallexample
246 Local label declarations must come at the beginning of the block,
247 before any ordinary declarations or statements.
249 The label declaration defines the label @emph{name}, but does not define
250 the label itself.  You must do this in the usual way, with
251 @code{@var{label}:}, within the statements of the statement expression.
253 The local label feature is useful for complex macros.  If a macro
254 contains nested loops, a @code{goto} can be useful for breaking out of
255 them.  However, an ordinary label whose scope is the whole function
256 cannot be used: if the macro can be expanded several times in one
257 function, the label is multiply defined in that function.  A
258 local label avoids this problem.  For example:
260 @smallexample
261 #define SEARCH(value, array, target)              \
262 do @{                                              \
263   __label__ found;                                \
264   typeof (target) _SEARCH_target = (target);      \
265   typeof (*(array)) *_SEARCH_array = (array);     \
266   int i, j;                                       \
267   int value;                                      \
268   for (i = 0; i < max; i++)                       \
269     for (j = 0; j < max; j++)                     \
270       if (_SEARCH_array[i][j] == _SEARCH_target)  \
271         @{ (value) = i; goto found; @}              \
272   (value) = -1;                                   \
273  found:;                                          \
274 @} while (0)
275 @end smallexample
277 This could also be written using a statement expression:
279 @smallexample
280 #define SEARCH(array, target)                     \
281 (@{                                                \
282   __label__ found;                                \
283   typeof (target) _SEARCH_target = (target);      \
284   typeof (*(array)) *_SEARCH_array = (array);     \
285   int i, j;                                       \
286   int value;                                      \
287   for (i = 0; i < max; i++)                       \
288     for (j = 0; j < max; j++)                     \
289       if (_SEARCH_array[i][j] == _SEARCH_target)  \
290         @{ value = i; goto found; @}                \
291   value = -1;                                     \
292  found:                                           \
293   value;                                          \
295 @end smallexample
297 Local label declarations also make the labels they declare visible to
298 nested functions, if there are any.  @xref{Nested Functions}, for details.
300 @node Labels as Values
301 @section Labels as Values
302 @cindex labels as values
303 @cindex computed gotos
304 @cindex goto with computed label
305 @cindex address of a label
307 You can get the address of a label defined in the current function
308 (or a containing function) with the unary operator @samp{&&}.  The
309 value has type @code{void *}.  This value is a constant and can be used
310 wherever a constant of that type is valid.  For example:
312 @smallexample
313 void *ptr;
314 /* @r{@dots{}} */
315 ptr = &&foo;
316 @end smallexample
318 To use these values, you need to be able to jump to one.  This is done
319 with the computed goto statement@footnote{The analogous feature in
320 Fortran is called an assigned goto, but that name seems inappropriate in
321 C, where one can do more than simply store label addresses in label
322 variables.}, @code{goto *@var{exp};}.  For example,
324 @smallexample
325 goto *ptr;
326 @end smallexample
328 @noindent
329 Any expression of type @code{void *} is allowed.
331 One way of using these constants is in initializing a static array that
332 serves as a jump table:
334 @smallexample
335 static void *array[] = @{ &&foo, &&bar, &&hack @};
336 @end smallexample
338 @noindent
339 Then you can select a label with indexing, like this:
341 @smallexample
342 goto *array[i];
343 @end smallexample
345 @noindent
346 Note that this does not check whether the subscript is in bounds---array
347 indexing in C never does that.
349 Such an array of label values serves a purpose much like that of the
350 @code{switch} statement.  The @code{switch} statement is cleaner, so
351 use that rather than an array unless the problem does not fit a
352 @code{switch} statement very well.
354 Another use of label values is in an interpreter for threaded code.
355 The labels within the interpreter function can be stored in the
356 threaded code for super-fast dispatching.
358 You may not use this mechanism to jump to code in a different function.
359 If you do that, totally unpredictable things happen.  The best way to
360 avoid this is to store the label address only in automatic variables and
361 never pass it as an argument.
363 An alternate way to write the above example is
365 @smallexample
366 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
367                              &&hack - &&foo @};
368 goto *(&&foo + array[i]);
369 @end smallexample
371 @noindent
372 This is more friendly to code living in shared libraries, as it reduces
373 the number of dynamic relocations that are needed, and by consequence,
374 allows the data to be read-only.
376 The @code{&&foo} expressions for the same label might have different
377 values if the containing function is inlined or cloned.  If a program
378 relies on them being always the same,
379 @code{__attribute__((__noinline__,__noclone__))} should be used to
380 prevent inlining and cloning.  If @code{&&foo} is used in a static
381 variable initializer, inlining and cloning is forbidden.
383 @node Nested Functions
384 @section Nested Functions
385 @cindex nested functions
386 @cindex downward funargs
387 @cindex thunks
389 A @dfn{nested function} is a function defined inside another function.
390 Nested functions are supported as an extension in GNU C, but are not
391 supported by GNU C++.
393 The nested function's name is local to the block where it is defined.
394 For example, here we define a nested function named @code{square}, and
395 call it twice:
397 @smallexample
398 @group
399 foo (double a, double b)
401   double square (double z) @{ return z * z; @}
403   return square (a) + square (b);
405 @end group
406 @end smallexample
408 The nested function can access all the variables of the containing
409 function that are visible at the point of its definition.  This is
410 called @dfn{lexical scoping}.  For example, here we show a nested
411 function which uses an inherited variable named @code{offset}:
413 @smallexample
414 @group
415 bar (int *array, int offset, int size)
417   int access (int *array, int index)
418     @{ return array[index + offset]; @}
419   int i;
420   /* @r{@dots{}} */
421   for (i = 0; i < size; i++)
422     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
424 @end group
425 @end smallexample
427 Nested function definitions are permitted within functions in the places
428 where variable definitions are allowed; that is, in any block, mixed
429 with the other declarations and statements in the block.
431 It is possible to call the nested function from outside the scope of its
432 name by storing its address or passing the address to another function:
434 @smallexample
435 hack (int *array, int size)
437   void store (int index, int value)
438     @{ array[index] = value; @}
440   intermediate (store, size);
442 @end smallexample
444 Here, the function @code{intermediate} receives the address of
445 @code{store} as an argument.  If @code{intermediate} calls @code{store},
446 the arguments given to @code{store} are used to store into @code{array}.
447 But this technique works only so long as the containing function
448 (@code{hack}, in this example) does not exit.
450 If you try to call the nested function through its address after the
451 containing function exits, all hell breaks loose.  If you try
452 to call it after a containing scope level exits, and if it refers
453 to some of the variables that are no longer in scope, you may be lucky,
454 but it's not wise to take the risk.  If, however, the nested function
455 does not refer to anything that has gone out of scope, you should be
456 safe.
458 GCC implements taking the address of a nested function using a technique
459 called @dfn{trampolines}.  This technique was described in
460 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
461 C++ Conference Proceedings, October 17-21, 1988).
463 A nested function can jump to a label inherited from a containing
464 function, provided the label is explicitly declared in the containing
465 function (@pxref{Local Labels}).  Such a jump returns instantly to the
466 containing function, exiting the nested function that did the
467 @code{goto} and any intermediate functions as well.  Here is an example:
469 @smallexample
470 @group
471 bar (int *array, int offset, int size)
473   __label__ failure;
474   int access (int *array, int index)
475     @{
476       if (index > size)
477         goto failure;
478       return array[index + offset];
479     @}
480   int i;
481   /* @r{@dots{}} */
482   for (i = 0; i < size; i++)
483     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
484   /* @r{@dots{}} */
485   return 0;
487  /* @r{Control comes here from @code{access}
488     if it detects an error.}  */
489  failure:
490   return -1;
492 @end group
493 @end smallexample
495 A nested function always has no linkage.  Declaring one with
496 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
497 before its definition, use @code{auto} (which is otherwise meaningless
498 for function declarations).
500 @smallexample
501 bar (int *array, int offset, int size)
503   __label__ failure;
504   auto int access (int *, int);
505   /* @r{@dots{}} */
506   int access (int *array, int index)
507     @{
508       if (index > size)
509         goto failure;
510       return array[index + offset];
511     @}
512   /* @r{@dots{}} */
514 @end smallexample
516 @node Constructing Calls
517 @section Constructing Function Calls
518 @cindex constructing calls
519 @cindex forwarding calls
521 Using the built-in functions described below, you can record
522 the arguments a function received, and call another function
523 with the same arguments, without knowing the number or types
524 of the arguments.
526 You can also record the return value of that function call,
527 and later return that value, without knowing what data type
528 the function tried to return (as long as your caller expects
529 that data type).
531 However, these built-in functions may interact badly with some
532 sophisticated features or other extensions of the language.  It
533 is, therefore, not recommended to use them outside very simple
534 functions acting as mere forwarders for their arguments.
536 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
537 This built-in function returns a pointer to data
538 describing how to perform a call with the same arguments as are passed
539 to the current function.
541 The function saves the arg pointer register, structure value address,
542 and all registers that might be used to pass arguments to a function
543 into a block of memory allocated on the stack.  Then it returns the
544 address of that block.
545 @end deftypefn
547 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
548 This built-in function invokes @var{function}
549 with a copy of the parameters described by @var{arguments}
550 and @var{size}.
552 The value of @var{arguments} should be the value returned by
553 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
554 of the stack argument data, in bytes.
556 This function returns a pointer to data describing
557 how to return whatever value is returned by @var{function}.  The data
558 is saved in a block of memory allocated on the stack.
560 It is not always simple to compute the proper value for @var{size}.  The
561 value is used by @code{__builtin_apply} to compute the amount of data
562 that should be pushed on the stack and copied from the incoming argument
563 area.
564 @end deftypefn
566 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
567 This built-in function returns the value described by @var{result} from
568 the containing function.  You should specify, for @var{result}, a value
569 returned by @code{__builtin_apply}.
570 @end deftypefn
572 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
573 This built-in function represents all anonymous arguments of an inline
574 function.  It can be used only in inline functions that are always
575 inlined, never compiled as a separate function, such as those using
576 @code{__attribute__ ((__always_inline__))} or
577 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
578 It must be only passed as last argument to some other function
579 with variable arguments.  This is useful for writing small wrapper
580 inlines for variable argument functions, when using preprocessor
581 macros is undesirable.  For example:
582 @smallexample
583 extern int myprintf (FILE *f, const char *format, ...);
584 extern inline __attribute__ ((__gnu_inline__)) int
585 myprintf (FILE *f, const char *format, ...)
587   int r = fprintf (f, "myprintf: ");
588   if (r < 0)
589     return r;
590   int s = fprintf (f, format, __builtin_va_arg_pack ());
591   if (s < 0)
592     return s;
593   return r + s;
595 @end smallexample
596 @end deftypefn
598 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
599 This built-in function returns the number of anonymous arguments of
600 an inline function.  It can be used only in inline functions that
601 are always inlined, never compiled as a separate function, such
602 as those using @code{__attribute__ ((__always_inline__))} or
603 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
604 For example following does link- or run-time checking of open
605 arguments for optimized code:
606 @smallexample
607 #ifdef __OPTIMIZE__
608 extern inline __attribute__((__gnu_inline__)) int
609 myopen (const char *path, int oflag, ...)
611   if (__builtin_va_arg_pack_len () > 1)
612     warn_open_too_many_arguments ();
614   if (__builtin_constant_p (oflag))
615     @{
616       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
617         @{
618           warn_open_missing_mode ();
619           return __open_2 (path, oflag);
620         @}
621       return open (path, oflag, __builtin_va_arg_pack ());
622     @}
624   if (__builtin_va_arg_pack_len () < 1)
625     return __open_2 (path, oflag);
627   return open (path, oflag, __builtin_va_arg_pack ());
629 #endif
630 @end smallexample
631 @end deftypefn
633 @node Typeof
634 @section Referring to a Type with @code{typeof}
635 @findex typeof
636 @findex sizeof
637 @cindex macros, types of arguments
639 Another way to refer to the type of an expression is with @code{typeof}.
640 The syntax of using of this keyword looks like @code{sizeof}, but the
641 construct acts semantically like a type name defined with @code{typedef}.
643 There are two ways of writing the argument to @code{typeof}: with an
644 expression or with a type.  Here is an example with an expression:
646 @smallexample
647 typeof (x[0](1))
648 @end smallexample
650 @noindent
651 This assumes that @code{x} is an array of pointers to functions;
652 the type described is that of the values of the functions.
654 Here is an example with a typename as the argument:
656 @smallexample
657 typeof (int *)
658 @end smallexample
660 @noindent
661 Here the type described is that of pointers to @code{int}.
663 If you are writing a header file that must work when included in ISO C
664 programs, write @code{__typeof__} instead of @code{typeof}.
665 @xref{Alternate Keywords}.
667 A @code{typeof} construct can be used anywhere a typedef name can be
668 used.  For example, you can use it in a declaration, in a cast, or inside
669 of @code{sizeof} or @code{typeof}.
671 The operand of @code{typeof} is evaluated for its side effects if and
672 only if it is an expression of variably modified type or the name of
673 such a type.
675 @code{typeof} is often useful in conjunction with
676 statement expressions (@pxref{Statement Exprs}).
677 Here is how the two together can
678 be used to define a safe ``maximum'' macro which operates on any
679 arithmetic type and evaluates each of its arguments exactly once:
681 @smallexample
682 #define max(a,b) \
683   (@{ typeof (a) _a = (a); \
684       typeof (b) _b = (b); \
685     _a > _b ? _a : _b; @})
686 @end smallexample
688 @cindex underscores in variables in macros
689 @cindex @samp{_} in variables in macros
690 @cindex local variables in macros
691 @cindex variables, local, in macros
692 @cindex macros, local variables in
694 The reason for using names that start with underscores for the local
695 variables is to avoid conflicts with variable names that occur within the
696 expressions that are substituted for @code{a} and @code{b}.  Eventually we
697 hope to design a new form of declaration syntax that allows you to declare
698 variables whose scopes start only after their initializers; this will be a
699 more reliable way to prevent such conflicts.
701 @noindent
702 Some more examples of the use of @code{typeof}:
704 @itemize @bullet
705 @item
706 This declares @code{y} with the type of what @code{x} points to.
708 @smallexample
709 typeof (*x) y;
710 @end smallexample
712 @item
713 This declares @code{y} as an array of such values.
715 @smallexample
716 typeof (*x) y[4];
717 @end smallexample
719 @item
720 This declares @code{y} as an array of pointers to characters:
722 @smallexample
723 typeof (typeof (char *)[4]) y;
724 @end smallexample
726 @noindent
727 It is equivalent to the following traditional C declaration:
729 @smallexample
730 char *y[4];
731 @end smallexample
733 To see the meaning of the declaration using @code{typeof}, and why it
734 might be a useful way to write, rewrite it with these macros:
736 @smallexample
737 #define pointer(T)  typeof(T *)
738 #define array(T, N) typeof(T [N])
739 @end smallexample
741 @noindent
742 Now the declaration can be rewritten this way:
744 @smallexample
745 array (pointer (char), 4) y;
746 @end smallexample
748 @noindent
749 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
750 pointers to @code{char}.
751 @end itemize
753 In GNU C, but not GNU C++, you may also declare the type of a variable
754 as @code{__auto_type}.  In that case, the declaration must declare
755 only one variable, whose declarator must just be an identifier, the
756 declaration must be initialized, and the type of the variable is
757 determined by the initializer; the name of the variable is not in
758 scope until after the initializer.  (In C++, you should use C++11
759 @code{auto} for this purpose.)  Using @code{__auto_type}, the
760 ``maximum'' macro above could be written as:
762 @smallexample
763 #define max(a,b) \
764   (@{ __auto_type _a = (a); \
765       __auto_type _b = (b); \
766     _a > _b ? _a : _b; @})
767 @end smallexample
769 Using @code{__auto_type} instead of @code{typeof} has two advantages:
771 @itemize @bullet
772 @item Each argument to the macro appears only once in the expansion of
773 the macro.  This prevents the size of the macro expansion growing
774 exponentially when calls to such macros are nested inside arguments of
775 such macros.
777 @item If the argument to the macro has variably modified type, it is
778 evaluated only once when using @code{__auto_type}, but twice if
779 @code{typeof} is used.
780 @end itemize
782 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
783 a more limited extension that permitted one to write
785 @smallexample
786 typedef @var{T} = @var{expr};
787 @end smallexample
789 @noindent
790 with the effect of declaring @var{T} to have the type of the expression
791 @var{expr}.  This extension does not work with GCC 3 (versions between
792 3.0 and 3.2 crash; 3.2.1 and later give an error).  Code that
793 relies on it should be rewritten to use @code{typeof}:
795 @smallexample
796 typedef typeof(@var{expr}) @var{T};
797 @end smallexample
799 @noindent
800 This works with all versions of GCC@.
802 @node Conditionals
803 @section Conditionals with Omitted Operands
804 @cindex conditional expressions, extensions
805 @cindex omitted middle-operands
806 @cindex middle-operands, omitted
807 @cindex extensions, @code{?:}
808 @cindex @code{?:} extensions
810 The middle operand in a conditional expression may be omitted.  Then
811 if the first operand is nonzero, its value is the value of the conditional
812 expression.
814 Therefore, the expression
816 @smallexample
817 x ? : y
818 @end smallexample
820 @noindent
821 has the value of @code{x} if that is nonzero; otherwise, the value of
822 @code{y}.
824 This example is perfectly equivalent to
826 @smallexample
827 x ? x : y
828 @end smallexample
830 @cindex side effect in @code{?:}
831 @cindex @code{?:} side effect
832 @noindent
833 In this simple case, the ability to omit the middle operand is not
834 especially useful.  When it becomes useful is when the first operand does,
835 or may (if it is a macro argument), contain a side effect.  Then repeating
836 the operand in the middle would perform the side effect twice.  Omitting
837 the middle operand uses the value already computed without the undesirable
838 effects of recomputing it.
840 @node __int128
841 @section 128-bit integers
842 @cindex @code{__int128} data types
844 As an extension the integer scalar type @code{__int128} is supported for
845 targets which have an integer mode wide enough to hold 128 bits.
846 Simply write @code{__int128} for a signed 128-bit integer, or
847 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
848 support in GCC for expressing an integer constant of type @code{__int128}
849 for targets with @code{long long} integer less than 128 bits wide.
851 @node Long Long
852 @section Double-Word Integers
853 @cindex @code{long long} data types
854 @cindex double-word arithmetic
855 @cindex multiprecision arithmetic
856 @cindex @code{LL} integer suffix
857 @cindex @code{ULL} integer suffix
859 ISO C99 supports data types for integers that are at least 64 bits wide,
860 and as an extension GCC supports them in C90 mode and in C++.
861 Simply write @code{long long int} for a signed integer, or
862 @code{unsigned long long int} for an unsigned integer.  To make an
863 integer constant of type @code{long long int}, add the suffix @samp{LL}
864 to the integer.  To make an integer constant of type @code{unsigned long
865 long int}, add the suffix @samp{ULL} to the integer.
867 You can use these types in arithmetic like any other integer types.
868 Addition, subtraction, and bitwise boolean operations on these types
869 are open-coded on all types of machines.  Multiplication is open-coded
870 if the machine supports a fullword-to-doubleword widening multiply
871 instruction.  Division and shifts are open-coded only on machines that
872 provide special support.  The operations that are not open-coded use
873 special library routines that come with GCC@.
875 There may be pitfalls when you use @code{long long} types for function
876 arguments without function prototypes.  If a function
877 expects type @code{int} for its argument, and you pass a value of type
878 @code{long long int}, confusion results because the caller and the
879 subroutine disagree about the number of bytes for the argument.
880 Likewise, if the function expects @code{long long int} and you pass
881 @code{int}.  The best way to avoid such problems is to use prototypes.
883 @node Complex
884 @section Complex Numbers
885 @cindex complex numbers
886 @cindex @code{_Complex} keyword
887 @cindex @code{__complex__} keyword
889 ISO C99 supports complex floating data types, and as an extension GCC
890 supports them in C90 mode and in C++.  GCC also supports complex integer data
891 types which are not part of ISO C99.  You can declare complex types
892 using the keyword @code{_Complex}.  As an extension, the older GNU
893 keyword @code{__complex__} is also supported.
895 For example, @samp{_Complex double x;} declares @code{x} as a
896 variable whose real part and imaginary part are both of type
897 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
898 have real and imaginary parts of type @code{short int}; this is not
899 likely to be useful, but it shows that the set of complex types is
900 complete.
902 To write a constant with a complex data type, use the suffix @samp{i} or
903 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
904 has type @code{_Complex float} and @code{3i} has type
905 @code{_Complex int}.  Such a constant always has a pure imaginary
906 value, but you can form any complex value you like by adding one to a
907 real constant.  This is a GNU extension; if you have an ISO C99
908 conforming C library (such as the GNU C Library), and want to construct complex
909 constants of floating type, you should include @code{<complex.h>} and
910 use the macros @code{I} or @code{_Complex_I} instead.
912 @cindex @code{__real__} keyword
913 @cindex @code{__imag__} keyword
914 To extract the real part of a complex-valued expression @var{exp}, write
915 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
916 extract the imaginary part.  This is a GNU extension; for values of
917 floating type, you should use the ISO C99 functions @code{crealf},
918 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
919 @code{cimagl}, declared in @code{<complex.h>} and also provided as
920 built-in functions by GCC@.
922 @cindex complex conjugation
923 The operator @samp{~} performs complex conjugation when used on a value
924 with a complex type.  This is a GNU extension; for values of
925 floating type, you should use the ISO C99 functions @code{conjf},
926 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
927 provided as built-in functions by GCC@.
929 GCC can allocate complex automatic variables in a noncontiguous
930 fashion; it's even possible for the real part to be in a register while
931 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
932 debug info format can represent this, so use of DWARF 2 is recommended.
933 If you are using the stabs debug info format, GCC describes a noncontiguous
934 complex variable as if it were two separate variables of noncomplex type.
935 If the variable's actual name is @code{foo}, the two fictitious
936 variables are named @code{foo$real} and @code{foo$imag}.  You can
937 examine and set these two fictitious variables with your debugger.
939 @node Floating Types
940 @section Additional Floating Types
941 @cindex additional floating types
942 @cindex @code{__float80} data type
943 @cindex @code{__float128} data type
944 @cindex @code{w} floating point suffix
945 @cindex @code{q} floating point suffix
946 @cindex @code{W} floating point suffix
947 @cindex @code{Q} floating point suffix
949 As an extension, GNU C supports additional floating
950 types, @code{__float80} and @code{__float128} to support 80-bit
951 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
952 Support for additional types includes the arithmetic operators:
953 add, subtract, multiply, divide; unary arithmetic operators;
954 relational operators; equality operators; and conversions to and from
955 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
956 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
957 for @code{_float128}.  You can declare complex types using the
958 corresponding internal complex type, @code{XCmode} for @code{__float80}
959 type and @code{TCmode} for @code{__float128} type:
961 @smallexample
962 typedef _Complex float __attribute__((mode(TC))) _Complex128;
963 typedef _Complex float __attribute__((mode(XC))) _Complex80;
964 @end smallexample
966 Not all targets support additional floating-point types.  @code{__float80}
967 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
968 The @code{__float128} type is supported on hppa HP-UX targets.
970 @node Half-Precision
971 @section Half-Precision Floating Point
972 @cindex half-precision floating point
973 @cindex @code{__fp16} data type
975 On ARM targets, GCC supports half-precision (16-bit) floating point via
976 the @code{__fp16} type.  You must enable this type explicitly
977 with the @option{-mfp16-format} command-line option in order to use it.
979 ARM supports two incompatible representations for half-precision
980 floating-point values.  You must choose one of the representations and
981 use it consistently in your program.
983 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
984 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
985 There are 11 bits of significand precision, approximately 3
986 decimal digits.
988 Specifying @option{-mfp16-format=alternative} selects the ARM
989 alternative format.  This representation is similar to the IEEE
990 format, but does not support infinities or NaNs.  Instead, the range
991 of exponents is extended, so that this format can represent normalized
992 values in the range of @math{2^{-14}} to 131008.
994 The @code{__fp16} type is a storage format only.  For purposes
995 of arithmetic and other operations, @code{__fp16} values in C or C++
996 expressions are automatically promoted to @code{float}.  In addition,
997 you cannot declare a function with a return value or parameters
998 of type @code{__fp16}.
1000 Note that conversions from @code{double} to @code{__fp16}
1001 involve an intermediate conversion to @code{float}.  Because
1002 of rounding, this can sometimes produce a different result than a
1003 direct conversion.
1005 ARM provides hardware support for conversions between
1006 @code{__fp16} and @code{float} values
1007 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
1008 code using these hardware instructions if you compile with
1009 options to select an FPU that provides them;
1010 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1011 in addition to the @option{-mfp16-format} option to select
1012 a half-precision format.
1014 Language-level support for the @code{__fp16} data type is
1015 independent of whether GCC generates code using hardware floating-point
1016 instructions.  In cases where hardware support is not specified, GCC
1017 implements conversions between @code{__fp16} and @code{float} values
1018 as library calls.
1020 @node Decimal Float
1021 @section Decimal Floating Types
1022 @cindex decimal floating types
1023 @cindex @code{_Decimal32} data type
1024 @cindex @code{_Decimal64} data type
1025 @cindex @code{_Decimal128} data type
1026 @cindex @code{df} integer suffix
1027 @cindex @code{dd} integer suffix
1028 @cindex @code{dl} integer suffix
1029 @cindex @code{DF} integer suffix
1030 @cindex @code{DD} integer suffix
1031 @cindex @code{DL} integer suffix
1033 As an extension, GNU C supports decimal floating types as
1034 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1035 floating types in GCC will evolve as the draft technical report changes.
1036 Calling conventions for any target might also change.  Not all targets
1037 support decimal floating types.
1039 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1040 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1041 @code{float}, @code{double}, and @code{long double} whose radix is not
1042 specified by the C standard but is usually two.
1044 Support for decimal floating types includes the arithmetic operators
1045 add, subtract, multiply, divide; unary arithmetic operators;
1046 relational operators; equality operators; and conversions to and from
1047 integer and other floating types.  Use a suffix @samp{df} or
1048 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1049 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1050 @code{_Decimal128}.
1052 GCC support of decimal float as specified by the draft technical report
1053 is incomplete:
1055 @itemize @bullet
1056 @item
1057 When the value of a decimal floating type cannot be represented in the
1058 integer type to which it is being converted, the result is undefined
1059 rather than the result value specified by the draft technical report.
1061 @item
1062 GCC does not provide the C library functionality associated with
1063 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1064 @file{wchar.h}, which must come from a separate C library implementation.
1065 Because of this the GNU C compiler does not define macro
1066 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1067 the technical report.
1068 @end itemize
1070 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1071 are supported by the DWARF 2 debug information format.
1073 @node Hex Floats
1074 @section Hex Floats
1075 @cindex hex floats
1077 ISO C99 supports floating-point numbers written not only in the usual
1078 decimal notation, such as @code{1.55e1}, but also numbers such as
1079 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1080 supports this in C90 mode (except in some cases when strictly
1081 conforming) and in C++.  In that format the
1082 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1083 mandatory.  The exponent is a decimal number that indicates the power of
1084 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1085 @tex
1086 $1 {15\over16}$,
1087 @end tex
1088 @ifnottex
1089 1 15/16,
1090 @end ifnottex
1091 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1092 is the same as @code{1.55e1}.
1094 Unlike for floating-point numbers in the decimal notation the exponent
1095 is always required in the hexadecimal notation.  Otherwise the compiler
1096 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1097 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1098 extension for floating-point constants of type @code{float}.
1100 @node Fixed-Point
1101 @section Fixed-Point Types
1102 @cindex fixed-point types
1103 @cindex @code{_Fract} data type
1104 @cindex @code{_Accum} data type
1105 @cindex @code{_Sat} data type
1106 @cindex @code{hr} fixed-suffix
1107 @cindex @code{r} fixed-suffix
1108 @cindex @code{lr} fixed-suffix
1109 @cindex @code{llr} fixed-suffix
1110 @cindex @code{uhr} fixed-suffix
1111 @cindex @code{ur} fixed-suffix
1112 @cindex @code{ulr} fixed-suffix
1113 @cindex @code{ullr} fixed-suffix
1114 @cindex @code{hk} fixed-suffix
1115 @cindex @code{k} fixed-suffix
1116 @cindex @code{lk} fixed-suffix
1117 @cindex @code{llk} fixed-suffix
1118 @cindex @code{uhk} fixed-suffix
1119 @cindex @code{uk} fixed-suffix
1120 @cindex @code{ulk} fixed-suffix
1121 @cindex @code{ullk} fixed-suffix
1122 @cindex @code{HR} fixed-suffix
1123 @cindex @code{R} fixed-suffix
1124 @cindex @code{LR} fixed-suffix
1125 @cindex @code{LLR} fixed-suffix
1126 @cindex @code{UHR} fixed-suffix
1127 @cindex @code{UR} fixed-suffix
1128 @cindex @code{ULR} fixed-suffix
1129 @cindex @code{ULLR} fixed-suffix
1130 @cindex @code{HK} fixed-suffix
1131 @cindex @code{K} fixed-suffix
1132 @cindex @code{LK} fixed-suffix
1133 @cindex @code{LLK} fixed-suffix
1134 @cindex @code{UHK} fixed-suffix
1135 @cindex @code{UK} fixed-suffix
1136 @cindex @code{ULK} fixed-suffix
1137 @cindex @code{ULLK} fixed-suffix
1139 As an extension, GNU C supports fixed-point types as
1140 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1141 types in GCC will evolve as the draft technical report changes.
1142 Calling conventions for any target might also change.  Not all targets
1143 support fixed-point types.
1145 The fixed-point types are
1146 @code{short _Fract},
1147 @code{_Fract},
1148 @code{long _Fract},
1149 @code{long long _Fract},
1150 @code{unsigned short _Fract},
1151 @code{unsigned _Fract},
1152 @code{unsigned long _Fract},
1153 @code{unsigned long long _Fract},
1154 @code{_Sat short _Fract},
1155 @code{_Sat _Fract},
1156 @code{_Sat long _Fract},
1157 @code{_Sat long long _Fract},
1158 @code{_Sat unsigned short _Fract},
1159 @code{_Sat unsigned _Fract},
1160 @code{_Sat unsigned long _Fract},
1161 @code{_Sat unsigned long long _Fract},
1162 @code{short _Accum},
1163 @code{_Accum},
1164 @code{long _Accum},
1165 @code{long long _Accum},
1166 @code{unsigned short _Accum},
1167 @code{unsigned _Accum},
1168 @code{unsigned long _Accum},
1169 @code{unsigned long long _Accum},
1170 @code{_Sat short _Accum},
1171 @code{_Sat _Accum},
1172 @code{_Sat long _Accum},
1173 @code{_Sat long long _Accum},
1174 @code{_Sat unsigned short _Accum},
1175 @code{_Sat unsigned _Accum},
1176 @code{_Sat unsigned long _Accum},
1177 @code{_Sat unsigned long long _Accum}.
1179 Fixed-point data values contain fractional and optional integral parts.
1180 The format of fixed-point data varies and depends on the target machine.
1182 Support for fixed-point types includes:
1183 @itemize @bullet
1184 @item
1185 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1186 @item
1187 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1188 @item
1189 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1190 @item
1191 binary shift operators (@code{<<}, @code{>>})
1192 @item
1193 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1194 @item
1195 equality operators (@code{==}, @code{!=})
1196 @item
1197 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1198 @code{<<=}, @code{>>=})
1199 @item
1200 conversions to and from integer, floating-point, or fixed-point types
1201 @end itemize
1203 Use a suffix in a fixed-point literal constant:
1204 @itemize
1205 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1206 @code{_Sat short _Fract}
1207 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1208 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1209 @code{_Sat long _Fract}
1210 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1211 @code{_Sat long long _Fract}
1212 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1213 @code{_Sat unsigned short _Fract}
1214 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1215 @code{_Sat unsigned _Fract}
1216 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1217 @code{_Sat unsigned long _Fract}
1218 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1219 and @code{_Sat unsigned long long _Fract}
1220 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1221 @code{_Sat short _Accum}
1222 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1223 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1224 @code{_Sat long _Accum}
1225 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1226 @code{_Sat long long _Accum}
1227 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1228 @code{_Sat unsigned short _Accum}
1229 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1230 @code{_Sat unsigned _Accum}
1231 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1232 @code{_Sat unsigned long _Accum}
1233 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1234 and @code{_Sat unsigned long long _Accum}
1235 @end itemize
1237 GCC support of fixed-point types as specified by the draft technical report
1238 is incomplete:
1240 @itemize @bullet
1241 @item
1242 Pragmas to control overflow and rounding behaviors are not implemented.
1243 @end itemize
1245 Fixed-point types are supported by the DWARF 2 debug information format.
1247 @node Named Address Spaces
1248 @section Named Address Spaces
1249 @cindex Named Address Spaces
1251 As an extension, GNU C supports named address spaces as
1252 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1253 address spaces in GCC will evolve as the draft technical report
1254 changes.  Calling conventions for any target might also change.  At
1255 present, only the AVR, SPU, M32C, and RL78 targets support address
1256 spaces other than the generic address space.
1258 Address space identifiers may be used exactly like any other C type
1259 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1260 document for more details.
1262 @anchor{AVR Named Address Spaces}
1263 @subsection AVR Named Address Spaces
1265 On the AVR target, there are several address spaces that can be used
1266 in order to put read-only data into the flash memory and access that
1267 data by means of the special instructions @code{LPM} or @code{ELPM}
1268 needed to read from flash.
1270 Per default, any data including read-only data is located in RAM
1271 (the generic address space) so that non-generic address spaces are
1272 needed to locate read-only data in flash memory
1273 @emph{and} to generate the right instructions to access this data
1274 without using (inline) assembler code.
1276 @table @code
1277 @item __flash
1278 @cindex @code{__flash} AVR Named Address Spaces
1279 The @code{__flash} qualifier locates data in the
1280 @code{.progmem.data} section. Data is read using the @code{LPM}
1281 instruction. Pointers to this address space are 16 bits wide.
1283 @item __flash1
1284 @itemx __flash2
1285 @itemx __flash3
1286 @itemx __flash4
1287 @itemx __flash5
1288 @cindex @code{__flash1} AVR Named Address Spaces
1289 @cindex @code{__flash2} AVR Named Address Spaces
1290 @cindex @code{__flash3} AVR Named Address Spaces
1291 @cindex @code{__flash4} AVR Named Address Spaces
1292 @cindex @code{__flash5} AVR Named Address Spaces
1293 These are 16-bit address spaces locating data in section
1294 @code{.progmem@var{N}.data} where @var{N} refers to
1295 address space @code{__flash@var{N}}.
1296 The compiler sets the @code{RAMPZ} segment register appropriately 
1297 before reading data by means of the @code{ELPM} instruction.
1299 @item __memx
1300 @cindex @code{__memx} AVR Named Address Spaces
1301 This is a 24-bit address space that linearizes flash and RAM:
1302 If the high bit of the address is set, data is read from
1303 RAM using the lower two bytes as RAM address.
1304 If the high bit of the address is clear, data is read from flash
1305 with @code{RAMPZ} set according to the high byte of the address.
1306 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1308 Objects in this address space are located in @code{.progmemx.data}.
1309 @end table
1311 @b{Example}
1313 @smallexample
1314 char my_read (const __flash char ** p)
1316     /* p is a pointer to RAM that points to a pointer to flash.
1317        The first indirection of p reads that flash pointer
1318        from RAM and the second indirection reads a char from this
1319        flash address.  */
1321     return **p;
1324 /* Locate array[] in flash memory */
1325 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1327 int i = 1;
1329 int main (void)
1331    /* Return 17 by reading from flash memory */
1332    return array[array[i]];
1334 @end smallexample
1336 @noindent
1337 For each named address space supported by avr-gcc there is an equally
1338 named but uppercase built-in macro defined. 
1339 The purpose is to facilitate testing if respective address space
1340 support is available or not:
1342 @smallexample
1343 #ifdef __FLASH
1344 const __flash int var = 1;
1346 int read_var (void)
1348     return var;
1350 #else
1351 #include <avr/pgmspace.h> /* From AVR-LibC */
1353 const int var PROGMEM = 1;
1355 int read_var (void)
1357     return (int) pgm_read_word (&var);
1359 #endif /* __FLASH */
1360 @end smallexample
1362 @noindent
1363 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1364 locates data in flash but
1365 accesses to these data read from generic address space, i.e.@:
1366 from RAM,
1367 so that you need special accessors like @code{pgm_read_byte}
1368 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1369 together with attribute @code{progmem}.
1371 @noindent
1372 @b{Limitations and caveats}
1374 @itemize
1375 @item
1376 Reading across the 64@tie{}KiB section boundary of
1377 the @code{__flash} or @code{__flash@var{N}} address spaces
1378 shows undefined behavior. The only address space that
1379 supports reading across the 64@tie{}KiB flash segment boundaries is
1380 @code{__memx}.
1382 @item
1383 If you use one of the @code{__flash@var{N}} address spaces
1384 you must arrange your linker script to locate the
1385 @code{.progmem@var{N}.data} sections according to your needs.
1387 @item
1388 Any data or pointers to the non-generic address spaces must
1389 be qualified as @code{const}, i.e.@: as read-only data.
1390 This still applies if the data in one of these address
1391 spaces like software version number or calibration lookup table are intended to
1392 be changed after load time by, say, a boot loader. In this case
1393 the right qualification is @code{const} @code{volatile} so that the compiler
1394 must not optimize away known values or insert them
1395 as immediates into operands of instructions.
1397 @item
1398 The following code initializes a variable @code{pfoo}
1399 located in static storage with a 24-bit address:
1400 @smallexample
1401 extern const __memx char foo;
1402 const __memx void *pfoo = &foo;
1403 @end smallexample
1405 @noindent
1406 Such code requires at least binutils 2.23, see
1407 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1409 @end itemize
1411 @subsection M32C Named Address Spaces
1412 @cindex @code{__far} M32C Named Address Spaces
1414 On the M32C target, with the R8C and M16C CPU variants, variables
1415 qualified with @code{__far} are accessed using 32-bit addresses in
1416 order to access memory beyond the first 64@tie{}Ki bytes.  If
1417 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1418 effect.
1420 @subsection RL78 Named Address Spaces
1421 @cindex @code{__far} RL78 Named Address Spaces
1423 On the RL78 target, variables qualified with @code{__far} are accessed
1424 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1425 addresses.  Non-far variables are assumed to appear in the topmost
1426 64@tie{}KiB of the address space.
1428 @subsection SPU Named Address Spaces
1429 @cindex @code{__ea} SPU Named Address Spaces
1431 On the SPU target variables may be declared as
1432 belonging to another address space by qualifying the type with the
1433 @code{__ea} address space identifier:
1435 @smallexample
1436 extern int __ea i;
1437 @end smallexample
1439 @noindent 
1440 The compiler generates special code to access the variable @code{i}.
1441 It may use runtime library
1442 support, or generate special machine instructions to access that address
1443 space.
1445 @node Zero Length
1446 @section Arrays of Length Zero
1447 @cindex arrays of length zero
1448 @cindex zero-length arrays
1449 @cindex length-zero arrays
1450 @cindex flexible array members
1452 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1453 last element of a structure that is really a header for a variable-length
1454 object:
1456 @smallexample
1457 struct line @{
1458   int length;
1459   char contents[0];
1462 struct line *thisline = (struct line *)
1463   malloc (sizeof (struct line) + this_length);
1464 thisline->length = this_length;
1465 @end smallexample
1467 In ISO C90, you would have to give @code{contents} a length of 1, which
1468 means either you waste space or complicate the argument to @code{malloc}.
1470 In ISO C99, you would use a @dfn{flexible array member}, which is
1471 slightly different in syntax and semantics:
1473 @itemize @bullet
1474 @item
1475 Flexible array members are written as @code{contents[]} without
1476 the @code{0}.
1478 @item
1479 Flexible array members have incomplete type, and so the @code{sizeof}
1480 operator may not be applied.  As a quirk of the original implementation
1481 of zero-length arrays, @code{sizeof} evaluates to zero.
1483 @item
1484 Flexible array members may only appear as the last member of a
1485 @code{struct} that is otherwise non-empty.
1487 @item
1488 A structure containing a flexible array member, or a union containing
1489 such a structure (possibly recursively), may not be a member of a
1490 structure or an element of an array.  (However, these uses are
1491 permitted by GCC as extensions.)
1492 @end itemize
1494 GCC versions before 3.0 allowed zero-length arrays to be statically
1495 initialized, as if they were flexible arrays.  In addition to those
1496 cases that were useful, it also allowed initializations in situations
1497 that would corrupt later data.  Non-empty initialization of zero-length
1498 arrays is now treated like any case where there are more initializer
1499 elements than the array holds, in that a suitable warning about ``excess
1500 elements in array'' is given, and the excess elements (all of them, in
1501 this case) are ignored.
1503 Instead GCC allows static initialization of flexible array members.
1504 This is equivalent to defining a new structure containing the original
1505 structure followed by an array of sufficient size to contain the data.
1506 E.g.@: in the following, @code{f1} is constructed as if it were declared
1507 like @code{f2}.
1509 @smallexample
1510 struct f1 @{
1511   int x; int y[];
1512 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1514 struct f2 @{
1515   struct f1 f1; int data[3];
1516 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1517 @end smallexample
1519 @noindent
1520 The convenience of this extension is that @code{f1} has the desired
1521 type, eliminating the need to consistently refer to @code{f2.f1}.
1523 This has symmetry with normal static arrays, in that an array of
1524 unknown size is also written with @code{[]}.
1526 Of course, this extension only makes sense if the extra data comes at
1527 the end of a top-level object, as otherwise we would be overwriting
1528 data at subsequent offsets.  To avoid undue complication and confusion
1529 with initialization of deeply nested arrays, we simply disallow any
1530 non-empty initialization except when the structure is the top-level
1531 object.  For example:
1533 @smallexample
1534 struct foo @{ int x; int y[]; @};
1535 struct bar @{ struct foo z; @};
1537 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1538 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1539 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1540 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1541 @end smallexample
1543 @node Empty Structures
1544 @section Structures With No Members
1545 @cindex empty structures
1546 @cindex zero-size structures
1548 GCC permits a C structure to have no members:
1550 @smallexample
1551 struct empty @{
1553 @end smallexample
1555 The structure has size zero.  In C++, empty structures are part
1556 of the language.  G++ treats empty structures as if they had a single
1557 member of type @code{char}.
1559 @node Variable Length
1560 @section Arrays of Variable Length
1561 @cindex variable-length arrays
1562 @cindex arrays of variable length
1563 @cindex VLAs
1565 Variable-length automatic arrays are allowed in ISO C99, and as an
1566 extension GCC accepts them in C90 mode and in C++.  These arrays are
1567 declared like any other automatic arrays, but with a length that is not
1568 a constant expression.  The storage is allocated at the point of
1569 declaration and deallocated when the block scope containing the declaration
1570 exits.  For
1571 example:
1573 @smallexample
1574 FILE *
1575 concat_fopen (char *s1, char *s2, char *mode)
1577   char str[strlen (s1) + strlen (s2) + 1];
1578   strcpy (str, s1);
1579   strcat (str, s2);
1580   return fopen (str, mode);
1582 @end smallexample
1584 @cindex scope of a variable length array
1585 @cindex variable-length array scope
1586 @cindex deallocating variable length arrays
1587 Jumping or breaking out of the scope of the array name deallocates the
1588 storage.  Jumping into the scope is not allowed; you get an error
1589 message for it.
1591 @cindex variable-length array in a structure
1592 As an extension, GCC accepts variable-length arrays as a member of
1593 a structure or a union.  For example:
1595 @smallexample
1596 void
1597 foo (int n)
1599   struct S @{ int x[n]; @};
1601 @end smallexample
1603 @cindex @code{alloca} vs variable-length arrays
1604 You can use the function @code{alloca} to get an effect much like
1605 variable-length arrays.  The function @code{alloca} is available in
1606 many other C implementations (but not in all).  On the other hand,
1607 variable-length arrays are more elegant.
1609 There are other differences between these two methods.  Space allocated
1610 with @code{alloca} exists until the containing @emph{function} returns.
1611 The space for a variable-length array is deallocated as soon as the array
1612 name's scope ends.  (If you use both variable-length arrays and
1613 @code{alloca} in the same function, deallocation of a variable-length array
1614 also deallocates anything more recently allocated with @code{alloca}.)
1616 You can also use variable-length arrays as arguments to functions:
1618 @smallexample
1619 struct entry
1620 tester (int len, char data[len][len])
1622   /* @r{@dots{}} */
1624 @end smallexample
1626 The length of an array is computed once when the storage is allocated
1627 and is remembered for the scope of the array in case you access it with
1628 @code{sizeof}.
1630 If you want to pass the array first and the length afterward, you can
1631 use a forward declaration in the parameter list---another GNU extension.
1633 @smallexample
1634 struct entry
1635 tester (int len; char data[len][len], int len)
1637   /* @r{@dots{}} */
1639 @end smallexample
1641 @cindex parameter forward declaration
1642 The @samp{int len} before the semicolon is a @dfn{parameter forward
1643 declaration}, and it serves the purpose of making the name @code{len}
1644 known when the declaration of @code{data} is parsed.
1646 You can write any number of such parameter forward declarations in the
1647 parameter list.  They can be separated by commas or semicolons, but the
1648 last one must end with a semicolon, which is followed by the ``real''
1649 parameter declarations.  Each forward declaration must match a ``real''
1650 declaration in parameter name and data type.  ISO C99 does not support
1651 parameter forward declarations.
1653 @node Variadic Macros
1654 @section Macros with a Variable Number of Arguments.
1655 @cindex variable number of arguments
1656 @cindex macro with variable arguments
1657 @cindex rest argument (in macro)
1658 @cindex variadic macros
1660 In the ISO C standard of 1999, a macro can be declared to accept a
1661 variable number of arguments much as a function can.  The syntax for
1662 defining the macro is similar to that of a function.  Here is an
1663 example:
1665 @smallexample
1666 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1667 @end smallexample
1669 @noindent
1670 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1671 such a macro, it represents the zero or more tokens until the closing
1672 parenthesis that ends the invocation, including any commas.  This set of
1673 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1674 wherever it appears.  See the CPP manual for more information.
1676 GCC has long supported variadic macros, and used a different syntax that
1677 allowed you to give a name to the variable arguments just like any other
1678 argument.  Here is an example:
1680 @smallexample
1681 #define debug(format, args...) fprintf (stderr, format, args)
1682 @end smallexample
1684 @noindent
1685 This is in all ways equivalent to the ISO C example above, but arguably
1686 more readable and descriptive.
1688 GNU CPP has two further variadic macro extensions, and permits them to
1689 be used with either of the above forms of macro definition.
1691 In standard C, you are not allowed to leave the variable argument out
1692 entirely; but you are allowed to pass an empty argument.  For example,
1693 this invocation is invalid in ISO C, because there is no comma after
1694 the string:
1696 @smallexample
1697 debug ("A message")
1698 @end smallexample
1700 GNU CPP permits you to completely omit the variable arguments in this
1701 way.  In the above examples, the compiler would complain, though since
1702 the expansion of the macro still has the extra comma after the format
1703 string.
1705 To help solve this problem, CPP behaves specially for variable arguments
1706 used with the token paste operator, @samp{##}.  If instead you write
1708 @smallexample
1709 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1710 @end smallexample
1712 @noindent
1713 and if the variable arguments are omitted or empty, the @samp{##}
1714 operator causes the preprocessor to remove the comma before it.  If you
1715 do provide some variable arguments in your macro invocation, GNU CPP
1716 does not complain about the paste operation and instead places the
1717 variable arguments after the comma.  Just like any other pasted macro
1718 argument, these arguments are not macro expanded.
1720 @node Escaped Newlines
1721 @section Slightly Looser Rules for Escaped Newlines
1722 @cindex escaped newlines
1723 @cindex newlines (escaped)
1725 Recently, the preprocessor has relaxed its treatment of escaped
1726 newlines.  Previously, the newline had to immediately follow a
1727 backslash.  The current implementation allows whitespace in the form
1728 of spaces, horizontal and vertical tabs, and form feeds between the
1729 backslash and the subsequent newline.  The preprocessor issues a
1730 warning, but treats it as a valid escaped newline and combines the two
1731 lines to form a single logical line.  This works within comments and
1732 tokens, as well as between tokens.  Comments are @emph{not} treated as
1733 whitespace for the purposes of this relaxation, since they have not
1734 yet been replaced with spaces.
1736 @node Subscripting
1737 @section Non-Lvalue Arrays May Have Subscripts
1738 @cindex subscripting
1739 @cindex arrays, non-lvalue
1741 @cindex subscripting and function values
1742 In ISO C99, arrays that are not lvalues still decay to pointers, and
1743 may be subscripted, although they may not be modified or used after
1744 the next sequence point and the unary @samp{&} operator may not be
1745 applied to them.  As an extension, GNU C allows such arrays to be
1746 subscripted in C90 mode, though otherwise they do not decay to
1747 pointers outside C99 mode.  For example,
1748 this is valid in GNU C though not valid in C90:
1750 @smallexample
1751 @group
1752 struct foo @{int a[4];@};
1754 struct foo f();
1756 bar (int index)
1758   return f().a[index];
1760 @end group
1761 @end smallexample
1763 @node Pointer Arith
1764 @section Arithmetic on @code{void}- and Function-Pointers
1765 @cindex void pointers, arithmetic
1766 @cindex void, size of pointer to
1767 @cindex function pointers, arithmetic
1768 @cindex function, size of pointer to
1770 In GNU C, addition and subtraction operations are supported on pointers to
1771 @code{void} and on pointers to functions.  This is done by treating the
1772 size of a @code{void} or of a function as 1.
1774 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1775 and on function types, and returns 1.
1777 @opindex Wpointer-arith
1778 The option @option{-Wpointer-arith} requests a warning if these extensions
1779 are used.
1781 @node Initializers
1782 @section Non-Constant Initializers
1783 @cindex initializers, non-constant
1784 @cindex non-constant initializers
1786 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1787 automatic variable are not required to be constant expressions in GNU C@.
1788 Here is an example of an initializer with run-time varying elements:
1790 @smallexample
1791 foo (float f, float g)
1793   float beat_freqs[2] = @{ f-g, f+g @};
1794   /* @r{@dots{}} */
1796 @end smallexample
1798 @node Compound Literals
1799 @section Compound Literals
1800 @cindex constructor expressions
1801 @cindex initializations in expressions
1802 @cindex structures, constructor expression
1803 @cindex expressions, constructor
1804 @cindex compound literals
1805 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1807 ISO C99 supports compound literals.  A compound literal looks like
1808 a cast containing an initializer.  Its value is an object of the
1809 type specified in the cast, containing the elements specified in
1810 the initializer; it is an lvalue.  As an extension, GCC supports
1811 compound literals in C90 mode and in C++, though the semantics are
1812 somewhat different in C++.
1814 Usually, the specified type is a structure.  Assume that
1815 @code{struct foo} and @code{structure} are declared as shown:
1817 @smallexample
1818 struct foo @{int a; char b[2];@} structure;
1819 @end smallexample
1821 @noindent
1822 Here is an example of constructing a @code{struct foo} with a compound literal:
1824 @smallexample
1825 structure = ((struct foo) @{x + y, 'a', 0@});
1826 @end smallexample
1828 @noindent
1829 This is equivalent to writing the following:
1831 @smallexample
1833   struct foo temp = @{x + y, 'a', 0@};
1834   structure = temp;
1836 @end smallexample
1838 You can also construct an array, though this is dangerous in C++, as
1839 explained below.  If all the elements of the compound literal are
1840 (made up of) simple constant expressions, suitable for use in
1841 initializers of objects of static storage duration, then the compound
1842 literal can be coerced to a pointer to its first element and used in
1843 such an initializer, as shown here:
1845 @smallexample
1846 char **foo = (char *[]) @{ "x", "y", "z" @};
1847 @end smallexample
1849 Compound literals for scalar types and union types are
1850 also allowed, but then the compound literal is equivalent
1851 to a cast.
1853 As a GNU extension, GCC allows initialization of objects with static storage
1854 duration by compound literals (which is not possible in ISO C99, because
1855 the initializer is not a constant).
1856 It is handled as if the object is initialized only with the bracket
1857 enclosed list if the types of the compound literal and the object match.
1858 The initializer list of the compound literal must be constant.
1859 If the object being initialized has array type of unknown size, the size is
1860 determined by compound literal size.
1862 @smallexample
1863 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1864 static int y[] = (int []) @{1, 2, 3@};
1865 static int z[] = (int [3]) @{1@};
1866 @end smallexample
1868 @noindent
1869 The above lines are equivalent to the following:
1870 @smallexample
1871 static struct foo x = @{1, 'a', 'b'@};
1872 static int y[] = @{1, 2, 3@};
1873 static int z[] = @{1, 0, 0@};
1874 @end smallexample
1876 In C, a compound literal designates an unnamed object with static or
1877 automatic storage duration.  In C++, a compound literal designates a
1878 temporary object, which only lives until the end of its
1879 full-expression.  As a result, well-defined C code that takes the
1880 address of a subobject of a compound literal can be undefined in C++.
1881 For instance, if the array compound literal example above appeared
1882 inside a function, any subsequent use of @samp{foo} in C++ has
1883 undefined behavior because the lifetime of the array ends after the
1884 declaration of @samp{foo}.  As a result, the C++ compiler now rejects
1885 the conversion of a temporary array to a pointer.
1887 As an optimization, the C++ compiler sometimes gives array compound
1888 literals longer lifetimes: when the array either appears outside a
1889 function or has const-qualified type.  If @samp{foo} and its
1890 initializer had elements of @samp{char *const} type rather than
1891 @samp{char *}, or if @samp{foo} were a global variable, the array
1892 would have static storage duration.  But it is probably safest just to
1893 avoid the use of array compound literals in code compiled as C++.
1895 @node Designated Inits
1896 @section Designated Initializers
1897 @cindex initializers with labeled elements
1898 @cindex labeled elements in initializers
1899 @cindex case labels in initializers
1900 @cindex designated initializers
1902 Standard C90 requires the elements of an initializer to appear in a fixed
1903 order, the same as the order of the elements in the array or structure
1904 being initialized.
1906 In ISO C99 you can give the elements in any order, specifying the array
1907 indices or structure field names they apply to, and GNU C allows this as
1908 an extension in C90 mode as well.  This extension is not
1909 implemented in GNU C++.
1911 To specify an array index, write
1912 @samp{[@var{index}] =} before the element value.  For example,
1914 @smallexample
1915 int a[6] = @{ [4] = 29, [2] = 15 @};
1916 @end smallexample
1918 @noindent
1919 is equivalent to
1921 @smallexample
1922 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1923 @end smallexample
1925 @noindent
1926 The index values must be constant expressions, even if the array being
1927 initialized is automatic.
1929 An alternative syntax for this that has been obsolete since GCC 2.5 but
1930 GCC still accepts is to write @samp{[@var{index}]} before the element
1931 value, with no @samp{=}.
1933 To initialize a range of elements to the same value, write
1934 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1935 extension.  For example,
1937 @smallexample
1938 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1939 @end smallexample
1941 @noindent
1942 If the value in it has side-effects, the side-effects happen only once,
1943 not for each initialized field by the range initializer.
1945 @noindent
1946 Note that the length of the array is the highest value specified
1947 plus one.
1949 In a structure initializer, specify the name of a field to initialize
1950 with @samp{.@var{fieldname} =} before the element value.  For example,
1951 given the following structure,
1953 @smallexample
1954 struct point @{ int x, y; @};
1955 @end smallexample
1957 @noindent
1958 the following initialization
1960 @smallexample
1961 struct point p = @{ .y = yvalue, .x = xvalue @};
1962 @end smallexample
1964 @noindent
1965 is equivalent to
1967 @smallexample
1968 struct point p = @{ xvalue, yvalue @};
1969 @end smallexample
1971 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1972 @samp{@var{fieldname}:}, as shown here:
1974 @smallexample
1975 struct point p = @{ y: yvalue, x: xvalue @};
1976 @end smallexample
1978 Omitted field members are implicitly initialized the same as objects
1979 that have static storage duration.
1981 @cindex designators
1982 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1983 @dfn{designator}.  You can also use a designator (or the obsolete colon
1984 syntax) when initializing a union, to specify which element of the union
1985 should be used.  For example,
1987 @smallexample
1988 union foo @{ int i; double d; @};
1990 union foo f = @{ .d = 4 @};
1991 @end smallexample
1993 @noindent
1994 converts 4 to a @code{double} to store it in the union using
1995 the second element.  By contrast, casting 4 to type @code{union foo}
1996 stores it into the union as the integer @code{i}, since it is
1997 an integer.  (@xref{Cast to Union}.)
1999 You can combine this technique of naming elements with ordinary C
2000 initialization of successive elements.  Each initializer element that
2001 does not have a designator applies to the next consecutive element of the
2002 array or structure.  For example,
2004 @smallexample
2005 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2006 @end smallexample
2008 @noindent
2009 is equivalent to
2011 @smallexample
2012 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2013 @end smallexample
2015 Labeling the elements of an array initializer is especially useful
2016 when the indices are characters or belong to an @code{enum} type.
2017 For example:
2019 @smallexample
2020 int whitespace[256]
2021   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2022       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2023 @end smallexample
2025 @cindex designator lists
2026 You can also write a series of @samp{.@var{fieldname}} and
2027 @samp{[@var{index}]} designators before an @samp{=} to specify a
2028 nested subobject to initialize; the list is taken relative to the
2029 subobject corresponding to the closest surrounding brace pair.  For
2030 example, with the @samp{struct point} declaration above:
2032 @smallexample
2033 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2034 @end smallexample
2036 @noindent
2037 If the same field is initialized multiple times, it has the value from
2038 the last initialization.  If any such overridden initialization has
2039 side-effect, it is unspecified whether the side-effect happens or not.
2040 Currently, GCC discards them and issues a warning.
2042 @node Case Ranges
2043 @section Case Ranges
2044 @cindex case ranges
2045 @cindex ranges in case statements
2047 You can specify a range of consecutive values in a single @code{case} label,
2048 like this:
2050 @smallexample
2051 case @var{low} ... @var{high}:
2052 @end smallexample
2054 @noindent
2055 This has the same effect as the proper number of individual @code{case}
2056 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2058 This feature is especially useful for ranges of ASCII character codes:
2060 @smallexample
2061 case 'A' ... 'Z':
2062 @end smallexample
2064 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2065 it may be parsed wrong when you use it with integer values.  For example,
2066 write this:
2068 @smallexample
2069 case 1 ... 5:
2070 @end smallexample
2072 @noindent
2073 rather than this:
2075 @smallexample
2076 case 1...5:
2077 @end smallexample
2079 @node Cast to Union
2080 @section Cast to a Union Type
2081 @cindex cast to a union
2082 @cindex union, casting to a
2084 A cast to union type is similar to other casts, except that the type
2085 specified is a union type.  You can specify the type either with
2086 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2087 a constructor, not a cast, and hence does not yield an lvalue like
2088 normal casts.  (@xref{Compound Literals}.)
2090 The types that may be cast to the union type are those of the members
2091 of the union.  Thus, given the following union and variables:
2093 @smallexample
2094 union foo @{ int i; double d; @};
2095 int x;
2096 double y;
2097 @end smallexample
2099 @noindent
2100 both @code{x} and @code{y} can be cast to type @code{union foo}.
2102 Using the cast as the right-hand side of an assignment to a variable of
2103 union type is equivalent to storing in a member of the union:
2105 @smallexample
2106 union foo u;
2107 /* @r{@dots{}} */
2108 u = (union foo) x  @equiv{}  u.i = x
2109 u = (union foo) y  @equiv{}  u.d = y
2110 @end smallexample
2112 You can also use the union cast as a function argument:
2114 @smallexample
2115 void hack (union foo);
2116 /* @r{@dots{}} */
2117 hack ((union foo) x);
2118 @end smallexample
2120 @node Mixed Declarations
2121 @section Mixed Declarations and Code
2122 @cindex mixed declarations and code
2123 @cindex declarations, mixed with code
2124 @cindex code, mixed with declarations
2126 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2127 within compound statements.  As an extension, GNU C also allows this in
2128 C90 mode.  For example, you could do:
2130 @smallexample
2131 int i;
2132 /* @r{@dots{}} */
2133 i++;
2134 int j = i + 2;
2135 @end smallexample
2137 Each identifier is visible from where it is declared until the end of
2138 the enclosing block.
2140 @node Function Attributes
2141 @section Declaring Attributes of Functions
2142 @cindex function attributes
2143 @cindex declaring attributes of functions
2144 @cindex functions that never return
2145 @cindex functions that return more than once
2146 @cindex functions that have no side effects
2147 @cindex functions in arbitrary sections
2148 @cindex functions that behave like malloc
2149 @cindex @code{volatile} applied to function
2150 @cindex @code{const} applied to function
2151 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2152 @cindex functions with non-null pointer arguments
2153 @cindex functions that are passed arguments in registers on the 386
2154 @cindex functions that pop the argument stack on the 386
2155 @cindex functions that do not pop the argument stack on the 386
2156 @cindex functions that have different compilation options on the 386
2157 @cindex functions that have different optimization options
2158 @cindex functions that are dynamically resolved
2160 In GNU C, you declare certain things about functions called in your program
2161 which help the compiler optimize function calls and check your code more
2162 carefully.
2164 The keyword @code{__attribute__} allows you to specify special
2165 attributes when making a declaration.  This keyword is followed by an
2166 attribute specification inside double parentheses.  The following
2167 attributes are currently defined for functions on all targets:
2168 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2169 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2170 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2171 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2172 @code{no_instrument_function}, @code{no_split_stack},
2173 @code{section}, @code{constructor},
2174 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2175 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2176 @code{warn_unused_result}, @code{nonnull},
2177 @code{returns_nonnull}, @code{gnu_inline},
2178 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2179 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2180 @code{no_sanitize_undefined},
2181 @code{error} and @code{warning}.
2182 Several other attributes are defined for functions on particular
2183 target systems.  Other attributes, including @code{section} are
2184 supported for variables declarations (@pxref{Variable Attributes})
2185 and for types (@pxref{Type Attributes}).
2187 GCC plugins may provide their own attributes.
2189 You may also specify attributes with @samp{__} preceding and following
2190 each keyword.  This allows you to use them in header files without
2191 being concerned about a possible macro of the same name.  For example,
2192 you may use @code{__noreturn__} instead of @code{noreturn}.
2194 @xref{Attribute Syntax}, for details of the exact syntax for using
2195 attributes.
2197 @table @code
2198 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2200 @item alias ("@var{target}")
2201 @cindex @code{alias} attribute
2202 The @code{alias} attribute causes the declaration to be emitted as an
2203 alias for another symbol, which must be specified.  For instance,
2205 @smallexample
2206 void __f () @{ /* @r{Do something.} */; @}
2207 void f () __attribute__ ((weak, alias ("__f")));
2208 @end smallexample
2210 @noindent
2211 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2212 mangled name for the target must be used.  It is an error if @samp{__f}
2213 is not defined in the same translation unit.
2215 Not all target machines support this attribute.
2217 @item aligned (@var{alignment})
2218 @cindex @code{aligned} attribute
2219 This attribute specifies a minimum alignment for the function,
2220 measured in bytes.
2222 You cannot use this attribute to decrease the alignment of a function,
2223 only to increase it.  However, when you explicitly specify a function
2224 alignment this overrides the effect of the
2225 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2226 function.
2228 Note that the effectiveness of @code{aligned} attributes may be
2229 limited by inherent limitations in your linker.  On many systems, the
2230 linker is only able to arrange for functions to be aligned up to a
2231 certain maximum alignment.  (For some linkers, the maximum supported
2232 alignment may be very very small.)  See your linker documentation for
2233 further information.
2235 The @code{aligned} attribute can also be used for variables and fields
2236 (@pxref{Variable Attributes}.)
2238 @item alloc_size
2239 @cindex @code{alloc_size} attribute
2240 The @code{alloc_size} attribute is used to tell the compiler that the
2241 function return value points to memory, where the size is given by
2242 one or two of the functions parameters.  GCC uses this
2243 information to improve the correctness of @code{__builtin_object_size}.
2245 The function parameter(s) denoting the allocated size are specified by
2246 one or two integer arguments supplied to the attribute.  The allocated size
2247 is either the value of the single function argument specified or the product
2248 of the two function arguments specified.  Argument numbering starts at
2249 one.
2251 For instance,
2253 @smallexample
2254 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2255 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2256 @end smallexample
2258 @noindent
2259 declares that @code{my_calloc} returns memory of the size given by
2260 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2261 of the size given by parameter 2.
2263 @item alloc_align
2264 @cindex @code{alloc_align} attribute
2265 The @code{alloc_align} attribute is used to tell the compiler that the
2266 function return value points to memory, where the returned pointer minimum
2267 alignment is given by one of the functions parameters.  GCC uses this
2268 information to improve pointer alignment analysis.
2270 The function parameter denoting the allocated alignment is specified by
2271 one integer argument, whose number is the argument of the attribute.
2272 Argument numbering starts at one.
2274 For instance,
2276 @smallexample
2277 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2278 @end smallexample
2280 @noindent
2281 declares that @code{my_memalign} returns memory with minimum alignment
2282 given by parameter 1.
2284 @item assume_aligned
2285 @cindex @code{assume_aligned} attribute
2286 The @code{assume_aligned} attribute is used to tell the compiler that the
2287 function return value points to memory, where the returned pointer minimum
2288 alignment is given by the first argument.
2289 If the attribute has two arguments, the second argument is misalignment offset.
2291 For instance
2293 @smallexample
2294 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2295 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2296 @end smallexample
2298 @noindent
2299 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2300 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2301 to 8.
2303 @item always_inline
2304 @cindex @code{always_inline} function attribute
2305 Generally, functions are not inlined unless optimization is specified.
2306 For functions declared inline, this attribute inlines the function even
2307 if no optimization level is specified.
2309 @item gnu_inline
2310 @cindex @code{gnu_inline} function attribute
2311 This attribute should be used with a function that is also declared
2312 with the @code{inline} keyword.  It directs GCC to treat the function
2313 as if it were defined in gnu90 mode even when compiling in C99 or
2314 gnu99 mode.
2316 If the function is declared @code{extern}, then this definition of the
2317 function is used only for inlining.  In no case is the function
2318 compiled as a standalone function, not even if you take its address
2319 explicitly.  Such an address becomes an external reference, as if you
2320 had only declared the function, and had not defined it.  This has
2321 almost the effect of a macro.  The way to use this is to put a
2322 function definition in a header file with this attribute, and put
2323 another copy of the function, without @code{extern}, in a library
2324 file.  The definition in the header file causes most calls to the
2325 function to be inlined.  If any uses of the function remain, they
2326 refer to the single copy in the library.  Note that the two
2327 definitions of the functions need not be precisely the same, although
2328 if they do not have the same effect your program may behave oddly.
2330 In C, if the function is neither @code{extern} nor @code{static}, then
2331 the function is compiled as a standalone function, as well as being
2332 inlined where possible.
2334 This is how GCC traditionally handled functions declared
2335 @code{inline}.  Since ISO C99 specifies a different semantics for
2336 @code{inline}, this function attribute is provided as a transition
2337 measure and as a useful feature in its own right.  This attribute is
2338 available in GCC 4.1.3 and later.  It is available if either of the
2339 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2340 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2341 Function is As Fast As a Macro}.
2343 In C++, this attribute does not depend on @code{extern} in any way,
2344 but it still requires the @code{inline} keyword to enable its special
2345 behavior.
2347 @item artificial
2348 @cindex @code{artificial} function attribute
2349 This attribute is useful for small inline wrappers that if possible
2350 should appear during debugging as a unit.  Depending on the debug
2351 info format it either means marking the function as artificial
2352 or using the caller location for all instructions within the inlined
2353 body.
2355 @item bank_switch
2356 @cindex interrupt handler functions
2357 When added to an interrupt handler with the M32C port, causes the
2358 prologue and epilogue to use bank switching to preserve the registers
2359 rather than saving them on the stack.
2361 @item flatten
2362 @cindex @code{flatten} function attribute
2363 Generally, inlining into a function is limited.  For a function marked with
2364 this attribute, every call inside this function is inlined, if possible.
2365 Whether the function itself is considered for inlining depends on its size and
2366 the current inlining parameters.
2368 @item error ("@var{message}")
2369 @cindex @code{error} function attribute
2370 If this attribute is used on a function declaration and a call to such a function
2371 is not eliminated through dead code elimination or other optimizations, an error
2372 that includes @var{message} is diagnosed.  This is useful
2373 for compile-time checking, especially together with @code{__builtin_constant_p}
2374 and inline functions where checking the inline function arguments is not
2375 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2376 While it is possible to leave the function undefined and thus invoke
2377 a link failure, when using this attribute the problem is diagnosed
2378 earlier and with exact location of the call even in presence of inline
2379 functions or when not emitting debugging information.
2381 @item warning ("@var{message}")
2382 @cindex @code{warning} function attribute
2383 If this attribute is used on a function declaration and a call to such a function
2384 is not eliminated through dead code elimination or other optimizations, a warning
2385 that includes @var{message} is diagnosed.  This is useful
2386 for compile-time checking, especially together with @code{__builtin_constant_p}
2387 and inline functions.  While it is possible to define the function with
2388 a message in @code{.gnu.warning*} section, when using this attribute the problem
2389 is diagnosed earlier and with exact location of the call even in presence
2390 of inline functions or when not emitting debugging information.
2392 @item cdecl
2393 @cindex functions that do pop the argument stack on the 386
2394 @opindex mrtd
2395 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2396 assume that the calling function pops off the stack space used to
2397 pass arguments.  This is
2398 useful to override the effects of the @option{-mrtd} switch.
2400 @item const
2401 @cindex @code{const} function attribute
2402 Many functions do not examine any values except their arguments, and
2403 have no effects except the return value.  Basically this is just slightly
2404 more strict class than the @code{pure} attribute below, since function is not
2405 allowed to read global memory.
2407 @cindex pointer arguments
2408 Note that a function that has pointer arguments and examines the data
2409 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2410 function that calls a non-@code{const} function usually must not be
2411 @code{const}.  It does not make sense for a @code{const} function to
2412 return @code{void}.
2414 The attribute @code{const} is not implemented in GCC versions earlier
2415 than 2.5.  An alternative way to declare that a function has no side
2416 effects, which works in the current version and in some older versions,
2417 is as follows:
2419 @smallexample
2420 typedef int intfn ();
2422 extern const intfn square;
2423 @end smallexample
2425 @noindent
2426 This approach does not work in GNU C++ from 2.6.0 on, since the language
2427 specifies that the @samp{const} must be attached to the return value.
2429 @item constructor
2430 @itemx destructor
2431 @itemx constructor (@var{priority})
2432 @itemx destructor (@var{priority})
2433 @cindex @code{constructor} function attribute
2434 @cindex @code{destructor} function attribute
2435 The @code{constructor} attribute causes the function to be called
2436 automatically before execution enters @code{main ()}.  Similarly, the
2437 @code{destructor} attribute causes the function to be called
2438 automatically after @code{main ()} completes or @code{exit ()} is
2439 called.  Functions with these attributes are useful for
2440 initializing data that is used implicitly during the execution of
2441 the program.
2443 You may provide an optional integer priority to control the order in
2444 which constructor and destructor functions are run.  A constructor
2445 with a smaller priority number runs before a constructor with a larger
2446 priority number; the opposite relationship holds for destructors.  So,
2447 if you have a constructor that allocates a resource and a destructor
2448 that deallocates the same resource, both functions typically have the
2449 same priority.  The priorities for constructor and destructor
2450 functions are the same as those specified for namespace-scope C++
2451 objects (@pxref{C++ Attributes}).
2453 These attributes are not currently implemented for Objective-C@.
2455 @item deprecated
2456 @itemx deprecated (@var{msg})
2457 @cindex @code{deprecated} attribute.
2458 The @code{deprecated} attribute results in a warning if the function
2459 is used anywhere in the source file.  This is useful when identifying
2460 functions that are expected to be removed in a future version of a
2461 program.  The warning also includes the location of the declaration
2462 of the deprecated function, to enable users to easily find further
2463 information about why the function is deprecated, or what they should
2464 do instead.  Note that the warnings only occurs for uses:
2466 @smallexample
2467 int old_fn () __attribute__ ((deprecated));
2468 int old_fn ();
2469 int (*fn_ptr)() = old_fn;
2470 @end smallexample
2472 @noindent
2473 results in a warning on line 3 but not line 2.  The optional @var{msg}
2474 argument, which must be a string, is printed in the warning if
2475 present.
2477 The @code{deprecated} attribute can also be used for variables and
2478 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2480 @item disinterrupt
2481 @cindex @code{disinterrupt} attribute
2482 On Epiphany and MeP targets, this attribute causes the compiler to emit
2483 instructions to disable interrupts for the duration of the given
2484 function.
2486 @item dllexport
2487 @cindex @code{__declspec(dllexport)}
2488 On Microsoft Windows targets and Symbian OS targets the
2489 @code{dllexport} attribute causes the compiler to provide a global
2490 pointer to a pointer in a DLL, so that it can be referenced with the
2491 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2492 name is formed by combining @code{_imp__} and the function or variable
2493 name.
2495 You can use @code{__declspec(dllexport)} as a synonym for
2496 @code{__attribute__ ((dllexport))} for compatibility with other
2497 compilers.
2499 On systems that support the @code{visibility} attribute, this
2500 attribute also implies ``default'' visibility.  It is an error to
2501 explicitly specify any other visibility.
2503 In previous versions of GCC, the @code{dllexport} attribute was ignored
2504 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2505 had been used.  The default behavior now is to emit all dllexported
2506 inline functions; however, this can cause object file-size bloat, in
2507 which case the old behavior can be restored by using
2508 @option{-fno-keep-inline-dllexport}.
2510 The attribute is also ignored for undefined symbols.
2512 When applied to C++ classes, the attribute marks defined non-inlined
2513 member functions and static data members as exports.  Static consts
2514 initialized in-class are not marked unless they are also defined
2515 out-of-class.
2517 For Microsoft Windows targets there are alternative methods for
2518 including the symbol in the DLL's export table such as using a
2519 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2520 the @option{--export-all} linker flag.
2522 @item dllimport
2523 @cindex @code{__declspec(dllimport)}
2524 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2525 attribute causes the compiler to reference a function or variable via
2526 a global pointer to a pointer that is set up by the DLL exporting the
2527 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2528 targets, the pointer name is formed by combining @code{_imp__} and the
2529 function or variable name.
2531 You can use @code{__declspec(dllimport)} as a synonym for
2532 @code{__attribute__ ((dllimport))} for compatibility with other
2533 compilers.
2535 On systems that support the @code{visibility} attribute, this
2536 attribute also implies ``default'' visibility.  It is an error to
2537 explicitly specify any other visibility.
2539 Currently, the attribute is ignored for inlined functions.  If the
2540 attribute is applied to a symbol @emph{definition}, an error is reported.
2541 If a symbol previously declared @code{dllimport} is later defined, the
2542 attribute is ignored in subsequent references, and a warning is emitted.
2543 The attribute is also overridden by a subsequent declaration as
2544 @code{dllexport}.
2546 When applied to C++ classes, the attribute marks non-inlined
2547 member functions and static data members as imports.  However, the
2548 attribute is ignored for virtual methods to allow creation of vtables
2549 using thunks.
2551 On the SH Symbian OS target the @code{dllimport} attribute also has
2552 another affect---it can cause the vtable and run-time type information
2553 for a class to be exported.  This happens when the class has a
2554 dllimported constructor or a non-inline, non-pure virtual function
2555 and, for either of those two conditions, the class also has an inline
2556 constructor or destructor and has a key function that is defined in
2557 the current translation unit.
2559 For Microsoft Windows targets the use of the @code{dllimport}
2560 attribute on functions is not necessary, but provides a small
2561 performance benefit by eliminating a thunk in the DLL@.  The use of the
2562 @code{dllimport} attribute on imported variables was required on older
2563 versions of the GNU linker, but can now be avoided by passing the
2564 @option{--enable-auto-import} switch to the GNU linker.  As with
2565 functions, using the attribute for a variable eliminates a thunk in
2566 the DLL@.
2568 One drawback to using this attribute is that a pointer to a
2569 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2570 address. However, a pointer to a @emph{function} with the
2571 @code{dllimport} attribute can be used as a constant initializer; in
2572 this case, the address of a stub function in the import lib is
2573 referenced.  On Microsoft Windows targets, the attribute can be disabled
2574 for functions by setting the @option{-mnop-fun-dllimport} flag.
2576 @item eightbit_data
2577 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2578 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2579 variable should be placed into the eight-bit data section.
2580 The compiler generates more efficient code for certain operations
2581 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2582 256 bytes of data.
2584 You must use GAS and GLD from GNU binutils version 2.7 or later for
2585 this attribute to work correctly.
2587 @item exception
2588 @cindex exception handler functions
2589 Use this attribute on the NDS32 target to indicate that the specified function
2590 is an exception handler.  The compiler will generate corresponding sections
2591 for use in an exception handler.
2593 @item exception_handler
2594 @cindex exception handler functions on the Blackfin processor
2595 Use this attribute on the Blackfin to indicate that the specified function
2596 is an exception handler.  The compiler generates function entry and
2597 exit sequences suitable for use in an exception handler when this
2598 attribute is present.
2600 @item externally_visible
2601 @cindex @code{externally_visible} attribute.
2602 This attribute, attached to a global variable or function, nullifies
2603 the effect of the @option{-fwhole-program} command-line option, so the
2604 object remains visible outside the current compilation unit.
2606 If @option{-fwhole-program} is used together with @option{-flto} and 
2607 @command{gold} is used as the linker plugin, 
2608 @code{externally_visible} attributes are automatically added to functions 
2609 (not variable yet due to a current @command{gold} issue) 
2610 that are accessed outside of LTO objects according to resolution file
2611 produced by @command{gold}.
2612 For other linkers that cannot generate resolution file,
2613 explicit @code{externally_visible} attributes are still necessary.
2615 @item far
2616 @cindex functions that handle memory bank switching
2617 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2618 use a calling convention that takes care of switching memory banks when
2619 entering and leaving a function.  This calling convention is also the
2620 default when using the @option{-mlong-calls} option.
2622 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2623 to call and return from a function.
2625 On 68HC11 the compiler generates a sequence of instructions
2626 to invoke a board-specific routine to switch the memory bank and call the
2627 real function.  The board-specific routine simulates a @code{call}.
2628 At the end of a function, it jumps to a board-specific routine
2629 instead of using @code{rts}.  The board-specific return routine simulates
2630 the @code{rtc}.
2632 On MeP targets this causes the compiler to use a calling convention
2633 that assumes the called function is too far away for the built-in
2634 addressing modes.
2636 @item fast_interrupt
2637 @cindex interrupt handler functions
2638 Use this attribute on the M32C and RX ports to indicate that the specified
2639 function is a fast interrupt handler.  This is just like the
2640 @code{interrupt} attribute, except that @code{freit} is used to return
2641 instead of @code{reit}.
2643 @item fastcall
2644 @cindex functions that pop the argument stack on the 386
2645 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2646 pass the first argument (if of integral type) in the register ECX and
2647 the second argument (if of integral type) in the register EDX@.  Subsequent
2648 and other typed arguments are passed on the stack.  The called function
2649 pops the arguments off the stack.  If the number of arguments is variable all
2650 arguments are pushed on the stack.
2652 @item thiscall
2653 @cindex functions that pop the argument stack on the 386
2654 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2655 pass the first argument (if of integral type) in the register ECX.
2656 Subsequent and other typed arguments are passed on the stack. The called
2657 function pops the arguments off the stack.
2658 If the number of arguments is variable all arguments are pushed on the
2659 stack.
2660 The @code{thiscall} attribute is intended for C++ non-static member functions.
2661 As a GCC extension, this calling convention can be used for C functions
2662 and for static member methods.
2664 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2665 @cindex @code{format} function attribute
2666 @opindex Wformat
2667 The @code{format} attribute specifies that a function takes @code{printf},
2668 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2669 should be type-checked against a format string.  For example, the
2670 declaration:
2672 @smallexample
2673 extern int
2674 my_printf (void *my_object, const char *my_format, ...)
2675       __attribute__ ((format (printf, 2, 3)));
2676 @end smallexample
2678 @noindent
2679 causes the compiler to check the arguments in calls to @code{my_printf}
2680 for consistency with the @code{printf} style format string argument
2681 @code{my_format}.
2683 The parameter @var{archetype} determines how the format string is
2684 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2685 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2686 @code{strfmon}.  (You can also use @code{__printf__},
2687 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2688 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2689 @code{ms_strftime} are also present.
2690 @var{archetype} values such as @code{printf} refer to the formats accepted
2691 by the system's C runtime library,
2692 while values prefixed with @samp{gnu_} always refer
2693 to the formats accepted by the GNU C Library.  On Microsoft Windows
2694 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2695 @file{msvcrt.dll} library.
2696 The parameter @var{string-index}
2697 specifies which argument is the format string argument (starting
2698 from 1), while @var{first-to-check} is the number of the first
2699 argument to check against the format string.  For functions
2700 where the arguments are not available to be checked (such as
2701 @code{vprintf}), specify the third parameter as zero.  In this case the
2702 compiler only checks the format string for consistency.  For
2703 @code{strftime} formats, the third parameter is required to be zero.
2704 Since non-static C++ methods have an implicit @code{this} argument, the
2705 arguments of such methods should be counted from two, not one, when
2706 giving values for @var{string-index} and @var{first-to-check}.
2708 In the example above, the format string (@code{my_format}) is the second
2709 argument of the function @code{my_print}, and the arguments to check
2710 start with the third argument, so the correct parameters for the format
2711 attribute are 2 and 3.
2713 @opindex ffreestanding
2714 @opindex fno-builtin
2715 The @code{format} attribute allows you to identify your own functions
2716 that take format strings as arguments, so that GCC can check the
2717 calls to these functions for errors.  The compiler always (unless
2718 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2719 for the standard library functions @code{printf}, @code{fprintf},
2720 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2721 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2722 warnings are requested (using @option{-Wformat}), so there is no need to
2723 modify the header file @file{stdio.h}.  In C99 mode, the functions
2724 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2725 @code{vsscanf} are also checked.  Except in strictly conforming C
2726 standard modes, the X/Open function @code{strfmon} is also checked as
2727 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2728 @xref{C Dialect Options,,Options Controlling C Dialect}.
2730 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2731 recognized in the same context.  Declarations including these format attributes
2732 are parsed for correct syntax, however the result of checking of such format
2733 strings is not yet defined, and is not carried out by this version of the
2734 compiler.
2736 The target may also provide additional types of format checks.
2737 @xref{Target Format Checks,,Format Checks Specific to Particular
2738 Target Machines}.
2740 @item format_arg (@var{string-index})
2741 @cindex @code{format_arg} function attribute
2742 @opindex Wformat-nonliteral
2743 The @code{format_arg} attribute specifies that a function takes a format
2744 string for a @code{printf}, @code{scanf}, @code{strftime} or
2745 @code{strfmon} style function and modifies it (for example, to translate
2746 it into another language), so the result can be passed to a
2747 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2748 function (with the remaining arguments to the format function the same
2749 as they would have been for the unmodified string).  For example, the
2750 declaration:
2752 @smallexample
2753 extern char *
2754 my_dgettext (char *my_domain, const char *my_format)
2755       __attribute__ ((format_arg (2)));
2756 @end smallexample
2758 @noindent
2759 causes the compiler to check the arguments in calls to a @code{printf},
2760 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2761 format string argument is a call to the @code{my_dgettext} function, for
2762 consistency with the format string argument @code{my_format}.  If the
2763 @code{format_arg} attribute had not been specified, all the compiler
2764 could tell in such calls to format functions would be that the format
2765 string argument is not constant; this would generate a warning when
2766 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2767 without the attribute.
2769 The parameter @var{string-index} specifies which argument is the format
2770 string argument (starting from one).  Since non-static C++ methods have
2771 an implicit @code{this} argument, the arguments of such methods should
2772 be counted from two.
2774 The @code{format_arg} attribute allows you to identify your own
2775 functions that modify format strings, so that GCC can check the
2776 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2777 type function whose operands are a call to one of your own function.
2778 The compiler always treats @code{gettext}, @code{dgettext}, and
2779 @code{dcgettext} in this manner except when strict ISO C support is
2780 requested by @option{-ansi} or an appropriate @option{-std} option, or
2781 @option{-ffreestanding} or @option{-fno-builtin}
2782 is used.  @xref{C Dialect Options,,Options
2783 Controlling C Dialect}.
2785 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2786 @code{NSString} reference for compatibility with the @code{format} attribute
2787 above.
2789 The target may also allow additional types in @code{format-arg} attributes.
2790 @xref{Target Format Checks,,Format Checks Specific to Particular
2791 Target Machines}.
2793 @item function_vector
2794 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2795 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2796 function should be called through the function vector.  Calling a
2797 function through the function vector reduces code size, however;
2798 the function vector has a limited size (maximum 128 entries on the H8/300
2799 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2801 On SH2A targets, this attribute declares a function to be called using the
2802 TBR relative addressing mode.  The argument to this attribute is the entry
2803 number of the same function in a vector table containing all the TBR
2804 relative addressable functions.  For correct operation the TBR must be setup
2805 accordingly to point to the start of the vector table before any functions with
2806 this attribute are invoked.  Usually a good place to do the initialization is
2807 the startup routine.  The TBR relative vector table can have at max 256 function
2808 entries.  The jumps to these functions are generated using a SH2A specific,
2809 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2810 from GNU binutils version 2.7 or later for this attribute to work correctly.
2812 Please refer the example of M16C target, to see the use of this
2813 attribute while declaring a function,
2815 In an application, for a function being called once, this attribute
2816 saves at least 8 bytes of code; and if other successive calls are being
2817 made to the same function, it saves 2 bytes of code per each of these
2818 calls.
2820 On M16C/M32C targets, the @code{function_vector} attribute declares a
2821 special page subroutine call function. Use of this attribute reduces
2822 the code size by 2 bytes for each call generated to the
2823 subroutine. The argument to the attribute is the vector number entry
2824 from the special page vector table which contains the 16 low-order
2825 bits of the subroutine's entry address. Each vector table has special
2826 page number (18 to 255) that is used in @code{jsrs} instructions.
2827 Jump addresses of the routines are generated by adding 0x0F0000 (in
2828 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2829 2-byte addresses set in the vector table. Therefore you need to ensure
2830 that all the special page vector routines should get mapped within the
2831 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2832 (for M32C).
2834 In the following example 2 bytes are saved for each call to
2835 function @code{foo}.
2837 @smallexample
2838 void foo (void) __attribute__((function_vector(0x18)));
2839 void foo (void)
2843 void bar (void)
2845     foo();
2847 @end smallexample
2849 If functions are defined in one file and are called in another file,
2850 then be sure to write this declaration in both files.
2852 This attribute is ignored for R8C target.
2854 @item ifunc ("@var{resolver}")
2855 @cindex @code{ifunc} attribute
2856 The @code{ifunc} attribute is used to mark a function as an indirect
2857 function using the STT_GNU_IFUNC symbol type extension to the ELF
2858 standard.  This allows the resolution of the symbol value to be
2859 determined dynamically at load time, and an optimized version of the
2860 routine can be selected for the particular processor or other system
2861 characteristics determined then.  To use this attribute, first define
2862 the implementation functions available, and a resolver function that
2863 returns a pointer to the selected implementation function.  The
2864 implementation functions' declarations must match the API of the
2865 function being implemented, the resolver's declaration is be a
2866 function returning pointer to void function returning void:
2868 @smallexample
2869 void *my_memcpy (void *dst, const void *src, size_t len)
2871   @dots{}
2874 static void (*resolve_memcpy (void)) (void)
2876   return my_memcpy; // we'll just always select this routine
2878 @end smallexample
2880 @noindent
2881 The exported header file declaring the function the user calls would
2882 contain:
2884 @smallexample
2885 extern void *memcpy (void *, const void *, size_t);
2886 @end smallexample
2888 @noindent
2889 allowing the user to call this as a regular function, unaware of the
2890 implementation.  Finally, the indirect function needs to be defined in
2891 the same translation unit as the resolver function:
2893 @smallexample
2894 void *memcpy (void *, const void *, size_t)
2895      __attribute__ ((ifunc ("resolve_memcpy")));
2896 @end smallexample
2898 Indirect functions cannot be weak, and require a recent binutils (at
2899 least version 2.20.1), and GNU C library (at least version 2.11.1).
2901 @item interrupt
2902 @cindex interrupt handler functions
2903 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2904 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2905 the specified function is an
2906 interrupt handler.  The compiler generates function entry and exit
2907 sequences suitable for use in an interrupt handler when this attribute
2908 is present.  With Epiphany targets it may also generate a special section with
2909 code to initialize the interrupt vector table.
2911 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2912 and SH processors can be specified via the @code{interrupt_handler} attribute.
2914 Note, on the ARC, you must specify the kind of interrupt to be handled
2915 in a parameter to the interrupt attribute like this:
2917 @smallexample
2918 void f () __attribute__ ((interrupt ("ilink1")));
2919 @end smallexample
2921 Permissible values for this parameter are: @w{@code{ilink1}} and
2922 @w{@code{ilink2}}.
2924 Note, on the AVR, the hardware globally disables interrupts when an
2925 interrupt is executed.  The first instruction of an interrupt handler
2926 declared with this attribute is a @code{SEI} instruction to
2927 re-enable interrupts.  See also the @code{signal} function attribute
2928 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2929 @code{interrupt} are specified for the same function, @code{signal}
2930 is silently ignored.
2932 Note, for the ARM, you can specify the kind of interrupt to be handled by
2933 adding an optional parameter to the interrupt attribute like this:
2935 @smallexample
2936 void f () __attribute__ ((interrupt ("IRQ")));
2937 @end smallexample
2939 @noindent
2940 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2941 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2943 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2944 may be called with a word-aligned stack pointer.
2946 Note, for the MSP430 you can provide an argument to the interrupt
2947 attribute which specifies a name or number.  If the argument is a
2948 number it indicates the slot in the interrupt vector table (0 - 31) to
2949 which this handler should be assigned.  If the argument is a name it
2950 is treated as a symbolic name for the vector slot.  These names should
2951 match up with appropriate entries in the linker script.  By default
2952 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2953 @code{reset} for vector 31 are recognised.
2955 You can also use the following function attributes to modify how
2956 normal functions interact with interrupt functions:
2958 @table @code
2959 @item critical
2960 @cindex @code{critical} attribute
2961 Critical functions disable interrupts upon entry and restore the
2962 previous interrupt state upon exit.  Critical functions cannot also
2963 have the @code{naked} or @code{reentrant} attributes.  They can have
2964 the @code{interrupt} attribute.
2966 @item reentrant
2967 @cindex @code{reentrant} attribute
2968 Reentrant functions disable interrupts upon entry and enable them
2969 upon exit.  Reentrant functions cannot also have the @code{naked}
2970 or @code{critical} attributes.  They can have the @code{interrupt}
2971 attribute.
2973 @item wakeup
2974 @cindex @code{wakeup} attribute
2975 This attribute only applies to interrupt functions.  It is silently
2976 ignored if applied to a non-interrupt function.  A wakeup interrupt
2977 function will rouse the processor from any low-power state that it
2978 might be in when the function exits.
2980 @end table
2982 On Epiphany targets one or more optional parameters can be added like this:
2984 @smallexample
2985 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2986 @end smallexample
2988 Permissible values for these parameters are: @w{@code{reset}},
2989 @w{@code{software_exception}}, @w{@code{page_miss}},
2990 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2991 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2992 Multiple parameters indicate that multiple entries in the interrupt
2993 vector table should be initialized for this function, i.e.@: for each
2994 parameter @w{@var{name}}, a jump to the function is emitted in
2995 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
2996 entirely, in which case no interrupt vector table entry is provided.
2998 Note, on Epiphany targets, interrupts are enabled inside the function
2999 unless the @code{disinterrupt} attribute is also specified.
3001 On Epiphany targets, you can also use the following attribute to
3002 modify the behavior of an interrupt handler:
3003 @table @code
3004 @item forwarder_section
3005 @cindex @code{forwarder_section} attribute
3006 The interrupt handler may be in external memory which cannot be
3007 reached by a branch instruction, so generate a local memory trampoline
3008 to transfer control.  The single parameter identifies the section where
3009 the trampoline is placed.
3010 @end table
3012 The following examples are all valid uses of these attributes on
3013 Epiphany targets:
3014 @smallexample
3015 void __attribute__ ((interrupt)) universal_handler ();
3016 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3017 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3018 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3019   fast_timer_handler ();
3020 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3021   external_dma_handler ();
3022 @end smallexample
3024 On MIPS targets, you can use the following attributes to modify the behavior
3025 of an interrupt handler:
3026 @table @code
3027 @item use_shadow_register_set
3028 @cindex @code{use_shadow_register_set} attribute
3029 Assume that the handler uses a shadow register set, instead of
3030 the main general-purpose registers.
3032 @item keep_interrupts_masked
3033 @cindex @code{keep_interrupts_masked} attribute
3034 Keep interrupts masked for the whole function.  Without this attribute,
3035 GCC tries to reenable interrupts for as much of the function as it can.
3037 @item use_debug_exception_return
3038 @cindex @code{use_debug_exception_return} attribute
3039 Return using the @code{deret} instruction.  Interrupt handlers that don't
3040 have this attribute return using @code{eret} instead.
3041 @end table
3043 You can use any combination of these attributes, as shown below:
3044 @smallexample
3045 void __attribute__ ((interrupt)) v0 ();
3046 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3047 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3048 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3049 void __attribute__ ((interrupt, use_shadow_register_set,
3050                      keep_interrupts_masked)) v4 ();
3051 void __attribute__ ((interrupt, use_shadow_register_set,
3052                      use_debug_exception_return)) v5 ();
3053 void __attribute__ ((interrupt, keep_interrupts_masked,
3054                      use_debug_exception_return)) v6 ();
3055 void __attribute__ ((interrupt, use_shadow_register_set,
3056                      keep_interrupts_masked,
3057                      use_debug_exception_return)) v7 ();
3058 @end smallexample
3060 On NDS32 target, this attribute is to indicate that the specified function
3061 is an interrupt handler.  The compiler will generate corresponding sections
3062 for use in an interrupt handler.  You can use the following attributes
3063 to modify the behavior:
3064 @table @code
3065 @item nested
3066 @cindex @code{nested} attribute
3067 This interrupt service routine is interruptible.
3068 @item not_nested
3069 @cindex @code{not_nested} attribute
3070 This interrupt service routine is not interruptible.
3071 @item nested_ready
3072 @cindex @code{nested_ready} attribute
3073 This interrupt service routine is interruptible after @code{PSW.GIE}
3074 (global interrupt enable) is set.  This allows interrupt service routine to
3075 finish some short critical code before enabling interrupts.
3076 @item save_all
3077 @cindex @code{save_all} attribute
3078 The system will help save all registers into stack before entering
3079 interrupt handler.
3080 @item partial_save
3081 @cindex @code{partial_save} attribute
3082 The system will help save caller registers into stack before entering
3083 interrupt handler.
3084 @end table
3086 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3087 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3088 that must end with @code{RETB} instead of @code{RETI}).
3090 @item interrupt_handler
3091 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3092 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3093 indicate that the specified function is an interrupt handler.  The compiler
3094 generates function entry and exit sequences suitable for use in an
3095 interrupt handler when this attribute is present.
3097 @item interrupt_thread
3098 @cindex interrupt thread functions on fido
3099 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3100 that the specified function is an interrupt handler that is designed
3101 to run as a thread.  The compiler omits generate prologue/epilogue
3102 sequences and replaces the return instruction with a @code{sleep}
3103 instruction.  This attribute is available only on fido.
3105 @item isr
3106 @cindex interrupt service routines on ARM
3107 Use this attribute on ARM to write Interrupt Service Routines. This is an
3108 alias to the @code{interrupt} attribute above.
3110 @item kspisusp
3111 @cindex User stack pointer in interrupts on the Blackfin
3112 When used together with @code{interrupt_handler}, @code{exception_handler}
3113 or @code{nmi_handler}, code is generated to load the stack pointer
3114 from the USP register in the function prologue.
3116 @item l1_text
3117 @cindex @code{l1_text} function attribute
3118 This attribute specifies a function to be placed into L1 Instruction
3119 SRAM@. The function is put into a specific section named @code{.l1.text}.
3120 With @option{-mfdpic}, function calls with a such function as the callee
3121 or caller uses inlined PLT.
3123 @item l2
3124 @cindex @code{l2} function attribute
3125 On the Blackfin, this attribute specifies a function to be placed into L2
3126 SRAM. The function is put into a specific section named
3127 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3128 an inlined PLT.
3130 @item leaf
3131 @cindex @code{leaf} function attribute
3132 Calls to external functions with this attribute must return to the current
3133 compilation unit only by return or by exception handling.  In particular, leaf
3134 functions are not allowed to call callback function passed to it from the current
3135 compilation unit or directly call functions exported by the unit or longjmp
3136 into the unit.  Leaf function might still call functions from other compilation
3137 units and thus they are not necessarily leaf in the sense that they contain no
3138 function calls at all.
3140 The attribute is intended for library functions to improve dataflow analysis.
3141 The compiler takes the hint that any data not escaping the current compilation unit can
3142 not be used or modified by the leaf function.  For example, the @code{sin} function
3143 is a leaf function, but @code{qsort} is not.
3145 Note that leaf functions might invoke signals and signal handlers might be
3146 defined in the current compilation unit and use static variables.  The only
3147 compliant way to write such a signal handler is to declare such variables
3148 @code{volatile}.
3150 The attribute has no effect on functions defined within the current compilation
3151 unit.  This is to allow easy merging of multiple compilation units into one,
3152 for example, by using the link-time optimization.  For this reason the
3153 attribute is not allowed on types to annotate indirect calls.
3155 @item long_call/medium_call/short_call
3156 @cindex indirect calls on ARC
3157 @cindex indirect calls on ARM
3158 @cindex indirect calls on Epiphany
3159 These attributes specify how a particular function is called on
3160 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3161 These attributes override the
3162 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3163 and @option{-mmedium-calls} (@pxref{ARC Options})
3164 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3165 @code{long_call} attribute indicates that the function might be far
3166 away from the call site and require a different (more expensive)
3167 calling sequence.   The @code{short_call} attribute always places
3168 the offset to the function from the call site into the @samp{BL}
3169 instruction directly.
3171 For ARC, a function marked with the @code{long_call} attribute is
3172 always called using register-indirect jump-and-link instructions,
3173 thereby enabling the called function to be placed anywhere within the
3174 32-bit address space.  A function marked with the @code{medium_call}
3175 attribute will always be close enough to be called with an unconditional
3176 branch-and-link instruction, which has a 25-bit offset from
3177 the call site.  A function marked with the @code{short_call}
3178 attribute will always be close enough to be called with a conditional
3179 branch-and-link instruction, which has a 21-bit offset from
3180 the call site.
3182 @item longcall/shortcall
3183 @cindex functions called via pointer on the RS/6000 and PowerPC
3184 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3185 indicates that the function might be far away from the call site and
3186 require a different (more expensive) calling sequence.  The
3187 @code{shortcall} attribute indicates that the function is always close
3188 enough for the shorter calling sequence to be used.  These attributes
3189 override both the @option{-mlongcall} switch and, on the RS/6000 and
3190 PowerPC, the @code{#pragma longcall} setting.
3192 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3193 calls are necessary.
3195 @item long_call/near/far
3196 @cindex indirect calls on MIPS
3197 These attributes specify how a particular function is called on MIPS@.
3198 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3199 command-line switch.  The @code{long_call} and @code{far} attributes are
3200 synonyms, and cause the compiler to always call
3201 the function by first loading its address into a register, and then using
3202 the contents of that register.  The @code{near} attribute has the opposite
3203 effect; it specifies that non-PIC calls should be made using the more
3204 efficient @code{jal} instruction.
3206 @item malloc
3207 @cindex @code{malloc} attribute
3208 The @code{malloc} attribute is used to tell the compiler that a function
3209 may be treated as if any non-@code{NULL} pointer it returns cannot
3210 alias any other pointer valid when the function returns and that the memory
3211 has undefined content.
3212 This often improves optimization.
3213 Standard functions with this property include @code{malloc} and
3214 @code{calloc}.  @code{realloc}-like functions do not have this
3215 property as the memory pointed to does not have undefined content.
3217 @item mips16/nomips16
3218 @cindex @code{mips16} attribute
3219 @cindex @code{nomips16} attribute
3221 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3222 function attributes to locally select or turn off MIPS16 code generation.
3223 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3224 while MIPS16 code generation is disabled for functions with the
3225 @code{nomips16} attribute.  These attributes override the
3226 @option{-mips16} and @option{-mno-mips16} options on the command line
3227 (@pxref{MIPS Options}).
3229 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3230 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3231 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3232 may interact badly with some GCC extensions such as @code{__builtin_apply}
3233 (@pxref{Constructing Calls}).
3235 @item micromips/nomicromips
3236 @cindex @code{micromips} attribute
3237 @cindex @code{nomicromips} attribute
3239 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3240 function attributes to locally select or turn off microMIPS code generation.
3241 A function with the @code{micromips} attribute is emitted as microMIPS code,
3242 while microMIPS code generation is disabled for functions with the
3243 @code{nomicromips} attribute.  These attributes override the
3244 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3245 (@pxref{MIPS Options}).
3247 When compiling files containing mixed microMIPS and non-microMIPS code, the
3248 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3249 command line,
3250 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3251 may interact badly with some GCC extensions such as @code{__builtin_apply}
3252 (@pxref{Constructing Calls}).
3254 @item model (@var{model-name})
3255 @cindex function addressability on the M32R/D
3256 @cindex variable addressability on the IA-64
3258 On the M32R/D, use this attribute to set the addressability of an
3259 object, and of the code generated for a function.  The identifier
3260 @var{model-name} is one of @code{small}, @code{medium}, or
3261 @code{large}, representing each of the code models.
3263 Small model objects live in the lower 16MB of memory (so that their
3264 addresses can be loaded with the @code{ld24} instruction), and are
3265 callable with the @code{bl} instruction.
3267 Medium model objects may live anywhere in the 32-bit address space (the
3268 compiler generates @code{seth/add3} instructions to load their addresses),
3269 and are callable with the @code{bl} instruction.
3271 Large model objects may live anywhere in the 32-bit address space (the
3272 compiler generates @code{seth/add3} instructions to load their addresses),
3273 and may not be reachable with the @code{bl} instruction (the compiler
3274 generates the much slower @code{seth/add3/jl} instruction sequence).
3276 On IA-64, use this attribute to set the addressability of an object.
3277 At present, the only supported identifier for @var{model-name} is
3278 @code{small}, indicating addressability via ``small'' (22-bit)
3279 addresses (so that their addresses can be loaded with the @code{addl}
3280 instruction).  Caveat: such addressing is by definition not position
3281 independent and hence this attribute must not be used for objects
3282 defined by shared libraries.
3284 @item ms_abi/sysv_abi
3285 @cindex @code{ms_abi} attribute
3286 @cindex @code{sysv_abi} attribute
3288 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3289 to indicate which calling convention should be used for a function.  The
3290 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3291 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3292 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3293 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3295 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3296 requires the @option{-maccumulate-outgoing-args} option.
3298 @item callee_pop_aggregate_return (@var{number})
3299 @cindex @code{callee_pop_aggregate_return} attribute
3301 On 32-bit i?86-*-* targets, you can use this attribute to control how
3302 aggregates are returned in memory.  If the caller is responsible for
3303 popping the hidden pointer together with the rest of the arguments, specify
3304 @var{number} equal to zero.  If callee is responsible for popping the
3305 hidden pointer, specify @var{number} equal to one.  
3307 The default i386 ABI assumes that the callee pops the
3308 stack for hidden pointer.  However, on 32-bit i386 Microsoft Windows targets,
3309 the compiler assumes that the
3310 caller pops the stack for hidden pointer.
3312 @item ms_hook_prologue
3313 @cindex @code{ms_hook_prologue} attribute
3315 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3316 this function attribute to make GCC generate the ``hot-patching'' function
3317 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3318 and newer.
3320 @item hotpatch [(@var{prologue-halfwords})]
3321 @cindex @code{hotpatch} attribute
3323 On S/390 System z targets, you can use this function attribute to
3324 make GCC generate a ``hot-patching'' function prologue.  The
3325 @code{hotpatch} has no effect on funtions that are explicitly
3326 inline.  If the @option{-mhotpatch} or @option{-mno-hotpatch}
3327 command-line option is used at the same time, the @code{hotpatch}
3328 attribute takes precedence.  If an argument is given, the maximum
3329 allowed value is 1000000.
3331 @item naked
3332 @cindex function without a prologue/epilogue code
3333 Use this attribute on the ARM, AVR, MCORE, MSP430, NDS32, RL78, RX and SPU
3334 ports to indicate that the specified function does not need prologue/epilogue
3335 sequences generated by the compiler.
3336 It is up to the programmer to provide these sequences. The
3337 only statements that can be safely included in naked functions are
3338 @code{asm} statements that do not have operands.  All other statements,
3339 including declarations of local variables, @code{if} statements, and so
3340 forth, should be avoided.  Naked functions should be used to implement the
3341 body of an assembly function, while allowing the compiler to construct
3342 the requisite function declaration for the assembler.
3344 @item near
3345 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3346 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3347 use the normal calling convention based on @code{jsr} and @code{rts}.
3348 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3349 option.
3351 On MeP targets this attribute causes the compiler to assume the called
3352 function is close enough to use the normal calling convention,
3353 overriding the @option{-mtf} command-line option.
3355 @item nesting
3356 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3357 Use this attribute together with @code{interrupt_handler},
3358 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3359 entry code should enable nested interrupts or exceptions.
3361 @item nmi_handler
3362 @cindex NMI handler functions on the Blackfin processor
3363 Use this attribute on the Blackfin to indicate that the specified function
3364 is an NMI handler.  The compiler generates function entry and
3365 exit sequences suitable for use in an NMI handler when this
3366 attribute is present.
3368 @item nocompression
3369 @cindex @code{nocompression} attribute
3370 On MIPS targets, you can use the @code{nocompression} function attribute
3371 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3372 overrides the @option{-mips16} and @option{-mmicromips} options on the
3373 command line (@pxref{MIPS Options}).
3375 @item no_instrument_function
3376 @cindex @code{no_instrument_function} function attribute
3377 @opindex finstrument-functions
3378 If @option{-finstrument-functions} is given, profiling function calls are
3379 generated at entry and exit of most user-compiled functions.
3380 Functions with this attribute are not so instrumented.
3382 @item no_split_stack
3383 @cindex @code{no_split_stack} function attribute
3384 @opindex fsplit-stack
3385 If @option{-fsplit-stack} is given, functions have a small
3386 prologue which decides whether to split the stack.  Functions with the
3387 @code{no_split_stack} attribute do not have that prologue, and thus
3388 may run with only a small amount of stack space available.
3390 @item noinline
3391 @cindex @code{noinline} function attribute
3392 This function attribute prevents a function from being considered for
3393 inlining.
3394 @c Don't enumerate the optimizations by name here; we try to be
3395 @c future-compatible with this mechanism.
3396 If the function does not have side-effects, there are optimizations
3397 other than inlining that cause function calls to be optimized away,
3398 although the function call is live.  To keep such calls from being
3399 optimized away, put
3400 @smallexample
3401 asm ("");
3402 @end smallexample
3404 @noindent
3405 (@pxref{Extended Asm}) in the called function, to serve as a special
3406 side-effect.
3408 @item noclone
3409 @cindex @code{noclone} function attribute
3410 This function attribute prevents a function from being considered for
3411 cloning---a mechanism that produces specialized copies of functions
3412 and which is (currently) performed by interprocedural constant
3413 propagation.
3415 @item nonnull (@var{arg-index}, @dots{})
3416 @cindex @code{nonnull} function attribute
3417 The @code{nonnull} attribute specifies that some function parameters should
3418 be non-null pointers.  For instance, the declaration:
3420 @smallexample
3421 extern void *
3422 my_memcpy (void *dest, const void *src, size_t len)
3423         __attribute__((nonnull (1, 2)));
3424 @end smallexample
3426 @noindent
3427 causes the compiler to check that, in calls to @code{my_memcpy},
3428 arguments @var{dest} and @var{src} are non-null.  If the compiler
3429 determines that a null pointer is passed in an argument slot marked
3430 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3431 is issued.  The compiler may also choose to make optimizations based
3432 on the knowledge that certain function arguments will never be null.
3434 If no argument index list is given to the @code{nonnull} attribute,
3435 all pointer arguments are marked as non-null.  To illustrate, the
3436 following declaration is equivalent to the previous example:
3438 @smallexample
3439 extern void *
3440 my_memcpy (void *dest, const void *src, size_t len)
3441         __attribute__((nonnull));
3442 @end smallexample
3444 @item returns_nonnull
3445 @cindex @code{returns_nonnull} function attribute
3446 The @code{returns_nonnull} attribute specifies that the function
3447 return value should be a non-null pointer.  For instance, the declaration:
3449 @smallexample
3450 extern void *
3451 mymalloc (size_t len) __attribute__((returns_nonnull));
3452 @end smallexample
3454 @noindent
3455 lets the compiler optimize callers based on the knowledge
3456 that the return value will never be null.
3458 @item noreturn
3459 @cindex @code{noreturn} function attribute
3460 A few standard library functions, such as @code{abort} and @code{exit},
3461 cannot return.  GCC knows this automatically.  Some programs define
3462 their own functions that never return.  You can declare them
3463 @code{noreturn} to tell the compiler this fact.  For example,
3465 @smallexample
3466 @group
3467 void fatal () __attribute__ ((noreturn));
3469 void
3470 fatal (/* @r{@dots{}} */)
3472   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3473   exit (1);
3475 @end group
3476 @end smallexample
3478 The @code{noreturn} keyword tells the compiler to assume that
3479 @code{fatal} cannot return.  It can then optimize without regard to what
3480 would happen if @code{fatal} ever did return.  This makes slightly
3481 better code.  More importantly, it helps avoid spurious warnings of
3482 uninitialized variables.
3484 The @code{noreturn} keyword does not affect the exceptional path when that
3485 applies: a @code{noreturn}-marked function may still return to the caller
3486 by throwing an exception or calling @code{longjmp}.
3488 Do not assume that registers saved by the calling function are
3489 restored before calling the @code{noreturn} function.
3491 It does not make sense for a @code{noreturn} function to have a return
3492 type other than @code{void}.
3494 The attribute @code{noreturn} is not implemented in GCC versions
3495 earlier than 2.5.  An alternative way to declare that a function does
3496 not return, which works in the current version and in some older
3497 versions, is as follows:
3499 @smallexample
3500 typedef void voidfn ();
3502 volatile voidfn fatal;
3503 @end smallexample
3505 @noindent
3506 This approach does not work in GNU C++.
3508 @item nothrow
3509 @cindex @code{nothrow} function attribute
3510 The @code{nothrow} attribute is used to inform the compiler that a
3511 function cannot throw an exception.  For example, most functions in
3512 the standard C library can be guaranteed not to throw an exception
3513 with the notable exceptions of @code{qsort} and @code{bsearch} that
3514 take function pointer arguments.  The @code{nothrow} attribute is not
3515 implemented in GCC versions earlier than 3.3.
3517 @item nosave_low_regs
3518 @cindex @code{nosave_low_regs} attribute
3519 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3520 function should not save and restore registers R0..R7.  This can be used on SH3*
3521 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3522 interrupt handlers.
3524 @item optimize
3525 @cindex @code{optimize} function attribute
3526 The @code{optimize} attribute is used to specify that a function is to
3527 be compiled with different optimization options than specified on the
3528 command line.  Arguments can either be numbers or strings.  Numbers
3529 are assumed to be an optimization level.  Strings that begin with
3530 @code{O} are assumed to be an optimization option, while other options
3531 are assumed to be used with a @code{-f} prefix.  You can also use the
3532 @samp{#pragma GCC optimize} pragma to set the optimization options
3533 that affect more than one function.
3534 @xref{Function Specific Option Pragmas}, for details about the
3535 @samp{#pragma GCC optimize} pragma.
3537 This can be used for instance to have frequently-executed functions
3538 compiled with more aggressive optimization options that produce faster
3539 and larger code, while other functions can be compiled with less
3540 aggressive options.
3542 @item OS_main/OS_task
3543 @cindex @code{OS_main} AVR function attribute
3544 @cindex @code{OS_task} AVR function attribute
3545 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3546 do not save/restore any call-saved register in their prologue/epilogue.
3548 The @code{OS_main} attribute can be used when there @emph{is
3549 guarantee} that interrupts are disabled at the time when the function
3550 is entered.  This saves resources when the stack pointer has to be
3551 changed to set up a frame for local variables.
3553 The @code{OS_task} attribute can be used when there is @emph{no
3554 guarantee} that interrupts are disabled at that time when the function
3555 is entered like for, e@.g@. task functions in a multi-threading operating
3556 system. In that case, changing the stack pointer register is
3557 guarded by save/clear/restore of the global interrupt enable flag.
3559 The differences to the @code{naked} function attribute are:
3560 @itemize @bullet
3561 @item @code{naked} functions do not have a return instruction whereas 
3562 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3563 @code{RETI} return instruction.
3564 @item @code{naked} functions do not set up a frame for local variables
3565 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3566 as needed.
3567 @end itemize
3569 @item pcs
3570 @cindex @code{pcs} function attribute
3572 The @code{pcs} attribute can be used to control the calling convention
3573 used for a function on ARM.  The attribute takes an argument that specifies
3574 the calling convention to use.
3576 When compiling using the AAPCS ABI (or a variant of it) then valid
3577 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3578 order to use a variant other than @code{"aapcs"} then the compiler must
3579 be permitted to use the appropriate co-processor registers (i.e., the
3580 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3581 For example,
3583 @smallexample
3584 /* Argument passed in r0, and result returned in r0+r1.  */
3585 double f2d (float) __attribute__((pcs("aapcs")));
3586 @end smallexample
3588 Variadic functions always use the @code{"aapcs"} calling convention and
3589 the compiler rejects attempts to specify an alternative.
3591 @item pure
3592 @cindex @code{pure} function attribute
3593 Many functions have no effects except the return value and their
3594 return value depends only on the parameters and/or global variables.
3595 Such a function can be subject
3596 to common subexpression elimination and loop optimization just as an
3597 arithmetic operator would be.  These functions should be declared
3598 with the attribute @code{pure}.  For example,
3600 @smallexample
3601 int square (int) __attribute__ ((pure));
3602 @end smallexample
3604 @noindent
3605 says that the hypothetical function @code{square} is safe to call
3606 fewer times than the program says.
3608 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3609 Interesting non-pure functions are functions with infinite loops or those
3610 depending on volatile memory or other system resource, that may change between
3611 two consecutive calls (such as @code{feof} in a multithreading environment).
3613 The attribute @code{pure} is not implemented in GCC versions earlier
3614 than 2.96.
3616 @item hot
3617 @cindex @code{hot} function attribute
3618 The @code{hot} attribute on a function is used to inform the compiler that
3619 the function is a hot spot of the compiled program.  The function is
3620 optimized more aggressively and on many target it is placed into special
3621 subsection of the text section so all hot functions appears close together
3622 improving locality.
3624 When profile feedback is available, via @option{-fprofile-use}, hot functions
3625 are automatically detected and this attribute is ignored.
3627 The @code{hot} attribute on functions is not implemented in GCC versions
3628 earlier than 4.3.
3630 @cindex @code{hot} label attribute
3631 The @code{hot} attribute on a label is used to inform the compiler that
3632 path following the label are more likely than paths that are not so
3633 annotated.  This attribute is used in cases where @code{__builtin_expect}
3634 cannot be used, for instance with computed goto or @code{asm goto}.
3636 The @code{hot} attribute on labels is not implemented in GCC versions
3637 earlier than 4.8.
3639 @item cold
3640 @cindex @code{cold} function attribute
3641 The @code{cold} attribute on functions is used to inform the compiler that
3642 the function is unlikely to be executed.  The function is optimized for
3643 size rather than speed and on many targets it is placed into special
3644 subsection of the text section so all cold functions appears close together
3645 improving code locality of non-cold parts of program.  The paths leading
3646 to call of cold functions within code are marked as unlikely by the branch
3647 prediction mechanism.  It is thus useful to mark functions used to handle
3648 unlikely conditions, such as @code{perror}, as cold to improve optimization
3649 of hot functions that do call marked functions in rare occasions.
3651 When profile feedback is available, via @option{-fprofile-use}, cold functions
3652 are automatically detected and this attribute is ignored.
3654 The @code{cold} attribute on functions is not implemented in GCC versions
3655 earlier than 4.3.
3657 @cindex @code{cold} label attribute
3658 The @code{cold} attribute on labels is used to inform the compiler that
3659 the path following the label is unlikely to be executed.  This attribute
3660 is used in cases where @code{__builtin_expect} cannot be used, for instance
3661 with computed goto or @code{asm goto}.
3663 The @code{cold} attribute on labels is not implemented in GCC versions
3664 earlier than 4.8.
3666 @item no_sanitize_address
3667 @itemx no_address_safety_analysis
3668 @cindex @code{no_sanitize_address} function attribute
3669 The @code{no_sanitize_address} attribute on functions is used
3670 to inform the compiler that it should not instrument memory accesses
3671 in the function when compiling with the @option{-fsanitize=address} option.
3672 The @code{no_address_safety_analysis} is a deprecated alias of the
3673 @code{no_sanitize_address} attribute, new code should use
3674 @code{no_sanitize_address}.
3676 @item no_sanitize_undefined
3677 @cindex @code{no_sanitize_undefined} function attribute
3678 The @code{no_sanitize_undefined} attribute on functions is used
3679 to inform the compiler that it should not check for undefined behavior
3680 in the function when compiling with the @option{-fsanitize=undefined} option.
3682 @item regparm (@var{number})
3683 @cindex @code{regparm} attribute
3684 @cindex functions that are passed arguments in registers on the 386
3685 On the Intel 386, the @code{regparm} attribute causes the compiler to
3686 pass arguments number one to @var{number} if they are of integral type
3687 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3688 take a variable number of arguments continue to be passed all of their
3689 arguments on the stack.
3691 Beware that on some ELF systems this attribute is unsuitable for
3692 global functions in shared libraries with lazy binding (which is the
3693 default).  Lazy binding sends the first call via resolving code in
3694 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3695 per the standard calling conventions.  Solaris 8 is affected by this.
3696 Systems with the GNU C Library version 2.1 or higher
3697 and FreeBSD are believed to be
3698 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3699 disabled with the linker or the loader if desired, to avoid the
3700 problem.)
3702 @item reset
3703 @cindex reset handler functions
3704 Use this attribute on the NDS32 target to indicate that the specified function
3705 is a reset handler.  The compiler will generate corresponding sections
3706 for use in a reset handler.  You can use the following attributes
3707 to provide extra exception handling:
3708 @table @code
3709 @item nmi
3710 @cindex @code{nmi} attribute
3711 Provide a user-defined function to handle NMI exception.
3712 @item warm
3713 @cindex @code{warm} attribute
3714 Provide a user-defined function to handle warm reset exception.
3715 @end table
3717 @item sseregparm
3718 @cindex @code{sseregparm} attribute
3719 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3720 causes the compiler to pass up to 3 floating-point arguments in
3721 SSE registers instead of on the stack.  Functions that take a
3722 variable number of arguments continue to pass all of their
3723 floating-point arguments on the stack.
3725 @item force_align_arg_pointer
3726 @cindex @code{force_align_arg_pointer} attribute
3727 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3728 applied to individual function definitions, generating an alternate
3729 prologue and epilogue that realigns the run-time stack if necessary.
3730 This supports mixing legacy codes that run with a 4-byte aligned stack
3731 with modern codes that keep a 16-byte stack for SSE compatibility.
3733 @item renesas
3734 @cindex @code{renesas} attribute
3735 On SH targets this attribute specifies that the function or struct follows the
3736 Renesas ABI.
3738 @item resbank
3739 @cindex @code{resbank} attribute
3740 On the SH2A target, this attribute enables the high-speed register
3741 saving and restoration using a register bank for @code{interrupt_handler}
3742 routines.  Saving to the bank is performed automatically after the CPU
3743 accepts an interrupt that uses a register bank.
3745 The nineteen 32-bit registers comprising general register R0 to R14,
3746 control register GBR, and system registers MACH, MACL, and PR and the
3747 vector table address offset are saved into a register bank.  Register
3748 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3749 from the bank is executed by issuing a RESBANK instruction.
3751 @item returns_twice
3752 @cindex @code{returns_twice} attribute
3753 The @code{returns_twice} attribute tells the compiler that a function may
3754 return more than one time.  The compiler ensures that all registers
3755 are dead before calling such a function and emits a warning about
3756 the variables that may be clobbered after the second return from the
3757 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3758 The @code{longjmp}-like counterpart of such function, if any, might need
3759 to be marked with the @code{noreturn} attribute.
3761 @item saveall
3762 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3763 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3764 all registers except the stack pointer should be saved in the prologue
3765 regardless of whether they are used or not.
3767 @item save_volatiles
3768 @cindex save volatile registers on the MicroBlaze
3769 Use this attribute on the MicroBlaze to indicate that the function is
3770 an interrupt handler.  All volatile registers (in addition to non-volatile
3771 registers) are saved in the function prologue.  If the function is a leaf
3772 function, only volatiles used by the function are saved.  A normal function
3773 return is generated instead of a return from interrupt.
3775 @item section ("@var{section-name}")
3776 @cindex @code{section} function attribute
3777 Normally, the compiler places the code it generates in the @code{text} section.
3778 Sometimes, however, you need additional sections, or you need certain
3779 particular functions to appear in special sections.  The @code{section}
3780 attribute specifies that a function lives in a particular section.
3781 For example, the declaration:
3783 @smallexample
3784 extern void foobar (void) __attribute__ ((section ("bar")));
3785 @end smallexample
3787 @noindent
3788 puts the function @code{foobar} in the @code{bar} section.
3790 Some file formats do not support arbitrary sections so the @code{section}
3791 attribute is not available on all platforms.
3792 If you need to map the entire contents of a module to a particular
3793 section, consider using the facilities of the linker instead.
3795 @item sentinel
3796 @cindex @code{sentinel} function attribute
3797 This function attribute ensures that a parameter in a function call is
3798 an explicit @code{NULL}.  The attribute is only valid on variadic
3799 functions.  By default, the sentinel is located at position zero, the
3800 last parameter of the function call.  If an optional integer position
3801 argument P is supplied to the attribute, the sentinel must be located at
3802 position P counting backwards from the end of the argument list.
3804 @smallexample
3805 __attribute__ ((sentinel))
3806 is equivalent to
3807 __attribute__ ((sentinel(0)))
3808 @end smallexample
3810 The attribute is automatically set with a position of 0 for the built-in
3811 functions @code{execl} and @code{execlp}.  The built-in function
3812 @code{execle} has the attribute set with a position of 1.
3814 A valid @code{NULL} in this context is defined as zero with any pointer
3815 type.  If your system defines the @code{NULL} macro with an integer type
3816 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3817 with a copy that redefines NULL appropriately.
3819 The warnings for missing or incorrect sentinels are enabled with
3820 @option{-Wformat}.
3822 @item short_call
3823 See @code{long_call/short_call}.
3825 @item shortcall
3826 See @code{longcall/shortcall}.
3828 @item signal
3829 @cindex interrupt handler functions on the AVR processors
3830 Use this attribute on the AVR to indicate that the specified
3831 function is an interrupt handler.  The compiler generates function
3832 entry and exit sequences suitable for use in an interrupt handler when this
3833 attribute is present.
3835 See also the @code{interrupt} function attribute. 
3837 The AVR hardware globally disables interrupts when an interrupt is executed.
3838 Interrupt handler functions defined with the @code{signal} attribute
3839 do not re-enable interrupts.  It is save to enable interrupts in a
3840 @code{signal} handler.  This ``save'' only applies to the code
3841 generated by the compiler and not to the IRQ layout of the
3842 application which is responsibility of the application.
3844 If both @code{signal} and @code{interrupt} are specified for the same
3845 function, @code{signal} is silently ignored.
3847 @item sp_switch
3848 @cindex @code{sp_switch} attribute
3849 Use this attribute on the SH to indicate an @code{interrupt_handler}
3850 function should switch to an alternate stack.  It expects a string
3851 argument that names a global variable holding the address of the
3852 alternate stack.
3854 @smallexample
3855 void *alt_stack;
3856 void f () __attribute__ ((interrupt_handler,
3857                           sp_switch ("alt_stack")));
3858 @end smallexample
3860 @item stdcall
3861 @cindex functions that pop the argument stack on the 386
3862 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3863 assume that the called function pops off the stack space used to
3864 pass arguments, unless it takes a variable number of arguments.
3866 @item syscall_linkage
3867 @cindex @code{syscall_linkage} attribute
3868 This attribute is used to modify the IA-64 calling convention by marking
3869 all input registers as live at all function exits.  This makes it possible
3870 to restart a system call after an interrupt without having to save/restore
3871 the input registers.  This also prevents kernel data from leaking into
3872 application code.
3874 @item target
3875 @cindex @code{target} function attribute
3876 The @code{target} attribute is used to specify that a function is to
3877 be compiled with different target options than specified on the
3878 command line.  This can be used for instance to have functions
3879 compiled with a different ISA (instruction set architecture) than the
3880 default.  You can also use the @samp{#pragma GCC target} pragma to set
3881 more than one function to be compiled with specific target options.
3882 @xref{Function Specific Option Pragmas}, for details about the
3883 @samp{#pragma GCC target} pragma.
3885 For instance on a 386, you could compile one function with
3886 @code{target("sse4.1,arch=core2")} and another with
3887 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3888 compiling the first function with @option{-msse4.1} and
3889 @option{-march=core2} options, and the second function with
3890 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3891 user to make sure that a function is only invoked on a machine that
3892 supports the particular ISA it is compiled for (for example by using
3893 @code{cpuid} on 386 to determine what feature bits and architecture
3894 family are used).
3896 @smallexample
3897 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3898 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3899 @end smallexample
3901 You can either use multiple
3902 strings to specify multiple options, or separate the options
3903 with a comma (@samp{,}).
3905 The @code{target} attribute is presently implemented for
3906 i386/x86_64, PowerPC, and Nios II targets only.
3907 The options supported are specific to each target.
3909 On the 386, the following options are allowed:
3911 @table @samp
3912 @item abm
3913 @itemx no-abm
3914 @cindex @code{target("abm")} attribute
3915 Enable/disable the generation of the advanced bit instructions.
3917 @item aes
3918 @itemx no-aes
3919 @cindex @code{target("aes")} attribute
3920 Enable/disable the generation of the AES instructions.
3922 @item default
3923 @cindex @code{target("default")} attribute
3924 @xref{Function Multiversioning}, where it is used to specify the
3925 default function version.
3927 @item mmx
3928 @itemx no-mmx
3929 @cindex @code{target("mmx")} attribute
3930 Enable/disable the generation of the MMX instructions.
3932 @item pclmul
3933 @itemx no-pclmul
3934 @cindex @code{target("pclmul")} attribute
3935 Enable/disable the generation of the PCLMUL instructions.
3937 @item popcnt
3938 @itemx no-popcnt
3939 @cindex @code{target("popcnt")} attribute
3940 Enable/disable the generation of the POPCNT instruction.
3942 @item sse
3943 @itemx no-sse
3944 @cindex @code{target("sse")} attribute
3945 Enable/disable the generation of the SSE instructions.
3947 @item sse2
3948 @itemx no-sse2
3949 @cindex @code{target("sse2")} attribute
3950 Enable/disable the generation of the SSE2 instructions.
3952 @item sse3
3953 @itemx no-sse3
3954 @cindex @code{target("sse3")} attribute
3955 Enable/disable the generation of the SSE3 instructions.
3957 @item sse4
3958 @itemx no-sse4
3959 @cindex @code{target("sse4")} attribute
3960 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3961 and SSE4.2).
3963 @item sse4.1
3964 @itemx no-sse4.1
3965 @cindex @code{target("sse4.1")} attribute
3966 Enable/disable the generation of the sse4.1 instructions.
3968 @item sse4.2
3969 @itemx no-sse4.2
3970 @cindex @code{target("sse4.2")} attribute
3971 Enable/disable the generation of the sse4.2 instructions.
3973 @item sse4a
3974 @itemx no-sse4a
3975 @cindex @code{target("sse4a")} attribute
3976 Enable/disable the generation of the SSE4A instructions.
3978 @item fma4
3979 @itemx no-fma4
3980 @cindex @code{target("fma4")} attribute
3981 Enable/disable the generation of the FMA4 instructions.
3983 @item xop
3984 @itemx no-xop
3985 @cindex @code{target("xop")} attribute
3986 Enable/disable the generation of the XOP instructions.
3988 @item lwp
3989 @itemx no-lwp
3990 @cindex @code{target("lwp")} attribute
3991 Enable/disable the generation of the LWP instructions.
3993 @item ssse3
3994 @itemx no-ssse3
3995 @cindex @code{target("ssse3")} attribute
3996 Enable/disable the generation of the SSSE3 instructions.
3998 @item cld
3999 @itemx no-cld
4000 @cindex @code{target("cld")} attribute
4001 Enable/disable the generation of the CLD before string moves.
4003 @item fancy-math-387
4004 @itemx no-fancy-math-387
4005 @cindex @code{target("fancy-math-387")} attribute
4006 Enable/disable the generation of the @code{sin}, @code{cos}, and
4007 @code{sqrt} instructions on the 387 floating-point unit.
4009 @item fused-madd
4010 @itemx no-fused-madd
4011 @cindex @code{target("fused-madd")} attribute
4012 Enable/disable the generation of the fused multiply/add instructions.
4014 @item ieee-fp
4015 @itemx no-ieee-fp
4016 @cindex @code{target("ieee-fp")} attribute
4017 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4019 @item inline-all-stringops
4020 @itemx no-inline-all-stringops
4021 @cindex @code{target("inline-all-stringops")} attribute
4022 Enable/disable inlining of string operations.
4024 @item inline-stringops-dynamically
4025 @itemx no-inline-stringops-dynamically
4026 @cindex @code{target("inline-stringops-dynamically")} attribute
4027 Enable/disable the generation of the inline code to do small string
4028 operations and calling the library routines for large operations.
4030 @item align-stringops
4031 @itemx no-align-stringops
4032 @cindex @code{target("align-stringops")} attribute
4033 Do/do not align destination of inlined string operations.
4035 @item recip
4036 @itemx no-recip
4037 @cindex @code{target("recip")} attribute
4038 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4039 instructions followed an additional Newton-Raphson step instead of
4040 doing a floating-point division.
4042 @item arch=@var{ARCH}
4043 @cindex @code{target("arch=@var{ARCH}")} attribute
4044 Specify the architecture to generate code for in compiling the function.
4046 @item tune=@var{TUNE}
4047 @cindex @code{target("tune=@var{TUNE}")} attribute
4048 Specify the architecture to tune for in compiling the function.
4050 @item fpmath=@var{FPMATH}
4051 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4052 Specify which floating-point unit to use.  The
4053 @code{target("fpmath=sse,387")} option must be specified as
4054 @code{target("fpmath=sse+387")} because the comma would separate
4055 different options.
4056 @end table
4058 On the PowerPC, the following options are allowed:
4060 @table @samp
4061 @item altivec
4062 @itemx no-altivec
4063 @cindex @code{target("altivec")} attribute
4064 Generate code that uses (does not use) AltiVec instructions.  In
4065 32-bit code, you cannot enable AltiVec instructions unless
4066 @option{-mabi=altivec} is used on the command line.
4068 @item cmpb
4069 @itemx no-cmpb
4070 @cindex @code{target("cmpb")} attribute
4071 Generate code that uses (does not use) the compare bytes instruction
4072 implemented on the POWER6 processor and other processors that support
4073 the PowerPC V2.05 architecture.
4075 @item dlmzb
4076 @itemx no-dlmzb
4077 @cindex @code{target("dlmzb")} attribute
4078 Generate code that uses (does not use) the string-search @samp{dlmzb}
4079 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4080 generated by default when targeting those processors.
4082 @item fprnd
4083 @itemx no-fprnd
4084 @cindex @code{target("fprnd")} attribute
4085 Generate code that uses (does not use) the FP round to integer
4086 instructions implemented on the POWER5+ processor and other processors
4087 that support the PowerPC V2.03 architecture.
4089 @item hard-dfp
4090 @itemx no-hard-dfp
4091 @cindex @code{target("hard-dfp")} attribute
4092 Generate code that uses (does not use) the decimal floating-point
4093 instructions implemented on some POWER processors.
4095 @item isel
4096 @itemx no-isel
4097 @cindex @code{target("isel")} attribute
4098 Generate code that uses (does not use) ISEL instruction.
4100 @item mfcrf
4101 @itemx no-mfcrf
4102 @cindex @code{target("mfcrf")} attribute
4103 Generate code that uses (does not use) the move from condition
4104 register field instruction implemented on the POWER4 processor and
4105 other processors that support the PowerPC V2.01 architecture.
4107 @item mfpgpr
4108 @itemx no-mfpgpr
4109 @cindex @code{target("mfpgpr")} attribute
4110 Generate code that uses (does not use) the FP move to/from general
4111 purpose register instructions implemented on the POWER6X processor and
4112 other processors that support the extended PowerPC V2.05 architecture.
4114 @item mulhw
4115 @itemx no-mulhw
4116 @cindex @code{target("mulhw")} attribute
4117 Generate code that uses (does not use) the half-word multiply and
4118 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4119 These instructions are generated by default when targeting those
4120 processors.
4122 @item multiple
4123 @itemx no-multiple
4124 @cindex @code{target("multiple")} attribute
4125 Generate code that uses (does not use) the load multiple word
4126 instructions and the store multiple word instructions.
4128 @item update
4129 @itemx no-update
4130 @cindex @code{target("update")} attribute
4131 Generate code that uses (does not use) the load or store instructions
4132 that update the base register to the address of the calculated memory
4133 location.
4135 @item popcntb
4136 @itemx no-popcntb
4137 @cindex @code{target("popcntb")} attribute
4138 Generate code that uses (does not use) the popcount and double-precision
4139 FP reciprocal estimate instruction implemented on the POWER5
4140 processor and other processors that support the PowerPC V2.02
4141 architecture.
4143 @item popcntd
4144 @itemx no-popcntd
4145 @cindex @code{target("popcntd")} attribute
4146 Generate code that uses (does not use) the popcount instruction
4147 implemented on the POWER7 processor and other processors that support
4148 the PowerPC V2.06 architecture.
4150 @item powerpc-gfxopt
4151 @itemx no-powerpc-gfxopt
4152 @cindex @code{target("powerpc-gfxopt")} attribute
4153 Generate code that uses (does not use) the optional PowerPC
4154 architecture instructions in the Graphics group, including
4155 floating-point select.
4157 @item powerpc-gpopt
4158 @itemx no-powerpc-gpopt
4159 @cindex @code{target("powerpc-gpopt")} attribute
4160 Generate code that uses (does not use) the optional PowerPC
4161 architecture instructions in the General Purpose group, including
4162 floating-point square root.
4164 @item recip-precision
4165 @itemx no-recip-precision
4166 @cindex @code{target("recip-precision")} attribute
4167 Assume (do not assume) that the reciprocal estimate instructions
4168 provide higher-precision estimates than is mandated by the powerpc
4169 ABI.
4171 @item string
4172 @itemx no-string
4173 @cindex @code{target("string")} attribute
4174 Generate code that uses (does not use) the load string instructions
4175 and the store string word instructions to save multiple registers and
4176 do small block moves.
4178 @item vsx
4179 @itemx no-vsx
4180 @cindex @code{target("vsx")} attribute
4181 Generate code that uses (does not use) vector/scalar (VSX)
4182 instructions, and also enable the use of built-in functions that allow
4183 more direct access to the VSX instruction set.  In 32-bit code, you
4184 cannot enable VSX or AltiVec instructions unless
4185 @option{-mabi=altivec} is used on the command line.
4187 @item friz
4188 @itemx no-friz
4189 @cindex @code{target("friz")} attribute
4190 Generate (do not generate) the @code{friz} instruction when the
4191 @option{-funsafe-math-optimizations} option is used to optimize
4192 rounding a floating-point value to 64-bit integer and back to floating
4193 point.  The @code{friz} instruction does not return the same value if
4194 the floating-point number is too large to fit in an integer.
4196 @item avoid-indexed-addresses
4197 @itemx no-avoid-indexed-addresses
4198 @cindex @code{target("avoid-indexed-addresses")} attribute
4199 Generate code that tries to avoid (not avoid) the use of indexed load
4200 or store instructions.
4202 @item paired
4203 @itemx no-paired
4204 @cindex @code{target("paired")} attribute
4205 Generate code that uses (does not use) the generation of PAIRED simd
4206 instructions.
4208 @item longcall
4209 @itemx no-longcall
4210 @cindex @code{target("longcall")} attribute
4211 Generate code that assumes (does not assume) that all calls are far
4212 away so that a longer more expensive calling sequence is required.
4214 @item cpu=@var{CPU}
4215 @cindex @code{target("cpu=@var{CPU}")} attribute
4216 Specify the architecture to generate code for when compiling the
4217 function.  If you select the @code{target("cpu=power7")} attribute when
4218 generating 32-bit code, VSX and AltiVec instructions are not generated
4219 unless you use the @option{-mabi=altivec} option on the command line.
4221 @item tune=@var{TUNE}
4222 @cindex @code{target("tune=@var{TUNE}")} attribute
4223 Specify the architecture to tune for when compiling the function.  If
4224 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4225 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4226 compilation tunes for the @var{CPU} architecture, and not the
4227 default tuning specified on the command line.
4228 @end table
4230 When compiling for Nios II, the following options are allowed:
4232 @table @samp
4233 @item custom-@var{insn}=@var{N}
4234 @itemx no-custom-@var{insn}
4235 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4236 @cindex @code{target("no-custom-@var{insn}")} attribute
4237 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4238 custom instruction with encoding @var{N} when generating code that uses 
4239 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4240 the custom instruction @var{insn}.
4241 These target attributes correspond to the
4242 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4243 command-line options, and support the same set of @var{insn} keywords.
4244 @xref{Nios II Options}, for more information.
4246 @item custom-fpu-cfg=@var{name}
4247 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4248 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4249 command-line option, to select a predefined set of custom instructions
4250 named @var{name}.
4251 @xref{Nios II Options}, for more information.
4252 @end table
4254 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4255 function that has different target options than the caller, unless the
4256 callee has a subset of the target options of the caller.  For example
4257 a function declared with @code{target("sse3")} can inline a function
4258 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4260 @item tiny_data
4261 @cindex tiny data section on the H8/300H and H8S
4262 Use this attribute on the H8/300H and H8S to indicate that the specified
4263 variable should be placed into the tiny data section.
4264 The compiler generates more efficient code for loads and stores
4265 on data in the tiny data section.  Note the tiny data area is limited to
4266 slightly under 32KB of data.
4268 @item trap_exit
4269 @cindex @code{trap_exit} attribute
4270 Use this attribute on the SH for an @code{interrupt_handler} to return using
4271 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4272 argument specifying the trap number to be used.
4274 @item trapa_handler
4275 @cindex @code{trapa_handler} attribute
4276 On SH targets this function attribute is similar to @code{interrupt_handler}
4277 but it does not save and restore all registers.
4279 @item unused
4280 @cindex @code{unused} attribute.
4281 This attribute, attached to a function, means that the function is meant
4282 to be possibly unused.  GCC does not produce a warning for this
4283 function.
4285 @item used
4286 @cindex @code{used} attribute.
4287 This attribute, attached to a function, means that code must be emitted
4288 for the function even if it appears that the function is not referenced.
4289 This is useful, for example, when the function is referenced only in
4290 inline assembly.
4292 When applied to a member function of a C++ class template, the
4293 attribute also means that the function is instantiated if the
4294 class itself is instantiated.
4296 @item version_id
4297 @cindex @code{version_id} attribute
4298 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4299 symbol to contain a version string, thus allowing for function level
4300 versioning.  HP-UX system header files may use function level versioning
4301 for some system calls.
4303 @smallexample
4304 extern int foo () __attribute__((version_id ("20040821")));
4305 @end smallexample
4307 @noindent
4308 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4310 @item visibility ("@var{visibility_type}")
4311 @cindex @code{visibility} attribute
4312 This attribute affects the linkage of the declaration to which it is attached.
4313 There are four supported @var{visibility_type} values: default,
4314 hidden, protected or internal visibility.
4316 @smallexample
4317 void __attribute__ ((visibility ("protected")))
4318 f () @{ /* @r{Do something.} */; @}
4319 int i __attribute__ ((visibility ("hidden")));
4320 @end smallexample
4322 The possible values of @var{visibility_type} correspond to the
4323 visibility settings in the ELF gABI.
4325 @table @dfn
4326 @c keep this list of visibilities in alphabetical order.
4328 @item default
4329 Default visibility is the normal case for the object file format.
4330 This value is available for the visibility attribute to override other
4331 options that may change the assumed visibility of entities.
4333 On ELF, default visibility means that the declaration is visible to other
4334 modules and, in shared libraries, means that the declared entity may be
4335 overridden.
4337 On Darwin, default visibility means that the declaration is visible to
4338 other modules.
4340 Default visibility corresponds to ``external linkage'' in the language.
4342 @item hidden
4343 Hidden visibility indicates that the entity declared has a new
4344 form of linkage, which we call ``hidden linkage''.  Two
4345 declarations of an object with hidden linkage refer to the same object
4346 if they are in the same shared object.
4348 @item internal
4349 Internal visibility is like hidden visibility, but with additional
4350 processor specific semantics.  Unless otherwise specified by the
4351 psABI, GCC defines internal visibility to mean that a function is
4352 @emph{never} called from another module.  Compare this with hidden
4353 functions which, while they cannot be referenced directly by other
4354 modules, can be referenced indirectly via function pointers.  By
4355 indicating that a function cannot be called from outside the module,
4356 GCC may for instance omit the load of a PIC register since it is known
4357 that the calling function loaded the correct value.
4359 @item protected
4360 Protected visibility is like default visibility except that it
4361 indicates that references within the defining module bind to the
4362 definition in that module.  That is, the declared entity cannot be
4363 overridden by another module.
4365 @end table
4367 All visibilities are supported on many, but not all, ELF targets
4368 (supported when the assembler supports the @samp{.visibility}
4369 pseudo-op).  Default visibility is supported everywhere.  Hidden
4370 visibility is supported on Darwin targets.
4372 The visibility attribute should be applied only to declarations that
4373 would otherwise have external linkage.  The attribute should be applied
4374 consistently, so that the same entity should not be declared with
4375 different settings of the attribute.
4377 In C++, the visibility attribute applies to types as well as functions
4378 and objects, because in C++ types have linkage.  A class must not have
4379 greater visibility than its non-static data member types and bases,
4380 and class members default to the visibility of their class.  Also, a
4381 declaration without explicit visibility is limited to the visibility
4382 of its type.
4384 In C++, you can mark member functions and static member variables of a
4385 class with the visibility attribute.  This is useful if you know a
4386 particular method or static member variable should only be used from
4387 one shared object; then you can mark it hidden while the rest of the
4388 class has default visibility.  Care must be taken to avoid breaking
4389 the One Definition Rule; for example, it is usually not useful to mark
4390 an inline method as hidden without marking the whole class as hidden.
4392 A C++ namespace declaration can also have the visibility attribute.
4394 @smallexample
4395 namespace nspace1 __attribute__ ((visibility ("protected")))
4396 @{ /* @r{Do something.} */; @}
4397 @end smallexample
4399 This attribute applies only to the particular namespace body, not to
4400 other definitions of the same namespace; it is equivalent to using
4401 @samp{#pragma GCC visibility} before and after the namespace
4402 definition (@pxref{Visibility Pragmas}).
4404 In C++, if a template argument has limited visibility, this
4405 restriction is implicitly propagated to the template instantiation.
4406 Otherwise, template instantiations and specializations default to the
4407 visibility of their template.
4409 If both the template and enclosing class have explicit visibility, the
4410 visibility from the template is used.
4412 @item vliw
4413 @cindex @code{vliw} attribute
4414 On MeP, the @code{vliw} attribute tells the compiler to emit
4415 instructions in VLIW mode instead of core mode.  Note that this
4416 attribute is not allowed unless a VLIW coprocessor has been configured
4417 and enabled through command-line options.
4419 @item warn_unused_result
4420 @cindex @code{warn_unused_result} attribute
4421 The @code{warn_unused_result} attribute causes a warning to be emitted
4422 if a caller of the function with this attribute does not use its
4423 return value.  This is useful for functions where not checking
4424 the result is either a security problem or always a bug, such as
4425 @code{realloc}.
4427 @smallexample
4428 int fn () __attribute__ ((warn_unused_result));
4429 int foo ()
4431   if (fn () < 0) return -1;
4432   fn ();
4433   return 0;
4435 @end smallexample
4437 @noindent
4438 results in warning on line 5.
4440 @item weak
4441 @cindex @code{weak} attribute
4442 The @code{weak} attribute causes the declaration to be emitted as a weak
4443 symbol rather than a global.  This is primarily useful in defining
4444 library functions that can be overridden in user code, though it can
4445 also be used with non-function declarations.  Weak symbols are supported
4446 for ELF targets, and also for a.out targets when using the GNU assembler
4447 and linker.
4449 @item weakref
4450 @itemx weakref ("@var{target}")
4451 @cindex @code{weakref} attribute
4452 The @code{weakref} attribute marks a declaration as a weak reference.
4453 Without arguments, it should be accompanied by an @code{alias} attribute
4454 naming the target symbol.  Optionally, the @var{target} may be given as
4455 an argument to @code{weakref} itself.  In either case, @code{weakref}
4456 implicitly marks the declaration as @code{weak}.  Without a
4457 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4458 @code{weakref} is equivalent to @code{weak}.
4460 @smallexample
4461 static int x() __attribute__ ((weakref ("y")));
4462 /* is equivalent to... */
4463 static int x() __attribute__ ((weak, weakref, alias ("y")));
4464 /* and to... */
4465 static int x() __attribute__ ((weakref));
4466 static int x() __attribute__ ((alias ("y")));
4467 @end smallexample
4469 A weak reference is an alias that does not by itself require a
4470 definition to be given for the target symbol.  If the target symbol is
4471 only referenced through weak references, then it becomes a @code{weak}
4472 undefined symbol.  If it is directly referenced, however, then such
4473 strong references prevail, and a definition is required for the
4474 symbol, not necessarily in the same translation unit.
4476 The effect is equivalent to moving all references to the alias to a
4477 separate translation unit, renaming the alias to the aliased symbol,
4478 declaring it as weak, compiling the two separate translation units and
4479 performing a reloadable link on them.
4481 At present, a declaration to which @code{weakref} is attached can
4482 only be @code{static}.
4484 @end table
4486 You can specify multiple attributes in a declaration by separating them
4487 by commas within the double parentheses or by immediately following an
4488 attribute declaration with another attribute declaration.
4490 @cindex @code{#pragma}, reason for not using
4491 @cindex pragma, reason for not using
4492 Some people object to the @code{__attribute__} feature, suggesting that
4493 ISO C's @code{#pragma} should be used instead.  At the time
4494 @code{__attribute__} was designed, there were two reasons for not doing
4495 this.
4497 @enumerate
4498 @item
4499 It is impossible to generate @code{#pragma} commands from a macro.
4501 @item
4502 There is no telling what the same @code{#pragma} might mean in another
4503 compiler.
4504 @end enumerate
4506 These two reasons applied to almost any application that might have been
4507 proposed for @code{#pragma}.  It was basically a mistake to use
4508 @code{#pragma} for @emph{anything}.
4510 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4511 to be generated from macros.  In addition, a @code{#pragma GCC}
4512 namespace is now in use for GCC-specific pragmas.  However, it has been
4513 found convenient to use @code{__attribute__} to achieve a natural
4514 attachment of attributes to their corresponding declarations, whereas
4515 @code{#pragma GCC} is of use for constructs that do not naturally form
4516 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4518 @node Attribute Syntax
4519 @section Attribute Syntax
4520 @cindex attribute syntax
4522 This section describes the syntax with which @code{__attribute__} may be
4523 used, and the constructs to which attribute specifiers bind, for the C
4524 language.  Some details may vary for C++ and Objective-C@.  Because of
4525 infelicities in the grammar for attributes, some forms described here
4526 may not be successfully parsed in all cases.
4528 There are some problems with the semantics of attributes in C++.  For
4529 example, there are no manglings for attributes, although they may affect
4530 code generation, so problems may arise when attributed types are used in
4531 conjunction with templates or overloading.  Similarly, @code{typeid}
4532 does not distinguish between types with different attributes.  Support
4533 for attributes in C++ may be restricted in future to attributes on
4534 declarations only, but not on nested declarators.
4536 @xref{Function Attributes}, for details of the semantics of attributes
4537 applying to functions.  @xref{Variable Attributes}, for details of the
4538 semantics of attributes applying to variables.  @xref{Type Attributes},
4539 for details of the semantics of attributes applying to structure, union
4540 and enumerated types.
4542 An @dfn{attribute specifier} is of the form
4543 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4544 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4545 each attribute is one of the following:
4547 @itemize @bullet
4548 @item
4549 Empty.  Empty attributes are ignored.
4551 @item
4552 A word (which may be an identifier such as @code{unused}, or a reserved
4553 word such as @code{const}).
4555 @item
4556 A word, followed by, in parentheses, parameters for the attribute.
4557 These parameters take one of the following forms:
4559 @itemize @bullet
4560 @item
4561 An identifier.  For example, @code{mode} attributes use this form.
4563 @item
4564 An identifier followed by a comma and a non-empty comma-separated list
4565 of expressions.  For example, @code{format} attributes use this form.
4567 @item
4568 A possibly empty comma-separated list of expressions.  For example,
4569 @code{format_arg} attributes use this form with the list being a single
4570 integer constant expression, and @code{alias} attributes use this form
4571 with the list being a single string constant.
4572 @end itemize
4573 @end itemize
4575 An @dfn{attribute specifier list} is a sequence of one or more attribute
4576 specifiers, not separated by any other tokens.
4578 In GNU C, an attribute specifier list may appear after the colon following a
4579 label, other than a @code{case} or @code{default} label.  The only
4580 attribute it makes sense to use after a label is @code{unused}.  This
4581 feature is intended for program-generated code that may contain unused labels,
4582 but which is compiled with @option{-Wall}.  It is
4583 not normally appropriate to use in it human-written code, though it
4584 could be useful in cases where the code that jumps to the label is
4585 contained within an @code{#ifdef} conditional.  GNU C++ only permits
4586 attributes on labels if the attribute specifier is immediately
4587 followed by a semicolon (i.e., the label applies to an empty
4588 statement).  If the semicolon is missing, C++ label attributes are
4589 ambiguous, as it is permissible for a declaration, which could begin
4590 with an attribute list, to be labelled in C++.  Declarations cannot be
4591 labelled in C90 or C99, so the ambiguity does not arise there.
4593 An attribute specifier list may appear as part of a @code{struct},
4594 @code{union} or @code{enum} specifier.  It may go either immediately
4595 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4596 the closing brace.  The former syntax is preferred.
4597 Where attribute specifiers follow the closing brace, they are considered
4598 to relate to the structure, union or enumerated type defined, not to any
4599 enclosing declaration the type specifier appears in, and the type
4600 defined is not complete until after the attribute specifiers.
4601 @c Otherwise, there would be the following problems: a shift/reduce
4602 @c conflict between attributes binding the struct/union/enum and
4603 @c binding to the list of specifiers/qualifiers; and "aligned"
4604 @c attributes could use sizeof for the structure, but the size could be
4605 @c changed later by "packed" attributes.
4607 Otherwise, an attribute specifier appears as part of a declaration,
4608 counting declarations of unnamed parameters and type names, and relates
4609 to that declaration (which may be nested in another declaration, for
4610 example in the case of a parameter declaration), or to a particular declarator
4611 within a declaration.  Where an
4612 attribute specifier is applied to a parameter declared as a function or
4613 an array, it should apply to the function or array rather than the
4614 pointer to which the parameter is implicitly converted, but this is not
4615 yet correctly implemented.
4617 Any list of specifiers and qualifiers at the start of a declaration may
4618 contain attribute specifiers, whether or not such a list may in that
4619 context contain storage class specifiers.  (Some attributes, however,
4620 are essentially in the nature of storage class specifiers, and only make
4621 sense where storage class specifiers may be used; for example,
4622 @code{section}.)  There is one necessary limitation to this syntax: the
4623 first old-style parameter declaration in a function definition cannot
4624 begin with an attribute specifier, because such an attribute applies to
4625 the function instead by syntax described below (which, however, is not
4626 yet implemented in this case).  In some other cases, attribute
4627 specifiers are permitted by this grammar but not yet supported by the
4628 compiler.  All attribute specifiers in this place relate to the
4629 declaration as a whole.  In the obsolescent usage where a type of
4630 @code{int} is implied by the absence of type specifiers, such a list of
4631 specifiers and qualifiers may be an attribute specifier list with no
4632 other specifiers or qualifiers.
4634 At present, the first parameter in a function prototype must have some
4635 type specifier that is not an attribute specifier; this resolves an
4636 ambiguity in the interpretation of @code{void f(int
4637 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4638 the parentheses of a function declarator contain only attributes then
4639 those attributes are ignored, rather than yielding an error or warning
4640 or implying a single parameter of type int, but this is subject to
4641 change.
4643 An attribute specifier list may appear immediately before a declarator
4644 (other than the first) in a comma-separated list of declarators in a
4645 declaration of more than one identifier using a single list of
4646 specifiers and qualifiers.  Such attribute specifiers apply
4647 only to the identifier before whose declarator they appear.  For
4648 example, in
4650 @smallexample
4651 __attribute__((noreturn)) void d0 (void),
4652     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4653      d2 (void)
4654 @end smallexample
4656 @noindent
4657 the @code{noreturn} attribute applies to all the functions
4658 declared; the @code{format} attribute only applies to @code{d1}.
4660 An attribute specifier list may appear immediately before the comma,
4661 @code{=} or semicolon terminating the declaration of an identifier other
4662 than a function definition.  Such attribute specifiers apply
4663 to the declared object or function.  Where an
4664 assembler name for an object or function is specified (@pxref{Asm
4665 Labels}), the attribute must follow the @code{asm}
4666 specification.
4668 An attribute specifier list may, in future, be permitted to appear after
4669 the declarator in a function definition (before any old-style parameter
4670 declarations or the function body).
4672 Attribute specifiers may be mixed with type qualifiers appearing inside
4673 the @code{[]} of a parameter array declarator, in the C99 construct by
4674 which such qualifiers are applied to the pointer to which the array is
4675 implicitly converted.  Such attribute specifiers apply to the pointer,
4676 not to the array, but at present this is not implemented and they are
4677 ignored.
4679 An attribute specifier list may appear at the start of a nested
4680 declarator.  At present, there are some limitations in this usage: the
4681 attributes correctly apply to the declarator, but for most individual
4682 attributes the semantics this implies are not implemented.
4683 When attribute specifiers follow the @code{*} of a pointer
4684 declarator, they may be mixed with any type qualifiers present.
4685 The following describes the formal semantics of this syntax.  It makes the
4686 most sense if you are familiar with the formal specification of
4687 declarators in the ISO C standard.
4689 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4690 D1}, where @code{T} contains declaration specifiers that specify a type
4691 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4692 contains an identifier @var{ident}.  The type specified for @var{ident}
4693 for derived declarators whose type does not include an attribute
4694 specifier is as in the ISO C standard.
4696 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4697 and the declaration @code{T D} specifies the type
4698 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4699 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4700 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4702 If @code{D1} has the form @code{*
4703 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4704 declaration @code{T D} specifies the type
4705 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4706 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4707 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4708 @var{ident}.
4710 For example,
4712 @smallexample
4713 void (__attribute__((noreturn)) ****f) (void);
4714 @end smallexample
4716 @noindent
4717 specifies the type ``pointer to pointer to pointer to pointer to
4718 non-returning function returning @code{void}''.  As another example,
4720 @smallexample
4721 char *__attribute__((aligned(8))) *f;
4722 @end smallexample
4724 @noindent
4725 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4726 Note again that this does not work with most attributes; for example,
4727 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4728 is not yet supported.
4730 For compatibility with existing code written for compiler versions that
4731 did not implement attributes on nested declarators, some laxity is
4732 allowed in the placing of attributes.  If an attribute that only applies
4733 to types is applied to a declaration, it is treated as applying to
4734 the type of that declaration.  If an attribute that only applies to
4735 declarations is applied to the type of a declaration, it is treated
4736 as applying to that declaration; and, for compatibility with code
4737 placing the attributes immediately before the identifier declared, such
4738 an attribute applied to a function return type is treated as
4739 applying to the function type, and such an attribute applied to an array
4740 element type is treated as applying to the array type.  If an
4741 attribute that only applies to function types is applied to a
4742 pointer-to-function type, it is treated as applying to the pointer
4743 target type; if such an attribute is applied to a function return type
4744 that is not a pointer-to-function type, it is treated as applying
4745 to the function type.
4747 @node Function Prototypes
4748 @section Prototypes and Old-Style Function Definitions
4749 @cindex function prototype declarations
4750 @cindex old-style function definitions
4751 @cindex promotion of formal parameters
4753 GNU C extends ISO C to allow a function prototype to override a later
4754 old-style non-prototype definition.  Consider the following example:
4756 @smallexample
4757 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4758 #ifdef __STDC__
4759 #define P(x) x
4760 #else
4761 #define P(x) ()
4762 #endif
4764 /* @r{Prototype function declaration.}  */
4765 int isroot P((uid_t));
4767 /* @r{Old-style function definition.}  */
4769 isroot (x)   /* @r{??? lossage here ???} */
4770      uid_t x;
4772   return x == 0;
4774 @end smallexample
4776 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4777 not allow this example, because subword arguments in old-style
4778 non-prototype definitions are promoted.  Therefore in this example the
4779 function definition's argument is really an @code{int}, which does not
4780 match the prototype argument type of @code{short}.
4782 This restriction of ISO C makes it hard to write code that is portable
4783 to traditional C compilers, because the programmer does not know
4784 whether the @code{uid_t} type is @code{short}, @code{int}, or
4785 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4786 to override a later old-style definition.  More precisely, in GNU C, a
4787 function prototype argument type overrides the argument type specified
4788 by a later old-style definition if the former type is the same as the
4789 latter type before promotion.  Thus in GNU C the above example is
4790 equivalent to the following:
4792 @smallexample
4793 int isroot (uid_t);
4796 isroot (uid_t x)
4798   return x == 0;
4800 @end smallexample
4802 @noindent
4803 GNU C++ does not support old-style function definitions, so this
4804 extension is irrelevant.
4806 @node C++ Comments
4807 @section C++ Style Comments
4808 @cindex @code{//}
4809 @cindex C++ comments
4810 @cindex comments, C++ style
4812 In GNU C, you may use C++ style comments, which start with @samp{//} and
4813 continue until the end of the line.  Many other C implementations allow
4814 such comments, and they are included in the 1999 C standard.  However,
4815 C++ style comments are not recognized if you specify an @option{-std}
4816 option specifying a version of ISO C before C99, or @option{-ansi}
4817 (equivalent to @option{-std=c90}).
4819 @node Dollar Signs
4820 @section Dollar Signs in Identifier Names
4821 @cindex $
4822 @cindex dollar signs in identifier names
4823 @cindex identifier names, dollar signs in
4825 In GNU C, you may normally use dollar signs in identifier names.
4826 This is because many traditional C implementations allow such identifiers.
4827 However, dollar signs in identifiers are not supported on a few target
4828 machines, typically because the target assembler does not allow them.
4830 @node Character Escapes
4831 @section The Character @key{ESC} in Constants
4833 You can use the sequence @samp{\e} in a string or character constant to
4834 stand for the ASCII character @key{ESC}.
4836 @node Variable Attributes
4837 @section Specifying Attributes of Variables
4838 @cindex attribute of variables
4839 @cindex variable attributes
4841 The keyword @code{__attribute__} allows you to specify special
4842 attributes of variables or structure fields.  This keyword is followed
4843 by an attribute specification inside double parentheses.  Some
4844 attributes are currently defined generically for variables.
4845 Other attributes are defined for variables on particular target
4846 systems.  Other attributes are available for functions
4847 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
4848 Other front ends might define more attributes
4849 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4851 You may also specify attributes with @samp{__} preceding and following
4852 each keyword.  This allows you to use them in header files without
4853 being concerned about a possible macro of the same name.  For example,
4854 you may use @code{__aligned__} instead of @code{aligned}.
4856 @xref{Attribute Syntax}, for details of the exact syntax for using
4857 attributes.
4859 @table @code
4860 @cindex @code{aligned} attribute
4861 @item aligned (@var{alignment})
4862 This attribute specifies a minimum alignment for the variable or
4863 structure field, measured in bytes.  For example, the declaration:
4865 @smallexample
4866 int x __attribute__ ((aligned (16))) = 0;
4867 @end smallexample
4869 @noindent
4870 causes the compiler to allocate the global variable @code{x} on a
4871 16-byte boundary.  On a 68040, this could be used in conjunction with
4872 an @code{asm} expression to access the @code{move16} instruction which
4873 requires 16-byte aligned operands.
4875 You can also specify the alignment of structure fields.  For example, to
4876 create a double-word aligned @code{int} pair, you could write:
4878 @smallexample
4879 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4880 @end smallexample
4882 @noindent
4883 This is an alternative to creating a union with a @code{double} member,
4884 which forces the union to be double-word aligned.
4886 As in the preceding examples, you can explicitly specify the alignment
4887 (in bytes) that you wish the compiler to use for a given variable or
4888 structure field.  Alternatively, you can leave out the alignment factor
4889 and just ask the compiler to align a variable or field to the
4890 default alignment for the target architecture you are compiling for.
4891 The default alignment is sufficient for all scalar types, but may not be
4892 enough for all vector types on a target that supports vector operations.
4893 The default alignment is fixed for a particular target ABI.
4895 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4896 which is the largest alignment ever used for any data type on the
4897 target machine you are compiling for.  For example, you could write:
4899 @smallexample
4900 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4901 @end smallexample
4903 The compiler automatically sets the alignment for the declared
4904 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
4905 often make copy operations more efficient, because the compiler can
4906 use whatever instructions copy the biggest chunks of memory when
4907 performing copies to or from the variables or fields that you have
4908 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
4909 may change depending on command-line options.
4911 When used on a struct, or struct member, the @code{aligned} attribute can
4912 only increase the alignment; in order to decrease it, the @code{packed}
4913 attribute must be specified as well.  When used as part of a typedef, the
4914 @code{aligned} attribute can both increase and decrease alignment, and
4915 specifying the @code{packed} attribute generates a warning.
4917 Note that the effectiveness of @code{aligned} attributes may be limited
4918 by inherent limitations in your linker.  On many systems, the linker is
4919 only able to arrange for variables to be aligned up to a certain maximum
4920 alignment.  (For some linkers, the maximum supported alignment may
4921 be very very small.)  If your linker is only able to align variables
4922 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
4923 in an @code{__attribute__} still only provides you with 8-byte
4924 alignment.  See your linker documentation for further information.
4926 The @code{aligned} attribute can also be used for functions
4927 (@pxref{Function Attributes}.)
4929 @item cleanup (@var{cleanup_function})
4930 @cindex @code{cleanup} attribute
4931 The @code{cleanup} attribute runs a function when the variable goes
4932 out of scope.  This attribute can only be applied to auto function
4933 scope variables; it may not be applied to parameters or variables
4934 with static storage duration.  The function must take one parameter,
4935 a pointer to a type compatible with the variable.  The return value
4936 of the function (if any) is ignored.
4938 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4939 is run during the stack unwinding that happens during the
4940 processing of the exception.  Note that the @code{cleanup} attribute
4941 does not allow the exception to be caught, only to perform an action.
4942 It is undefined what happens if @var{cleanup_function} does not
4943 return normally.
4945 @item common
4946 @itemx nocommon
4947 @cindex @code{common} attribute
4948 @cindex @code{nocommon} attribute
4949 @opindex fcommon
4950 @opindex fno-common
4951 The @code{common} attribute requests GCC to place a variable in
4952 ``common'' storage.  The @code{nocommon} attribute requests the
4953 opposite---to allocate space for it directly.
4955 These attributes override the default chosen by the
4956 @option{-fno-common} and @option{-fcommon} flags respectively.
4958 @item deprecated
4959 @itemx deprecated (@var{msg})
4960 @cindex @code{deprecated} attribute
4961 The @code{deprecated} attribute results in a warning if the variable
4962 is used anywhere in the source file.  This is useful when identifying
4963 variables that are expected to be removed in a future version of a
4964 program.  The warning also includes the location of the declaration
4965 of the deprecated variable, to enable users to easily find further
4966 information about why the variable is deprecated, or what they should
4967 do instead.  Note that the warning only occurs for uses:
4969 @smallexample
4970 extern int old_var __attribute__ ((deprecated));
4971 extern int old_var;
4972 int new_fn () @{ return old_var; @}
4973 @end smallexample
4975 @noindent
4976 results in a warning on line 3 but not line 2.  The optional @var{msg}
4977 argument, which must be a string, is printed in the warning if
4978 present.
4980 The @code{deprecated} attribute can also be used for functions and
4981 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4983 @item mode (@var{mode})
4984 @cindex @code{mode} attribute
4985 This attribute specifies the data type for the declaration---whichever
4986 type corresponds to the mode @var{mode}.  This in effect lets you
4987 request an integer or floating-point type according to its width.
4989 You may also specify a mode of @code{byte} or @code{__byte__} to
4990 indicate the mode corresponding to a one-byte integer, @code{word} or
4991 @code{__word__} for the mode of a one-word integer, and @code{pointer}
4992 or @code{__pointer__} for the mode used to represent pointers.
4994 @item packed
4995 @cindex @code{packed} attribute
4996 The @code{packed} attribute specifies that a variable or structure field
4997 should have the smallest possible alignment---one byte for a variable,
4998 and one bit for a field, unless you specify a larger value with the
4999 @code{aligned} attribute.
5001 Here is a structure in which the field @code{x} is packed, so that it
5002 immediately follows @code{a}:
5004 @smallexample
5005 struct foo
5007   char a;
5008   int x[2] __attribute__ ((packed));
5010 @end smallexample
5012 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5013 @code{packed} attribute on bit-fields of type @code{char}.  This has
5014 been fixed in GCC 4.4 but the change can lead to differences in the
5015 structure layout.  See the documentation of
5016 @option{-Wpacked-bitfield-compat} for more information.
5018 @item section ("@var{section-name}")
5019 @cindex @code{section} variable attribute
5020 Normally, the compiler places the objects it generates in sections like
5021 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5022 or you need certain particular variables to appear in special sections,
5023 for example to map to special hardware.  The @code{section}
5024 attribute specifies that a variable (or function) lives in a particular
5025 section.  For example, this small program uses several specific section names:
5027 @smallexample
5028 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5029 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5030 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5031 int init_data __attribute__ ((section ("INITDATA")));
5033 main()
5035   /* @r{Initialize stack pointer} */
5036   init_sp (stack + sizeof (stack));
5038   /* @r{Initialize initialized data} */
5039   memcpy (&init_data, &data, &edata - &data);
5041   /* @r{Turn on the serial ports} */
5042   init_duart (&a);
5043   init_duart (&b);
5045 @end smallexample
5047 @noindent
5048 Use the @code{section} attribute with
5049 @emph{global} variables and not @emph{local} variables,
5050 as shown in the example.
5052 You may use the @code{section} attribute with initialized or
5053 uninitialized global variables but the linker requires
5054 each object be defined once, with the exception that uninitialized
5055 variables tentatively go in the @code{common} (or @code{bss}) section
5056 and can be multiply ``defined''.  Using the @code{section} attribute
5057 changes what section the variable goes into and may cause the
5058 linker to issue an error if an uninitialized variable has multiple
5059 definitions.  You can force a variable to be initialized with the
5060 @option{-fno-common} flag or the @code{nocommon} attribute.
5062 Some file formats do not support arbitrary sections so the @code{section}
5063 attribute is not available on all platforms.
5064 If you need to map the entire contents of a module to a particular
5065 section, consider using the facilities of the linker instead.
5067 @item shared
5068 @cindex @code{shared} variable attribute
5069 On Microsoft Windows, in addition to putting variable definitions in a named
5070 section, the section can also be shared among all running copies of an
5071 executable or DLL@.  For example, this small program defines shared data
5072 by putting it in a named section @code{shared} and marking the section
5073 shareable:
5075 @smallexample
5076 int foo __attribute__((section ("shared"), shared)) = 0;
5079 main()
5081   /* @r{Read and write foo.  All running
5082      copies see the same value.}  */
5083   return 0;
5085 @end smallexample
5087 @noindent
5088 You may only use the @code{shared} attribute along with @code{section}
5089 attribute with a fully-initialized global definition because of the way
5090 linkers work.  See @code{section} attribute for more information.
5092 The @code{shared} attribute is only available on Microsoft Windows@.
5094 @item tls_model ("@var{tls_model}")
5095 @cindex @code{tls_model} attribute
5096 The @code{tls_model} attribute sets thread-local storage model
5097 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5098 overriding @option{-ftls-model=} command-line switch on a per-variable
5099 basis.
5100 The @var{tls_model} argument should be one of @code{global-dynamic},
5101 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5103 Not all targets support this attribute.
5105 @item unused
5106 This attribute, attached to a variable, means that the variable is meant
5107 to be possibly unused.  GCC does not produce a warning for this
5108 variable.
5110 @item used
5111 This attribute, attached to a variable with the static storage, means that
5112 the variable must be emitted even if it appears that the variable is not
5113 referenced.
5115 When applied to a static data member of a C++ class template, the
5116 attribute also means that the member is instantiated if the
5117 class itself is instantiated.
5119 @item vector_size (@var{bytes})
5120 This attribute specifies the vector size for the variable, measured in
5121 bytes.  For example, the declaration:
5123 @smallexample
5124 int foo __attribute__ ((vector_size (16)));
5125 @end smallexample
5127 @noindent
5128 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5129 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5130 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5132 This attribute is only applicable to integral and float scalars,
5133 although arrays, pointers, and function return values are allowed in
5134 conjunction with this construct.
5136 Aggregates with this attribute are invalid, even if they are of the same
5137 size as a corresponding scalar.  For example, the declaration:
5139 @smallexample
5140 struct S @{ int a; @};
5141 struct S  __attribute__ ((vector_size (16))) foo;
5142 @end smallexample
5144 @noindent
5145 is invalid even if the size of the structure is the same as the size of
5146 the @code{int}.
5148 @item selectany
5149 The @code{selectany} attribute causes an initialized global variable to
5150 have link-once semantics.  When multiple definitions of the variable are
5151 encountered by the linker, the first is selected and the remainder are
5152 discarded.  Following usage by the Microsoft compiler, the linker is told
5153 @emph{not} to warn about size or content differences of the multiple
5154 definitions.
5156 Although the primary usage of this attribute is for POD types, the
5157 attribute can also be applied to global C++ objects that are initialized
5158 by a constructor.  In this case, the static initialization and destruction
5159 code for the object is emitted in each translation defining the object,
5160 but the calls to the constructor and destructor are protected by a
5161 link-once guard variable.
5163 The @code{selectany} attribute is only available on Microsoft Windows
5164 targets.  You can use @code{__declspec (selectany)} as a synonym for
5165 @code{__attribute__ ((selectany))} for compatibility with other
5166 compilers.
5168 @item weak
5169 The @code{weak} attribute is described in @ref{Function Attributes}.
5171 @item dllimport
5172 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5174 @item dllexport
5175 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5177 @end table
5179 @anchor{AVR Variable Attributes}
5180 @subsection AVR Variable Attributes
5182 @table @code
5183 @item progmem
5184 @cindex @code{progmem} AVR variable attribute
5185 The @code{progmem} attribute is used on the AVR to place read-only
5186 data in the non-volatile program memory (flash). The @code{progmem}
5187 attribute accomplishes this by putting respective variables into a
5188 section whose name starts with @code{.progmem}.
5190 This attribute works similar to the @code{section} attribute
5191 but adds additional checking. Notice that just like the
5192 @code{section} attribute, @code{progmem} affects the location
5193 of the data but not how this data is accessed.
5195 In order to read data located with the @code{progmem} attribute
5196 (inline) assembler must be used.
5197 @smallexample
5198 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5199 #include <avr/pgmspace.h> 
5201 /* Locate var in flash memory */
5202 const int var[2] PROGMEM = @{ 1, 2 @};
5204 int read_var (int i)
5206     /* Access var[] by accessor macro from avr/pgmspace.h */
5207     return (int) pgm_read_word (& var[i]);
5209 @end smallexample
5211 AVR is a Harvard architecture processor and data and read-only data
5212 normally resides in the data memory (RAM).
5214 See also the @ref{AVR Named Address Spaces} section for
5215 an alternate way to locate and access data in flash memory.
5216 @end table
5218 @subsection Blackfin Variable Attributes
5220 Three attributes are currently defined for the Blackfin.
5222 @table @code
5223 @item l1_data
5224 @itemx l1_data_A
5225 @itemx l1_data_B
5226 @cindex @code{l1_data} variable attribute
5227 @cindex @code{l1_data_A} variable attribute
5228 @cindex @code{l1_data_B} variable attribute
5229 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5230 Variables with @code{l1_data} attribute are put into the specific section
5231 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5232 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5233 attribute are put into the specific section named @code{.l1.data.B}.
5235 @item l2
5236 @cindex @code{l2} variable attribute
5237 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5238 Variables with @code{l2} attribute are put into the specific section
5239 named @code{.l2.data}.
5240 @end table
5242 @subsection M32R/D Variable Attributes
5244 One attribute is currently defined for the M32R/D@.
5246 @table @code
5247 @item model (@var{model-name})
5248 @cindex variable addressability on the M32R/D
5249 Use this attribute on the M32R/D to set the addressability of an object.
5250 The identifier @var{model-name} is one of @code{small}, @code{medium},
5251 or @code{large}, representing each of the code models.
5253 Small model objects live in the lower 16MB of memory (so that their
5254 addresses can be loaded with the @code{ld24} instruction).
5256 Medium and large model objects may live anywhere in the 32-bit address space
5257 (the compiler generates @code{seth/add3} instructions to load their
5258 addresses).
5259 @end table
5261 @anchor{MeP Variable Attributes}
5262 @subsection MeP Variable Attributes
5264 The MeP target has a number of addressing modes and busses.  The
5265 @code{near} space spans the standard memory space's first 16 megabytes
5266 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5267 The @code{based} space is a 128-byte region in the memory space that
5268 is addressed relative to the @code{$tp} register.  The @code{tiny}
5269 space is a 65536-byte region relative to the @code{$gp} register.  In
5270 addition to these memory regions, the MeP target has a separate 16-bit
5271 control bus which is specified with @code{cb} attributes.
5273 @table @code
5275 @item based
5276 Any variable with the @code{based} attribute is assigned to the
5277 @code{.based} section, and is accessed with relative to the
5278 @code{$tp} register.
5280 @item tiny
5281 Likewise, the @code{tiny} attribute assigned variables to the
5282 @code{.tiny} section, relative to the @code{$gp} register.
5284 @item near
5285 Variables with the @code{near} attribute are assumed to have addresses
5286 that fit in a 24-bit addressing mode.  This is the default for large
5287 variables (@code{-mtiny=4} is the default) but this attribute can
5288 override @code{-mtiny=} for small variables, or override @code{-ml}.
5290 @item far
5291 Variables with the @code{far} attribute are addressed using a full
5292 32-bit address.  Since this covers the entire memory space, this
5293 allows modules to make no assumptions about where variables might be
5294 stored.
5296 @item io
5297 @itemx io (@var{addr})
5298 Variables with the @code{io} attribute are used to address
5299 memory-mapped peripherals.  If an address is specified, the variable
5300 is assigned that address, else it is not assigned an address (it is
5301 assumed some other module assigns an address).  Example:
5303 @smallexample
5304 int timer_count __attribute__((io(0x123)));
5305 @end smallexample
5307 @item cb
5308 @itemx cb (@var{addr})
5309 Variables with the @code{cb} attribute are used to access the control
5310 bus, using special instructions.  @code{addr} indicates the control bus
5311 address.  Example:
5313 @smallexample
5314 int cpu_clock __attribute__((cb(0x123)));
5315 @end smallexample
5317 @end table
5319 @anchor{i386 Variable Attributes}
5320 @subsection i386 Variable Attributes
5322 Two attributes are currently defined for i386 configurations:
5323 @code{ms_struct} and @code{gcc_struct}
5325 @table @code
5326 @item ms_struct
5327 @itemx gcc_struct
5328 @cindex @code{ms_struct} attribute
5329 @cindex @code{gcc_struct} attribute
5331 If @code{packed} is used on a structure, or if bit-fields are used,
5332 it may be that the Microsoft ABI lays out the structure differently
5333 than the way GCC normally does.  Particularly when moving packed
5334 data between functions compiled with GCC and the native Microsoft compiler
5335 (either via function call or as data in a file), it may be necessary to access
5336 either format.
5338 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5339 compilers to match the native Microsoft compiler.
5341 The Microsoft structure layout algorithm is fairly simple with the exception
5342 of the bit-field packing.  
5343 The padding and alignment of members of structures and whether a bit-field 
5344 can straddle a storage-unit boundary are determine by these rules:
5346 @enumerate
5347 @item Structure members are stored sequentially in the order in which they are
5348 declared: the first member has the lowest memory address and the last member
5349 the highest.
5351 @item Every data object has an alignment requirement.  The alignment requirement
5352 for all data except structures, unions, and arrays is either the size of the
5353 object or the current packing size (specified with either the
5354 @code{aligned} attribute or the @code{pack} pragma),
5355 whichever is less.  For structures, unions, and arrays,
5356 the alignment requirement is the largest alignment requirement of its members.
5357 Every object is allocated an offset so that:
5359 @smallexample
5360 offset % alignment_requirement == 0
5361 @end smallexample
5363 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5364 unit if the integral types are the same size and if the next bit-field fits
5365 into the current allocation unit without crossing the boundary imposed by the
5366 common alignment requirements of the bit-fields.
5367 @end enumerate
5369 MSVC interprets zero-length bit-fields in the following ways:
5371 @enumerate
5372 @item If a zero-length bit-field is inserted between two bit-fields that
5373 are normally coalesced, the bit-fields are not coalesced.
5375 For example:
5377 @smallexample
5378 struct
5379  @{
5380    unsigned long bf_1 : 12;
5381    unsigned long : 0;
5382    unsigned long bf_2 : 12;
5383  @} t1;
5384 @end smallexample
5386 @noindent
5387 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5388 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5390 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5391 alignment of the zero-length bit-field is greater than the member that follows it,
5392 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5394 For example:
5396 @smallexample
5397 struct
5398  @{
5399    char foo : 4;
5400    short : 0;
5401    char bar;
5402  @} t2;
5404 struct
5405  @{
5406    char foo : 4;
5407    short : 0;
5408    double bar;
5409  @} t3;
5410 @end smallexample
5412 @noindent
5413 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5414 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5415 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5416 of the structure.
5418 Taking this into account, it is important to note the following:
5420 @enumerate
5421 @item If a zero-length bit-field follows a normal bit-field, the type of the
5422 zero-length bit-field may affect the alignment of the structure as whole. For
5423 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5424 normal bit-field, and is of type short.
5426 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5427 still affect the alignment of the structure:
5429 @smallexample
5430 struct
5431  @{
5432    char foo : 6;
5433    long : 0;
5434  @} t4;
5435 @end smallexample
5437 @noindent
5438 Here, @code{t4} takes up 4 bytes.
5439 @end enumerate
5441 @item Zero-length bit-fields following non-bit-field members are ignored:
5443 @smallexample
5444 struct
5445  @{
5446    char foo;
5447    long : 0;
5448    char bar;
5449  @} t5;
5450 @end smallexample
5452 @noindent
5453 Here, @code{t5} takes up 2 bytes.
5454 @end enumerate
5455 @end table
5457 @subsection PowerPC Variable Attributes
5459 Three attributes currently are defined for PowerPC configurations:
5460 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5462 For full documentation of the struct attributes please see the
5463 documentation in @ref{i386 Variable Attributes}.
5465 For documentation of @code{altivec} attribute please see the
5466 documentation in @ref{PowerPC Type Attributes}.
5468 @subsection SPU Variable Attributes
5470 The SPU supports the @code{spu_vector} attribute for variables.  For
5471 documentation of this attribute please see the documentation in
5472 @ref{SPU Type Attributes}.
5474 @subsection Xstormy16 Variable Attributes
5476 One attribute is currently defined for xstormy16 configurations:
5477 @code{below100}.
5479 @table @code
5480 @item below100
5481 @cindex @code{below100} attribute
5483 If a variable has the @code{below100} attribute (@code{BELOW100} is
5484 allowed also), GCC places the variable in the first 0x100 bytes of
5485 memory and use special opcodes to access it.  Such variables are
5486 placed in either the @code{.bss_below100} section or the
5487 @code{.data_below100} section.
5489 @end table
5491 @node Type Attributes
5492 @section Specifying Attributes of Types
5493 @cindex attribute of types
5494 @cindex type attributes
5496 The keyword @code{__attribute__} allows you to specify special
5497 attributes of @code{struct} and @code{union} types when you define
5498 such types.  This keyword is followed by an attribute specification
5499 inside double parentheses.  Seven attributes are currently defined for
5500 types: @code{aligned}, @code{packed}, @code{transparent_union},
5501 @code{unused}, @code{deprecated}, @code{visibility}, and
5502 @code{may_alias}.  Other attributes are defined for functions
5503 (@pxref{Function Attributes}) and for variables (@pxref{Variable
5504 Attributes}).
5506 You may also specify any one of these attributes with @samp{__}
5507 preceding and following its keyword.  This allows you to use these
5508 attributes in header files without being concerned about a possible
5509 macro of the same name.  For example, you may use @code{__aligned__}
5510 instead of @code{aligned}.
5512 You may specify type attributes in an enum, struct or union type
5513 declaration or definition, or for other types in a @code{typedef}
5514 declaration.
5516 For an enum, struct or union type, you may specify attributes either
5517 between the enum, struct or union tag and the name of the type, or
5518 just past the closing curly brace of the @emph{definition}.  The
5519 former syntax is preferred.
5521 @xref{Attribute Syntax}, for details of the exact syntax for using
5522 attributes.
5524 @table @code
5525 @cindex @code{aligned} attribute
5526 @item aligned (@var{alignment})
5527 This attribute specifies a minimum alignment (in bytes) for variables
5528 of the specified type.  For example, the declarations:
5530 @smallexample
5531 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5532 typedef int more_aligned_int __attribute__ ((aligned (8)));
5533 @end smallexample
5535 @noindent
5536 force the compiler to ensure (as far as it can) that each variable whose
5537 type is @code{struct S} or @code{more_aligned_int} is allocated and
5538 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5539 variables of type @code{struct S} aligned to 8-byte boundaries allows
5540 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5541 store) instructions when copying one variable of type @code{struct S} to
5542 another, thus improving run-time efficiency.
5544 Note that the alignment of any given @code{struct} or @code{union} type
5545 is required by the ISO C standard to be at least a perfect multiple of
5546 the lowest common multiple of the alignments of all of the members of
5547 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5548 effectively adjust the alignment of a @code{struct} or @code{union}
5549 type by attaching an @code{aligned} attribute to any one of the members
5550 of such a type, but the notation illustrated in the example above is a
5551 more obvious, intuitive, and readable way to request the compiler to
5552 adjust the alignment of an entire @code{struct} or @code{union} type.
5554 As in the preceding example, you can explicitly specify the alignment
5555 (in bytes) that you wish the compiler to use for a given @code{struct}
5556 or @code{union} type.  Alternatively, you can leave out the alignment factor
5557 and just ask the compiler to align a type to the maximum
5558 useful alignment for the target machine you are compiling for.  For
5559 example, you could write:
5561 @smallexample
5562 struct S @{ short f[3]; @} __attribute__ ((aligned));
5563 @end smallexample
5565 Whenever you leave out the alignment factor in an @code{aligned}
5566 attribute specification, the compiler automatically sets the alignment
5567 for the type to the largest alignment that is ever used for any data
5568 type on the target machine you are compiling for.  Doing this can often
5569 make copy operations more efficient, because the compiler can use
5570 whatever instructions copy the biggest chunks of memory when performing
5571 copies to or from the variables that have types that you have aligned
5572 this way.
5574 In the example above, if the size of each @code{short} is 2 bytes, then
5575 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5576 power of two that is greater than or equal to that is 8, so the
5577 compiler sets the alignment for the entire @code{struct S} type to 8
5578 bytes.
5580 Note that although you can ask the compiler to select a time-efficient
5581 alignment for a given type and then declare only individual stand-alone
5582 objects of that type, the compiler's ability to select a time-efficient
5583 alignment is primarily useful only when you plan to create arrays of
5584 variables having the relevant (efficiently aligned) type.  If you
5585 declare or use arrays of variables of an efficiently-aligned type, then
5586 it is likely that your program also does pointer arithmetic (or
5587 subscripting, which amounts to the same thing) on pointers to the
5588 relevant type, and the code that the compiler generates for these
5589 pointer arithmetic operations is often more efficient for
5590 efficiently-aligned types than for other types.
5592 The @code{aligned} attribute can only increase the alignment; but you
5593 can decrease it by specifying @code{packed} as well.  See below.
5595 Note that the effectiveness of @code{aligned} attributes may be limited
5596 by inherent limitations in your linker.  On many systems, the linker is
5597 only able to arrange for variables to be aligned up to a certain maximum
5598 alignment.  (For some linkers, the maximum supported alignment may
5599 be very very small.)  If your linker is only able to align variables
5600 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5601 in an @code{__attribute__} still only provides you with 8-byte
5602 alignment.  See your linker documentation for further information.
5604 @item packed
5605 This attribute, attached to @code{struct} or @code{union} type
5606 definition, specifies that each member (other than zero-width bit-fields)
5607 of the structure or union is placed to minimize the memory required.  When
5608 attached to an @code{enum} definition, it indicates that the smallest
5609 integral type should be used.
5611 @opindex fshort-enums
5612 Specifying this attribute for @code{struct} and @code{union} types is
5613 equivalent to specifying the @code{packed} attribute on each of the
5614 structure or union members.  Specifying the @option{-fshort-enums}
5615 flag on the line is equivalent to specifying the @code{packed}
5616 attribute on all @code{enum} definitions.
5618 In the following example @code{struct my_packed_struct}'s members are
5619 packed closely together, but the internal layout of its @code{s} member
5620 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5621 be packed too.
5623 @smallexample
5624 struct my_unpacked_struct
5625  @{
5626     char c;
5627     int i;
5628  @};
5630 struct __attribute__ ((__packed__)) my_packed_struct
5631   @{
5632      char c;
5633      int  i;
5634      struct my_unpacked_struct s;
5635   @};
5636 @end smallexample
5638 You may only specify this attribute on the definition of an @code{enum},
5639 @code{struct} or @code{union}, not on a @code{typedef} that does not
5640 also define the enumerated type, structure or union.
5642 @item transparent_union
5643 This attribute, attached to a @code{union} type definition, indicates
5644 that any function parameter having that union type causes calls to that
5645 function to be treated in a special way.
5647 First, the argument corresponding to a transparent union type can be of
5648 any type in the union; no cast is required.  Also, if the union contains
5649 a pointer type, the corresponding argument can be a null pointer
5650 constant or a void pointer expression; and if the union contains a void
5651 pointer type, the corresponding argument can be any pointer expression.
5652 If the union member type is a pointer, qualifiers like @code{const} on
5653 the referenced type must be respected, just as with normal pointer
5654 conversions.
5656 Second, the argument is passed to the function using the calling
5657 conventions of the first member of the transparent union, not the calling
5658 conventions of the union itself.  All members of the union must have the
5659 same machine representation; this is necessary for this argument passing
5660 to work properly.
5662 Transparent unions are designed for library functions that have multiple
5663 interfaces for compatibility reasons.  For example, suppose the
5664 @code{wait} function must accept either a value of type @code{int *} to
5665 comply with POSIX, or a value of type @code{union wait *} to comply with
5666 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5667 @code{wait} would accept both kinds of arguments, but it would also
5668 accept any other pointer type and this would make argument type checking
5669 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5670 as follows:
5672 @smallexample
5673 typedef union __attribute__ ((__transparent_union__))
5674   @{
5675     int *__ip;
5676     union wait *__up;
5677   @} wait_status_ptr_t;
5679 pid_t wait (wait_status_ptr_t);
5680 @end smallexample
5682 @noindent
5683 This interface allows either @code{int *} or @code{union wait *}
5684 arguments to be passed, using the @code{int *} calling convention.
5685 The program can call @code{wait} with arguments of either type:
5687 @smallexample
5688 int w1 () @{ int w; return wait (&w); @}
5689 int w2 () @{ union wait w; return wait (&w); @}
5690 @end smallexample
5692 @noindent
5693 With this interface, @code{wait}'s implementation might look like this:
5695 @smallexample
5696 pid_t wait (wait_status_ptr_t p)
5698   return waitpid (-1, p.__ip, 0);
5700 @end smallexample
5702 @item unused
5703 When attached to a type (including a @code{union} or a @code{struct}),
5704 this attribute means that variables of that type are meant to appear
5705 possibly unused.  GCC does not produce a warning for any variables of
5706 that type, even if the variable appears to do nothing.  This is often
5707 the case with lock or thread classes, which are usually defined and then
5708 not referenced, but contain constructors and destructors that have
5709 nontrivial bookkeeping functions.
5711 @item deprecated
5712 @itemx deprecated (@var{msg})
5713 The @code{deprecated} attribute results in a warning if the type
5714 is used anywhere in the source file.  This is useful when identifying
5715 types that are expected to be removed in a future version of a program.
5716 If possible, the warning also includes the location of the declaration
5717 of the deprecated type, to enable users to easily find further
5718 information about why the type is deprecated, or what they should do
5719 instead.  Note that the warnings only occur for uses and then only
5720 if the type is being applied to an identifier that itself is not being
5721 declared as deprecated.
5723 @smallexample
5724 typedef int T1 __attribute__ ((deprecated));
5725 T1 x;
5726 typedef T1 T2;
5727 T2 y;
5728 typedef T1 T3 __attribute__ ((deprecated));
5729 T3 z __attribute__ ((deprecated));
5730 @end smallexample
5732 @noindent
5733 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5734 warning is issued for line 4 because T2 is not explicitly
5735 deprecated.  Line 5 has no warning because T3 is explicitly
5736 deprecated.  Similarly for line 6.  The optional @var{msg}
5737 argument, which must be a string, is printed in the warning if
5738 present.
5740 The @code{deprecated} attribute can also be used for functions and
5741 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5743 @item may_alias
5744 Accesses through pointers to types with this attribute are not subject
5745 to type-based alias analysis, but are instead assumed to be able to alias
5746 any other type of objects.
5747 In the context of section 6.5 paragraph 7 of the C99 standard,
5748 an lvalue expression
5749 dereferencing such a pointer is treated like having a character type.
5750 See @option{-fstrict-aliasing} for more information on aliasing issues.
5751 This extension exists to support some vector APIs, in which pointers to
5752 one vector type are permitted to alias pointers to a different vector type.
5754 Note that an object of a type with this attribute does not have any
5755 special semantics.
5757 Example of use:
5759 @smallexample
5760 typedef short __attribute__((__may_alias__)) short_a;
5763 main (void)
5765   int a = 0x12345678;
5766   short_a *b = (short_a *) &a;
5768   b[1] = 0;
5770   if (a == 0x12345678)
5771     abort();
5773   exit(0);
5775 @end smallexample
5777 @noindent
5778 If you replaced @code{short_a} with @code{short} in the variable
5779 declaration, the above program would abort when compiled with
5780 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5781 above in recent GCC versions.
5783 @item visibility
5784 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5785 applied to class, struct, union and enum types.  Unlike other type
5786 attributes, the attribute must appear between the initial keyword and
5787 the name of the type; it cannot appear after the body of the type.
5789 Note that the type visibility is applied to vague linkage entities
5790 associated with the class (vtable, typeinfo node, etc.).  In
5791 particular, if a class is thrown as an exception in one shared object
5792 and caught in another, the class must have default visibility.
5793 Otherwise the two shared objects are unable to use the same
5794 typeinfo node and exception handling will break.
5796 @end table
5798 To specify multiple attributes, separate them by commas within the
5799 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5800 packed))}.
5802 @subsection ARM Type Attributes
5804 On those ARM targets that support @code{dllimport} (such as Symbian
5805 OS), you can use the @code{notshared} attribute to indicate that the
5806 virtual table and other similar data for a class should not be
5807 exported from a DLL@.  For example:
5809 @smallexample
5810 class __declspec(notshared) C @{
5811 public:
5812   __declspec(dllimport) C();
5813   virtual void f();
5816 __declspec(dllexport)
5817 C::C() @{@}
5818 @end smallexample
5820 @noindent
5821 In this code, @code{C::C} is exported from the current DLL, but the
5822 virtual table for @code{C} is not exported.  (You can use
5823 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5824 most Symbian OS code uses @code{__declspec}.)
5826 @anchor{MeP Type Attributes}
5827 @subsection MeP Type Attributes
5829 Many of the MeP variable attributes may be applied to types as well.
5830 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5831 @code{far} attributes may be applied to either.  The @code{io} and
5832 @code{cb} attributes may not be applied to types.
5834 @anchor{i386 Type Attributes}
5835 @subsection i386 Type Attributes
5837 Two attributes are currently defined for i386 configurations:
5838 @code{ms_struct} and @code{gcc_struct}.
5840 @table @code
5842 @item ms_struct
5843 @itemx gcc_struct
5844 @cindex @code{ms_struct}
5845 @cindex @code{gcc_struct}
5847 If @code{packed} is used on a structure, or if bit-fields are used
5848 it may be that the Microsoft ABI packs them differently
5849 than GCC normally packs them.  Particularly when moving packed
5850 data between functions compiled with GCC and the native Microsoft compiler
5851 (either via function call or as data in a file), it may be necessary to access
5852 either format.
5854 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5855 compilers to match the native Microsoft compiler.
5856 @end table
5858 @anchor{PowerPC Type Attributes}
5859 @subsection PowerPC Type Attributes
5861 Three attributes currently are defined for PowerPC configurations:
5862 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5864 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5865 attributes please see the documentation in @ref{i386 Type Attributes}.
5867 The @code{altivec} attribute allows one to declare AltiVec vector data
5868 types supported by the AltiVec Programming Interface Manual.  The
5869 attribute requires an argument to specify one of three vector types:
5870 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5871 and @code{bool__} (always followed by unsigned).
5873 @smallexample
5874 __attribute__((altivec(vector__)))
5875 __attribute__((altivec(pixel__))) unsigned short
5876 __attribute__((altivec(bool__))) unsigned
5877 @end smallexample
5879 These attributes mainly are intended to support the @code{__vector},
5880 @code{__pixel}, and @code{__bool} AltiVec keywords.
5882 @anchor{SPU Type Attributes}
5883 @subsection SPU Type Attributes
5885 The SPU supports the @code{spu_vector} attribute for types.  This attribute
5886 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5887 Language Extensions Specification.  It is intended to support the
5888 @code{__vector} keyword.
5890 @node Alignment
5891 @section Inquiring on Alignment of Types or Variables
5892 @cindex alignment
5893 @cindex type alignment
5894 @cindex variable alignment
5896 The keyword @code{__alignof__} allows you to inquire about how an object
5897 is aligned, or the minimum alignment usually required by a type.  Its
5898 syntax is just like @code{sizeof}.
5900 For example, if the target machine requires a @code{double} value to be
5901 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5902 This is true on many RISC machines.  On more traditional machine
5903 designs, @code{__alignof__ (double)} is 4 or even 2.
5905 Some machines never actually require alignment; they allow reference to any
5906 data type even at an odd address.  For these machines, @code{__alignof__}
5907 reports the smallest alignment that GCC gives the data type, usually as
5908 mandated by the target ABI.
5910 If the operand of @code{__alignof__} is an lvalue rather than a type,
5911 its value is the required alignment for its type, taking into account
5912 any minimum alignment specified with GCC's @code{__attribute__}
5913 extension (@pxref{Variable Attributes}).  For example, after this
5914 declaration:
5916 @smallexample
5917 struct foo @{ int x; char y; @} foo1;
5918 @end smallexample
5920 @noindent
5921 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
5922 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
5924 It is an error to ask for the alignment of an incomplete type.
5927 @node Inline
5928 @section An Inline Function is As Fast As a Macro
5929 @cindex inline functions
5930 @cindex integrating function code
5931 @cindex open coding
5932 @cindex macros, inline alternative
5934 By declaring a function inline, you can direct GCC to make
5935 calls to that function faster.  One way GCC can achieve this is to
5936 integrate that function's code into the code for its callers.  This
5937 makes execution faster by eliminating the function-call overhead; in
5938 addition, if any of the actual argument values are constant, their
5939 known values may permit simplifications at compile time so that not
5940 all of the inline function's code needs to be included.  The effect on
5941 code size is less predictable; object code may be larger or smaller
5942 with function inlining, depending on the particular case.  You can
5943 also direct GCC to try to integrate all ``simple enough'' functions
5944 into their callers with the option @option{-finline-functions}.
5946 GCC implements three different semantics of declaring a function
5947 inline.  One is available with @option{-std=gnu89} or
5948 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
5949 on all inline declarations, another when
5950 @option{-std=c99}, @option{-std=c11},
5951 @option{-std=gnu99} or @option{-std=gnu11}
5952 (without @option{-fgnu89-inline}), and the third
5953 is used when compiling C++.
5955 To declare a function inline, use the @code{inline} keyword in its
5956 declaration, like this:
5958 @smallexample
5959 static inline int
5960 inc (int *a)
5962   return (*a)++;
5964 @end smallexample
5966 If you are writing a header file to be included in ISO C90 programs, write
5967 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
5969 The three types of inlining behave similarly in two important cases:
5970 when the @code{inline} keyword is used on a @code{static} function,
5971 like the example above, and when a function is first declared without
5972 using the @code{inline} keyword and then is defined with
5973 @code{inline}, like this:
5975 @smallexample
5976 extern int inc (int *a);
5977 inline int
5978 inc (int *a)
5980   return (*a)++;
5982 @end smallexample
5984 In both of these common cases, the program behaves the same as if you
5985 had not used the @code{inline} keyword, except for its speed.
5987 @cindex inline functions, omission of
5988 @opindex fkeep-inline-functions
5989 When a function is both inline and @code{static}, if all calls to the
5990 function are integrated into the caller, and the function's address is
5991 never used, then the function's own assembler code is never referenced.
5992 In this case, GCC does not actually output assembler code for the
5993 function, unless you specify the option @option{-fkeep-inline-functions}.
5994 Some calls cannot be integrated for various reasons (in particular,
5995 calls that precede the function's definition cannot be integrated, and
5996 neither can recursive calls within the definition).  If there is a
5997 nonintegrated call, then the function is compiled to assembler code as
5998 usual.  The function must also be compiled as usual if the program
5999 refers to its address, because that can't be inlined.
6001 @opindex Winline
6002 Note that certain usages in a function definition can make it unsuitable
6003 for inline substitution.  Among these usages are: variadic functions, use of
6004 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6005 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6006 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6007 warns when a function marked @code{inline} could not be substituted,
6008 and gives the reason for the failure.
6010 @cindex automatic @code{inline} for C++ member fns
6011 @cindex @code{inline} automatic for C++ member fns
6012 @cindex member fns, automatically @code{inline}
6013 @cindex C++ member fns, automatically @code{inline}
6014 @opindex fno-default-inline
6015 As required by ISO C++, GCC considers member functions defined within
6016 the body of a class to be marked inline even if they are
6017 not explicitly declared with the @code{inline} keyword.  You can
6018 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6019 Options,,Options Controlling C++ Dialect}.
6021 GCC does not inline any functions when not optimizing unless you specify
6022 the @samp{always_inline} attribute for the function, like this:
6024 @smallexample
6025 /* @r{Prototype.}  */
6026 inline void foo (const char) __attribute__((always_inline));
6027 @end smallexample
6029 The remainder of this section is specific to GNU C90 inlining.
6031 @cindex non-static inline function
6032 When an inline function is not @code{static}, then the compiler must assume
6033 that there may be calls from other source files; since a global symbol can
6034 be defined only once in any program, the function must not be defined in
6035 the other source files, so the calls therein cannot be integrated.
6036 Therefore, a non-@code{static} inline function is always compiled on its
6037 own in the usual fashion.
6039 If you specify both @code{inline} and @code{extern} in the function
6040 definition, then the definition is used only for inlining.  In no case
6041 is the function compiled on its own, not even if you refer to its
6042 address explicitly.  Such an address becomes an external reference, as
6043 if you had only declared the function, and had not defined it.
6045 This combination of @code{inline} and @code{extern} has almost the
6046 effect of a macro.  The way to use it is to put a function definition in
6047 a header file with these keywords, and put another copy of the
6048 definition (lacking @code{inline} and @code{extern}) in a library file.
6049 The definition in the header file causes most calls to the function
6050 to be inlined.  If any uses of the function remain, they refer to
6051 the single copy in the library.
6053 @node Volatiles
6054 @section When is a Volatile Object Accessed?
6055 @cindex accessing volatiles
6056 @cindex volatile read
6057 @cindex volatile write
6058 @cindex volatile access
6060 C has the concept of volatile objects.  These are normally accessed by
6061 pointers and used for accessing hardware or inter-thread
6062 communication.  The standard encourages compilers to refrain from
6063 optimizations concerning accesses to volatile objects, but leaves it
6064 implementation defined as to what constitutes a volatile access.  The
6065 minimum requirement is that at a sequence point all previous accesses
6066 to volatile objects have stabilized and no subsequent accesses have
6067 occurred.  Thus an implementation is free to reorder and combine
6068 volatile accesses that occur between sequence points, but cannot do
6069 so for accesses across a sequence point.  The use of volatile does
6070 not allow you to violate the restriction on updating objects multiple
6071 times between two sequence points.
6073 Accesses to non-volatile objects are not ordered with respect to
6074 volatile accesses.  You cannot use a volatile object as a memory
6075 barrier to order a sequence of writes to non-volatile memory.  For
6076 instance:
6078 @smallexample
6079 int *ptr = @var{something};
6080 volatile int vobj;
6081 *ptr = @var{something};
6082 vobj = 1;
6083 @end smallexample
6085 @noindent
6086 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6087 that the write to @var{*ptr} occurs by the time the update
6088 of @var{vobj} happens.  If you need this guarantee, you must use
6089 a stronger memory barrier such as:
6091 @smallexample
6092 int *ptr = @var{something};
6093 volatile int vobj;
6094 *ptr = @var{something};
6095 asm volatile ("" : : : "memory");
6096 vobj = 1;
6097 @end smallexample
6099 A scalar volatile object is read when it is accessed in a void context:
6101 @smallexample
6102 volatile int *src = @var{somevalue};
6103 *src;
6104 @end smallexample
6106 Such expressions are rvalues, and GCC implements this as a
6107 read of the volatile object being pointed to.
6109 Assignments are also expressions and have an rvalue.  However when
6110 assigning to a scalar volatile, the volatile object is not reread,
6111 regardless of whether the assignment expression's rvalue is used or
6112 not.  If the assignment's rvalue is used, the value is that assigned
6113 to the volatile object.  For instance, there is no read of @var{vobj}
6114 in all the following cases:
6116 @smallexample
6117 int obj;
6118 volatile int vobj;
6119 vobj = @var{something};
6120 obj = vobj = @var{something};
6121 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6122 obj = (@var{something}, vobj = @var{anotherthing});
6123 @end smallexample
6125 If you need to read the volatile object after an assignment has
6126 occurred, you must use a separate expression with an intervening
6127 sequence point.
6129 As bit-fields are not individually addressable, volatile bit-fields may
6130 be implicitly read when written to, or when adjacent bit-fields are
6131 accessed.  Bit-field operations may be optimized such that adjacent
6132 bit-fields are only partially accessed, if they straddle a storage unit
6133 boundary.  For these reasons it is unwise to use volatile bit-fields to
6134 access hardware.
6136 @node Using Assembly Language with C
6137 @section How to Use Inline Assembly Language in C Code
6139 GCC provides various extensions that allow you to embed assembler within 
6140 C code.
6142 @menu
6143 * Basic Asm::          Inline assembler with no operands.
6144 * Extended Asm::       Inline assembler with operands.
6145 * Constraints::        Constraints for @code{asm} operands
6146 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6147 * Explicit Reg Vars::  Defining variables residing in specified registers.
6148 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6149 @end menu
6151 @node Basic Asm
6152 @subsection Basic Asm --- Assembler Instructions with No Operands
6153 @cindex basic @code{asm}
6155 The @code{asm} keyword allows you to embed assembler instructions within 
6156 C code.
6158 @example
6159 asm [ volatile ] ( AssemblerInstructions )
6160 @end example
6162 To create headers compatible with ISO C, write @code{__asm__} instead of 
6163 @code{asm} (@pxref{Alternate Keywords}).
6165 By definition, a Basic @code{asm} statement is one with no operands. 
6166 @code{asm} statements that contain one or more colons (used to delineate 
6167 operands) are considered to be Extended (for example, @code{asm("int $3")} 
6168 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6170 @subsubheading Qualifiers
6171 @emph{volatile}
6173 This optional qualifier has no effect. All Basic @code{asm} blocks are 
6174 implicitly volatile.
6176 @subsubheading Parameters
6177 @emph{AssemblerInstructions}
6179 This is a literal string that specifies the assembler code. The string can 
6180 contain any instructions recognized by the assembler, including directives. 
6181 GCC does not parse the assembler instructions themselves and 
6182 does not know what they mean or even whether they are valid assembler input. 
6183 The compiler copies it verbatim to the assembly language output file, without 
6184 processing dialects or any of the "%" operators that are available with
6185 Extended @code{asm}. This results in minor differences between Basic 
6186 @code{asm} strings and Extended @code{asm} templates. For example, to refer to 
6187 registers you might use %%eax in Extended @code{asm} and %eax in Basic 
6188 @code{asm}.
6190 You may place multiple assembler instructions together in a single @code{asm} 
6191 string, separated by the characters normally used in assembly code for the 
6192 system. A combination that works in most places is a newline to break the 
6193 line, plus a tab character (written as "\n\t").
6194 Some assemblers allow semicolons as a line separator. However, 
6195 note that some assembler dialects use semicolons to start a comment. 
6197 Do not expect a sequence of @code{asm} statements to remain perfectly 
6198 consecutive after compilation. If certain instructions need to remain 
6199 consecutive in the output, put them in a single multi-instruction asm 
6200 statement. Note that GCC's optimizers can move @code{asm} statements 
6201 relative to other code, including across jumps.
6203 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6204 GCC does not know about these jumps, and therefore cannot take 
6205 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6206 labels are only supported in Extended @code{asm}.
6208 @subsubheading Remarks
6209 Using Extended @code{asm} will typically produce smaller, safer, and more 
6210 efficient code, and in most cases it is a better solution. When writing 
6211 inline assembly language outside of C functions, however, you must use Basic 
6212 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6214 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6215 assembly code when optimizing. This can lead to unexpected duplicate 
6216 symbol errors during compilation if your assembly code defines symbols or 
6217 labels.
6219 Safely accessing C data and calling functions from Basic @code{asm} is more 
6220 complex than it may appear. To access C data, it is better to use Extended 
6221 @code{asm}.
6223 Since GCC does not parse the AssemblerInstructions, it has no 
6224 visibility of any symbols it references. This may result in GCC discarding 
6225 those symbols as unreferenced.
6227 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly 
6228 volatile. @xref{Volatile}.  Similarly, Basic @code{asm} blocks are not treated 
6229 as though they used a "memory" clobber (@pxref{Clobbers}).
6231 All Basic @code{asm} blocks use the assembler dialect specified by the 
6232 @option{-masm} command-line option. Basic @code{asm} provides no
6233 mechanism to provide different assembler strings for different dialects.
6235 Here is an example of Basic @code{asm} for i386:
6237 @example
6238 /* Note that this code will not compile with -masm=intel */
6239 #define DebugBreak() asm("int $3")
6240 @end example
6242 @node Extended Asm
6243 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6244 @cindex @code{asm} keyword
6245 @cindex extended @code{asm}
6246 @cindex assembler instructions
6248 The @code{asm} keyword allows you to embed assembler instructions within C 
6249 code. With Extended @code{asm} you can read and write C variables from 
6250 assembler and perform jumps from assembler code to C labels.
6252 @example
6253 @ifhtml
6254 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6256 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6257 @end ifhtml
6258 @ifnothtml
6259 asm [volatile] ( AssemblerTemplate 
6260                  : [OutputOperands] 
6261                  [ : [InputOperands] 
6262                  [ : [Clobbers] ] ])
6264 asm [volatile] goto ( AssemblerTemplate 
6265                       : 
6266                       : [InputOperands] 
6267                       : [Clobbers] 
6268                       : GotoLabels)
6269 @end ifnothtml
6270 @end example
6272 To create headers compatible with ISO C, write @code{__asm__} instead of 
6273 @code{asm} and @code{__volatile__} instead of @code{volatile} 
6274 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6276 By definition, Extended @code{asm} is an @code{asm} statement that contains 
6277 operands. To separate the classes of operands, you use colons. Basic 
6278 @code{asm} statements contain no colons. (So, for example, 
6279 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is 
6280 Extended @code{asm}. @pxref{Basic Asm}.)
6282 @subsubheading Qualifiers
6283 @emph{volatile}
6285 The typical use of Extended @code{asm} statements is to manipulate input 
6286 values to produce output values. However, your @code{asm} statements may 
6287 also produce side effects. If so, you may need to use the @code{volatile} 
6288 qualifier to disable certain optimizations. @xref{Volatile}.
6290 @emph{goto}
6292 This qualifier informs the compiler that the @code{asm} statement may 
6293 perform a jump to one of the labels listed in the GotoLabels section. 
6294 @xref{GotoLabels}.
6296 @subsubheading Parameters
6297 @emph{AssemblerTemplate}
6299 This is a literal string that contains the assembler code. It is a 
6300 combination of fixed text and tokens that refer to the input, output, 
6301 and goto parameters. @xref{AssemblerTemplate}.
6303 @emph{OutputOperands}
6305 A comma-separated list of the C variables modified by the instructions in the 
6306 AssemblerTemplate. @xref{OutputOperands}.
6308 @emph{InputOperands}
6310 A comma-separated list of C expressions read by the instructions in the 
6311 AssemblerTemplate. @xref{InputOperands}.
6313 @emph{Clobbers}
6315 A comma-separated list of registers or other values changed by the 
6316 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6318 @emph{GotoLabels}
6320 When you are using the @code{goto} form of @code{asm}, this section contains 
6321 the list of all C labels to which the AssemblerTemplate may jump. 
6322 @xref{GotoLabels}.
6324 @subsubheading Remarks
6325 The @code{asm} statement allows you to include assembly instructions directly 
6326 within C code. This may help you to maximize performance in time-sensitive 
6327 code or to access assembly instructions that are not readily available to C 
6328 programs.
6330 Note that Extended @code{asm} statements must be inside a function. Only 
6331 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6333 While the uses of @code{asm} are many and varied, it may help to think of an 
6334 @code{asm} statement as a series of low-level instructions that convert input 
6335 parameters to output parameters. So a simple (if not particularly useful) 
6336 example for i386 using @code{asm} might look like this:
6338 @example
6339 int src = 1;
6340 int dst;   
6342 asm ("mov %1, %0\n\t"
6343     "add $1, %0"
6344     : "=r" (dst) 
6345     : "r" (src));
6347 printf("%d\n", dst);
6348 @end example
6350 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6352 @anchor{Volatile}
6353 @subsubsection Volatile
6354 @cindex volatile @code{asm}
6355 @cindex @code{asm} volatile
6357 GCC's optimizers sometimes discard @code{asm} statements if they determine 
6358 there is no need for the output variables. Also, the optimizers may move 
6359 code out of loops if they believe that the code will always return the same 
6360 result (i.e. none of its input values change between calls). Using the 
6361 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
6362 that have no output operands are implicitly volatile.
6364 Examples:
6366 This i386 code demonstrates a case that does not use (or require) the 
6367 @code{volatile} qualifier. If it is performing assertion checking, this code 
6368 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is 
6369 unreferenced by any code. As a result, the optimizers can discard the 
6370 @code{asm} statement, which in turn removes the need for the entire 
6371 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
6372 isn't needed you allow the optimizers to produce the most efficient code 
6373 possible.
6375 @example
6376 void DoCheck(uint32_t dwSomeValue)
6378    uint32_t dwRes;
6380    // Assumes dwSomeValue is not zero.
6381    asm ("bsfl %1,%0"
6382      : "=r" (dwRes)
6383      : "r" (dwSomeValue)
6384      : "cc");
6386    assert(dwRes > 3);
6388 @end example
6390 The next example shows a case where the optimizers can recognize that the input 
6391 (@var{dwSomeValue}) never changes during the execution of the function and can 
6392 therefore move the @code{asm} outside the loop to produce more efficient code. 
6393 Again, using @code{volatile} disables this type of optimization.
6395 @example
6396 void do_print(uint32_t dwSomeValue)
6398    uint32_t dwRes;
6400    for (uint32_t x=0; x < 5; x++)
6401    @{
6402       // Assumes dwSomeValue is not zero.
6403       asm ("bsfl %1,%0"
6404         : "=r" (dwRes)
6405         : "r" (dwSomeValue)
6406         : "cc");
6408       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6409    @}
6411 @end example
6413 The following example demonstrates a case where you need to use the 
6414 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads 
6415 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
6416 the optimizers might assume that the @code{asm} block will always return the 
6417 same value and therefore optimize away the second call.
6419 @example
6420 uint64_t msr;
6422 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6423         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6424         "or %%rdx, %0"        // 'Or' in the lower bits.
6425         : "=a" (msr)
6426         : 
6427         : "rdx");
6429 printf("msr: %llx\n", msr);
6431 // Do other work...
6433 // Reprint the timestamp
6434 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6435         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6436         "or %%rdx, %0"        // 'Or' in the lower bits.
6437         : "=a" (msr)
6438         : 
6439         : "rdx");
6441 printf("msr: %llx\n", msr);
6442 @end example
6444 GCC's optimizers will not treat this code like the non-volatile code in the 
6445 earlier examples. They do not move it out of loops or omit it on the 
6446 assumption that the result from a previous call is still valid.
6448 Note that the compiler can move even volatile @code{asm} instructions relative 
6449 to other code, including across jump instructions. For example, on many 
6450 targets there is a system register that controls the rounding mode of 
6451 floating-point operations. Setting it with a volatile @code{asm}, as in the 
6452 following PowerPC example, will not work reliably.
6454 @example
6455 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6456 sum = x + y;
6457 @end example
6459 The compiler may move the addition back before the volatile @code{asm}. To 
6460 make it work as expected, add an artificial dependency to the @code{asm} by 
6461 referencing a variable in the subsequent code, for example: 
6463 @example
6464 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6465 sum = x + y;
6466 @end example
6468 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6469 assembly code when optimizing. This can lead to unexpected duplicate symbol 
6470 errors during compilation if your asm code defines symbols or labels. Using %= 
6471 (@pxref{AssemblerTemplate}) may help resolve this problem.
6473 @anchor{AssemblerTemplate}
6474 @subsubsection Assembler Template
6475 @cindex @code{asm} assembler template
6477 An assembler template is a literal string containing assembler instructions. 
6478 The compiler will replace any references to inputs, outputs, and goto labels 
6479 in the template, and then output the resulting string to the assembler. The 
6480 string can contain any instructions recognized by the assembler, including 
6481 directives. GCC does not parse the assembler instructions 
6482 themselves and does not know what they mean or even whether they are valid 
6483 assembler input. However, it does count the statements 
6484 (@pxref{Size of an asm}).
6486 You may place multiple assembler instructions together in a single @code{asm} 
6487 string, separated by the characters normally used in assembly code for the 
6488 system. A combination that works in most places is a newline to break the 
6489 line, plus a tab character to move to the instruction field (written as 
6490 "\n\t"). Some assemblers allow semicolons as a line separator. However, note 
6491 that some assembler dialects use semicolons to start a comment. 
6493 Do not expect a sequence of @code{asm} statements to remain perfectly 
6494 consecutive after compilation, even when you are using the @code{volatile} 
6495 qualifier. If certain instructions need to remain consecutive in the output, 
6496 put them in a single multi-instruction asm statement.
6498 Accessing data from C programs without using input/output operands (such as 
6499 by using global symbols directly from the assembler template) may not work as 
6500 expected. Similarly, calling functions directly from an assembler template 
6501 requires a detailed understanding of the target assembler and ABI.
6503 Since GCC does not parse the AssemblerTemplate, it has no visibility of any 
6504 symbols it references. This may result in GCC discarding those symbols as 
6505 unreferenced unless they are also listed as input, output, or goto operands.
6507 GCC can support multiple assembler dialects (for example, GCC for i386 
6508 supports "att" and "intel" dialects) for inline assembler. In builds that 
6509 support this capability, the @option{-masm} option controls which dialect 
6510 GCC uses as its default. The hardware-specific documentation for the 
6511 @option{-masm} option contains the list of supported dialects, as well as the 
6512 default dialect if the option is not specified. This information may be 
6513 important to understand, since assembler code that works correctly when 
6514 compiled using one dialect will likely fail if compiled using another.
6516 @subsubheading Using braces in @code{asm} templates
6518 If your code needs to support multiple assembler dialects (for example, if 
6519 you are writing public headers that need to support a variety of compilation 
6520 options), use constructs of this form:
6522 @example
6523 @{ dialect0 | dialect1 | dialect2... @}
6524 @end example
6526 This construct outputs 'dialect0' when using dialect #0 to compile the code, 
6527 'dialect1' for dialect #1, etc. If there are fewer alternatives within the 
6528 braces than the number of dialects the compiler supports, the construct 
6529 outputs nothing.
6531 For example, if an i386 compiler supports two dialects (att, intel), an 
6532 assembler template such as this:
6534 @example
6535 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6536 @end example
6538 would produce the output:
6540 @example
6541 For att: "btl %[Offset],%[Base] ; jc %l2"
6542 For intel: "bt %[Base],%[Offset]; jc %l2"
6543 @end example
6545 Using that same compiler, this code:
6547 @example
6548 "xchg@{l@}\t@{%%@}ebx, %1"
6549 @end example
6551 would produce 
6553 @example
6554 For att: "xchgl\t%%ebx, %1"
6555 For intel: "xchg\tebx, %1"
6556 @end example
6558 There is no support for nesting dialect alternatives. Also, there is no 
6559 ``escape'' for an open brace (@{), so do not use open braces in an Extended 
6560 @code{asm} template other than as a dialect indicator.
6562 @subsubheading Other format strings
6564 In addition to the tokens described by the input, output, and goto operands, 
6565 there are a few special cases:
6567 @itemize
6568 @item
6569 "%%" outputs a single "%" into the assembler code.
6571 @item
6572 "%=" outputs a number that is unique to each instance of the @code{asm} 
6573 statement in the entire compilation. This option is useful when creating local 
6574 labels and referring to them multiple times in a single template that 
6575 generates multiple assembler instructions. 
6577 @end itemize
6579 @anchor{OutputOperands}
6580 @subsubsection Output Operands
6581 @cindex @code{asm} output operands
6583 An @code{asm} statement has zero or more output operands indicating the names
6584 of C variables modified by the assembler code.
6586 In this i386 example, @var{old} (referred to in the template string as 
6587 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset} 
6588 (@code{%2}) is an input:
6590 @example
6591 bool old;
6593 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6594          "sbb %0,%0"      // Use the CF to calculate old.
6595    : "=r" (old), "+rm" (*Base)
6596    : "Ir" (Offset)
6597    : "cc");
6599 return old;
6600 @end example
6602 Operands use this format:
6604 @example
6605 [ [asmSymbolicName] ] "constraint" (cvariablename)
6606 @end example
6608 @emph{asmSymbolicName}
6611 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6612 in the list of operands in the assembler template. For example if there are 
6613 three output operands, use @code{%0} in the template to refer to the first, 
6614 @code{%1} for the second, and @code{%2} for the third. When using an 
6615 asmSymbolicName, reference it by enclosing the name in square brackets 
6616 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement 
6617 that contains the definition. Any valid C variable name is acceptable, 
6618 including names already defined in the surrounding code. No two operands 
6619 within the same @code{asm} statement can use the same symbolic name.
6621 @emph{constraint}
6623 Output constraints must begin with either @code{"="} (a variable overwriting an 
6624 existing value) or @code{"+"} (when reading and writing). When using 
6625 @code{"="}, do not assume the location will contain the existing value (except 
6626 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6628 After the prefix, there must be one or more additional constraints 
6629 (@pxref{Constraints}) that describe where the value resides. Common 
6630 constraints include @code{"r"} for register and @code{"m"} for memory. 
6631 When you list more than one possible location (for example @code{"=rm"}), the 
6632 compiler chooses the most efficient one based on the current context. If you 
6633 list as many alternates as the @code{asm} statement allows, you will permit 
6634 the optimizers to produce the best possible code. If you must use a specific
6635 register, but your Machine Constraints do not provide sufficient 
6636 control to select the specific register you want, Local Reg Vars may provide 
6637 a solution (@pxref{Local Reg Vars}).
6639 @emph{cvariablename}
6641 Specifies the C variable name of the output (enclosed by parentheses). Accepts 
6642 any (non-constant) variable within scope.
6644 Remarks:
6646 The total number of input + output + goto operands has a limit of 30. Commas 
6647 separate the operands. When the compiler selects the registers to use to 
6648 represent the output operands, it will not use any of the clobbered registers 
6649 (@pxref{Clobbers}).
6651 Output operand expressions must be lvalues. The compiler cannot check whether 
6652 the operands have data types that are reasonable for the instruction being 
6653 executed. For output expressions that are not directly addressable (for 
6654 example a bit-field), the constraint must allow a register. In that case, GCC 
6655 uses the register as the output of the @code{asm}, and then stores that 
6656 register into the output. 
6658 Unless an output operand has the '@code{&}' constraint modifier 
6659 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated 
6660 input operand, on the assumption that the assembler code will consume its 
6661 inputs before producing outputs. This assumption may be false if the assembler 
6662 code actually consists of more than one instruction. In this case, use 
6663 '@code{&}' on each output operand that must not overlap an input.
6665 The same problem can occur if one output parameter (@var{a}) allows a register 
6666 constraint and another output parameter (@var{b}) allows a memory constraint.
6667 The code generated by GCC to access the memory address in @var{b} can contain
6668 registers which @emph{might} be shared by @var{a}, and GCC considers those 
6669 registers to be inputs to the asm. As above, GCC assumes that such input
6670 registers are consumed before any outputs are written. This assumption may 
6671 result in incorrect behavior if the asm writes to @var{a} before using 
6672 @var{b}. Combining the `@code{&}' constraint with the register constraint 
6673 ensures that modifying @var{a} will not affect what address is referenced by 
6674 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b} 
6675 will be undefined if @var{a} is modified before using @var{b}.
6677 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6678 instead of simply @code{%2}). Typically these qualifiers are hardware 
6679 dependent. The list of supported modifiers for i386 is found at 
6680 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6682 If the C code that follows the @code{asm} makes no use of any of the output 
6683 operands, use @code{volatile} for the @code{asm} statement to prevent the 
6684 optimizers from discarding the @code{asm} statement as unneeded 
6685 (see @ref{Volatile}).
6687 Examples:
6689 This code makes no use of the optional asmSymbolicName. Therefore it 
6690 references the first output operand as @code{%0} (were there a second, it 
6691 would be @code{%1}, etc). The number of the first input operand is one greater 
6692 than that of the last output operand. In this i386 example, that makes 
6693 @var{Mask} @code{%1}:
6695 @example
6696 uint32_t Mask = 1234;
6697 uint32_t Index;
6699   asm ("bsfl %1, %0"
6700      : "=r" (Index)
6701      : "r" (Mask)
6702      : "cc");
6703 @end example
6705 That code overwrites the variable Index ("="), placing the value in a register 
6706 ("r"). The generic "r" constraint instead of a constraint for a specific 
6707 register allows the compiler to pick the register to use, which can result 
6708 in more efficient code. This may not be possible if an assembler instruction 
6709 requires a specific register.
6711 The following i386 example uses the asmSymbolicName operand. It produces the 
6712 same result as the code above, but some may consider it more readable or more 
6713 maintainable since reordering index numbers is not necessary when adding or 
6714 removing operands. The names aIndex and aMask are only used to emphasize which 
6715 names get used where. It is acceptable to reuse the names Index and Mask.
6717 @example
6718 uint32_t Mask = 1234;
6719 uint32_t Index;
6721   asm ("bsfl %[aMask], %[aIndex]"
6722      : [aIndex] "=r" (Index)
6723      : [aMask] "r" (Mask)
6724      : "cc");
6725 @end example
6727 Here are some more examples of output operands.
6729 @example
6730 uint32_t c = 1;
6731 uint32_t d;
6732 uint32_t *e = &c;
6734 asm ("mov %[e], %[d]"
6735    : [d] "=rm" (d)
6736    : [e] "rm" (*e));
6737 @end example
6739 Here, @var{d} may either be in a register or in memory. Since the compiler 
6740 might already have the current value of the uint32_t pointed to by @var{e} 
6741 in a register, you can enable it to choose the best location
6742 for @var{d} by specifying both constraints.
6744 @anchor{InputOperands}
6745 @subsubsection Input Operands
6746 @cindex @code{asm} input operands
6747 @cindex @code{asm} expressions
6749 Input operands make inputs from C variables and expressions available to the 
6750 assembly code.
6752 Specify input operands by using the format:
6754 @example
6755 [ [asmSymbolicName] ] "constraint" (cexpression)
6756 @end example
6758 @emph{asmSymbolicName}
6760 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6761 in the list of operands, including outputs, in the assembler template. For 
6762 example, if there are two output parameters and three inputs, @code{%2} refers 
6763 to the first input, @code{%3} to the second, and @code{%4} to the third.
6764 When using an asmSymbolicName, reference it by enclosing the name in square 
6765 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm} 
6766 statement that contains the definition. Any valid C variable name is 
6767 acceptable, including names already defined in the surrounding code. No two 
6768 operands within the same @code{asm} statement can use the same symbolic name.
6770 @emph{constraint}
6772 Input constraints must be a string containing one or more constraints 
6773 (@pxref{Constraints}). When you give more than one possible constraint 
6774 (for example, @code{"irm"}), the compiler will choose the most efficient 
6775 method based on the current context. Input constraints may not begin with 
6776 either "=" or "+". If you must use a specific register, but your Machine
6777 Constraints do not provide sufficient control to select the specific 
6778 register you want, Local Reg Vars may provide a solution 
6779 (@pxref{Local Reg Vars}).
6781 Input constraints can also be digits (for example, @code{"0"}). This indicates 
6782 that the specified input will be in the same place as the output constraint 
6783 at the (zero-based) index in the output constraint list. When using 
6784 asmSymbolicNames for the output operands, you may use these names (enclosed 
6785 in brackets []) instead of digits.
6787 @emph{cexpression}
6789 This is the C variable or expression being passed to the @code{asm} statement 
6790 as input.
6792 When the compiler selects the registers to use to represent the input 
6793 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
6795 If there are no output operands but there are input operands, place two 
6796 consecutive colons where the output operands would go:
6798 @example
6799 __asm__ ("some instructions"
6800    : /* No outputs. */
6801    : "r" (Offset / 8);
6802 @end example
6804 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
6805 (except for inputs tied to outputs). The compiler assumes that on exit from 
6806 the @code{asm} statement these operands will contain the same values as they 
6807 had before executing the assembler. It is @emph{not} possible to use Clobbers 
6808 to inform the compiler that the values in these inputs are changing. One 
6809 common work-around is to tie the changing input variable to an output variable 
6810 that never gets used. Note, however, that if the code that follows the 
6811 @code{asm} statement makes no use of any of the output operands, the GCC 
6812 optimizers may discard the @code{asm} statement as unneeded 
6813 (see @ref{Volatile}).
6815 Remarks:
6817 The total number of input + output + goto operands has a limit of 30.
6819 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6820 instead of simply @code{%2}). Typically these qualifiers are hardware 
6821 dependent. The list of supported modifiers for i386 is found at 
6822 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6824 Examples:
6826 In this example using the fictitious @code{combine} instruction, the 
6827 constraint @code{"0"} for input operand 1 says that it must occupy the same 
6828 location as output operand 0. Only input operands may use numbers in 
6829 constraints, and they must each refer to an output operand. Only a number (or 
6830 the symbolic assembler name) in the constraint can guarantee that one operand 
6831 is in the same place as another. The mere fact that @var{foo} is the value of 
6832 both operands is not enough to guarantee that they are in the same place in 
6833 the generated assembler code.
6835 @example
6836 asm ("combine %2, %0" 
6837    : "=r" (foo) 
6838    : "0" (foo), "g" (bar));
6839 @end example
6841 Here is an example using symbolic names.
6843 @example
6844 asm ("cmoveq %1, %2, %[result]" 
6845    : [result] "=r"(result) 
6846    : "r" (test), "r" (new), "[result]" (old));
6847 @end example
6849 @anchor{Clobbers}
6850 @subsubsection Clobbers
6851 @cindex @code{asm} clobbers
6853 While the compiler is aware of changes to entries listed in the output 
6854 operands, the assembler code may modify more than just the outputs. For 
6855 example, calculations may require additional registers, or the processor may 
6856 overwrite a register as a side effect of a particular assembler instruction. 
6857 In order to inform the compiler of these changes, list them in the clobber 
6858 list. Clobber list items are either register names or the special clobbers 
6859 (listed below). Each clobber list item is enclosed in double quotes and 
6860 separated by commas.
6862 Clobber descriptions may not in any way overlap with an input or output 
6863 operand. For example, you may not have an operand describing a register class 
6864 with one member when listing that register in the clobber list. Variables 
6865 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used 
6866 as @code{asm} input or output operands, must have no part mentioned in the 
6867 clobber description. In particular, there is no way to specify that input 
6868 operands get modified without also specifying them as output operands.
6870 When the compiler selects which registers to use to represent input and output 
6871 operands, it will not use any of the clobbered registers. As a result, 
6872 clobbered registers are available for any use in the assembler code.
6874 Here is a realistic example for the VAX showing the use of clobbered 
6875 registers: 
6877 @example
6878 asm volatile ("movc3 %0, %1, %2"
6879                    : /* No outputs. */
6880                    : "g" (from), "g" (to), "g" (count)
6881                    : "r0", "r1", "r2", "r3", "r4", "r5");
6882 @end example
6884 Also, there are two special clobber arguments:
6886 @enumerate
6887 @item
6888 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
6889 register. On some machines, GCC represents the condition codes as a specific 
6890 hardware register; "cc" serves to name this register. On other machines, 
6891 condition code handling is different, and specifying "cc" has no effect. But 
6892 it is valid no matter what the machine.
6894 @item
6895 The "memory" clobber tells the compiler that the assembly code performs memory 
6896 reads or writes to items other than those listed in the input and output 
6897 operands (for example accessing the memory pointed to by one of the input 
6898 parameters). To ensure memory contains correct values, GCC may need to flush 
6899 specific register values to memory before executing the @code{asm}. Further, 
6900 the compiler will not assume that any values read from memory before an 
6901 @code{asm} will remain unchanged after that @code{asm}; it will reload them as 
6902 needed. This effectively forms a read/write memory barrier for the compiler.
6904 Note that this clobber does not prevent the @emph{processor} from doing 
6905 speculative reads past the @code{asm} statement. To prevent that, you need 
6906 processor-specific fence instructions.
6908 Flushing registers to memory has performance implications and may be an issue 
6909 for time-sensitive code. One trick to avoid this is available if the size of 
6910 the memory being accessed is known at compile time. For example, if accessing 
6911 ten bytes of a string, use a memory input like: 
6913 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
6915 @end enumerate
6917 @anchor{GotoLabels}
6918 @subsubsection Goto Labels
6919 @cindex @code{asm} goto labels
6921 @code{asm goto} allows assembly code to jump to one or more C labels. The 
6922 GotoLabels section in an @code{asm goto} statement contains a comma-separated 
6923 list of all C labels to which the assembler code may jump. GCC assumes that 
6924 @code{asm} execution falls through to the next statement (if this is not the 
6925 case, consider using the @code{__builtin_unreachable} intrinsic after the 
6926 @code{asm} statement). The total number of input + output + goto operands has 
6927 a limit of 30.
6929 An @code{asm goto} statement can not have outputs (which means that the 
6930 statement is implicitly volatile). This is due to an internal restriction of 
6931 the compiler: control transfer instructions cannot have outputs. If the 
6932 assembler code does modify anything, use the "memory" clobber to force the 
6933 optimizers to flush all register values to memory, and reload them if 
6934 necessary, after the @code{asm} statement.
6936 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed 
6937 by its (zero-based) position in GotoLabels plus the number of input 
6938 arguments.  For example, if the @code{asm} has three inputs and references two 
6939 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
6941 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6942 GCC's optimizers do not know about these jumps; therefore they cannot take 
6943 account of them when deciding how to optimize.
6945 Example code for i386 might look like:
6947 @example
6948 asm goto (
6949     "btl %1, %0\n\t"
6950     "jc %l2"
6951     : /* No outputs. */
6952     : "r" (p1), "r" (p2) 
6953     : "cc" 
6954     : carry);
6956 return 0;
6958 carry:
6959 return 1;
6960 @end example
6962 The following example shows an @code{asm goto} that uses the memory clobber.
6964 @example
6965 int frob(int x)
6967   int y;
6968   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
6969             : /* No outputs. */
6970             : "r"(x), "r"(&y)
6971             : "r5", "memory" 
6972             : error);
6973   return y;
6974 error:
6975   return -1;
6977 @end example
6979 @anchor{i386Operandmodifiers}
6980 @subsubsection i386 Operand modifiers
6982 Input, output, and goto operands for extended @code{asm} statements can use 
6983 modifiers to affect the code output to the assembler. For example, the 
6984 following code uses the "h" and "b" modifiers for i386:
6986 @example
6987 uint16_t  num;
6988 asm volatile ("xchg %h0, %b0" : "+a" (num) );
6989 @end example
6991 These modifiers generate this assembler code:
6993 @example
6994 xchg %ah, %al
6995 @end example
6997 The rest of this discussion uses the following code for illustrative purposes.
6999 @example
7000 int main()
7002    int iInt = 1;
7004 top:
7006    asm volatile goto ("some assembler instructions here"
7007    : /* No outputs. */
7008    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7009    : /* No clobbers. */
7010    : top);
7012 @end example
7014 With no modifiers, this is what the output from the operands would be for the 
7015 att and intel dialects of assembler:
7017 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7018 @headitem Operand @tab masm=att @tab masm=intel
7019 @item @code{%0}
7020 @tab @code{%eax}
7021 @tab @code{eax}
7022 @item @code{%1}
7023 @tab @code{$2}
7024 @tab @code{2}
7025 @item @code{%2}
7026 @tab @code{$.L2}
7027 @tab @code{OFFSET FLAT:.L2}
7028 @end multitable
7030 The table below shows the list of supported modifiers and their effects.
7032 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7033 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7034 @item @code{z}
7035 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7036 @tab @code{%z0}
7037 @tab @code{l}
7038 @tab 
7039 @item @code{b}
7040 @tab Print the QImode name of the register.
7041 @tab @code{%b0}
7042 @tab @code{%al}
7043 @tab @code{al}
7044 @item @code{h}
7045 @tab Print the QImode name for a ``high'' register.
7046 @tab @code{%h0}
7047 @tab @code{%ah}
7048 @tab @code{ah}
7049 @item @code{w}
7050 @tab Print the HImode name of the register.
7051 @tab @code{%w0}
7052 @tab @code{%ax}
7053 @tab @code{ax}
7054 @item @code{k}
7055 @tab Print the SImode name of the register.
7056 @tab @code{%k0}
7057 @tab @code{%eax}
7058 @tab @code{eax}
7059 @item @code{q}
7060 @tab Print the DImode name of the register.
7061 @tab @code{%q0}
7062 @tab @code{%rax}
7063 @tab @code{rax}
7064 @item @code{l}
7065 @tab Print the label name with no punctuation.
7066 @tab @code{%l2}
7067 @tab @code{.L2}
7068 @tab @code{.L2}
7069 @item @code{c}
7070 @tab Require a constant operand and print the constant expression with no punctuation.
7071 @tab @code{%c1}
7072 @tab @code{2}
7073 @tab @code{2}
7074 @end multitable
7076 @anchor{i386floatingpointasmoperands}
7077 @subsubsection i386 floating-point asm operands
7079 On i386 targets, there are several rules on the usage of stack-like registers
7080 in the operands of an @code{asm}.  These rules apply only to the operands
7081 that are stack-like registers:
7083 @enumerate
7084 @item
7085 Given a set of input registers that die in an @code{asm}, it is
7086 necessary to know which are implicitly popped by the @code{asm}, and
7087 which must be explicitly popped by GCC@.
7089 An input register that is implicitly popped by the @code{asm} must be
7090 explicitly clobbered, unless it is constrained to match an
7091 output operand.
7093 @item
7094 For any input register that is implicitly popped by an @code{asm}, it is
7095 necessary to know how to adjust the stack to compensate for the pop.
7096 If any non-popped input is closer to the top of the reg-stack than
7097 the implicitly popped register, it would not be possible to know what the
7098 stack looked like---it's not clear how the rest of the stack ``slides
7099 up''.
7101 All implicitly popped input registers must be closer to the top of
7102 the reg-stack than any input that is not implicitly popped.
7104 It is possible that if an input dies in an @code{asm}, the compiler might
7105 use the input register for an output reload.  Consider this example:
7107 @smallexample
7108 asm ("foo" : "=t" (a) : "f" (b));
7109 @end smallexample
7111 @noindent
7112 This code says that input @code{b} is not popped by the @code{asm}, and that
7113 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7114 deeper after the @code{asm} than it was before.  But, it is possible that
7115 reload may think that it can use the same register for both the input and
7116 the output.
7118 To prevent this from happening,
7119 if any input operand uses the @code{f} constraint, all output register
7120 constraints must use the @code{&} early-clobber modifier.
7122 The example above would be correctly written as:
7124 @smallexample
7125 asm ("foo" : "=&t" (a) : "f" (b));
7126 @end smallexample
7128 @item
7129 Some operands need to be in particular places on the stack.  All
7130 output operands fall in this category---GCC has no other way to
7131 know which registers the outputs appear in unless you indicate
7132 this in the constraints.
7134 Output operands must specifically indicate which register an output
7135 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
7136 constraints must select a class with a single register.
7138 @item
7139 Output operands may not be ``inserted'' between existing stack registers.
7140 Since no 387 opcode uses a read/write operand, all output operands
7141 are dead before the @code{asm}, and are pushed by the @code{asm}.
7142 It makes no sense to push anywhere but the top of the reg-stack.
7144 Output operands must start at the top of the reg-stack: output
7145 operands may not ``skip'' a register.
7147 @item
7148 Some @code{asm} statements may need extra stack space for internal
7149 calculations.  This can be guaranteed by clobbering stack registers
7150 unrelated to the inputs and outputs.
7152 @end enumerate
7154 Here are a couple of reasonable @code{asm}s to want to write.  This
7155 @code{asm}
7156 takes one input, which is internally popped, and produces two outputs.
7158 @smallexample
7159 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7160 @end smallexample
7162 @noindent
7163 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7164 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7165 for the compiler to know that @code{fyl2xp1} pops both inputs.
7167 @smallexample
7168 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7169 @end smallexample
7171 @lowersections
7172 @include md.texi
7173 @raisesections
7175 @node Asm Labels
7176 @subsection Controlling Names Used in Assembler Code
7177 @cindex assembler names for identifiers
7178 @cindex names used in assembler code
7179 @cindex identifiers, names in assembler code
7181 You can specify the name to be used in the assembler code for a C
7182 function or variable by writing the @code{asm} (or @code{__asm__})
7183 keyword after the declarator as follows:
7185 @smallexample
7186 int foo asm ("myfoo") = 2;
7187 @end smallexample
7189 @noindent
7190 This specifies that the name to be used for the variable @code{foo} in
7191 the assembler code should be @samp{myfoo} rather than the usual
7192 @samp{_foo}.
7194 On systems where an underscore is normally prepended to the name of a C
7195 function or variable, this feature allows you to define names for the
7196 linker that do not start with an underscore.
7198 It does not make sense to use this feature with a non-static local
7199 variable since such variables do not have assembler names.  If you are
7200 trying to put the variable in a particular register, see @ref{Explicit
7201 Reg Vars}.  GCC presently accepts such code with a warning, but will
7202 probably be changed to issue an error, rather than a warning, in the
7203 future.
7205 You cannot use @code{asm} in this way in a function @emph{definition}; but
7206 you can get the same effect by writing a declaration for the function
7207 before its definition and putting @code{asm} there, like this:
7209 @smallexample
7210 extern func () asm ("FUNC");
7212 func (x, y)
7213      int x, y;
7214 /* @r{@dots{}} */
7215 @end smallexample
7217 It is up to you to make sure that the assembler names you choose do not
7218 conflict with any other assembler symbols.  Also, you must not use a
7219 register name; that would produce completely invalid assembler code.  GCC
7220 does not as yet have the ability to store static variables in registers.
7221 Perhaps that will be added.
7223 @node Explicit Reg Vars
7224 @subsection Variables in Specified Registers
7225 @cindex explicit register variables
7226 @cindex variables in specified registers
7227 @cindex specified registers
7228 @cindex registers, global allocation
7230 GNU C allows you to put a few global variables into specified hardware
7231 registers.  You can also specify the register in which an ordinary
7232 register variable should be allocated.
7234 @itemize @bullet
7235 @item
7236 Global register variables reserve registers throughout the program.
7237 This may be useful in programs such as programming language
7238 interpreters that have a couple of global variables that are accessed
7239 very often.
7241 @item
7242 Local register variables in specific registers do not reserve the
7243 registers, except at the point where they are used as input or output
7244 operands in an @code{asm} statement and the @code{asm} statement itself is
7245 not deleted.  The compiler's data flow analysis is capable of determining
7246 where the specified registers contain live values, and where they are
7247 available for other uses.  Stores into local register variables may be deleted
7248 when they appear to be dead according to dataflow analysis.  References
7249 to local register variables may be deleted or moved or simplified.
7251 These local variables are sometimes convenient for use with the extended
7252 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7253 output of the assembler instruction directly into a particular register.
7254 (This works provided the register you specify fits the constraints
7255 specified for that operand in the @code{asm}.)
7256 @end itemize
7258 @node Size of an asm
7259 @subsection Size of an @code{asm}
7261 Some targets require that GCC track the size of each instruction used
7262 in order to generate correct code.  Because the final length of the
7263 code produced by an @code{asm} statement is only known by the
7264 assembler, GCC must make an estimate as to how big it will be.  It
7265 does this by counting the number of instructions in the pattern of the
7266 @code{asm} and multiplying that by the length of the longest
7267 instruction supported by that processor.  (When working out the number
7268 of instructions, it assumes that any occurrence of a newline or of
7269 whatever statement separator character is supported by the assembler --
7270 typically @samp{;} --- indicates the end of an instruction.)
7272 Normally, GCC's estimate is adequate to ensure that correct
7273 code is generated, but it is possible to confuse the compiler if you use
7274 pseudo instructions or assembler macros that expand into multiple real
7275 instructions, or if you use assembler directives that expand to more
7276 space in the object file than is needed for a single instruction.
7277 If this happens then the assembler may produce a diagnostic saying that
7278 a label is unreachable.
7280 @menu
7281 * Global Reg Vars::
7282 * Local Reg Vars::
7283 @end menu
7285 @node Global Reg Vars
7286 @subsubsection Defining Global Register Variables
7287 @cindex global register variables
7288 @cindex registers, global variables in
7290 You can define a global register variable in GNU C like this:
7292 @smallexample
7293 register int *foo asm ("a5");
7294 @end smallexample
7296 @noindent
7297 Here @code{a5} is the name of the register that should be used.  Choose a
7298 register that is normally saved and restored by function calls on your
7299 machine, so that library routines will not clobber it.
7301 Naturally the register name is cpu-dependent, so you need to
7302 conditionalize your program according to cpu type.  The register
7303 @code{a5} is a good choice on a 68000 for a variable of pointer
7304 type.  On machines with register windows, be sure to choose a ``global''
7305 register that is not affected magically by the function call mechanism.
7307 In addition, different operating systems on the same CPU may differ in how they
7308 name the registers; then you need additional conditionals.  For
7309 example, some 68000 operating systems call this register @code{%a5}.
7311 Eventually there may be a way of asking the compiler to choose a register
7312 automatically, but first we need to figure out how it should choose and
7313 how to enable you to guide the choice.  No solution is evident.
7315 Defining a global register variable in a certain register reserves that
7316 register entirely for this use, at least within the current compilation.
7317 The register is not allocated for any other purpose in the functions
7318 in the current compilation, and is not saved and restored by
7319 these functions.  Stores into this register are never deleted even if they
7320 appear to be dead, but references may be deleted or moved or
7321 simplified.
7323 It is not safe to access the global register variables from signal
7324 handlers, or from more than one thread of control, because the system
7325 library routines may temporarily use the register for other things (unless
7326 you recompile them specially for the task at hand).
7328 @cindex @code{qsort}, and global register variables
7329 It is not safe for one function that uses a global register variable to
7330 call another such function @code{foo} by way of a third function
7331 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7332 different source file in which the variable isn't declared).  This is
7333 because @code{lose} might save the register and put some other value there.
7334 For example, you can't expect a global register variable to be available in
7335 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7336 might have put something else in that register.  (If you are prepared to
7337 recompile @code{qsort} with the same global register variable, you can
7338 solve this problem.)
7340 If you want to recompile @code{qsort} or other source files that do not
7341 actually use your global register variable, so that they do not use that
7342 register for any other purpose, then it suffices to specify the compiler
7343 option @option{-ffixed-@var{reg}}.  You need not actually add a global
7344 register declaration to their source code.
7346 A function that can alter the value of a global register variable cannot
7347 safely be called from a function compiled without this variable, because it
7348 could clobber the value the caller expects to find there on return.
7349 Therefore, the function that is the entry point into the part of the
7350 program that uses the global register variable must explicitly save and
7351 restore the value that belongs to its caller.
7353 @cindex register variable after @code{longjmp}
7354 @cindex global register after @code{longjmp}
7355 @cindex value after @code{longjmp}
7356 @findex longjmp
7357 @findex setjmp
7358 On most machines, @code{longjmp} restores to each global register
7359 variable the value it had at the time of the @code{setjmp}.  On some
7360 machines, however, @code{longjmp} does not change the value of global
7361 register variables.  To be portable, the function that called @code{setjmp}
7362 should make other arrangements to save the values of the global register
7363 variables, and to restore them in a @code{longjmp}.  This way, the same
7364 thing happens regardless of what @code{longjmp} does.
7366 All global register variable declarations must precede all function
7367 definitions.  If such a declaration could appear after function
7368 definitions, the declaration would be too late to prevent the register from
7369 being used for other purposes in the preceding functions.
7371 Global register variables may not have initial values, because an
7372 executable file has no means to supply initial contents for a register.
7374 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7375 registers, but certain library functions, such as @code{getwd}, as well
7376 as the subroutines for division and remainder, modify g3 and g4.  g1 and
7377 g2 are local temporaries.
7379 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7380 Of course, it does not do to use more than a few of those.
7382 @node Local Reg Vars
7383 @subsubsection Specifying Registers for Local Variables
7384 @cindex local variables, specifying registers
7385 @cindex specifying registers for local variables
7386 @cindex registers for local variables
7388 You can define a local register variable with a specified register
7389 like this:
7391 @smallexample
7392 register int *foo asm ("a5");
7393 @end smallexample
7395 @noindent
7396 Here @code{a5} is the name of the register that should be used.  Note
7397 that this is the same syntax used for defining global register
7398 variables, but for a local variable it appears within a function.
7400 Naturally the register name is cpu-dependent, but this is not a
7401 problem, since specific registers are most often useful with explicit
7402 assembler instructions (@pxref{Extended Asm}).  Both of these things
7403 generally require that you conditionalize your program according to
7404 cpu type.
7406 In addition, operating systems on one type of cpu may differ in how they
7407 name the registers; then you need additional conditionals.  For
7408 example, some 68000 operating systems call this register @code{%a5}.
7410 Defining such a register variable does not reserve the register; it
7411 remains available for other uses in places where flow control determines
7412 the variable's value is not live.
7414 This option does not guarantee that GCC generates code that has
7415 this variable in the register you specify at all times.  You may not
7416 code an explicit reference to this register in the @emph{assembler
7417 instruction template} part of an @code{asm} statement and assume it
7418 always refers to this variable.  However, using the variable as an
7419 @code{asm} @emph{operand} guarantees that the specified register is used
7420 for the operand.
7422 Stores into local register variables may be deleted when they appear to be dead
7423 according to dataflow analysis.  References to local register variables may
7424 be deleted or moved or simplified.
7426 As with global register variables, it is recommended that you choose a
7427 register that is normally saved and restored by function calls on
7428 your machine, so that library routines will not clobber it.  
7430 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
7431 specific register, but there's no matching constraint letter for that 
7432 register. To force the operand into that register, create a local variable 
7433 and specify the register in the variable's declaration. Then use the local 
7434 variable for the asm operand and specify any constraint letter that matches 
7435 the register:
7437 @smallexample
7438 register int *p1 asm ("r0") = @dots{};
7439 register int *p2 asm ("r1") = @dots{};
7440 register int *result asm ("r0");
7441 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7442 @end smallexample
7444 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
7445 call-clobbered by subsequent code, including function calls and library calls 
7446 for arithmetic operators on other variables (for example the initialization 
7447 of p2). In this case, use temporary variables for expressions between the 
7448 register assignments:
7450 @smallexample
7451 int t1 = @dots{};
7452 register int *p1 asm ("r0") = @dots{};
7453 register int *p2 asm ("r1") = t1;
7454 register int *result asm ("r0");
7455 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7456 @end smallexample
7458 @node Alternate Keywords
7459 @section Alternate Keywords
7460 @cindex alternate keywords
7461 @cindex keywords, alternate
7463 @option{-ansi} and the various @option{-std} options disable certain
7464 keywords.  This causes trouble when you want to use GNU C extensions, or
7465 a general-purpose header file that should be usable by all programs,
7466 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
7467 @code{inline} are not available in programs compiled with
7468 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7469 program compiled with @option{-std=c99} or @option{-std=c11}).  The
7470 ISO C99 keyword
7471 @code{restrict} is only available when @option{-std=gnu99} (which will
7472 eventually be the default) or @option{-std=c99} (or the equivalent
7473 @option{-std=iso9899:1999}), or an option for a later standard
7474 version, is used.
7476 The way to solve these problems is to put @samp{__} at the beginning and
7477 end of each problematical keyword.  For example, use @code{__asm__}
7478 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7480 Other C compilers won't accept these alternative keywords; if you want to
7481 compile with another compiler, you can define the alternate keywords as
7482 macros to replace them with the customary keywords.  It looks like this:
7484 @smallexample
7485 #ifndef __GNUC__
7486 #define __asm__ asm
7487 #endif
7488 @end smallexample
7490 @findex __extension__
7491 @opindex pedantic
7492 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7493 You can
7494 prevent such warnings within one expression by writing
7495 @code{__extension__} before the expression.  @code{__extension__} has no
7496 effect aside from this.
7498 @node Incomplete Enums
7499 @section Incomplete @code{enum} Types
7501 You can define an @code{enum} tag without specifying its possible values.
7502 This results in an incomplete type, much like what you get if you write
7503 @code{struct foo} without describing the elements.  A later declaration
7504 that does specify the possible values completes the type.
7506 You can't allocate variables or storage using the type while it is
7507 incomplete.  However, you can work with pointers to that type.
7509 This extension may not be very useful, but it makes the handling of
7510 @code{enum} more consistent with the way @code{struct} and @code{union}
7511 are handled.
7513 This extension is not supported by GNU C++.
7515 @node Function Names
7516 @section Function Names as Strings
7517 @cindex @code{__func__} identifier
7518 @cindex @code{__FUNCTION__} identifier
7519 @cindex @code{__PRETTY_FUNCTION__} identifier
7521 GCC provides three magic variables that hold the name of the current
7522 function, as a string.  The first of these is @code{__func__}, which
7523 is part of the C99 standard:
7525 The identifier @code{__func__} is implicitly declared by the translator
7526 as if, immediately following the opening brace of each function
7527 definition, the declaration
7529 @smallexample
7530 static const char __func__[] = "function-name";
7531 @end smallexample
7533 @noindent
7534 appeared, where function-name is the name of the lexically-enclosing
7535 function.  This name is the unadorned name of the function.
7537 @code{__FUNCTION__} is another name for @code{__func__}.  Older
7538 versions of GCC recognize only this name.  However, it is not
7539 standardized.  For maximum portability, we recommend you use
7540 @code{__func__}, but provide a fallback definition with the
7541 preprocessor:
7543 @smallexample
7544 #if __STDC_VERSION__ < 199901L
7545 # if __GNUC__ >= 2
7546 #  define __func__ __FUNCTION__
7547 # else
7548 #  define __func__ "<unknown>"
7549 # endif
7550 #endif
7551 @end smallexample
7553 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7554 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
7555 the type signature of the function as well as its bare name.  For
7556 example, this program:
7558 @smallexample
7559 extern "C" @{
7560 extern int printf (char *, ...);
7563 class a @{
7564  public:
7565   void sub (int i)
7566     @{
7567       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7568       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7569     @}
7573 main (void)
7575   a ax;
7576   ax.sub (0);
7577   return 0;
7579 @end smallexample
7581 @noindent
7582 gives this output:
7584 @smallexample
7585 __FUNCTION__ = sub
7586 __PRETTY_FUNCTION__ = void a::sub(int)
7587 @end smallexample
7589 These identifiers are not preprocessor macros.  In GCC 3.3 and
7590 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7591 were treated as string literals; they could be used to initialize
7592 @code{char} arrays, and they could be concatenated with other string
7593 literals.  GCC 3.4 and later treat them as variables, like
7594 @code{__func__}.  In C++, @code{__FUNCTION__} and
7595 @code{__PRETTY_FUNCTION__} have always been variables.
7597 @node Return Address
7598 @section Getting the Return or Frame Address of a Function
7600 These functions may be used to get information about the callers of a
7601 function.
7603 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7604 This function returns the return address of the current function, or of
7605 one of its callers.  The @var{level} argument is number of frames to
7606 scan up the call stack.  A value of @code{0} yields the return address
7607 of the current function, a value of @code{1} yields the return address
7608 of the caller of the current function, and so forth.  When inlining
7609 the expected behavior is that the function returns the address of
7610 the function that is returned to.  To work around this behavior use
7611 the @code{noinline} function attribute.
7613 The @var{level} argument must be a constant integer.
7615 On some machines it may be impossible to determine the return address of
7616 any function other than the current one; in such cases, or when the top
7617 of the stack has been reached, this function returns @code{0} or a
7618 random value.  In addition, @code{__builtin_frame_address} may be used
7619 to determine if the top of the stack has been reached.
7621 Additional post-processing of the returned value may be needed, see
7622 @code{__builtin_extract_return_addr}.
7624 This function should only be used with a nonzero argument for debugging
7625 purposes.
7626 @end deftypefn
7628 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7629 The address as returned by @code{__builtin_return_address} may have to be fed
7630 through this function to get the actual encoded address.  For example, on the
7631 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7632 platforms an offset has to be added for the true next instruction to be
7633 executed.
7635 If no fixup is needed, this function simply passes through @var{addr}.
7636 @end deftypefn
7638 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7639 This function does the reverse of @code{__builtin_extract_return_addr}.
7640 @end deftypefn
7642 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7643 This function is similar to @code{__builtin_return_address}, but it
7644 returns the address of the function frame rather than the return address
7645 of the function.  Calling @code{__builtin_frame_address} with a value of
7646 @code{0} yields the frame address of the current function, a value of
7647 @code{1} yields the frame address of the caller of the current function,
7648 and so forth.
7650 The frame is the area on the stack that holds local variables and saved
7651 registers.  The frame address is normally the address of the first word
7652 pushed on to the stack by the function.  However, the exact definition
7653 depends upon the processor and the calling convention.  If the processor
7654 has a dedicated frame pointer register, and the function has a frame,
7655 then @code{__builtin_frame_address} returns the value of the frame
7656 pointer register.
7658 On some machines it may be impossible to determine the frame address of
7659 any function other than the current one; in such cases, or when the top
7660 of the stack has been reached, this function returns @code{0} if
7661 the first frame pointer is properly initialized by the startup code.
7663 This function should only be used with a nonzero argument for debugging
7664 purposes.
7665 @end deftypefn
7667 @node Vector Extensions
7668 @section Using Vector Instructions through Built-in Functions
7670 On some targets, the instruction set contains SIMD vector instructions which
7671 operate on multiple values contained in one large register at the same time.
7672 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7673 this way.
7675 The first step in using these extensions is to provide the necessary data
7676 types.  This should be done using an appropriate @code{typedef}:
7678 @smallexample
7679 typedef int v4si __attribute__ ((vector_size (16)));
7680 @end smallexample
7682 @noindent
7683 The @code{int} type specifies the base type, while the attribute specifies
7684 the vector size for the variable, measured in bytes.  For example, the
7685 declaration above causes the compiler to set the mode for the @code{v4si}
7686 type to be 16 bytes wide and divided into @code{int} sized units.  For
7687 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7688 corresponding mode of @code{foo} is @acronym{V4SI}.
7690 The @code{vector_size} attribute is only applicable to integral and
7691 float scalars, although arrays, pointers, and function return values
7692 are allowed in conjunction with this construct. Only sizes that are
7693 a power of two are currently allowed.
7695 All the basic integer types can be used as base types, both as signed
7696 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7697 @code{long long}.  In addition, @code{float} and @code{double} can be
7698 used to build floating-point vector types.
7700 Specifying a combination that is not valid for the current architecture
7701 causes GCC to synthesize the instructions using a narrower mode.
7702 For example, if you specify a variable of type @code{V4SI} and your
7703 architecture does not allow for this specific SIMD type, GCC
7704 produces code that uses 4 @code{SIs}.
7706 The types defined in this manner can be used with a subset of normal C
7707 operations.  Currently, GCC allows using the following operators
7708 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7710 The operations behave like C++ @code{valarrays}.  Addition is defined as
7711 the addition of the corresponding elements of the operands.  For
7712 example, in the code below, each of the 4 elements in @var{a} is
7713 added to the corresponding 4 elements in @var{b} and the resulting
7714 vector is stored in @var{c}.
7716 @smallexample
7717 typedef int v4si __attribute__ ((vector_size (16)));
7719 v4si a, b, c;
7721 c = a + b;
7722 @end smallexample
7724 Subtraction, multiplication, division, and the logical operations
7725 operate in a similar manner.  Likewise, the result of using the unary
7726 minus or complement operators on a vector type is a vector whose
7727 elements are the negative or complemented values of the corresponding
7728 elements in the operand.
7730 It is possible to use shifting operators @code{<<}, @code{>>} on
7731 integer-type vectors. The operation is defined as following: @code{@{a0,
7732 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7733 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7734 elements. 
7736 For convenience, it is allowed to use a binary vector operation
7737 where one operand is a scalar. In that case the compiler transforms
7738 the scalar operand into a vector where each element is the scalar from
7739 the operation. The transformation happens only if the scalar could be
7740 safely converted to the vector-element type.
7741 Consider the following code.
7743 @smallexample
7744 typedef int v4si __attribute__ ((vector_size (16)));
7746 v4si a, b, c;
7747 long l;
7749 a = b + 1;    /* a = b + @{1,1,1,1@}; */
7750 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
7752 a = l + a;    /* Error, cannot convert long to int. */
7753 @end smallexample
7755 Vectors can be subscripted as if the vector were an array with
7756 the same number of elements and base type.  Out of bound accesses
7757 invoke undefined behavior at run time.  Warnings for out of bound
7758 accesses for vector subscription can be enabled with
7759 @option{-Warray-bounds}.
7761 Vector comparison is supported with standard comparison
7762 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7763 vector expressions of integer-type or real-type. Comparison between
7764 integer-type vectors and real-type vectors are not supported.  The
7765 result of the comparison is a vector of the same width and number of
7766 elements as the comparison operands with a signed integral element
7767 type.
7769 Vectors are compared element-wise producing 0 when comparison is false
7770 and -1 (constant of the appropriate type where all bits are set)
7771 otherwise. Consider the following example.
7773 @smallexample
7774 typedef int v4si __attribute__ ((vector_size (16)));
7776 v4si a = @{1,2,3,4@};
7777 v4si b = @{3,2,1,4@};
7778 v4si c;
7780 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
7781 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
7782 @end smallexample
7784 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
7785 @code{b} and @code{c} are vectors of the same type and @code{a} is an
7786 integer vector with the same number of elements of the same size as @code{b}
7787 and @code{c}, computes all three arguments and creates a vector
7788 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
7789 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
7790 As in the case of binary operations, this syntax is also accepted when
7791 one of @code{b} or @code{c} is a scalar that is then transformed into a
7792 vector. If both @code{b} and @code{c} are scalars and the type of
7793 @code{true?b:c} has the same size as the element type of @code{a}, then
7794 @code{b} and @code{c} are converted to a vector type whose elements have
7795 this type and with the same number of elements as @code{a}.
7797 Vector shuffling is available using functions
7798 @code{__builtin_shuffle (vec, mask)} and
7799 @code{__builtin_shuffle (vec0, vec1, mask)}.
7800 Both functions construct a permutation of elements from one or two
7801 vectors and return a vector of the same type as the input vector(s).
7802 The @var{mask} is an integral vector with the same width (@var{W})
7803 and element count (@var{N}) as the output vector.
7805 The elements of the input vectors are numbered in memory ordering of
7806 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
7807 elements of @var{mask} are considered modulo @var{N} in the single-operand
7808 case and modulo @math{2*@var{N}} in the two-operand case.
7810 Consider the following example,
7812 @smallexample
7813 typedef int v4si __attribute__ ((vector_size (16)));
7815 v4si a = @{1,2,3,4@};
7816 v4si b = @{5,6,7,8@};
7817 v4si mask1 = @{0,1,1,3@};
7818 v4si mask2 = @{0,4,2,5@};
7819 v4si res;
7821 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
7822 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
7823 @end smallexample
7825 Note that @code{__builtin_shuffle} is intentionally semantically
7826 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7828 You can declare variables and use them in function calls and returns, as
7829 well as in assignments and some casts.  You can specify a vector type as
7830 a return type for a function.  Vector types can also be used as function
7831 arguments.  It is possible to cast from one vector type to another,
7832 provided they are of the same size (in fact, you can also cast vectors
7833 to and from other datatypes of the same size).
7835 You cannot operate between vectors of different lengths or different
7836 signedness without a cast.
7838 @node Offsetof
7839 @section Offsetof
7840 @findex __builtin_offsetof
7842 GCC implements for both C and C++ a syntactic extension to implement
7843 the @code{offsetof} macro.
7845 @smallexample
7846 primary:
7847         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7849 offsetof_member_designator:
7850           @code{identifier}
7851         | offsetof_member_designator "." @code{identifier}
7852         | offsetof_member_designator "[" @code{expr} "]"
7853 @end smallexample
7855 This extension is sufficient such that
7857 @smallexample
7858 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
7859 @end smallexample
7861 @noindent
7862 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
7863 may be dependent.  In either case, @var{member} may consist of a single
7864 identifier, or a sequence of member accesses and array references.
7866 @node __sync Builtins
7867 @section Legacy __sync Built-in Functions for Atomic Memory Access
7869 The following built-in functions
7870 are intended to be compatible with those described
7871 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7872 section 7.4.  As such, they depart from the normal GCC practice of using
7873 the @samp{__builtin_} prefix, and further that they are overloaded such that
7874 they work on multiple types.
7876 The definition given in the Intel documentation allows only for the use of
7877 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7878 counterparts.  GCC allows any integral scalar or pointer type that is
7879 1, 2, 4 or 8 bytes in length.
7881 Not all operations are supported by all target processors.  If a particular
7882 operation cannot be implemented on the target processor, a warning is
7883 generated and a call an external function is generated.  The external
7884 function carries the same name as the built-in version,
7885 with an additional suffix
7886 @samp{_@var{n}} where @var{n} is the size of the data type.
7888 @c ??? Should we have a mechanism to suppress this warning?  This is almost
7889 @c useful for implementing the operation under the control of an external
7890 @c mutex.
7892 In most cases, these built-in functions are considered a @dfn{full barrier}.
7893 That is,
7894 no memory operand is moved across the operation, either forward or
7895 backward.  Further, instructions are issued as necessary to prevent the
7896 processor from speculating loads across the operation and from queuing stores
7897 after the operation.
7899 All of the routines are described in the Intel documentation to take
7900 ``an optional list of variables protected by the memory barrier''.  It's
7901 not clear what is meant by that; it could mean that @emph{only} the
7902 following variables are protected, or it could mean that these variables
7903 should in addition be protected.  At present GCC ignores this list and
7904 protects all variables that are globally accessible.  If in the future
7905 we make some use of this list, an empty list will continue to mean all
7906 globally accessible variables.
7908 @table @code
7909 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
7910 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
7911 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
7912 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
7913 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
7914 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
7915 @findex __sync_fetch_and_add
7916 @findex __sync_fetch_and_sub
7917 @findex __sync_fetch_and_or
7918 @findex __sync_fetch_and_and
7919 @findex __sync_fetch_and_xor
7920 @findex __sync_fetch_and_nand
7921 These built-in functions perform the operation suggested by the name, and
7922 returns the value that had previously been in memory.  That is,
7924 @smallexample
7925 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
7926 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
7927 @end smallexample
7929 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
7930 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
7932 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
7933 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
7934 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
7935 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
7936 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
7937 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
7938 @findex __sync_add_and_fetch
7939 @findex __sync_sub_and_fetch
7940 @findex __sync_or_and_fetch
7941 @findex __sync_and_and_fetch
7942 @findex __sync_xor_and_fetch
7943 @findex __sync_nand_and_fetch
7944 These built-in functions perform the operation suggested by the name, and
7945 return the new value.  That is,
7947 @smallexample
7948 @{ *ptr @var{op}= value; return *ptr; @}
7949 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
7950 @end smallexample
7952 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
7953 as @code{*ptr = ~(*ptr & value)} instead of
7954 @code{*ptr = ~*ptr & value}.
7956 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7957 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7958 @findex __sync_bool_compare_and_swap
7959 @findex __sync_val_compare_and_swap
7960 These built-in functions perform an atomic compare and swap.
7961 That is, if the current
7962 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
7963 @code{*@var{ptr}}.
7965 The ``bool'' version returns true if the comparison is successful and
7966 @var{newval} is written.  The ``val'' version returns the contents
7967 of @code{*@var{ptr}} before the operation.
7969 @item __sync_synchronize (...)
7970 @findex __sync_synchronize
7971 This built-in function issues a full memory barrier.
7973 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
7974 @findex __sync_lock_test_and_set
7975 This built-in function, as described by Intel, is not a traditional test-and-set
7976 operation, but rather an atomic exchange operation.  It writes @var{value}
7977 into @code{*@var{ptr}}, and returns the previous contents of
7978 @code{*@var{ptr}}.
7980 Many targets have only minimal support for such locks, and do not support
7981 a full exchange operation.  In this case, a target may support reduced
7982 functionality here by which the @emph{only} valid value to store is the
7983 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
7984 is implementation defined.
7986 This built-in function is not a full barrier,
7987 but rather an @dfn{acquire barrier}.
7988 This means that references after the operation cannot move to (or be
7989 speculated to) before the operation, but previous memory stores may not
7990 be globally visible yet, and previous memory loads may not yet be
7991 satisfied.
7993 @item void __sync_lock_release (@var{type} *ptr, ...)
7994 @findex __sync_lock_release
7995 This built-in function releases the lock acquired by
7996 @code{__sync_lock_test_and_set}.
7997 Normally this means writing the constant 0 to @code{*@var{ptr}}.
7999 This built-in function is not a full barrier,
8000 but rather a @dfn{release barrier}.
8001 This means that all previous memory stores are globally visible, and all
8002 previous memory loads have been satisfied, but following memory reads
8003 are not prevented from being speculated to before the barrier.
8004 @end table
8006 @node __atomic Builtins
8007 @section Built-in functions for memory model aware atomic operations
8009 The following built-in functions approximately match the requirements for
8010 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8011 functions, but all also have a memory model parameter.  These are all
8012 identified by being prefixed with @samp{__atomic}, and most are overloaded
8013 such that they work with multiple types.
8015 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8016 bytes in length. 16-byte integral types are also allowed if
8017 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8019 Target architectures are encouraged to provide their own patterns for
8020 each of these built-in functions.  If no target is provided, the original 
8021 non-memory model set of @samp{__sync} atomic built-in functions are
8022 utilized, along with any required synchronization fences surrounding it in
8023 order to achieve the proper behavior.  Execution in this case is subject
8024 to the same restrictions as those built-in functions.
8026 If there is no pattern or mechanism to provide a lock free instruction
8027 sequence, a call is made to an external routine with the same parameters
8028 to be resolved at run time.
8030 The four non-arithmetic functions (load, store, exchange, and 
8031 compare_exchange) all have a generic version as well.  This generic
8032 version works on any data type.  If the data type size maps to one
8033 of the integral sizes that may have lock free support, the generic
8034 version utilizes the lock free built-in function.  Otherwise an
8035 external call is left to be resolved at run time.  This external call is
8036 the same format with the addition of a @samp{size_t} parameter inserted
8037 as the first parameter indicating the size of the object being pointed to.
8038 All objects must be the same size.
8040 There are 6 different memory models that can be specified.  These map
8041 to the same names in the C++11 standard.  Refer there or to the
8042 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8043 atomic synchronization} for more detailed definitions.  These memory
8044 models integrate both barriers to code motion as well as synchronization
8045 requirements with other threads. These are listed in approximately
8046 ascending order of strength. It is also possible to use target specific
8047 flags for memory model flags, like Hardware Lock Elision.
8049 @table  @code
8050 @item __ATOMIC_RELAXED
8051 No barriers or synchronization.
8052 @item __ATOMIC_CONSUME
8053 Data dependency only for both barrier and synchronization with another
8054 thread.
8055 @item __ATOMIC_ACQUIRE
8056 Barrier to hoisting of code and synchronizes with release (or stronger)
8057 semantic stores from another thread.
8058 @item __ATOMIC_RELEASE
8059 Barrier to sinking of code and synchronizes with acquire (or stronger)
8060 semantic loads from another thread.
8061 @item __ATOMIC_ACQ_REL
8062 Full barrier in both directions and synchronizes with acquire loads and
8063 release stores in another thread.
8064 @item __ATOMIC_SEQ_CST
8065 Full barrier in both directions and synchronizes with acquire loads and
8066 release stores in all threads.
8067 @end table
8069 When implementing patterns for these built-in functions, the memory model
8070 parameter can be ignored as long as the pattern implements the most
8071 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8072 execute correctly with this memory model but they may not execute as
8073 efficiently as they could with a more appropriate implementation of the
8074 relaxed requirements.
8076 Note that the C++11 standard allows for the memory model parameter to be
8077 determined at run time rather than at compile time.  These built-in
8078 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8079 than invoke a runtime library call or inline a switch statement.  This is
8080 standard compliant, safe, and the simplest approach for now.
8082 The memory model parameter is a signed int, but only the lower 8 bits are
8083 reserved for the memory model.  The remainder of the signed int is reserved
8084 for future use and should be 0.  Use of the predefined atomic values
8085 ensures proper usage.
8087 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8088 This built-in function implements an atomic load operation.  It returns the
8089 contents of @code{*@var{ptr}}.
8091 The valid memory model variants are
8092 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8093 and @code{__ATOMIC_CONSUME}.
8095 @end deftypefn
8097 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8098 This is the generic version of an atomic load.  It returns the
8099 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8101 @end deftypefn
8103 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8104 This built-in function implements an atomic store operation.  It writes 
8105 @code{@var{val}} into @code{*@var{ptr}}.  
8107 The valid memory model variants are
8108 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8110 @end deftypefn
8112 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8113 This is the generic version of an atomic store.  It stores the value
8114 of @code{*@var{val}} into @code{*@var{ptr}}.
8116 @end deftypefn
8118 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8119 This built-in function implements an atomic exchange operation.  It writes
8120 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8121 @code{*@var{ptr}}.
8123 The valid memory model variants are
8124 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8125 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8127 @end deftypefn
8129 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8130 This is the generic version of an atomic exchange.  It stores the
8131 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8132 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8134 @end deftypefn
8136 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memmodel, int failure_memmodel)
8137 This built-in function implements an atomic compare and exchange operation.
8138 This compares the contents of @code{*@var{ptr}} with the contents of
8139 @code{*@var{expected}} and if equal, writes @var{desired} into
8140 @code{*@var{ptr}}.  If they are not equal, the current contents of
8141 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8142 for weak compare_exchange, and false for the strong variation.  Many targets 
8143 only offer the strong variation and ignore the parameter.  When in doubt, use
8144 the strong variation.
8146 True is returned if @var{desired} is written into
8147 @code{*@var{ptr}} and the execution is considered to conform to the
8148 memory model specified by @var{success_memmodel}.  There are no
8149 restrictions on what memory model can be used here.
8151 False is returned otherwise, and the execution is considered to conform
8152 to @var{failure_memmodel}. This memory model cannot be
8153 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8154 stronger model than that specified by @var{success_memmodel}.
8156 @end deftypefn
8158 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memmodel, int failure_memmodel)
8159 This built-in function implements the generic version of
8160 @code{__atomic_compare_exchange}.  The function is virtually identical to
8161 @code{__atomic_compare_exchange_n}, except the desired value is also a
8162 pointer.
8164 @end deftypefn
8166 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8167 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8168 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8169 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8170 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8171 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8172 These built-in functions perform the operation suggested by the name, and
8173 return the result of the operation. That is,
8175 @smallexample
8176 @{ *ptr @var{op}= val; return *ptr; @}
8177 @end smallexample
8179 All memory models are valid.
8181 @end deftypefn
8183 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8184 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8185 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8186 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8187 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8188 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8189 These built-in functions perform the operation suggested by the name, and
8190 return the value that had previously been in @code{*@var{ptr}}.  That is,
8192 @smallexample
8193 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8194 @end smallexample
8196 All memory models are valid.
8198 @end deftypefn
8200 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8202 This built-in function performs an atomic test-and-set operation on
8203 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
8204 defined nonzero ``set'' value and the return value is @code{true} if and only
8205 if the previous contents were ``set''.
8206 It should be only used for operands of type @code{bool} or @code{char}. For 
8207 other types only part of the value may be set.
8209 All memory models are valid.
8211 @end deftypefn
8213 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8215 This built-in function performs an atomic clear operation on
8216 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
8217 It should be only used for operands of type @code{bool} or @code{char} and 
8218 in conjunction with @code{__atomic_test_and_set}.
8219 For other types it may only clear partially. If the type is not @code{bool}
8220 prefer using @code{__atomic_store}.
8222 The valid memory model variants are
8223 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8224 @code{__ATOMIC_RELEASE}.
8226 @end deftypefn
8228 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8230 This built-in function acts as a synchronization fence between threads
8231 based on the specified memory model.
8233 All memory orders are valid.
8235 @end deftypefn
8237 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8239 This built-in function acts as a synchronization fence between a thread
8240 and signal handlers based in the same thread.
8242 All memory orders are valid.
8244 @end deftypefn
8246 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
8248 This built-in function returns true if objects of @var{size} bytes always
8249 generate lock free atomic instructions for the target architecture.  
8250 @var{size} must resolve to a compile-time constant and the result also
8251 resolves to a compile-time constant.
8253 @var{ptr} is an optional pointer to the object that may be used to determine
8254 alignment.  A value of 0 indicates typical alignment should be used.  The 
8255 compiler may also ignore this parameter.
8257 @smallexample
8258 if (_atomic_always_lock_free (sizeof (long long), 0))
8259 @end smallexample
8261 @end deftypefn
8263 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8265 This built-in function returns true if objects of @var{size} bytes always
8266 generate lock free atomic instructions for the target architecture.  If
8267 it is not known to be lock free a call is made to a runtime routine named
8268 @code{__atomic_is_lock_free}.
8270 @var{ptr} is an optional pointer to the object that may be used to determine
8271 alignment.  A value of 0 indicates typical alignment should be used.  The 
8272 compiler may also ignore this parameter.
8273 @end deftypefn
8275 @node x86 specific memory model extensions for transactional memory
8276 @section x86 specific memory model extensions for transactional memory
8278 The i386 architecture supports additional memory ordering flags
8279 to mark lock critical sections for hardware lock elision. 
8280 These must be specified in addition to an existing memory model to 
8281 atomic intrinsics.
8283 @table @code
8284 @item __ATOMIC_HLE_ACQUIRE
8285 Start lock elision on a lock variable.
8286 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8287 @item __ATOMIC_HLE_RELEASE
8288 End lock elision on a lock variable.
8289 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8290 @end table
8292 When a lock acquire fails it is required for good performance to abort
8293 the transaction quickly. This can be done with a @code{_mm_pause}
8295 @smallexample
8296 #include <immintrin.h> // For _mm_pause
8298 int lockvar;
8300 /* Acquire lock with lock elision */
8301 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8302     _mm_pause(); /* Abort failed transaction */
8304 /* Free lock with lock elision */
8305 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8306 @end smallexample
8308 @node Object Size Checking
8309 @section Object Size Checking Built-in Functions
8310 @findex __builtin_object_size
8311 @findex __builtin___memcpy_chk
8312 @findex __builtin___mempcpy_chk
8313 @findex __builtin___memmove_chk
8314 @findex __builtin___memset_chk
8315 @findex __builtin___strcpy_chk
8316 @findex __builtin___stpcpy_chk
8317 @findex __builtin___strncpy_chk
8318 @findex __builtin___strcat_chk
8319 @findex __builtin___strncat_chk
8320 @findex __builtin___sprintf_chk
8321 @findex __builtin___snprintf_chk
8322 @findex __builtin___vsprintf_chk
8323 @findex __builtin___vsnprintf_chk
8324 @findex __builtin___printf_chk
8325 @findex __builtin___vprintf_chk
8326 @findex __builtin___fprintf_chk
8327 @findex __builtin___vfprintf_chk
8329 GCC implements a limited buffer overflow protection mechanism
8330 that can prevent some buffer overflow attacks.
8332 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8333 is a built-in construct that returns a constant number of bytes from
8334 @var{ptr} to the end of the object @var{ptr} pointer points to
8335 (if known at compile time).  @code{__builtin_object_size} never evaluates
8336 its arguments for side-effects.  If there are any side-effects in them, it
8337 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8338 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
8339 point to and all of them are known at compile time, the returned number
8340 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8341 0 and minimum if nonzero.  If it is not possible to determine which objects
8342 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8343 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8344 for @var{type} 2 or 3.
8346 @var{type} is an integer constant from 0 to 3.  If the least significant
8347 bit is clear, objects are whole variables, if it is set, a closest
8348 surrounding subobject is considered the object a pointer points to.
8349 The second bit determines if maximum or minimum of remaining bytes
8350 is computed.
8352 @smallexample
8353 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8354 char *p = &var.buf1[1], *q = &var.b;
8356 /* Here the object p points to is var.  */
8357 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8358 /* The subobject p points to is var.buf1.  */
8359 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8360 /* The object q points to is var.  */
8361 assert (__builtin_object_size (q, 0)
8362         == (char *) (&var + 1) - (char *) &var.b);
8363 /* The subobject q points to is var.b.  */
8364 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8365 @end smallexample
8366 @end deftypefn
8368 There are built-in functions added for many common string operation
8369 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8370 built-in is provided.  This built-in has an additional last argument,
8371 which is the number of bytes remaining in object the @var{dest}
8372 argument points to or @code{(size_t) -1} if the size is not known.
8374 The built-in functions are optimized into the normal string functions
8375 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8376 it is known at compile time that the destination object will not
8377 be overflown.  If the compiler can determine at compile time the
8378 object will be always overflown, it issues a warning.
8380 The intended use can be e.g.@:
8382 @smallexample
8383 #undef memcpy
8384 #define bos0(dest) __builtin_object_size (dest, 0)
8385 #define memcpy(dest, src, n) \
8386   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8388 char *volatile p;
8389 char buf[10];
8390 /* It is unknown what object p points to, so this is optimized
8391    into plain memcpy - no checking is possible.  */
8392 memcpy (p, "abcde", n);
8393 /* Destination is known and length too.  It is known at compile
8394    time there will be no overflow.  */
8395 memcpy (&buf[5], "abcde", 5);
8396 /* Destination is known, but the length is not known at compile time.
8397    This will result in __memcpy_chk call that can check for overflow
8398    at run time.  */
8399 memcpy (&buf[5], "abcde", n);
8400 /* Destination is known and it is known at compile time there will
8401    be overflow.  There will be a warning and __memcpy_chk call that
8402    will abort the program at run time.  */
8403 memcpy (&buf[6], "abcde", 5);
8404 @end smallexample
8406 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8407 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8408 @code{strcat} and @code{strncat}.
8410 There are also checking built-in functions for formatted output functions.
8411 @smallexample
8412 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8413 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8414                               const char *fmt, ...);
8415 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8416                               va_list ap);
8417 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8418                                const char *fmt, va_list ap);
8419 @end smallexample
8421 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8422 etc.@: functions and can contain implementation specific flags on what
8423 additional security measures the checking function might take, such as
8424 handling @code{%n} differently.
8426 The @var{os} argument is the object size @var{s} points to, like in the
8427 other built-in functions.  There is a small difference in the behavior
8428 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8429 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8430 the checking function is called with @var{os} argument set to
8431 @code{(size_t) -1}.
8433 In addition to this, there are checking built-in functions
8434 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8435 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8436 These have just one additional argument, @var{flag}, right before
8437 format string @var{fmt}.  If the compiler is able to optimize them to
8438 @code{fputc} etc.@: functions, it does, otherwise the checking function
8439 is called and the @var{flag} argument passed to it.
8441 @node Cilk Plus Builtins
8442 @section Cilk Plus C/C++ language extension Built-in Functions.
8444 GCC provides support for the following built-in reduction funtions if Cilk Plus
8445 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8447 @itemize @bullet
8448 @item __sec_implicit_index
8449 @item __sec_reduce
8450 @item __sec_reduce_add
8451 @item __sec_reduce_all_nonzero
8452 @item __sec_reduce_all_zero
8453 @item __sec_reduce_any_nonzero
8454 @item __sec_reduce_any_zero
8455 @item __sec_reduce_max
8456 @item __sec_reduce_min
8457 @item __sec_reduce_max_ind
8458 @item __sec_reduce_min_ind
8459 @item __sec_reduce_mul
8460 @item __sec_reduce_mutating
8461 @end itemize
8463 Further details and examples about these built-in functions are described 
8464 in the Cilk Plus language manual which can be found at 
8465 @uref{http://www.cilkplus.org}.
8467 @node Other Builtins
8468 @section Other Built-in Functions Provided by GCC
8469 @cindex built-in functions
8470 @findex __builtin_fpclassify
8471 @findex __builtin_isfinite
8472 @findex __builtin_isnormal
8473 @findex __builtin_isgreater
8474 @findex __builtin_isgreaterequal
8475 @findex __builtin_isinf_sign
8476 @findex __builtin_isless
8477 @findex __builtin_islessequal
8478 @findex __builtin_islessgreater
8479 @findex __builtin_isunordered
8480 @findex __builtin_powi
8481 @findex __builtin_powif
8482 @findex __builtin_powil
8483 @findex _Exit
8484 @findex _exit
8485 @findex abort
8486 @findex abs
8487 @findex acos
8488 @findex acosf
8489 @findex acosh
8490 @findex acoshf
8491 @findex acoshl
8492 @findex acosl
8493 @findex alloca
8494 @findex asin
8495 @findex asinf
8496 @findex asinh
8497 @findex asinhf
8498 @findex asinhl
8499 @findex asinl
8500 @findex atan
8501 @findex atan2
8502 @findex atan2f
8503 @findex atan2l
8504 @findex atanf
8505 @findex atanh
8506 @findex atanhf
8507 @findex atanhl
8508 @findex atanl
8509 @findex bcmp
8510 @findex bzero
8511 @findex cabs
8512 @findex cabsf
8513 @findex cabsl
8514 @findex cacos
8515 @findex cacosf
8516 @findex cacosh
8517 @findex cacoshf
8518 @findex cacoshl
8519 @findex cacosl
8520 @findex calloc
8521 @findex carg
8522 @findex cargf
8523 @findex cargl
8524 @findex casin
8525 @findex casinf
8526 @findex casinh
8527 @findex casinhf
8528 @findex casinhl
8529 @findex casinl
8530 @findex catan
8531 @findex catanf
8532 @findex catanh
8533 @findex catanhf
8534 @findex catanhl
8535 @findex catanl
8536 @findex cbrt
8537 @findex cbrtf
8538 @findex cbrtl
8539 @findex ccos
8540 @findex ccosf
8541 @findex ccosh
8542 @findex ccoshf
8543 @findex ccoshl
8544 @findex ccosl
8545 @findex ceil
8546 @findex ceilf
8547 @findex ceill
8548 @findex cexp
8549 @findex cexpf
8550 @findex cexpl
8551 @findex cimag
8552 @findex cimagf
8553 @findex cimagl
8554 @findex clog
8555 @findex clogf
8556 @findex clogl
8557 @findex conj
8558 @findex conjf
8559 @findex conjl
8560 @findex copysign
8561 @findex copysignf
8562 @findex copysignl
8563 @findex cos
8564 @findex cosf
8565 @findex cosh
8566 @findex coshf
8567 @findex coshl
8568 @findex cosl
8569 @findex cpow
8570 @findex cpowf
8571 @findex cpowl
8572 @findex cproj
8573 @findex cprojf
8574 @findex cprojl
8575 @findex creal
8576 @findex crealf
8577 @findex creall
8578 @findex csin
8579 @findex csinf
8580 @findex csinh
8581 @findex csinhf
8582 @findex csinhl
8583 @findex csinl
8584 @findex csqrt
8585 @findex csqrtf
8586 @findex csqrtl
8587 @findex ctan
8588 @findex ctanf
8589 @findex ctanh
8590 @findex ctanhf
8591 @findex ctanhl
8592 @findex ctanl
8593 @findex dcgettext
8594 @findex dgettext
8595 @findex drem
8596 @findex dremf
8597 @findex dreml
8598 @findex erf
8599 @findex erfc
8600 @findex erfcf
8601 @findex erfcl
8602 @findex erff
8603 @findex erfl
8604 @findex exit
8605 @findex exp
8606 @findex exp10
8607 @findex exp10f
8608 @findex exp10l
8609 @findex exp2
8610 @findex exp2f
8611 @findex exp2l
8612 @findex expf
8613 @findex expl
8614 @findex expm1
8615 @findex expm1f
8616 @findex expm1l
8617 @findex fabs
8618 @findex fabsf
8619 @findex fabsl
8620 @findex fdim
8621 @findex fdimf
8622 @findex fdiml
8623 @findex ffs
8624 @findex floor
8625 @findex floorf
8626 @findex floorl
8627 @findex fma
8628 @findex fmaf
8629 @findex fmal
8630 @findex fmax
8631 @findex fmaxf
8632 @findex fmaxl
8633 @findex fmin
8634 @findex fminf
8635 @findex fminl
8636 @findex fmod
8637 @findex fmodf
8638 @findex fmodl
8639 @findex fprintf
8640 @findex fprintf_unlocked
8641 @findex fputs
8642 @findex fputs_unlocked
8643 @findex frexp
8644 @findex frexpf
8645 @findex frexpl
8646 @findex fscanf
8647 @findex gamma
8648 @findex gammaf
8649 @findex gammal
8650 @findex gamma_r
8651 @findex gammaf_r
8652 @findex gammal_r
8653 @findex gettext
8654 @findex hypot
8655 @findex hypotf
8656 @findex hypotl
8657 @findex ilogb
8658 @findex ilogbf
8659 @findex ilogbl
8660 @findex imaxabs
8661 @findex index
8662 @findex isalnum
8663 @findex isalpha
8664 @findex isascii
8665 @findex isblank
8666 @findex iscntrl
8667 @findex isdigit
8668 @findex isgraph
8669 @findex islower
8670 @findex isprint
8671 @findex ispunct
8672 @findex isspace
8673 @findex isupper
8674 @findex iswalnum
8675 @findex iswalpha
8676 @findex iswblank
8677 @findex iswcntrl
8678 @findex iswdigit
8679 @findex iswgraph
8680 @findex iswlower
8681 @findex iswprint
8682 @findex iswpunct
8683 @findex iswspace
8684 @findex iswupper
8685 @findex iswxdigit
8686 @findex isxdigit
8687 @findex j0
8688 @findex j0f
8689 @findex j0l
8690 @findex j1
8691 @findex j1f
8692 @findex j1l
8693 @findex jn
8694 @findex jnf
8695 @findex jnl
8696 @findex labs
8697 @findex ldexp
8698 @findex ldexpf
8699 @findex ldexpl
8700 @findex lgamma
8701 @findex lgammaf
8702 @findex lgammal
8703 @findex lgamma_r
8704 @findex lgammaf_r
8705 @findex lgammal_r
8706 @findex llabs
8707 @findex llrint
8708 @findex llrintf
8709 @findex llrintl
8710 @findex llround
8711 @findex llroundf
8712 @findex llroundl
8713 @findex log
8714 @findex log10
8715 @findex log10f
8716 @findex log10l
8717 @findex log1p
8718 @findex log1pf
8719 @findex log1pl
8720 @findex log2
8721 @findex log2f
8722 @findex log2l
8723 @findex logb
8724 @findex logbf
8725 @findex logbl
8726 @findex logf
8727 @findex logl
8728 @findex lrint
8729 @findex lrintf
8730 @findex lrintl
8731 @findex lround
8732 @findex lroundf
8733 @findex lroundl
8734 @findex malloc
8735 @findex memchr
8736 @findex memcmp
8737 @findex memcpy
8738 @findex mempcpy
8739 @findex memset
8740 @findex modf
8741 @findex modff
8742 @findex modfl
8743 @findex nearbyint
8744 @findex nearbyintf
8745 @findex nearbyintl
8746 @findex nextafter
8747 @findex nextafterf
8748 @findex nextafterl
8749 @findex nexttoward
8750 @findex nexttowardf
8751 @findex nexttowardl
8752 @findex pow
8753 @findex pow10
8754 @findex pow10f
8755 @findex pow10l
8756 @findex powf
8757 @findex powl
8758 @findex printf
8759 @findex printf_unlocked
8760 @findex putchar
8761 @findex puts
8762 @findex remainder
8763 @findex remainderf
8764 @findex remainderl
8765 @findex remquo
8766 @findex remquof
8767 @findex remquol
8768 @findex rindex
8769 @findex rint
8770 @findex rintf
8771 @findex rintl
8772 @findex round
8773 @findex roundf
8774 @findex roundl
8775 @findex scalb
8776 @findex scalbf
8777 @findex scalbl
8778 @findex scalbln
8779 @findex scalblnf
8780 @findex scalblnf
8781 @findex scalbn
8782 @findex scalbnf
8783 @findex scanfnl
8784 @findex signbit
8785 @findex signbitf
8786 @findex signbitl
8787 @findex signbitd32
8788 @findex signbitd64
8789 @findex signbitd128
8790 @findex significand
8791 @findex significandf
8792 @findex significandl
8793 @findex sin
8794 @findex sincos
8795 @findex sincosf
8796 @findex sincosl
8797 @findex sinf
8798 @findex sinh
8799 @findex sinhf
8800 @findex sinhl
8801 @findex sinl
8802 @findex snprintf
8803 @findex sprintf
8804 @findex sqrt
8805 @findex sqrtf
8806 @findex sqrtl
8807 @findex sscanf
8808 @findex stpcpy
8809 @findex stpncpy
8810 @findex strcasecmp
8811 @findex strcat
8812 @findex strchr
8813 @findex strcmp
8814 @findex strcpy
8815 @findex strcspn
8816 @findex strdup
8817 @findex strfmon
8818 @findex strftime
8819 @findex strlen
8820 @findex strncasecmp
8821 @findex strncat
8822 @findex strncmp
8823 @findex strncpy
8824 @findex strndup
8825 @findex strpbrk
8826 @findex strrchr
8827 @findex strspn
8828 @findex strstr
8829 @findex tan
8830 @findex tanf
8831 @findex tanh
8832 @findex tanhf
8833 @findex tanhl
8834 @findex tanl
8835 @findex tgamma
8836 @findex tgammaf
8837 @findex tgammal
8838 @findex toascii
8839 @findex tolower
8840 @findex toupper
8841 @findex towlower
8842 @findex towupper
8843 @findex trunc
8844 @findex truncf
8845 @findex truncl
8846 @findex vfprintf
8847 @findex vfscanf
8848 @findex vprintf
8849 @findex vscanf
8850 @findex vsnprintf
8851 @findex vsprintf
8852 @findex vsscanf
8853 @findex y0
8854 @findex y0f
8855 @findex y0l
8856 @findex y1
8857 @findex y1f
8858 @findex y1l
8859 @findex yn
8860 @findex ynf
8861 @findex ynl
8863 GCC provides a large number of built-in functions other than the ones
8864 mentioned above.  Some of these are for internal use in the processing
8865 of exceptions or variable-length argument lists and are not
8866 documented here because they may change from time to time; we do not
8867 recommend general use of these functions.
8869 The remaining functions are provided for optimization purposes.
8871 @opindex fno-builtin
8872 GCC includes built-in versions of many of the functions in the standard
8873 C library.  The versions prefixed with @code{__builtin_} are always
8874 treated as having the same meaning as the C library function even if you
8875 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
8876 Many of these functions are only optimized in certain cases; if they are
8877 not optimized in a particular case, a call to the library function is
8878 emitted.
8880 @opindex ansi
8881 @opindex std
8882 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
8883 @option{-std=c99} or @option{-std=c11}), the functions
8884 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
8885 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
8886 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
8887 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
8888 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
8889 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
8890 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
8891 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
8892 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
8893 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
8894 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
8895 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
8896 @code{signbitd64}, @code{signbitd128}, @code{significandf},
8897 @code{significandl}, @code{significand}, @code{sincosf},
8898 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
8899 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
8900 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
8901 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
8902 @code{yn}
8903 may be handled as built-in functions.
8904 All these functions have corresponding versions
8905 prefixed with @code{__builtin_}, which may be used even in strict C90
8906 mode.
8908 The ISO C99 functions
8909 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
8910 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
8911 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
8912 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
8913 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
8914 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
8915 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
8916 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
8917 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
8918 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
8919 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
8920 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
8921 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
8922 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
8923 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
8924 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
8925 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
8926 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
8927 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
8928 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
8929 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
8930 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
8931 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
8932 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
8933 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
8934 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
8935 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
8936 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
8937 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
8938 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
8939 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
8940 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
8941 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
8942 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
8943 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
8944 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
8945 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
8946 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
8947 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
8948 are handled as built-in functions
8949 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8951 There are also built-in versions of the ISO C99 functions
8952 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
8953 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
8954 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
8955 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
8956 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
8957 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
8958 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
8959 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
8960 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
8961 that are recognized in any mode since ISO C90 reserves these names for
8962 the purpose to which ISO C99 puts them.  All these functions have
8963 corresponding versions prefixed with @code{__builtin_}.
8965 The ISO C94 functions
8966 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
8967 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
8968 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
8969 @code{towupper}
8970 are handled as built-in functions
8971 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8973 The ISO C90 functions
8974 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
8975 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
8976 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
8977 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
8978 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
8979 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
8980 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
8981 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
8982 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
8983 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
8984 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
8985 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
8986 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
8987 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
8988 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
8989 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
8990 are all recognized as built-in functions unless
8991 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
8992 is specified for an individual function).  All of these functions have
8993 corresponding versions prefixed with @code{__builtin_}.
8995 GCC provides built-in versions of the ISO C99 floating-point comparison
8996 macros that avoid raising exceptions for unordered operands.  They have
8997 the same names as the standard macros ( @code{isgreater},
8998 @code{isgreaterequal}, @code{isless}, @code{islessequal},
8999 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9000 prefixed.  We intend for a library implementor to be able to simply
9001 @code{#define} each standard macro to its built-in equivalent.
9002 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9003 @code{isinf_sign} and @code{isnormal} built-ins used with
9004 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
9005 built-in functions appear both with and without the @code{__builtin_} prefix.
9007 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9009 You can use the built-in function @code{__builtin_types_compatible_p} to
9010 determine whether two types are the same.
9012 This built-in function returns 1 if the unqualified versions of the
9013 types @var{type1} and @var{type2} (which are types, not expressions) are
9014 compatible, 0 otherwise.  The result of this built-in function can be
9015 used in integer constant expressions.
9017 This built-in function ignores top level qualifiers (e.g., @code{const},
9018 @code{volatile}).  For example, @code{int} is equivalent to @code{const
9019 int}.
9021 The type @code{int[]} and @code{int[5]} are compatible.  On the other
9022 hand, @code{int} and @code{char *} are not compatible, even if the size
9023 of their types, on the particular architecture are the same.  Also, the
9024 amount of pointer indirection is taken into account when determining
9025 similarity.  Consequently, @code{short *} is not similar to
9026 @code{short **}.  Furthermore, two types that are typedefed are
9027 considered compatible if their underlying types are compatible.
9029 An @code{enum} type is not considered to be compatible with another
9030 @code{enum} type even if both are compatible with the same integer
9031 type; this is what the C standard specifies.
9032 For example, @code{enum @{foo, bar@}} is not similar to
9033 @code{enum @{hot, dog@}}.
9035 You typically use this function in code whose execution varies
9036 depending on the arguments' types.  For example:
9038 @smallexample
9039 #define foo(x)                                                  \
9040   (@{                                                           \
9041     typeof (x) tmp = (x);                                       \
9042     if (__builtin_types_compatible_p (typeof (x), long double)) \
9043       tmp = foo_long_double (tmp);                              \
9044     else if (__builtin_types_compatible_p (typeof (x), double)) \
9045       tmp = foo_double (tmp);                                   \
9046     else if (__builtin_types_compatible_p (typeof (x), float))  \
9047       tmp = foo_float (tmp);                                    \
9048     else                                                        \
9049       abort ();                                                 \
9050     tmp;                                                        \
9051   @})
9052 @end smallexample
9054 @emph{Note:} This construct is only available for C@.
9056 @end deftypefn
9058 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9060 You can use the built-in function @code{__builtin_choose_expr} to
9061 evaluate code depending on the value of a constant expression.  This
9062 built-in function returns @var{exp1} if @var{const_exp}, which is an
9063 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
9065 This built-in function is analogous to the @samp{? :} operator in C,
9066 except that the expression returned has its type unaltered by promotion
9067 rules.  Also, the built-in function does not evaluate the expression
9068 that is not chosen.  For example, if @var{const_exp} evaluates to true,
9069 @var{exp2} is not evaluated even if it has side-effects.
9071 This built-in function can return an lvalue if the chosen argument is an
9072 lvalue.
9074 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9075 type.  Similarly, if @var{exp2} is returned, its return type is the same
9076 as @var{exp2}.
9078 Example:
9080 @smallexample
9081 #define foo(x)                                                    \
9082   __builtin_choose_expr (                                         \
9083     __builtin_types_compatible_p (typeof (x), double),            \
9084     foo_double (x),                                               \
9085     __builtin_choose_expr (                                       \
9086       __builtin_types_compatible_p (typeof (x), float),           \
9087       foo_float (x),                                              \
9088       /* @r{The void expression results in a compile-time error}  \
9089          @r{when assigning the result to something.}  */          \
9090       (void)0))
9091 @end smallexample
9093 @emph{Note:} This construct is only available for C@.  Furthermore, the
9094 unused expression (@var{exp1} or @var{exp2} depending on the value of
9095 @var{const_exp}) may still generate syntax errors.  This may change in
9096 future revisions.
9098 @end deftypefn
9100 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9102 The built-in function @code{__builtin_complex} is provided for use in
9103 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9104 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
9105 real binary floating-point type, and the result has the corresponding
9106 complex type with real and imaginary parts @var{real} and @var{imag}.
9107 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9108 infinities, NaNs and negative zeros are involved.
9110 @end deftypefn
9112 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9113 You can use the built-in function @code{__builtin_constant_p} to
9114 determine if a value is known to be constant at compile time and hence
9115 that GCC can perform constant-folding on expressions involving that
9116 value.  The argument of the function is the value to test.  The function
9117 returns the integer 1 if the argument is known to be a compile-time
9118 constant and 0 if it is not known to be a compile-time constant.  A
9119 return of 0 does not indicate that the value is @emph{not} a constant,
9120 but merely that GCC cannot prove it is a constant with the specified
9121 value of the @option{-O} option.
9123 You typically use this function in an embedded application where
9124 memory is a critical resource.  If you have some complex calculation,
9125 you may want it to be folded if it involves constants, but need to call
9126 a function if it does not.  For example:
9128 @smallexample
9129 #define Scale_Value(X)      \
9130   (__builtin_constant_p (X) \
9131   ? ((X) * SCALE + OFFSET) : Scale (X))
9132 @end smallexample
9134 You may use this built-in function in either a macro or an inline
9135 function.  However, if you use it in an inlined function and pass an
9136 argument of the function as the argument to the built-in, GCC 
9137 never returns 1 when you call the inline function with a string constant
9138 or compound literal (@pxref{Compound Literals}) and does not return 1
9139 when you pass a constant numeric value to the inline function unless you
9140 specify the @option{-O} option.
9142 You may also use @code{__builtin_constant_p} in initializers for static
9143 data.  For instance, you can write
9145 @smallexample
9146 static const int table[] = @{
9147    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9148    /* @r{@dots{}} */
9150 @end smallexample
9152 @noindent
9153 This is an acceptable initializer even if @var{EXPRESSION} is not a
9154 constant expression, including the case where
9155 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9156 folded to a constant but @var{EXPRESSION} contains operands that are
9157 not otherwise permitted in a static initializer (for example,
9158 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
9159 built-in in this case, because it has no opportunity to perform
9160 optimization.
9162 Previous versions of GCC did not accept this built-in in data
9163 initializers.  The earliest version where it is completely safe is
9164 3.0.1.
9165 @end deftypefn
9167 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9168 @opindex fprofile-arcs
9169 You may use @code{__builtin_expect} to provide the compiler with
9170 branch prediction information.  In general, you should prefer to
9171 use actual profile feedback for this (@option{-fprofile-arcs}), as
9172 programmers are notoriously bad at predicting how their programs
9173 actually perform.  However, there are applications in which this
9174 data is hard to collect.
9176 The return value is the value of @var{exp}, which should be an integral
9177 expression.  The semantics of the built-in are that it is expected that
9178 @var{exp} == @var{c}.  For example:
9180 @smallexample
9181 if (__builtin_expect (x, 0))
9182   foo ();
9183 @end smallexample
9185 @noindent
9186 indicates that we do not expect to call @code{foo}, since
9187 we expect @code{x} to be zero.  Since you are limited to integral
9188 expressions for @var{exp}, you should use constructions such as
9190 @smallexample
9191 if (__builtin_expect (ptr != NULL, 1))
9192   foo (*ptr);
9193 @end smallexample
9195 @noindent
9196 when testing pointer or floating-point values.
9197 @end deftypefn
9199 @deftypefn {Built-in Function} void __builtin_trap (void)
9200 This function causes the program to exit abnormally.  GCC implements
9201 this function by using a target-dependent mechanism (such as
9202 intentionally executing an illegal instruction) or by calling
9203 @code{abort}.  The mechanism used may vary from release to release so
9204 you should not rely on any particular implementation.
9205 @end deftypefn
9207 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9208 If control flow reaches the point of the @code{__builtin_unreachable},
9209 the program is undefined.  It is useful in situations where the
9210 compiler cannot deduce the unreachability of the code.
9212 One such case is immediately following an @code{asm} statement that
9213 either never terminates, or one that transfers control elsewhere
9214 and never returns.  In this example, without the
9215 @code{__builtin_unreachable}, GCC issues a warning that control
9216 reaches the end of a non-void function.  It also generates code
9217 to return after the @code{asm}.
9219 @smallexample
9220 int f (int c, int v)
9222   if (c)
9223     @{
9224       return v;
9225     @}
9226   else
9227     @{
9228       asm("jmp error_handler");
9229       __builtin_unreachable ();
9230     @}
9232 @end smallexample
9234 @noindent
9235 Because the @code{asm} statement unconditionally transfers control out
9236 of the function, control never reaches the end of the function
9237 body.  The @code{__builtin_unreachable} is in fact unreachable and
9238 communicates this fact to the compiler.
9240 Another use for @code{__builtin_unreachable} is following a call a
9241 function that never returns but that is not declared
9242 @code{__attribute__((noreturn))}, as in this example:
9244 @smallexample
9245 void function_that_never_returns (void);
9247 int g (int c)
9249   if (c)
9250     @{
9251       return 1;
9252     @}
9253   else
9254     @{
9255       function_that_never_returns ();
9256       __builtin_unreachable ();
9257     @}
9259 @end smallexample
9261 @end deftypefn
9263 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9264 This function returns its first argument, and allows the compiler
9265 to assume that the returned pointer is at least @var{align} bytes
9266 aligned.  This built-in can have either two or three arguments,
9267 if it has three, the third argument should have integer type, and
9268 if it is nonzero means misalignment offset.  For example:
9270 @smallexample
9271 void *x = __builtin_assume_aligned (arg, 16);
9272 @end smallexample
9274 @noindent
9275 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9276 16-byte aligned, while:
9278 @smallexample
9279 void *x = __builtin_assume_aligned (arg, 32, 8);
9280 @end smallexample
9282 @noindent
9283 means that the compiler can assume for @code{x}, set to @code{arg}, that
9284 @code{(char *) x - 8} is 32-byte aligned.
9285 @end deftypefn
9287 @deftypefn {Built-in Function} int __builtin_LINE ()
9288 This function is the equivalent to the preprocessor @code{__LINE__}
9289 macro and returns the line number of the invocation of the built-in.
9290 In a C++ default argument for a function @var{F}, it gets the line number of
9291 the call to @var{F}.
9292 @end deftypefn
9294 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9295 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9296 macro and returns the function name the invocation of the built-in is in.
9297 @end deftypefn
9299 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9300 This function is the equivalent to the preprocessor @code{__FILE__}
9301 macro and returns the file name the invocation of the built-in is in.
9302 In a C++ default argument for a function @var{F}, it gets the file name of
9303 the call to @var{F}.
9304 @end deftypefn
9306 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9307 This function is used to flush the processor's instruction cache for
9308 the region of memory between @var{begin} inclusive and @var{end}
9309 exclusive.  Some targets require that the instruction cache be
9310 flushed, after modifying memory containing code, in order to obtain
9311 deterministic behavior.
9313 If the target does not require instruction cache flushes,
9314 @code{__builtin___clear_cache} has no effect.  Otherwise either
9315 instructions are emitted in-line to clear the instruction cache or a
9316 call to the @code{__clear_cache} function in libgcc is made.
9317 @end deftypefn
9319 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9320 This function is used to minimize cache-miss latency by moving data into
9321 a cache before it is accessed.
9322 You can insert calls to @code{__builtin_prefetch} into code for which
9323 you know addresses of data in memory that is likely to be accessed soon.
9324 If the target supports them, data prefetch instructions are generated.
9325 If the prefetch is done early enough before the access then the data will
9326 be in the cache by the time it is accessed.
9328 The value of @var{addr} is the address of the memory to prefetch.
9329 There are two optional arguments, @var{rw} and @var{locality}.
9330 The value of @var{rw} is a compile-time constant one or zero; one
9331 means that the prefetch is preparing for a write to the memory address
9332 and zero, the default, means that the prefetch is preparing for a read.
9333 The value @var{locality} must be a compile-time constant integer between
9334 zero and three.  A value of zero means that the data has no temporal
9335 locality, so it need not be left in the cache after the access.  A value
9336 of three means that the data has a high degree of temporal locality and
9337 should be left in all levels of cache possible.  Values of one and two
9338 mean, respectively, a low or moderate degree of temporal locality.  The
9339 default is three.
9341 @smallexample
9342 for (i = 0; i < n; i++)
9343   @{
9344     a[i] = a[i] + b[i];
9345     __builtin_prefetch (&a[i+j], 1, 1);
9346     __builtin_prefetch (&b[i+j], 0, 1);
9347     /* @r{@dots{}} */
9348   @}
9349 @end smallexample
9351 Data prefetch does not generate faults if @var{addr} is invalid, but
9352 the address expression itself must be valid.  For example, a prefetch
9353 of @code{p->next} does not fault if @code{p->next} is not a valid
9354 address, but evaluation faults if @code{p} is not a valid address.
9356 If the target does not support data prefetch, the address expression
9357 is evaluated if it includes side effects but no other code is generated
9358 and GCC does not issue a warning.
9359 @end deftypefn
9361 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9362 Returns a positive infinity, if supported by the floating-point format,
9363 else @code{DBL_MAX}.  This function is suitable for implementing the
9364 ISO C macro @code{HUGE_VAL}.
9365 @end deftypefn
9367 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9368 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9369 @end deftypefn
9371 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9372 Similar to @code{__builtin_huge_val}, except the return
9373 type is @code{long double}.
9374 @end deftypefn
9376 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9377 This built-in implements the C99 fpclassify functionality.  The first
9378 five int arguments should be the target library's notion of the
9379 possible FP classes and are used for return values.  They must be
9380 constant values and they must appear in this order: @code{FP_NAN},
9381 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9382 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
9383 to classify.  GCC treats the last argument as type-generic, which
9384 means it does not do default promotion from float to double.
9385 @end deftypefn
9387 @deftypefn {Built-in Function} double __builtin_inf (void)
9388 Similar to @code{__builtin_huge_val}, except a warning is generated
9389 if the target floating-point format does not support infinities.
9390 @end deftypefn
9392 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9393 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9394 @end deftypefn
9396 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9397 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9398 @end deftypefn
9400 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9401 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9402 @end deftypefn
9404 @deftypefn {Built-in Function} float __builtin_inff (void)
9405 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9406 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9407 @end deftypefn
9409 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9410 Similar to @code{__builtin_inf}, except the return
9411 type is @code{long double}.
9412 @end deftypefn
9414 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9415 Similar to @code{isinf}, except the return value is -1 for
9416 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9417 Note while the parameter list is an
9418 ellipsis, this function only accepts exactly one floating-point
9419 argument.  GCC treats this parameter as type-generic, which means it
9420 does not do default promotion from float to double.
9421 @end deftypefn
9423 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9424 This is an implementation of the ISO C99 function @code{nan}.
9426 Since ISO C99 defines this function in terms of @code{strtod}, which we
9427 do not implement, a description of the parsing is in order.  The string
9428 is parsed as by @code{strtol}; that is, the base is recognized by
9429 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
9430 in the significand such that the least significant bit of the number
9431 is at the least significant bit of the significand.  The number is
9432 truncated to fit the significand field provided.  The significand is
9433 forced to be a quiet NaN@.
9435 This function, if given a string literal all of which would have been
9436 consumed by @code{strtol}, is evaluated early enough that it is considered a
9437 compile-time constant.
9438 @end deftypefn
9440 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9441 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9442 @end deftypefn
9444 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9445 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9446 @end deftypefn
9448 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9449 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9450 @end deftypefn
9452 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9453 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9454 @end deftypefn
9456 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9457 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9458 @end deftypefn
9460 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9461 Similar to @code{__builtin_nan}, except the significand is forced
9462 to be a signaling NaN@.  The @code{nans} function is proposed by
9463 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9464 @end deftypefn
9466 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9467 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9468 @end deftypefn
9470 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9471 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9472 @end deftypefn
9474 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9475 Returns one plus the index of the least significant 1-bit of @var{x}, or
9476 if @var{x} is zero, returns zero.
9477 @end deftypefn
9479 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9480 Returns the number of leading 0-bits in @var{x}, starting at the most
9481 significant bit position.  If @var{x} is 0, the result is undefined.
9482 @end deftypefn
9484 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9485 Returns the number of trailing 0-bits in @var{x}, starting at the least
9486 significant bit position.  If @var{x} is 0, the result is undefined.
9487 @end deftypefn
9489 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9490 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9491 number of bits following the most significant bit that are identical
9492 to it.  There are no special cases for 0 or other values. 
9493 @end deftypefn
9495 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9496 Returns the number of 1-bits in @var{x}.
9497 @end deftypefn
9499 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9500 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9501 modulo 2.
9502 @end deftypefn
9504 @deftypefn {Built-in Function} int __builtin_ffsl (long)
9505 Similar to @code{__builtin_ffs}, except the argument type is
9506 @code{long}.
9507 @end deftypefn
9509 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9510 Similar to @code{__builtin_clz}, except the argument type is
9511 @code{unsigned long}.
9512 @end deftypefn
9514 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9515 Similar to @code{__builtin_ctz}, except the argument type is
9516 @code{unsigned long}.
9517 @end deftypefn
9519 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
9520 Similar to @code{__builtin_clrsb}, except the argument type is
9521 @code{long}.
9522 @end deftypefn
9524 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
9525 Similar to @code{__builtin_popcount}, except the argument type is
9526 @code{unsigned long}.
9527 @end deftypefn
9529 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
9530 Similar to @code{__builtin_parity}, except the argument type is
9531 @code{unsigned long}.
9532 @end deftypefn
9534 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
9535 Similar to @code{__builtin_ffs}, except the argument type is
9536 @code{long long}.
9537 @end deftypefn
9539 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
9540 Similar to @code{__builtin_clz}, except the argument type is
9541 @code{unsigned long long}.
9542 @end deftypefn
9544 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
9545 Similar to @code{__builtin_ctz}, except the argument type is
9546 @code{unsigned long long}.
9547 @end deftypefn
9549 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
9550 Similar to @code{__builtin_clrsb}, except the argument type is
9551 @code{long long}.
9552 @end deftypefn
9554 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
9555 Similar to @code{__builtin_popcount}, except the argument type is
9556 @code{unsigned long long}.
9557 @end deftypefn
9559 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
9560 Similar to @code{__builtin_parity}, except the argument type is
9561 @code{unsigned long long}.
9562 @end deftypefn
9564 @deftypefn {Built-in Function} double __builtin_powi (double, int)
9565 Returns the first argument raised to the power of the second.  Unlike the
9566 @code{pow} function no guarantees about precision and rounding are made.
9567 @end deftypefn
9569 @deftypefn {Built-in Function} float __builtin_powif (float, int)
9570 Similar to @code{__builtin_powi}, except the argument and return types
9571 are @code{float}.
9572 @end deftypefn
9574 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
9575 Similar to @code{__builtin_powi}, except the argument and return types
9576 are @code{long double}.
9577 @end deftypefn
9579 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
9580 Returns @var{x} with the order of the bytes reversed; for example,
9581 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
9582 exactly 8 bits.
9583 @end deftypefn
9585 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
9586 Similar to @code{__builtin_bswap16}, except the argument and return types
9587 are 32 bit.
9588 @end deftypefn
9590 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
9591 Similar to @code{__builtin_bswap32}, except the argument and return types
9592 are 64 bit.
9593 @end deftypefn
9595 @node Target Builtins
9596 @section Built-in Functions Specific to Particular Target Machines
9598 On some target machines, GCC supports many built-in functions specific
9599 to those machines.  Generally these generate calls to specific machine
9600 instructions, but allow the compiler to schedule those calls.
9602 @menu
9603 * Alpha Built-in Functions::
9604 * Altera Nios II Built-in Functions::
9605 * ARC Built-in Functions::
9606 * ARC SIMD Built-in Functions::
9607 * ARM iWMMXt Built-in Functions::
9608 * ARM NEON Intrinsics::
9609 * ARM ACLE Intrinsics::
9610 * AVR Built-in Functions::
9611 * Blackfin Built-in Functions::
9612 * FR-V Built-in Functions::
9613 * X86 Built-in Functions::
9614 * X86 transactional memory intrinsics::
9615 * MIPS DSP Built-in Functions::
9616 * MIPS Paired-Single Support::
9617 * MIPS Loongson Built-in Functions::
9618 * Other MIPS Built-in Functions::
9619 * MSP430 Built-in Functions::
9620 * NDS32 Built-in Functions::
9621 * picoChip Built-in Functions::
9622 * PowerPC Built-in Functions::
9623 * PowerPC AltiVec/VSX Built-in Functions::
9624 * PowerPC Hardware Transactional Memory Built-in Functions::
9625 * RX Built-in Functions::
9626 * S/390 System z Built-in Functions::
9627 * SH Built-in Functions::
9628 * SPARC VIS Built-in Functions::
9629 * SPU Built-in Functions::
9630 * TI C6X Built-in Functions::
9631 * TILE-Gx Built-in Functions::
9632 * TILEPro Built-in Functions::
9633 @end menu
9635 @node Alpha Built-in Functions
9636 @subsection Alpha Built-in Functions
9638 These built-in functions are available for the Alpha family of
9639 processors, depending on the command-line switches used.
9641 The following built-in functions are always available.  They
9642 all generate the machine instruction that is part of the name.
9644 @smallexample
9645 long __builtin_alpha_implver (void)
9646 long __builtin_alpha_rpcc (void)
9647 long __builtin_alpha_amask (long)
9648 long __builtin_alpha_cmpbge (long, long)
9649 long __builtin_alpha_extbl (long, long)
9650 long __builtin_alpha_extwl (long, long)
9651 long __builtin_alpha_extll (long, long)
9652 long __builtin_alpha_extql (long, long)
9653 long __builtin_alpha_extwh (long, long)
9654 long __builtin_alpha_extlh (long, long)
9655 long __builtin_alpha_extqh (long, long)
9656 long __builtin_alpha_insbl (long, long)
9657 long __builtin_alpha_inswl (long, long)
9658 long __builtin_alpha_insll (long, long)
9659 long __builtin_alpha_insql (long, long)
9660 long __builtin_alpha_inswh (long, long)
9661 long __builtin_alpha_inslh (long, long)
9662 long __builtin_alpha_insqh (long, long)
9663 long __builtin_alpha_mskbl (long, long)
9664 long __builtin_alpha_mskwl (long, long)
9665 long __builtin_alpha_mskll (long, long)
9666 long __builtin_alpha_mskql (long, long)
9667 long __builtin_alpha_mskwh (long, long)
9668 long __builtin_alpha_msklh (long, long)
9669 long __builtin_alpha_mskqh (long, long)
9670 long __builtin_alpha_umulh (long, long)
9671 long __builtin_alpha_zap (long, long)
9672 long __builtin_alpha_zapnot (long, long)
9673 @end smallexample
9675 The following built-in functions are always with @option{-mmax}
9676 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
9677 later.  They all generate the machine instruction that is part
9678 of the name.
9680 @smallexample
9681 long __builtin_alpha_pklb (long)
9682 long __builtin_alpha_pkwb (long)
9683 long __builtin_alpha_unpkbl (long)
9684 long __builtin_alpha_unpkbw (long)
9685 long __builtin_alpha_minub8 (long, long)
9686 long __builtin_alpha_minsb8 (long, long)
9687 long __builtin_alpha_minuw4 (long, long)
9688 long __builtin_alpha_minsw4 (long, long)
9689 long __builtin_alpha_maxub8 (long, long)
9690 long __builtin_alpha_maxsb8 (long, long)
9691 long __builtin_alpha_maxuw4 (long, long)
9692 long __builtin_alpha_maxsw4 (long, long)
9693 long __builtin_alpha_perr (long, long)
9694 @end smallexample
9696 The following built-in functions are always with @option{-mcix}
9697 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
9698 later.  They all generate the machine instruction that is part
9699 of the name.
9701 @smallexample
9702 long __builtin_alpha_cttz (long)
9703 long __builtin_alpha_ctlz (long)
9704 long __builtin_alpha_ctpop (long)
9705 @end smallexample
9707 The following built-in functions are available on systems that use the OSF/1
9708 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
9709 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
9710 @code{rdval} and @code{wrval}.
9712 @smallexample
9713 void *__builtin_thread_pointer (void)
9714 void __builtin_set_thread_pointer (void *)
9715 @end smallexample
9717 @node Altera Nios II Built-in Functions
9718 @subsection Altera Nios II Built-in Functions
9720 These built-in functions are available for the Altera Nios II
9721 family of processors.
9723 The following built-in functions are always available.  They
9724 all generate the machine instruction that is part of the name.
9726 @example
9727 int __builtin_ldbio (volatile const void *)
9728 int __builtin_ldbuio (volatile const void *)
9729 int __builtin_ldhio (volatile const void *)
9730 int __builtin_ldhuio (volatile const void *)
9731 int __builtin_ldwio (volatile const void *)
9732 void __builtin_stbio (volatile void *, int)
9733 void __builtin_sthio (volatile void *, int)
9734 void __builtin_stwio (volatile void *, int)
9735 void __builtin_sync (void)
9736 int __builtin_rdctl (int) 
9737 void __builtin_wrctl (int, int)
9738 @end example
9740 The following built-in functions are always available.  They
9741 all generate a Nios II Custom Instruction. The name of the
9742 function represents the types that the function takes and
9743 returns. The letter before the @code{n} is the return type
9744 or void if absent. The @code{n} represents the first parameter
9745 to all the custom instructions, the custom instruction number.
9746 The two letters after the @code{n} represent the up to two
9747 parameters to the function.
9749 The letters represent the following data types:
9750 @table @code
9751 @item <no letter>
9752 @code{void} for return type and no parameter for parameter types.
9754 @item i
9755 @code{int} for return type and parameter type
9757 @item f
9758 @code{float} for return type and parameter type
9760 @item p
9761 @code{void *} for return type and parameter type
9763 @end table
9765 And the function names are:
9766 @example
9767 void __builtin_custom_n (void)
9768 void __builtin_custom_ni (int)
9769 void __builtin_custom_nf (float)
9770 void __builtin_custom_np (void *)
9771 void __builtin_custom_nii (int, int)
9772 void __builtin_custom_nif (int, float)
9773 void __builtin_custom_nip (int, void *)
9774 void __builtin_custom_nfi (float, int)
9775 void __builtin_custom_nff (float, float)
9776 void __builtin_custom_nfp (float, void *)
9777 void __builtin_custom_npi (void *, int)
9778 void __builtin_custom_npf (void *, float)
9779 void __builtin_custom_npp (void *, void *)
9780 int __builtin_custom_in (void)
9781 int __builtin_custom_ini (int)
9782 int __builtin_custom_inf (float)
9783 int __builtin_custom_inp (void *)
9784 int __builtin_custom_inii (int, int)
9785 int __builtin_custom_inif (int, float)
9786 int __builtin_custom_inip (int, void *)
9787 int __builtin_custom_infi (float, int)
9788 int __builtin_custom_inff (float, float)
9789 int __builtin_custom_infp (float, void *)
9790 int __builtin_custom_inpi (void *, int)
9791 int __builtin_custom_inpf (void *, float)
9792 int __builtin_custom_inpp (void *, void *)
9793 float __builtin_custom_fn (void)
9794 float __builtin_custom_fni (int)
9795 float __builtin_custom_fnf (float)
9796 float __builtin_custom_fnp (void *)
9797 float __builtin_custom_fnii (int, int)
9798 float __builtin_custom_fnif (int, float)
9799 float __builtin_custom_fnip (int, void *)
9800 float __builtin_custom_fnfi (float, int)
9801 float __builtin_custom_fnff (float, float)
9802 float __builtin_custom_fnfp (float, void *)
9803 float __builtin_custom_fnpi (void *, int)
9804 float __builtin_custom_fnpf (void *, float)
9805 float __builtin_custom_fnpp (void *, void *)
9806 void * __builtin_custom_pn (void)
9807 void * __builtin_custom_pni (int)
9808 void * __builtin_custom_pnf (float)
9809 void * __builtin_custom_pnp (void *)
9810 void * __builtin_custom_pnii (int, int)
9811 void * __builtin_custom_pnif (int, float)
9812 void * __builtin_custom_pnip (int, void *)
9813 void * __builtin_custom_pnfi (float, int)
9814 void * __builtin_custom_pnff (float, float)
9815 void * __builtin_custom_pnfp (float, void *)
9816 void * __builtin_custom_pnpi (void *, int)
9817 void * __builtin_custom_pnpf (void *, float)
9818 void * __builtin_custom_pnpp (void *, void *)
9819 @end example
9821 @node ARC Built-in Functions
9822 @subsection ARC Built-in Functions
9824 The following built-in functions are provided for ARC targets.  The
9825 built-ins generate the corresponding assembly instructions.  In the
9826 examples given below, the generated code often requires an operand or
9827 result to be in a register.  Where necessary further code will be
9828 generated to ensure this is true, but for brevity this is not
9829 described in each case.
9831 @emph{Note:} Using a built-in to generate an instruction not supported
9832 by a target may cause problems. At present the compiler is not
9833 guaranteed to detect such misuse, and as a result an internal compiler
9834 error may be generated.
9836 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
9837 Return 1 if @var{val} is known to have the byte alignment given
9838 by @var{alignval}, otherwise return 0.
9839 Note that this is different from
9840 @smallexample
9841 __alignof__(*(char *)@var{val}) >= alignval
9842 @end smallexample
9843 because __alignof__ sees only the type of the dereference, whereas
9844 __builtin_arc_align uses alignment information from the pointer
9845 as well as from the pointed-to type.
9846 The information available will depend on optimization level.
9847 @end deftypefn
9849 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
9850 Generates
9851 @example
9853 @end example
9854 @end deftypefn
9856 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
9857 The operand is the number of a register to be read.  Generates:
9858 @example
9859 mov  @var{dest}, r@var{regno}
9860 @end example
9861 where the value in @var{dest} will be the result returned from the
9862 built-in.
9863 @end deftypefn
9865 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
9866 The first operand is the number of a register to be written, the
9867 second operand is a compile time constant to write into that
9868 register.  Generates:
9869 @example
9870 mov  r@var{regno}, @var{val}
9871 @end example
9872 @end deftypefn
9874 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
9875 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
9876 Generates:
9877 @example
9878 divaw  @var{dest}, @var{a}, @var{b}
9879 @end example
9880 where the value in @var{dest} will be the result returned from the
9881 built-in.
9882 @end deftypefn
9884 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
9885 Generates
9886 @example
9887 flag  @var{a}
9888 @end example
9889 @end deftypefn
9891 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
9892 The operand, @var{auxv}, is the address of an auxiliary register and
9893 must be a compile time constant.  Generates:
9894 @example
9895 lr  @var{dest}, [@var{auxr}]
9896 @end example
9897 Where the value in @var{dest} will be the result returned from the
9898 built-in.
9899 @end deftypefn
9901 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
9902 Only available with @option{-mmul64}.  Generates:
9903 @example
9904 mul64  @var{a}, @var{b}
9905 @end example
9906 @end deftypefn
9908 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
9909 Only available with @option{-mmul64}.  Generates:
9910 @example
9911 mulu64  @var{a}, @var{b}
9912 @end example
9913 @end deftypefn
9915 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
9916 Generates:
9917 @example
9919 @end example
9920 @end deftypefn
9922 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
9923 Only valid if the @samp{norm} instruction is available through the
9924 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
9925 Generates:
9926 @example
9927 norm  @var{dest}, @var{src}
9928 @end example
9929 Where the value in @var{dest} will be the result returned from the
9930 built-in.
9931 @end deftypefn
9933 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
9934 Only valid if the @samp{normw} instruction is available through the
9935 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
9936 Generates:
9937 @example
9938 normw  @var{dest}, @var{src}
9939 @end example
9940 Where the value in @var{dest} will be the result returned from the
9941 built-in.
9942 @end deftypefn
9944 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
9945 Generates:
9946 @example
9947 rtie
9948 @end example
9949 @end deftypefn
9951 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
9952 Generates:
9953 @example
9954 sleep  @var{a}
9955 @end example
9956 @end deftypefn
9958 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
9959 The first argument, @var{auxv}, is the address of an auxiliary
9960 register, the second argument, @var{val}, is a compile time constant
9961 to be written to the register.  Generates:
9962 @example
9963 sr  @var{auxr}, [@var{val}]
9964 @end example
9965 @end deftypefn
9967 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
9968 Only valid with @option{-mswap}.  Generates:
9969 @example
9970 swap  @var{dest}, @var{src}
9971 @end example
9972 Where the value in @var{dest} will be the result returned from the
9973 built-in.
9974 @end deftypefn
9976 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
9977 Generates:
9978 @example
9980 @end example
9981 @end deftypefn
9983 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
9984 Only available with @option{-mcpu=ARC700}.  Generates:
9985 @example
9986 sync
9987 @end example
9988 @end deftypefn
9990 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
9991 Only available with @option{-mcpu=ARC700}.  Generates:
9992 @example
9993 trap_s  @var{c}
9994 @end example
9995 @end deftypefn
9997 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
9998 Only available with @option{-mcpu=ARC700}.  Generates:
9999 @example
10000 unimp_s
10001 @end example
10002 @end deftypefn
10004 The instructions generated by the following builtins are not
10005 considered as candidates for scheduling.  They are not moved around by
10006 the compiler during scheduling, and thus can be expected to appear
10007 where they are put in the C code:
10008 @example
10009 __builtin_arc_brk()
10010 __builtin_arc_core_read()
10011 __builtin_arc_core_write()
10012 __builtin_arc_flag()
10013 __builtin_arc_lr()
10014 __builtin_arc_sleep()
10015 __builtin_arc_sr()
10016 __builtin_arc_swi()
10017 @end example
10019 @node ARC SIMD Built-in Functions
10020 @subsection ARC SIMD Built-in Functions
10022 SIMD builtins provided by the compiler can be used to generate the
10023 vector instructions.  This section describes the available builtins
10024 and their usage in programs.  With the @option{-msimd} option, the
10025 compiler provides 128-bit vector types, which can be specified using
10026 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
10027 can be included to use the following predefined types:
10028 @example
10029 typedef int __v4si   __attribute__((vector_size(16)));
10030 typedef short __v8hi __attribute__((vector_size(16)));
10031 @end example
10033 These types can be used to define 128-bit variables.  The built-in
10034 functions listed in the following section can be used on these
10035 variables to generate the vector operations.
10037 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10038 @file{arc-simd.h} also provides equivalent macros called
10039 @code{_@var{someinsn}} that can be used for programming ease and
10040 improved readability.  The following macros for DMA control are also
10041 provided:
10042 @example
10043 #define _setup_dma_in_channel_reg _vdiwr
10044 #define _setup_dma_out_channel_reg _vdowr
10045 @end example
10047 The following is a complete list of all the SIMD built-ins provided
10048 for ARC, grouped by calling signature.
10050 The following take two @code{__v8hi} arguments and return a
10051 @code{__v8hi} result:
10052 @example
10053 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10054 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10055 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10056 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10057 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10058 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10059 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10060 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10061 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10062 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10063 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10064 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10065 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10066 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10067 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10068 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10069 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10070 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10071 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10072 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10073 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10074 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10075 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10076 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10077 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10078 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10079 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10080 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10081 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10082 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10083 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10084 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10085 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10086 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10087 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10088 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10089 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10090 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10091 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10092 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10093 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10094 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10095 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10096 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10097 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10098 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10099 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10100 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10101 @end example
10103 The following take one @code{__v8hi} and one @code{int} argument and return a
10104 @code{__v8hi} result:
10106 @example
10107 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10108 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10109 __v8hi __builtin_arc_vbminw (__v8hi, int)
10110 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10111 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10112 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10113 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10114 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10115 @end example
10117 The following take one @code{__v8hi} argument and one @code{int} argument which
10118 must be a 3-bit compile time constant indicating a register number
10119 I0-I7.  They return a @code{__v8hi} result.
10120 @example
10121 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10122 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10123 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10124 @end example
10126 The following take one @code{__v8hi} argument and one @code{int}
10127 argument which must be a 6-bit compile time constant.  They return a
10128 @code{__v8hi} result.
10129 @example
10130 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10131 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10132 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10133 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10134 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10135 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10136 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10137 @end example
10139 The following take one @code{__v8hi} argument and one @code{int} argument which
10140 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10141 result.
10142 @example
10143 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10144 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10145 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10146 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10147 @end example
10149 The following take two @code{int} arguments, the second of which which
10150 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10151 result:
10152 @example
10153 __v8hi __builtin_arc_vmovaw (int, const int)
10154 __v8hi __builtin_arc_vmovw (int, const int)
10155 __v8hi __builtin_arc_vmovzw (int, const int)
10156 @end example
10158 The following take a single @code{__v8hi} argument and return a
10159 @code{__v8hi} result:
10160 @example
10161 __v8hi __builtin_arc_vabsaw (__v8hi)
10162 __v8hi __builtin_arc_vabsw (__v8hi)
10163 __v8hi __builtin_arc_vaddsuw (__v8hi)
10164 __v8hi __builtin_arc_vexch1 (__v8hi)
10165 __v8hi __builtin_arc_vexch2 (__v8hi)
10166 __v8hi __builtin_arc_vexch4 (__v8hi)
10167 __v8hi __builtin_arc_vsignw (__v8hi)
10168 __v8hi __builtin_arc_vupbaw (__v8hi)
10169 __v8hi __builtin_arc_vupbw (__v8hi)
10170 __v8hi __builtin_arc_vupsbaw (__v8hi)
10171 __v8hi __builtin_arc_vupsbw (__v8hi)
10172 @end example
10174 The followign take two @code{int} arguments and return no result:
10175 @example
10176 void __builtin_arc_vdirun (int, int)
10177 void __builtin_arc_vdorun (int, int)
10178 @end example
10180 The following take two @code{int} arguments and return no result.  The
10181 first argument must a 3-bit compile time constant indicating one of
10182 the DR0-DR7 DMA setup channels:
10183 @example
10184 void __builtin_arc_vdiwr (const int, int)
10185 void __builtin_arc_vdowr (const int, int)
10186 @end example
10188 The following take an @code{int} argument and return no result:
10189 @example
10190 void __builtin_arc_vendrec (int)
10191 void __builtin_arc_vrec (int)
10192 void __builtin_arc_vrecrun (int)
10193 void __builtin_arc_vrun (int)
10194 @end example
10196 The following take a @code{__v8hi} argument and two @code{int}
10197 arguments and return a @code{__v8hi} result.  The second argument must
10198 be a 3-bit compile time constants, indicating one the registers I0-I7,
10199 and the third argument must be an 8-bit compile time constant.
10201 @emph{Note:} Although the equivalent hardware instructions do not take
10202 an SIMD register as an operand, these builtins overwrite the relevant
10203 bits of the @code{__v8hi} register provided as the first argument with
10204 the value loaded from the @code{[Ib, u8]} location in the SDM.
10206 @example
10207 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10208 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10209 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10210 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10211 @end example
10213 The following take two @code{int} arguments and return a @code{__v8hi}
10214 result.  The first argument must be a 3-bit compile time constants,
10215 indicating one the registers I0-I7, and the second argument must be an
10216 8-bit compile time constant.
10218 @example
10219 __v8hi __builtin_arc_vld128 (const int, const int)
10220 __v8hi __builtin_arc_vld64w (const int, const int)
10221 @end example
10223 The following take a @code{__v8hi} argument and two @code{int}
10224 arguments and return no result.  The second argument must be a 3-bit
10225 compile time constants, indicating one the registers I0-I7, and the
10226 third argument must be an 8-bit compile time constant.
10228 @example
10229 void __builtin_arc_vst128 (__v8hi, const int, const int)
10230 void __builtin_arc_vst64 (__v8hi, const int, const int)
10231 @end example
10233 The following take a @code{__v8hi} argument and three @code{int}
10234 arguments and return no result.  The second argument must be a 3-bit
10235 compile-time constant, identifying the 16-bit sub-register to be
10236 stored, the third argument must be a 3-bit compile time constants,
10237 indicating one the registers I0-I7, and the fourth argument must be an
10238 8-bit compile time constant.
10240 @example
10241 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10242 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10243 @end example
10245 @node ARM iWMMXt Built-in Functions
10246 @subsection ARM iWMMXt Built-in Functions
10248 These built-in functions are available for the ARM family of
10249 processors when the @option{-mcpu=iwmmxt} switch is used:
10251 @smallexample
10252 typedef int v2si __attribute__ ((vector_size (8)));
10253 typedef short v4hi __attribute__ ((vector_size (8)));
10254 typedef char v8qi __attribute__ ((vector_size (8)));
10256 int __builtin_arm_getwcgr0 (void)
10257 void __builtin_arm_setwcgr0 (int)
10258 int __builtin_arm_getwcgr1 (void)
10259 void __builtin_arm_setwcgr1 (int)
10260 int __builtin_arm_getwcgr2 (void)
10261 void __builtin_arm_setwcgr2 (int)
10262 int __builtin_arm_getwcgr3 (void)
10263 void __builtin_arm_setwcgr3 (int)
10264 int __builtin_arm_textrmsb (v8qi, int)
10265 int __builtin_arm_textrmsh (v4hi, int)
10266 int __builtin_arm_textrmsw (v2si, int)
10267 int __builtin_arm_textrmub (v8qi, int)
10268 int __builtin_arm_textrmuh (v4hi, int)
10269 int __builtin_arm_textrmuw (v2si, int)
10270 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10271 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10272 v2si __builtin_arm_tinsrw (v2si, int, int)
10273 long long __builtin_arm_tmia (long long, int, int)
10274 long long __builtin_arm_tmiabb (long long, int, int)
10275 long long __builtin_arm_tmiabt (long long, int, int)
10276 long long __builtin_arm_tmiaph (long long, int, int)
10277 long long __builtin_arm_tmiatb (long long, int, int)
10278 long long __builtin_arm_tmiatt (long long, int, int)
10279 int __builtin_arm_tmovmskb (v8qi)
10280 int __builtin_arm_tmovmskh (v4hi)
10281 int __builtin_arm_tmovmskw (v2si)
10282 long long __builtin_arm_waccb (v8qi)
10283 long long __builtin_arm_wacch (v4hi)
10284 long long __builtin_arm_waccw (v2si)
10285 v8qi __builtin_arm_waddb (v8qi, v8qi)
10286 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10287 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10288 v4hi __builtin_arm_waddh (v4hi, v4hi)
10289 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10290 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10291 v2si __builtin_arm_waddw (v2si, v2si)
10292 v2si __builtin_arm_waddwss (v2si, v2si)
10293 v2si __builtin_arm_waddwus (v2si, v2si)
10294 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10295 long long __builtin_arm_wand(long long, long long)
10296 long long __builtin_arm_wandn (long long, long long)
10297 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10298 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10299 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10300 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10301 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10302 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10303 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10304 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10305 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10306 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10307 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10308 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10309 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10310 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10311 long long __builtin_arm_wmacsz (v4hi, v4hi)
10312 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10313 long long __builtin_arm_wmacuz (v4hi, v4hi)
10314 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10315 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10316 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10317 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10318 v2si __builtin_arm_wmaxsw (v2si, v2si)
10319 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10320 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10321 v2si __builtin_arm_wmaxuw (v2si, v2si)
10322 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10323 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10324 v2si __builtin_arm_wminsw (v2si, v2si)
10325 v8qi __builtin_arm_wminub (v8qi, v8qi)
10326 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10327 v2si __builtin_arm_wminuw (v2si, v2si)
10328 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10329 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10330 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10331 long long __builtin_arm_wor (long long, long long)
10332 v2si __builtin_arm_wpackdss (long long, long long)
10333 v2si __builtin_arm_wpackdus (long long, long long)
10334 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10335 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10336 v4hi __builtin_arm_wpackwss (v2si, v2si)
10337 v4hi __builtin_arm_wpackwus (v2si, v2si)
10338 long long __builtin_arm_wrord (long long, long long)
10339 long long __builtin_arm_wrordi (long long, int)
10340 v4hi __builtin_arm_wrorh (v4hi, long long)
10341 v4hi __builtin_arm_wrorhi (v4hi, int)
10342 v2si __builtin_arm_wrorw (v2si, long long)
10343 v2si __builtin_arm_wrorwi (v2si, int)
10344 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10345 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10346 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10347 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10348 v4hi __builtin_arm_wshufh (v4hi, int)
10349 long long __builtin_arm_wslld (long long, long long)
10350 long long __builtin_arm_wslldi (long long, int)
10351 v4hi __builtin_arm_wsllh (v4hi, long long)
10352 v4hi __builtin_arm_wsllhi (v4hi, int)
10353 v2si __builtin_arm_wsllw (v2si, long long)
10354 v2si __builtin_arm_wsllwi (v2si, int)
10355 long long __builtin_arm_wsrad (long long, long long)
10356 long long __builtin_arm_wsradi (long long, int)
10357 v4hi __builtin_arm_wsrah (v4hi, long long)
10358 v4hi __builtin_arm_wsrahi (v4hi, int)
10359 v2si __builtin_arm_wsraw (v2si, long long)
10360 v2si __builtin_arm_wsrawi (v2si, int)
10361 long long __builtin_arm_wsrld (long long, long long)
10362 long long __builtin_arm_wsrldi (long long, int)
10363 v4hi __builtin_arm_wsrlh (v4hi, long long)
10364 v4hi __builtin_arm_wsrlhi (v4hi, int)
10365 v2si __builtin_arm_wsrlw (v2si, long long)
10366 v2si __builtin_arm_wsrlwi (v2si, int)
10367 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10368 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10369 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10370 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10371 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10372 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10373 v2si __builtin_arm_wsubw (v2si, v2si)
10374 v2si __builtin_arm_wsubwss (v2si, v2si)
10375 v2si __builtin_arm_wsubwus (v2si, v2si)
10376 v4hi __builtin_arm_wunpckehsb (v8qi)
10377 v2si __builtin_arm_wunpckehsh (v4hi)
10378 long long __builtin_arm_wunpckehsw (v2si)
10379 v4hi __builtin_arm_wunpckehub (v8qi)
10380 v2si __builtin_arm_wunpckehuh (v4hi)
10381 long long __builtin_arm_wunpckehuw (v2si)
10382 v4hi __builtin_arm_wunpckelsb (v8qi)
10383 v2si __builtin_arm_wunpckelsh (v4hi)
10384 long long __builtin_arm_wunpckelsw (v2si)
10385 v4hi __builtin_arm_wunpckelub (v8qi)
10386 v2si __builtin_arm_wunpckeluh (v4hi)
10387 long long __builtin_arm_wunpckeluw (v2si)
10388 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10389 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10390 v2si __builtin_arm_wunpckihw (v2si, v2si)
10391 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10392 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10393 v2si __builtin_arm_wunpckilw (v2si, v2si)
10394 long long __builtin_arm_wxor (long long, long long)
10395 long long __builtin_arm_wzero ()
10396 @end smallexample
10398 @node ARM NEON Intrinsics
10399 @subsection ARM NEON Intrinsics
10401 These built-in intrinsics for the ARM Advanced SIMD extension are available
10402 when the @option{-mfpu=neon} switch is used:
10404 @include arm-neon-intrinsics.texi
10406 @node ARM ACLE Intrinsics
10407 @subsection ARM ACLE Intrinsics
10409 These built-in intrinsics for the ARMv8-A CRC32 extension are available when
10410 the @option{-march=armv8-a+crc} switch is used:
10412 @include arm-acle-intrinsics.texi
10414 @node AVR Built-in Functions
10415 @subsection AVR Built-in Functions
10417 For each built-in function for AVR, there is an equally named,
10418 uppercase built-in macro defined. That way users can easily query if
10419 or if not a specific built-in is implemented or not. For example, if
10420 @code{__builtin_avr_nop} is available the macro
10421 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10423 The following built-in functions map to the respective machine
10424 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10425 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10426 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10427 as library call if no hardware multiplier is available.
10429 @smallexample
10430 void __builtin_avr_nop (void)
10431 void __builtin_avr_sei (void)
10432 void __builtin_avr_cli (void)
10433 void __builtin_avr_sleep (void)
10434 void __builtin_avr_wdr (void)
10435 unsigned char __builtin_avr_swap (unsigned char)
10436 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10437 int __builtin_avr_fmuls (char, char)
10438 int __builtin_avr_fmulsu (char, unsigned char)
10439 @end smallexample
10441 In order to delay execution for a specific number of cycles, GCC
10442 implements
10443 @smallexample
10444 void __builtin_avr_delay_cycles (unsigned long ticks)
10445 @end smallexample
10447 @noindent
10448 @code{ticks} is the number of ticks to delay execution. Note that this
10449 built-in does not take into account the effect of interrupts that
10450 might increase delay time. @code{ticks} must be a compile-time
10451 integer constant; delays with a variable number of cycles are not supported.
10453 @smallexample
10454 char __builtin_avr_flash_segment (const __memx void*)
10455 @end smallexample
10457 @noindent
10458 This built-in takes a byte address to the 24-bit
10459 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10460 the number of the flash segment (the 64 KiB chunk) where the address
10461 points to.  Counting starts at @code{0}.
10462 If the address does not point to flash memory, return @code{-1}.
10464 @smallexample
10465 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10466 @end smallexample
10468 @noindent
10469 Insert bits from @var{bits} into @var{val} and return the resulting
10470 value. The nibbles of @var{map} determine how the insertion is
10471 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
10472 @enumerate
10473 @item If @var{X} is @code{0xf},
10474 then the @var{n}-th bit of @var{val} is returned unaltered.
10476 @item If X is in the range 0@dots{}7,
10477 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
10479 @item If X is in the range 8@dots{}@code{0xe},
10480 then the @var{n}-th result bit is undefined.
10481 @end enumerate
10483 @noindent
10484 One typical use case for this built-in is adjusting input and
10485 output values to non-contiguous port layouts. Some examples:
10487 @smallexample
10488 // same as val, bits is unused
10489 __builtin_avr_insert_bits (0xffffffff, bits, val)
10490 @end smallexample
10492 @smallexample
10493 // same as bits, val is unused
10494 __builtin_avr_insert_bits (0x76543210, bits, val)
10495 @end smallexample
10497 @smallexample
10498 // same as rotating bits by 4
10499 __builtin_avr_insert_bits (0x32107654, bits, 0)
10500 @end smallexample
10502 @smallexample
10503 // high nibble of result is the high nibble of val
10504 // low nibble of result is the low nibble of bits
10505 __builtin_avr_insert_bits (0xffff3210, bits, val)
10506 @end smallexample
10508 @smallexample
10509 // reverse the bit order of bits
10510 __builtin_avr_insert_bits (0x01234567, bits, 0)
10511 @end smallexample
10513 @node Blackfin Built-in Functions
10514 @subsection Blackfin Built-in Functions
10516 Currently, there are two Blackfin-specific built-in functions.  These are
10517 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
10518 using inline assembly; by using these built-in functions the compiler can
10519 automatically add workarounds for hardware errata involving these
10520 instructions.  These functions are named as follows:
10522 @smallexample
10523 void __builtin_bfin_csync (void)
10524 void __builtin_bfin_ssync (void)
10525 @end smallexample
10527 @node FR-V Built-in Functions
10528 @subsection FR-V Built-in Functions
10530 GCC provides many FR-V-specific built-in functions.  In general,
10531 these functions are intended to be compatible with those described
10532 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
10533 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
10534 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
10535 pointer rather than by value.
10537 Most of the functions are named after specific FR-V instructions.
10538 Such functions are said to be ``directly mapped'' and are summarized
10539 here in tabular form.
10541 @menu
10542 * Argument Types::
10543 * Directly-mapped Integer Functions::
10544 * Directly-mapped Media Functions::
10545 * Raw read/write Functions::
10546 * Other Built-in Functions::
10547 @end menu
10549 @node Argument Types
10550 @subsubsection Argument Types
10552 The arguments to the built-in functions can be divided into three groups:
10553 register numbers, compile-time constants and run-time values.  In order
10554 to make this classification clear at a glance, the arguments and return
10555 values are given the following pseudo types:
10557 @multitable @columnfractions .20 .30 .15 .35
10558 @item Pseudo type @tab Real C type @tab Constant? @tab Description
10559 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
10560 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
10561 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
10562 @item @code{uw2} @tab @code{unsigned long long} @tab No
10563 @tab an unsigned doubleword
10564 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
10565 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
10566 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
10567 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
10568 @end multitable
10570 These pseudo types are not defined by GCC, they are simply a notational
10571 convenience used in this manual.
10573 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
10574 and @code{sw2} are evaluated at run time.  They correspond to
10575 register operands in the underlying FR-V instructions.
10577 @code{const} arguments represent immediate operands in the underlying
10578 FR-V instructions.  They must be compile-time constants.
10580 @code{acc} arguments are evaluated at compile time and specify the number
10581 of an accumulator register.  For example, an @code{acc} argument of 2
10582 selects the ACC2 register.
10584 @code{iacc} arguments are similar to @code{acc} arguments but specify the
10585 number of an IACC register.  See @pxref{Other Built-in Functions}
10586 for more details.
10588 @node Directly-mapped Integer Functions
10589 @subsubsection Directly-mapped Integer Functions
10591 The functions listed below map directly to FR-V I-type instructions.
10593 @multitable @columnfractions .45 .32 .23
10594 @item Function prototype @tab Example usage @tab Assembly output
10595 @item @code{sw1 __ADDSS (sw1, sw1)}
10596 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
10597 @tab @code{ADDSS @var{a},@var{b},@var{c}}
10598 @item @code{sw1 __SCAN (sw1, sw1)}
10599 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
10600 @tab @code{SCAN @var{a},@var{b},@var{c}}
10601 @item @code{sw1 __SCUTSS (sw1)}
10602 @tab @code{@var{b} = __SCUTSS (@var{a})}
10603 @tab @code{SCUTSS @var{a},@var{b}}
10604 @item @code{sw1 __SLASS (sw1, sw1)}
10605 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
10606 @tab @code{SLASS @var{a},@var{b},@var{c}}
10607 @item @code{void __SMASS (sw1, sw1)}
10608 @tab @code{__SMASS (@var{a}, @var{b})}
10609 @tab @code{SMASS @var{a},@var{b}}
10610 @item @code{void __SMSSS (sw1, sw1)}
10611 @tab @code{__SMSSS (@var{a}, @var{b})}
10612 @tab @code{SMSSS @var{a},@var{b}}
10613 @item @code{void __SMU (sw1, sw1)}
10614 @tab @code{__SMU (@var{a}, @var{b})}
10615 @tab @code{SMU @var{a},@var{b}}
10616 @item @code{sw2 __SMUL (sw1, sw1)}
10617 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
10618 @tab @code{SMUL @var{a},@var{b},@var{c}}
10619 @item @code{sw1 __SUBSS (sw1, sw1)}
10620 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
10621 @tab @code{SUBSS @var{a},@var{b},@var{c}}
10622 @item @code{uw2 __UMUL (uw1, uw1)}
10623 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
10624 @tab @code{UMUL @var{a},@var{b},@var{c}}
10625 @end multitable
10627 @node Directly-mapped Media Functions
10628 @subsubsection Directly-mapped Media Functions
10630 The functions listed below map directly to FR-V M-type instructions.
10632 @multitable @columnfractions .45 .32 .23
10633 @item Function prototype @tab Example usage @tab Assembly output
10634 @item @code{uw1 __MABSHS (sw1)}
10635 @tab @code{@var{b} = __MABSHS (@var{a})}
10636 @tab @code{MABSHS @var{a},@var{b}}
10637 @item @code{void __MADDACCS (acc, acc)}
10638 @tab @code{__MADDACCS (@var{b}, @var{a})}
10639 @tab @code{MADDACCS @var{a},@var{b}}
10640 @item @code{sw1 __MADDHSS (sw1, sw1)}
10641 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
10642 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
10643 @item @code{uw1 __MADDHUS (uw1, uw1)}
10644 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
10645 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
10646 @item @code{uw1 __MAND (uw1, uw1)}
10647 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
10648 @tab @code{MAND @var{a},@var{b},@var{c}}
10649 @item @code{void __MASACCS (acc, acc)}
10650 @tab @code{__MASACCS (@var{b}, @var{a})}
10651 @tab @code{MASACCS @var{a},@var{b}}
10652 @item @code{uw1 __MAVEH (uw1, uw1)}
10653 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
10654 @tab @code{MAVEH @var{a},@var{b},@var{c}}
10655 @item @code{uw2 __MBTOH (uw1)}
10656 @tab @code{@var{b} = __MBTOH (@var{a})}
10657 @tab @code{MBTOH @var{a},@var{b}}
10658 @item @code{void __MBTOHE (uw1 *, uw1)}
10659 @tab @code{__MBTOHE (&@var{b}, @var{a})}
10660 @tab @code{MBTOHE @var{a},@var{b}}
10661 @item @code{void __MCLRACC (acc)}
10662 @tab @code{__MCLRACC (@var{a})}
10663 @tab @code{MCLRACC @var{a}}
10664 @item @code{void __MCLRACCA (void)}
10665 @tab @code{__MCLRACCA ()}
10666 @tab @code{MCLRACCA}
10667 @item @code{uw1 __Mcop1 (uw1, uw1)}
10668 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
10669 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
10670 @item @code{uw1 __Mcop2 (uw1, uw1)}
10671 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
10672 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
10673 @item @code{uw1 __MCPLHI (uw2, const)}
10674 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
10675 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
10676 @item @code{uw1 __MCPLI (uw2, const)}
10677 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
10678 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
10679 @item @code{void __MCPXIS (acc, sw1, sw1)}
10680 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
10681 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
10682 @item @code{void __MCPXIU (acc, uw1, uw1)}
10683 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
10684 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
10685 @item @code{void __MCPXRS (acc, sw1, sw1)}
10686 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
10687 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
10688 @item @code{void __MCPXRU (acc, uw1, uw1)}
10689 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
10690 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
10691 @item @code{uw1 __MCUT (acc, uw1)}
10692 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
10693 @tab @code{MCUT @var{a},@var{b},@var{c}}
10694 @item @code{uw1 __MCUTSS (acc, sw1)}
10695 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
10696 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
10697 @item @code{void __MDADDACCS (acc, acc)}
10698 @tab @code{__MDADDACCS (@var{b}, @var{a})}
10699 @tab @code{MDADDACCS @var{a},@var{b}}
10700 @item @code{void __MDASACCS (acc, acc)}
10701 @tab @code{__MDASACCS (@var{b}, @var{a})}
10702 @tab @code{MDASACCS @var{a},@var{b}}
10703 @item @code{uw2 __MDCUTSSI (acc, const)}
10704 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
10705 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
10706 @item @code{uw2 __MDPACKH (uw2, uw2)}
10707 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
10708 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
10709 @item @code{uw2 __MDROTLI (uw2, const)}
10710 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
10711 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
10712 @item @code{void __MDSUBACCS (acc, acc)}
10713 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
10714 @tab @code{MDSUBACCS @var{a},@var{b}}
10715 @item @code{void __MDUNPACKH (uw1 *, uw2)}
10716 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
10717 @tab @code{MDUNPACKH @var{a},@var{b}}
10718 @item @code{uw2 __MEXPDHD (uw1, const)}
10719 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
10720 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
10721 @item @code{uw1 __MEXPDHW (uw1, const)}
10722 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
10723 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
10724 @item @code{uw1 __MHDSETH (uw1, const)}
10725 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
10726 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
10727 @item @code{sw1 __MHDSETS (const)}
10728 @tab @code{@var{b} = __MHDSETS (@var{a})}
10729 @tab @code{MHDSETS #@var{a},@var{b}}
10730 @item @code{uw1 __MHSETHIH (uw1, const)}
10731 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
10732 @tab @code{MHSETHIH #@var{a},@var{b}}
10733 @item @code{sw1 __MHSETHIS (sw1, const)}
10734 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
10735 @tab @code{MHSETHIS #@var{a},@var{b}}
10736 @item @code{uw1 __MHSETLOH (uw1, const)}
10737 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
10738 @tab @code{MHSETLOH #@var{a},@var{b}}
10739 @item @code{sw1 __MHSETLOS (sw1, const)}
10740 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
10741 @tab @code{MHSETLOS #@var{a},@var{b}}
10742 @item @code{uw1 __MHTOB (uw2)}
10743 @tab @code{@var{b} = __MHTOB (@var{a})}
10744 @tab @code{MHTOB @var{a},@var{b}}
10745 @item @code{void __MMACHS (acc, sw1, sw1)}
10746 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
10747 @tab @code{MMACHS @var{a},@var{b},@var{c}}
10748 @item @code{void __MMACHU (acc, uw1, uw1)}
10749 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
10750 @tab @code{MMACHU @var{a},@var{b},@var{c}}
10751 @item @code{void __MMRDHS (acc, sw1, sw1)}
10752 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
10753 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
10754 @item @code{void __MMRDHU (acc, uw1, uw1)}
10755 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
10756 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
10757 @item @code{void __MMULHS (acc, sw1, sw1)}
10758 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
10759 @tab @code{MMULHS @var{a},@var{b},@var{c}}
10760 @item @code{void __MMULHU (acc, uw1, uw1)}
10761 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
10762 @tab @code{MMULHU @var{a},@var{b},@var{c}}
10763 @item @code{void __MMULXHS (acc, sw1, sw1)}
10764 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
10765 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
10766 @item @code{void __MMULXHU (acc, uw1, uw1)}
10767 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
10768 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
10769 @item @code{uw1 __MNOT (uw1)}
10770 @tab @code{@var{b} = __MNOT (@var{a})}
10771 @tab @code{MNOT @var{a},@var{b}}
10772 @item @code{uw1 __MOR (uw1, uw1)}
10773 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
10774 @tab @code{MOR @var{a},@var{b},@var{c}}
10775 @item @code{uw1 __MPACKH (uh, uh)}
10776 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
10777 @tab @code{MPACKH @var{a},@var{b},@var{c}}
10778 @item @code{sw2 __MQADDHSS (sw2, sw2)}
10779 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
10780 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
10781 @item @code{uw2 __MQADDHUS (uw2, uw2)}
10782 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
10783 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
10784 @item @code{void __MQCPXIS (acc, sw2, sw2)}
10785 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
10786 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
10787 @item @code{void __MQCPXIU (acc, uw2, uw2)}
10788 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
10789 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
10790 @item @code{void __MQCPXRS (acc, sw2, sw2)}
10791 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
10792 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
10793 @item @code{void __MQCPXRU (acc, uw2, uw2)}
10794 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
10795 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
10796 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
10797 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
10798 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
10799 @item @code{sw2 __MQLMTHS (sw2, sw2)}
10800 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
10801 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
10802 @item @code{void __MQMACHS (acc, sw2, sw2)}
10803 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
10804 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
10805 @item @code{void __MQMACHU (acc, uw2, uw2)}
10806 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
10807 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
10808 @item @code{void __MQMACXHS (acc, sw2, sw2)}
10809 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
10810 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
10811 @item @code{void __MQMULHS (acc, sw2, sw2)}
10812 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
10813 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
10814 @item @code{void __MQMULHU (acc, uw2, uw2)}
10815 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
10816 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
10817 @item @code{void __MQMULXHS (acc, sw2, sw2)}
10818 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
10819 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
10820 @item @code{void __MQMULXHU (acc, uw2, uw2)}
10821 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
10822 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
10823 @item @code{sw2 __MQSATHS (sw2, sw2)}
10824 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
10825 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
10826 @item @code{uw2 __MQSLLHI (uw2, int)}
10827 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
10828 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
10829 @item @code{sw2 __MQSRAHI (sw2, int)}
10830 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
10831 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
10832 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
10833 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
10834 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
10835 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
10836 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
10837 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
10838 @item @code{void __MQXMACHS (acc, sw2, sw2)}
10839 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
10840 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
10841 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
10842 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
10843 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
10844 @item @code{uw1 __MRDACC (acc)}
10845 @tab @code{@var{b} = __MRDACC (@var{a})}
10846 @tab @code{MRDACC @var{a},@var{b}}
10847 @item @code{uw1 __MRDACCG (acc)}
10848 @tab @code{@var{b} = __MRDACCG (@var{a})}
10849 @tab @code{MRDACCG @var{a},@var{b}}
10850 @item @code{uw1 __MROTLI (uw1, const)}
10851 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
10852 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
10853 @item @code{uw1 __MROTRI (uw1, const)}
10854 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
10855 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
10856 @item @code{sw1 __MSATHS (sw1, sw1)}
10857 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
10858 @tab @code{MSATHS @var{a},@var{b},@var{c}}
10859 @item @code{uw1 __MSATHU (uw1, uw1)}
10860 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
10861 @tab @code{MSATHU @var{a},@var{b},@var{c}}
10862 @item @code{uw1 __MSLLHI (uw1, const)}
10863 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
10864 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
10865 @item @code{sw1 __MSRAHI (sw1, const)}
10866 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
10867 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
10868 @item @code{uw1 __MSRLHI (uw1, const)}
10869 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
10870 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
10871 @item @code{void __MSUBACCS (acc, acc)}
10872 @tab @code{__MSUBACCS (@var{b}, @var{a})}
10873 @tab @code{MSUBACCS @var{a},@var{b}}
10874 @item @code{sw1 __MSUBHSS (sw1, sw1)}
10875 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
10876 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
10877 @item @code{uw1 __MSUBHUS (uw1, uw1)}
10878 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
10879 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
10880 @item @code{void __MTRAP (void)}
10881 @tab @code{__MTRAP ()}
10882 @tab @code{MTRAP}
10883 @item @code{uw2 __MUNPACKH (uw1)}
10884 @tab @code{@var{b} = __MUNPACKH (@var{a})}
10885 @tab @code{MUNPACKH @var{a},@var{b}}
10886 @item @code{uw1 __MWCUT (uw2, uw1)}
10887 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
10888 @tab @code{MWCUT @var{a},@var{b},@var{c}}
10889 @item @code{void __MWTACC (acc, uw1)}
10890 @tab @code{__MWTACC (@var{b}, @var{a})}
10891 @tab @code{MWTACC @var{a},@var{b}}
10892 @item @code{void __MWTACCG (acc, uw1)}
10893 @tab @code{__MWTACCG (@var{b}, @var{a})}
10894 @tab @code{MWTACCG @var{a},@var{b}}
10895 @item @code{uw1 __MXOR (uw1, uw1)}
10896 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
10897 @tab @code{MXOR @var{a},@var{b},@var{c}}
10898 @end multitable
10900 @node Raw read/write Functions
10901 @subsubsection Raw read/write Functions
10903 This sections describes built-in functions related to read and write
10904 instructions to access memory.  These functions generate
10905 @code{membar} instructions to flush the I/O load and stores where
10906 appropriate, as described in Fujitsu's manual described above.
10908 @table @code
10910 @item unsigned char __builtin_read8 (void *@var{data})
10911 @item unsigned short __builtin_read16 (void *@var{data})
10912 @item unsigned long __builtin_read32 (void *@var{data})
10913 @item unsigned long long __builtin_read64 (void *@var{data})
10915 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
10916 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
10917 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
10918 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
10919 @end table
10921 @node Other Built-in Functions
10922 @subsubsection Other Built-in Functions
10924 This section describes built-in functions that are not named after
10925 a specific FR-V instruction.
10927 @table @code
10928 @item sw2 __IACCreadll (iacc @var{reg})
10929 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
10930 for future expansion and must be 0.
10932 @item sw1 __IACCreadl (iacc @var{reg})
10933 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
10934 Other values of @var{reg} are rejected as invalid.
10936 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
10937 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
10938 is reserved for future expansion and must be 0.
10940 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
10941 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
10942 is 1.  Other values of @var{reg} are rejected as invalid.
10944 @item void __data_prefetch0 (const void *@var{x})
10945 Use the @code{dcpl} instruction to load the contents of address @var{x}
10946 into the data cache.
10948 @item void __data_prefetch (const void *@var{x})
10949 Use the @code{nldub} instruction to load the contents of address @var{x}
10950 into the data cache.  The instruction is issued in slot I1@.
10951 @end table
10953 @node X86 Built-in Functions
10954 @subsection X86 Built-in Functions
10956 These built-in functions are available for the i386 and x86-64 family
10957 of computers, depending on the command-line switches used.
10959 If you specify command-line switches such as @option{-msse},
10960 the compiler could use the extended instruction sets even if the built-ins
10961 are not used explicitly in the program.  For this reason, applications
10962 that perform run-time CPU detection must compile separate files for each
10963 supported architecture, using the appropriate flags.  In particular,
10964 the file containing the CPU detection code should be compiled without
10965 these options.
10967 The following machine modes are available for use with MMX built-in functions
10968 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
10969 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
10970 vector of eight 8-bit integers.  Some of the built-in functions operate on
10971 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
10973 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
10974 of two 32-bit floating-point values.
10976 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
10977 floating-point values.  Some instructions use a vector of four 32-bit
10978 integers, these use @code{V4SI}.  Finally, some instructions operate on an
10979 entire vector register, interpreting it as a 128-bit integer, these use mode
10980 @code{TI}.
10982 In 64-bit mode, the x86-64 family of processors uses additional built-in
10983 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
10984 floating point and @code{TC} 128-bit complex floating-point values.
10986 The following floating-point built-in functions are available in 64-bit
10987 mode.  All of them implement the function that is part of the name.
10989 @smallexample
10990 __float128 __builtin_fabsq (__float128)
10991 __float128 __builtin_copysignq (__float128, __float128)
10992 @end smallexample
10994 The following built-in function is always available.
10996 @table @code
10997 @item void __builtin_ia32_pause (void)
10998 Generates the @code{pause} machine instruction with a compiler memory
10999 barrier.
11000 @end table
11002 The following floating-point built-in functions are made available in the
11003 64-bit mode.
11005 @table @code
11006 @item __float128 __builtin_infq (void)
11007 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11008 @findex __builtin_infq
11010 @item __float128 __builtin_huge_valq (void)
11011 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11012 @findex __builtin_huge_valq
11013 @end table
11015 The following built-in functions are always available and can be used to
11016 check the target platform type.
11018 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11019 This function runs the CPU detection code to check the type of CPU and the
11020 features supported.  This built-in function needs to be invoked along with the built-in functions
11021 to check CPU type and features, @code{__builtin_cpu_is} and
11022 @code{__builtin_cpu_supports}, only when used in a function that is
11023 executed before any constructors are called.  The CPU detection code is
11024 automatically executed in a very high priority constructor.
11026 For example, this function has to be used in @code{ifunc} resolvers that
11027 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11028 and @code{__builtin_cpu_supports}, or in constructors on targets that
11029 don't support constructor priority.
11030 @smallexample
11032 static void (*resolve_memcpy (void)) (void)
11034   // ifunc resolvers fire before constructors, explicitly call the init
11035   // function.
11036   __builtin_cpu_init ();
11037   if (__builtin_cpu_supports ("ssse3"))
11038     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11039   else
11040     return default_memcpy;
11043 void *memcpy (void *, const void *, size_t)
11044      __attribute__ ((ifunc ("resolve_memcpy")));
11045 @end smallexample
11047 @end deftypefn
11049 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11050 This function returns a positive integer if the run-time CPU
11051 is of type @var{cpuname}
11052 and returns @code{0} otherwise. The following CPU names can be detected:
11054 @table @samp
11055 @item intel
11056 Intel CPU.
11058 @item atom
11059 Intel Atom CPU.
11061 @item core2
11062 Intel Core 2 CPU.
11064 @item corei7
11065 Intel Core i7 CPU.
11067 @item nehalem
11068 Intel Core i7 Nehalem CPU.
11070 @item westmere
11071 Intel Core i7 Westmere CPU.
11073 @item sandybridge
11074 Intel Core i7 Sandy Bridge CPU.
11076 @item amd
11077 AMD CPU.
11079 @item amdfam10h
11080 AMD Family 10h CPU.
11082 @item barcelona
11083 AMD Family 10h Barcelona CPU.
11085 @item shanghai
11086 AMD Family 10h Shanghai CPU.
11088 @item istanbul
11089 AMD Family 10h Istanbul CPU.
11091 @item btver1
11092 AMD Family 14h CPU.
11094 @item amdfam15h
11095 AMD Family 15h CPU.
11097 @item bdver1
11098 AMD Family 15h Bulldozer version 1.
11100 @item bdver2
11101 AMD Family 15h Bulldozer version 2.
11103 @item bdver3
11104 AMD Family 15h Bulldozer version 3.
11106 @item bdver4
11107 AMD Family 15h Bulldozer version 4.
11109 @item btver2
11110 AMD Family 16h CPU.
11111 @end table
11113 Here is an example:
11114 @smallexample
11115 if (__builtin_cpu_is ("corei7"))
11116   @{
11117      do_corei7 (); // Core i7 specific implementation.
11118   @}
11119 else
11120   @{
11121      do_generic (); // Generic implementation.
11122   @}
11123 @end smallexample
11124 @end deftypefn
11126 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11127 This function returns a positive integer if the run-time CPU
11128 supports @var{feature}
11129 and returns @code{0} otherwise. The following features can be detected:
11131 @table @samp
11132 @item cmov
11133 CMOV instruction.
11134 @item mmx
11135 MMX instructions.
11136 @item popcnt
11137 POPCNT instruction.
11138 @item sse
11139 SSE instructions.
11140 @item sse2
11141 SSE2 instructions.
11142 @item sse3
11143 SSE3 instructions.
11144 @item ssse3
11145 SSSE3 instructions.
11146 @item sse4.1
11147 SSE4.1 instructions.
11148 @item sse4.2
11149 SSE4.2 instructions.
11150 @item avx
11151 AVX instructions.
11152 @item avx2
11153 AVX2 instructions.
11154 @end table
11156 Here is an example:
11157 @smallexample
11158 if (__builtin_cpu_supports ("popcnt"))
11159   @{
11160      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11161   @}
11162 else
11163   @{
11164      count = generic_countbits (n); //generic implementation.
11165   @}
11166 @end smallexample
11167 @end deftypefn
11170 The following built-in functions are made available by @option{-mmmx}.
11171 All of them generate the machine instruction that is part of the name.
11173 @smallexample
11174 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11175 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11176 v2si __builtin_ia32_paddd (v2si, v2si)
11177 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11178 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11179 v2si __builtin_ia32_psubd (v2si, v2si)
11180 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11181 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11182 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11183 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11184 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11185 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11186 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11187 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11188 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11189 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11190 di __builtin_ia32_pand (di, di)
11191 di __builtin_ia32_pandn (di,di)
11192 di __builtin_ia32_por (di, di)
11193 di __builtin_ia32_pxor (di, di)
11194 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11195 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11196 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11197 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11198 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11199 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11200 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11201 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11202 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11203 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11204 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11205 v2si __builtin_ia32_punpckldq (v2si, v2si)
11206 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11207 v4hi __builtin_ia32_packssdw (v2si, v2si)
11208 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11210 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11211 v2si __builtin_ia32_pslld (v2si, v2si)
11212 v1di __builtin_ia32_psllq (v1di, v1di)
11213 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11214 v2si __builtin_ia32_psrld (v2si, v2si)
11215 v1di __builtin_ia32_psrlq (v1di, v1di)
11216 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11217 v2si __builtin_ia32_psrad (v2si, v2si)
11218 v4hi __builtin_ia32_psllwi (v4hi, int)
11219 v2si __builtin_ia32_pslldi (v2si, int)
11220 v1di __builtin_ia32_psllqi (v1di, int)
11221 v4hi __builtin_ia32_psrlwi (v4hi, int)
11222 v2si __builtin_ia32_psrldi (v2si, int)
11223 v1di __builtin_ia32_psrlqi (v1di, int)
11224 v4hi __builtin_ia32_psrawi (v4hi, int)
11225 v2si __builtin_ia32_psradi (v2si, int)
11227 @end smallexample
11229 The following built-in functions are made available either with
11230 @option{-msse}, or with a combination of @option{-m3dnow} and
11231 @option{-march=athlon}.  All of them generate the machine
11232 instruction that is part of the name.
11234 @smallexample
11235 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11236 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11237 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11238 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11239 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11240 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11241 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11242 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11243 int __builtin_ia32_pmovmskb (v8qi)
11244 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11245 void __builtin_ia32_movntq (di *, di)
11246 void __builtin_ia32_sfence (void)
11247 @end smallexample
11249 The following built-in functions are available when @option{-msse} is used.
11250 All of them generate the machine instruction that is part of the name.
11252 @smallexample
11253 int __builtin_ia32_comieq (v4sf, v4sf)
11254 int __builtin_ia32_comineq (v4sf, v4sf)
11255 int __builtin_ia32_comilt (v4sf, v4sf)
11256 int __builtin_ia32_comile (v4sf, v4sf)
11257 int __builtin_ia32_comigt (v4sf, v4sf)
11258 int __builtin_ia32_comige (v4sf, v4sf)
11259 int __builtin_ia32_ucomieq (v4sf, v4sf)
11260 int __builtin_ia32_ucomineq (v4sf, v4sf)
11261 int __builtin_ia32_ucomilt (v4sf, v4sf)
11262 int __builtin_ia32_ucomile (v4sf, v4sf)
11263 int __builtin_ia32_ucomigt (v4sf, v4sf)
11264 int __builtin_ia32_ucomige (v4sf, v4sf)
11265 v4sf __builtin_ia32_addps (v4sf, v4sf)
11266 v4sf __builtin_ia32_subps (v4sf, v4sf)
11267 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11268 v4sf __builtin_ia32_divps (v4sf, v4sf)
11269 v4sf __builtin_ia32_addss (v4sf, v4sf)
11270 v4sf __builtin_ia32_subss (v4sf, v4sf)
11271 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11272 v4sf __builtin_ia32_divss (v4sf, v4sf)
11273 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11274 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11275 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11276 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11277 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11278 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11279 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11280 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11281 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11282 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11283 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11284 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11285 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11286 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11287 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11288 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11289 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11290 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11291 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11292 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11293 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11294 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11295 v4sf __builtin_ia32_minps (v4sf, v4sf)
11296 v4sf __builtin_ia32_minss (v4sf, v4sf)
11297 v4sf __builtin_ia32_andps (v4sf, v4sf)
11298 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11299 v4sf __builtin_ia32_orps (v4sf, v4sf)
11300 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11301 v4sf __builtin_ia32_movss (v4sf, v4sf)
11302 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11303 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11304 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11305 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11306 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11307 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11308 v2si __builtin_ia32_cvtps2pi (v4sf)
11309 int __builtin_ia32_cvtss2si (v4sf)
11310 v2si __builtin_ia32_cvttps2pi (v4sf)
11311 int __builtin_ia32_cvttss2si (v4sf)
11312 v4sf __builtin_ia32_rcpps (v4sf)
11313 v4sf __builtin_ia32_rsqrtps (v4sf)
11314 v4sf __builtin_ia32_sqrtps (v4sf)
11315 v4sf __builtin_ia32_rcpss (v4sf)
11316 v4sf __builtin_ia32_rsqrtss (v4sf)
11317 v4sf __builtin_ia32_sqrtss (v4sf)
11318 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11319 void __builtin_ia32_movntps (float *, v4sf)
11320 int __builtin_ia32_movmskps (v4sf)
11321 @end smallexample
11323 The following built-in functions are available when @option{-msse} is used.
11325 @table @code
11326 @item v4sf __builtin_ia32_loadups (float *)
11327 Generates the @code{movups} machine instruction as a load from memory.
11328 @item void __builtin_ia32_storeups (float *, v4sf)
11329 Generates the @code{movups} machine instruction as a store to memory.
11330 @item v4sf __builtin_ia32_loadss (float *)
11331 Generates the @code{movss} machine instruction as a load from memory.
11332 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11333 Generates the @code{movhps} machine instruction as a load from memory.
11334 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11335 Generates the @code{movlps} machine instruction as a load from memory
11336 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11337 Generates the @code{movhps} machine instruction as a store to memory.
11338 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11339 Generates the @code{movlps} machine instruction as a store to memory.
11340 @end table
11342 The following built-in functions are available when @option{-msse2} is used.
11343 All of them generate the machine instruction that is part of the name.
11345 @smallexample
11346 int __builtin_ia32_comisdeq (v2df, v2df)
11347 int __builtin_ia32_comisdlt (v2df, v2df)
11348 int __builtin_ia32_comisdle (v2df, v2df)
11349 int __builtin_ia32_comisdgt (v2df, v2df)
11350 int __builtin_ia32_comisdge (v2df, v2df)
11351 int __builtin_ia32_comisdneq (v2df, v2df)
11352 int __builtin_ia32_ucomisdeq (v2df, v2df)
11353 int __builtin_ia32_ucomisdlt (v2df, v2df)
11354 int __builtin_ia32_ucomisdle (v2df, v2df)
11355 int __builtin_ia32_ucomisdgt (v2df, v2df)
11356 int __builtin_ia32_ucomisdge (v2df, v2df)
11357 int __builtin_ia32_ucomisdneq (v2df, v2df)
11358 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11359 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11360 v2df __builtin_ia32_cmplepd (v2df, v2df)
11361 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11362 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11363 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11364 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11365 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11366 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11367 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11368 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11369 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11370 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11371 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11372 v2df __builtin_ia32_cmplesd (v2df, v2df)
11373 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11374 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11375 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11376 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11377 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11378 v2di __builtin_ia32_paddq (v2di, v2di)
11379 v2di __builtin_ia32_psubq (v2di, v2di)
11380 v2df __builtin_ia32_addpd (v2df, v2df)
11381 v2df __builtin_ia32_subpd (v2df, v2df)
11382 v2df __builtin_ia32_mulpd (v2df, v2df)
11383 v2df __builtin_ia32_divpd (v2df, v2df)
11384 v2df __builtin_ia32_addsd (v2df, v2df)
11385 v2df __builtin_ia32_subsd (v2df, v2df)
11386 v2df __builtin_ia32_mulsd (v2df, v2df)
11387 v2df __builtin_ia32_divsd (v2df, v2df)
11388 v2df __builtin_ia32_minpd (v2df, v2df)
11389 v2df __builtin_ia32_maxpd (v2df, v2df)
11390 v2df __builtin_ia32_minsd (v2df, v2df)
11391 v2df __builtin_ia32_maxsd (v2df, v2df)
11392 v2df __builtin_ia32_andpd (v2df, v2df)
11393 v2df __builtin_ia32_andnpd (v2df, v2df)
11394 v2df __builtin_ia32_orpd (v2df, v2df)
11395 v2df __builtin_ia32_xorpd (v2df, v2df)
11396 v2df __builtin_ia32_movsd (v2df, v2df)
11397 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11398 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11399 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11400 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11401 v4si __builtin_ia32_paddd128 (v4si, v4si)
11402 v2di __builtin_ia32_paddq128 (v2di, v2di)
11403 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11404 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11405 v4si __builtin_ia32_psubd128 (v4si, v4si)
11406 v2di __builtin_ia32_psubq128 (v2di, v2di)
11407 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11408 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11409 v2di __builtin_ia32_pand128 (v2di, v2di)
11410 v2di __builtin_ia32_pandn128 (v2di, v2di)
11411 v2di __builtin_ia32_por128 (v2di, v2di)
11412 v2di __builtin_ia32_pxor128 (v2di, v2di)
11413 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11414 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11415 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11416 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11417 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11418 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11419 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11420 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11421 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11422 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11423 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11424 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11425 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11426 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11427 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11428 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11429 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11430 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11431 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11432 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11433 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11434 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11435 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11436 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11437 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11438 v2df __builtin_ia32_loadupd (double *)
11439 void __builtin_ia32_storeupd (double *, v2df)
11440 v2df __builtin_ia32_loadhpd (v2df, double const *)
11441 v2df __builtin_ia32_loadlpd (v2df, double const *)
11442 int __builtin_ia32_movmskpd (v2df)
11443 int __builtin_ia32_pmovmskb128 (v16qi)
11444 void __builtin_ia32_movnti (int *, int)
11445 void __builtin_ia32_movnti64 (long long int *, long long int)
11446 void __builtin_ia32_movntpd (double *, v2df)
11447 void __builtin_ia32_movntdq (v2df *, v2df)
11448 v4si __builtin_ia32_pshufd (v4si, int)
11449 v8hi __builtin_ia32_pshuflw (v8hi, int)
11450 v8hi __builtin_ia32_pshufhw (v8hi, int)
11451 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11452 v2df __builtin_ia32_sqrtpd (v2df)
11453 v2df __builtin_ia32_sqrtsd (v2df)
11454 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11455 v2df __builtin_ia32_cvtdq2pd (v4si)
11456 v4sf __builtin_ia32_cvtdq2ps (v4si)
11457 v4si __builtin_ia32_cvtpd2dq (v2df)
11458 v2si __builtin_ia32_cvtpd2pi (v2df)
11459 v4sf __builtin_ia32_cvtpd2ps (v2df)
11460 v4si __builtin_ia32_cvttpd2dq (v2df)
11461 v2si __builtin_ia32_cvttpd2pi (v2df)
11462 v2df __builtin_ia32_cvtpi2pd (v2si)
11463 int __builtin_ia32_cvtsd2si (v2df)
11464 int __builtin_ia32_cvttsd2si (v2df)
11465 long long __builtin_ia32_cvtsd2si64 (v2df)
11466 long long __builtin_ia32_cvttsd2si64 (v2df)
11467 v4si __builtin_ia32_cvtps2dq (v4sf)
11468 v2df __builtin_ia32_cvtps2pd (v4sf)
11469 v4si __builtin_ia32_cvttps2dq (v4sf)
11470 v2df __builtin_ia32_cvtsi2sd (v2df, int)
11471 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
11472 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
11473 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
11474 void __builtin_ia32_clflush (const void *)
11475 void __builtin_ia32_lfence (void)
11476 void __builtin_ia32_mfence (void)
11477 v16qi __builtin_ia32_loaddqu (const char *)
11478 void __builtin_ia32_storedqu (char *, v16qi)
11479 v1di __builtin_ia32_pmuludq (v2si, v2si)
11480 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
11481 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
11482 v4si __builtin_ia32_pslld128 (v4si, v4si)
11483 v2di __builtin_ia32_psllq128 (v2di, v2di)
11484 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
11485 v4si __builtin_ia32_psrld128 (v4si, v4si)
11486 v2di __builtin_ia32_psrlq128 (v2di, v2di)
11487 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
11488 v4si __builtin_ia32_psrad128 (v4si, v4si)
11489 v2di __builtin_ia32_pslldqi128 (v2di, int)
11490 v8hi __builtin_ia32_psllwi128 (v8hi, int)
11491 v4si __builtin_ia32_pslldi128 (v4si, int)
11492 v2di __builtin_ia32_psllqi128 (v2di, int)
11493 v2di __builtin_ia32_psrldqi128 (v2di, int)
11494 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
11495 v4si __builtin_ia32_psrldi128 (v4si, int)
11496 v2di __builtin_ia32_psrlqi128 (v2di, int)
11497 v8hi __builtin_ia32_psrawi128 (v8hi, int)
11498 v4si __builtin_ia32_psradi128 (v4si, int)
11499 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
11500 v2di __builtin_ia32_movq128 (v2di)
11501 @end smallexample
11503 The following built-in functions are available when @option{-msse3} is used.
11504 All of them generate the machine instruction that is part of the name.
11506 @smallexample
11507 v2df __builtin_ia32_addsubpd (v2df, v2df)
11508 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
11509 v2df __builtin_ia32_haddpd (v2df, v2df)
11510 v4sf __builtin_ia32_haddps (v4sf, v4sf)
11511 v2df __builtin_ia32_hsubpd (v2df, v2df)
11512 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
11513 v16qi __builtin_ia32_lddqu (char const *)
11514 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
11515 v4sf __builtin_ia32_movshdup (v4sf)
11516 v4sf __builtin_ia32_movsldup (v4sf)
11517 void __builtin_ia32_mwait (unsigned int, unsigned int)
11518 @end smallexample
11520 The following built-in functions are available when @option{-mssse3} is used.
11521 All of them generate the machine instruction that is part of the name.
11523 @smallexample
11524 v2si __builtin_ia32_phaddd (v2si, v2si)
11525 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
11526 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
11527 v2si __builtin_ia32_phsubd (v2si, v2si)
11528 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
11529 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
11530 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
11531 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
11532 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
11533 v8qi __builtin_ia32_psignb (v8qi, v8qi)
11534 v2si __builtin_ia32_psignd (v2si, v2si)
11535 v4hi __builtin_ia32_psignw (v4hi, v4hi)
11536 v1di __builtin_ia32_palignr (v1di, v1di, int)
11537 v8qi __builtin_ia32_pabsb (v8qi)
11538 v2si __builtin_ia32_pabsd (v2si)
11539 v4hi __builtin_ia32_pabsw (v4hi)
11540 @end smallexample
11542 The following built-in functions are available when @option{-mssse3} is used.
11543 All of them generate the machine instruction that is part of the name.
11545 @smallexample
11546 v4si __builtin_ia32_phaddd128 (v4si, v4si)
11547 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
11548 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
11549 v4si __builtin_ia32_phsubd128 (v4si, v4si)
11550 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
11551 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
11552 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
11553 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
11554 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
11555 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
11556 v4si __builtin_ia32_psignd128 (v4si, v4si)
11557 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
11558 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
11559 v16qi __builtin_ia32_pabsb128 (v16qi)
11560 v4si __builtin_ia32_pabsd128 (v4si)
11561 v8hi __builtin_ia32_pabsw128 (v8hi)
11562 @end smallexample
11564 The following built-in functions are available when @option{-msse4.1} is
11565 used.  All of them generate the machine instruction that is part of the
11566 name.
11568 @smallexample
11569 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
11570 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
11571 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
11572 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
11573 v2df __builtin_ia32_dppd (v2df, v2df, const int)
11574 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
11575 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
11576 v2di __builtin_ia32_movntdqa (v2di *);
11577 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
11578 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
11579 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
11580 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
11581 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
11582 v8hi __builtin_ia32_phminposuw128 (v8hi)
11583 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
11584 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
11585 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
11586 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
11587 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
11588 v4si __builtin_ia32_pminsd128 (v4si, v4si)
11589 v4si __builtin_ia32_pminud128 (v4si, v4si)
11590 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
11591 v4si __builtin_ia32_pmovsxbd128 (v16qi)
11592 v2di __builtin_ia32_pmovsxbq128 (v16qi)
11593 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
11594 v2di __builtin_ia32_pmovsxdq128 (v4si)
11595 v4si __builtin_ia32_pmovsxwd128 (v8hi)
11596 v2di __builtin_ia32_pmovsxwq128 (v8hi)
11597 v4si __builtin_ia32_pmovzxbd128 (v16qi)
11598 v2di __builtin_ia32_pmovzxbq128 (v16qi)
11599 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
11600 v2di __builtin_ia32_pmovzxdq128 (v4si)
11601 v4si __builtin_ia32_pmovzxwd128 (v8hi)
11602 v2di __builtin_ia32_pmovzxwq128 (v8hi)
11603 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
11604 v4si __builtin_ia32_pmulld128 (v4si, v4si)
11605 int __builtin_ia32_ptestc128 (v2di, v2di)
11606 int __builtin_ia32_ptestnzc128 (v2di, v2di)
11607 int __builtin_ia32_ptestz128 (v2di, v2di)
11608 v2df __builtin_ia32_roundpd (v2df, const int)
11609 v4sf __builtin_ia32_roundps (v4sf, const int)
11610 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
11611 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
11612 @end smallexample
11614 The following built-in functions are available when @option{-msse4.1} is
11615 used.
11617 @table @code
11618 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
11619 Generates the @code{insertps} machine instruction.
11620 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
11621 Generates the @code{pextrb} machine instruction.
11622 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
11623 Generates the @code{pinsrb} machine instruction.
11624 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
11625 Generates the @code{pinsrd} machine instruction.
11626 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
11627 Generates the @code{pinsrq} machine instruction in 64bit mode.
11628 @end table
11630 The following built-in functions are changed to generate new SSE4.1
11631 instructions when @option{-msse4.1} is used.
11633 @table @code
11634 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
11635 Generates the @code{extractps} machine instruction.
11636 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
11637 Generates the @code{pextrd} machine instruction.
11638 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
11639 Generates the @code{pextrq} machine instruction in 64bit mode.
11640 @end table
11642 The following built-in functions are available when @option{-msse4.2} is
11643 used.  All of them generate the machine instruction that is part of the
11644 name.
11646 @smallexample
11647 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
11648 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
11649 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
11650 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
11651 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
11652 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
11653 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
11654 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
11655 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
11656 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
11657 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
11658 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
11659 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
11660 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
11661 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
11662 @end smallexample
11664 The following built-in functions are available when @option{-msse4.2} is
11665 used.
11667 @table @code
11668 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
11669 Generates the @code{crc32b} machine instruction.
11670 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
11671 Generates the @code{crc32w} machine instruction.
11672 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
11673 Generates the @code{crc32l} machine instruction.
11674 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
11675 Generates the @code{crc32q} machine instruction.
11676 @end table
11678 The following built-in functions are changed to generate new SSE4.2
11679 instructions when @option{-msse4.2} is used.
11681 @table @code
11682 @item int __builtin_popcount (unsigned int)
11683 Generates the @code{popcntl} machine instruction.
11684 @item int __builtin_popcountl (unsigned long)
11685 Generates the @code{popcntl} or @code{popcntq} machine instruction,
11686 depending on the size of @code{unsigned long}.
11687 @item int __builtin_popcountll (unsigned long long)
11688 Generates the @code{popcntq} machine instruction.
11689 @end table
11691 The following built-in functions are available when @option{-mavx} is
11692 used. All of them generate the machine instruction that is part of the
11693 name.
11695 @smallexample
11696 v4df __builtin_ia32_addpd256 (v4df,v4df)
11697 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
11698 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
11699 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
11700 v4df __builtin_ia32_andnpd256 (v4df,v4df)
11701 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
11702 v4df __builtin_ia32_andpd256 (v4df,v4df)
11703 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
11704 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
11705 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
11706 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
11707 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
11708 v2df __builtin_ia32_cmppd (v2df,v2df,int)
11709 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
11710 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
11711 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
11712 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
11713 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
11714 v4df __builtin_ia32_cvtdq2pd256 (v4si)
11715 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
11716 v4si __builtin_ia32_cvtpd2dq256 (v4df)
11717 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
11718 v8si __builtin_ia32_cvtps2dq256 (v8sf)
11719 v4df __builtin_ia32_cvtps2pd256 (v4sf)
11720 v4si __builtin_ia32_cvttpd2dq256 (v4df)
11721 v8si __builtin_ia32_cvttps2dq256 (v8sf)
11722 v4df __builtin_ia32_divpd256 (v4df,v4df)
11723 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
11724 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
11725 v4df __builtin_ia32_haddpd256 (v4df,v4df)
11726 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
11727 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
11728 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
11729 v32qi __builtin_ia32_lddqu256 (pcchar)
11730 v32qi __builtin_ia32_loaddqu256 (pcchar)
11731 v4df __builtin_ia32_loadupd256 (pcdouble)
11732 v8sf __builtin_ia32_loadups256 (pcfloat)
11733 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
11734 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
11735 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
11736 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
11737 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
11738 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
11739 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
11740 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
11741 v4df __builtin_ia32_maxpd256 (v4df,v4df)
11742 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
11743 v4df __builtin_ia32_minpd256 (v4df,v4df)
11744 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
11745 v4df __builtin_ia32_movddup256 (v4df)
11746 int __builtin_ia32_movmskpd256 (v4df)
11747 int __builtin_ia32_movmskps256 (v8sf)
11748 v8sf __builtin_ia32_movshdup256 (v8sf)
11749 v8sf __builtin_ia32_movsldup256 (v8sf)
11750 v4df __builtin_ia32_mulpd256 (v4df,v4df)
11751 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
11752 v4df __builtin_ia32_orpd256 (v4df,v4df)
11753 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
11754 v2df __builtin_ia32_pd_pd256 (v4df)
11755 v4df __builtin_ia32_pd256_pd (v2df)
11756 v4sf __builtin_ia32_ps_ps256 (v8sf)
11757 v8sf __builtin_ia32_ps256_ps (v4sf)
11758 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
11759 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
11760 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
11761 v8sf __builtin_ia32_rcpps256 (v8sf)
11762 v4df __builtin_ia32_roundpd256 (v4df,int)
11763 v8sf __builtin_ia32_roundps256 (v8sf,int)
11764 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
11765 v8sf __builtin_ia32_rsqrtps256 (v8sf)
11766 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
11767 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
11768 v4si __builtin_ia32_si_si256 (v8si)
11769 v8si __builtin_ia32_si256_si (v4si)
11770 v4df __builtin_ia32_sqrtpd256 (v4df)
11771 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
11772 v8sf __builtin_ia32_sqrtps256 (v8sf)
11773 void __builtin_ia32_storedqu256 (pchar,v32qi)
11774 void __builtin_ia32_storeupd256 (pdouble,v4df)
11775 void __builtin_ia32_storeups256 (pfloat,v8sf)
11776 v4df __builtin_ia32_subpd256 (v4df,v4df)
11777 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
11778 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
11779 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
11780 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
11781 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
11782 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
11783 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
11784 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
11785 v4sf __builtin_ia32_vbroadcastss (pcfloat)
11786 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
11787 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
11788 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
11789 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
11790 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
11791 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
11792 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
11793 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
11794 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
11795 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
11796 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
11797 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
11798 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
11799 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
11800 v2df __builtin_ia32_vpermilpd (v2df,int)
11801 v4df __builtin_ia32_vpermilpd256 (v4df,int)
11802 v4sf __builtin_ia32_vpermilps (v4sf,int)
11803 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
11804 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
11805 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
11806 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
11807 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
11808 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
11809 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
11810 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
11811 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
11812 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
11813 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
11814 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
11815 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
11816 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
11817 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
11818 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
11819 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
11820 void __builtin_ia32_vzeroall (void)
11821 void __builtin_ia32_vzeroupper (void)
11822 v4df __builtin_ia32_xorpd256 (v4df,v4df)
11823 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
11824 @end smallexample
11826 The following built-in functions are available when @option{-mavx2} is
11827 used. All of them generate the machine instruction that is part of the
11828 name.
11830 @smallexample
11831 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,v32qi,int)
11832 v32qi __builtin_ia32_pabsb256 (v32qi)
11833 v16hi __builtin_ia32_pabsw256 (v16hi)
11834 v8si __builtin_ia32_pabsd256 (v8si)
11835 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
11836 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
11837 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
11838 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
11839 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
11840 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
11841 v8si __builtin_ia32_paddd256 (v8si,v8si)
11842 v4di __builtin_ia32_paddq256 (v4di,v4di)
11843 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
11844 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
11845 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
11846 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
11847 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
11848 v4di __builtin_ia32_andsi256 (v4di,v4di)
11849 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
11850 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
11851 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
11852 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
11853 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
11854 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
11855 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
11856 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
11857 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
11858 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
11859 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
11860 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
11861 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
11862 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
11863 v8si __builtin_ia32_phaddd256 (v8si,v8si)
11864 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
11865 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
11866 v8si __builtin_ia32_phsubd256 (v8si,v8si)
11867 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
11868 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
11869 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
11870 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
11871 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
11872 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
11873 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
11874 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
11875 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
11876 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
11877 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
11878 v8si __builtin_ia32_pminsd256 (v8si,v8si)
11879 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
11880 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
11881 v8si __builtin_ia32_pminud256 (v8si,v8si)
11882 int __builtin_ia32_pmovmskb256 (v32qi)
11883 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
11884 v8si __builtin_ia32_pmovsxbd256 (v16qi)
11885 v4di __builtin_ia32_pmovsxbq256 (v16qi)
11886 v8si __builtin_ia32_pmovsxwd256 (v8hi)
11887 v4di __builtin_ia32_pmovsxwq256 (v8hi)
11888 v4di __builtin_ia32_pmovsxdq256 (v4si)
11889 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
11890 v8si __builtin_ia32_pmovzxbd256 (v16qi)
11891 v4di __builtin_ia32_pmovzxbq256 (v16qi)
11892 v8si __builtin_ia32_pmovzxwd256 (v8hi)
11893 v4di __builtin_ia32_pmovzxwq256 (v8hi)
11894 v4di __builtin_ia32_pmovzxdq256 (v4si)
11895 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
11896 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
11897 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
11898 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
11899 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
11900 v8si __builtin_ia32_pmulld256 (v8si,v8si)
11901 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
11902 v4di __builtin_ia32_por256 (v4di,v4di)
11903 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
11904 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
11905 v8si __builtin_ia32_pshufd256 (v8si,int)
11906 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
11907 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
11908 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
11909 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
11910 v8si __builtin_ia32_psignd256 (v8si,v8si)
11911 v4di __builtin_ia32_pslldqi256 (v4di,int)
11912 v16hi __builtin_ia32_psllwi256 (16hi,int)
11913 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
11914 v8si __builtin_ia32_pslldi256 (v8si,int)
11915 v8si __builtin_ia32_pslld256(v8si,v4si)
11916 v4di __builtin_ia32_psllqi256 (v4di,int)
11917 v4di __builtin_ia32_psllq256(v4di,v2di)
11918 v16hi __builtin_ia32_psrawi256 (v16hi,int)
11919 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
11920 v8si __builtin_ia32_psradi256 (v8si,int)
11921 v8si __builtin_ia32_psrad256 (v8si,v4si)
11922 v4di __builtin_ia32_psrldqi256 (v4di, int)
11923 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
11924 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
11925 v8si __builtin_ia32_psrldi256 (v8si,int)
11926 v8si __builtin_ia32_psrld256 (v8si,v4si)
11927 v4di __builtin_ia32_psrlqi256 (v4di,int)
11928 v4di __builtin_ia32_psrlq256(v4di,v2di)
11929 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
11930 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
11931 v8si __builtin_ia32_psubd256 (v8si,v8si)
11932 v4di __builtin_ia32_psubq256 (v4di,v4di)
11933 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
11934 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
11935 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
11936 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
11937 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
11938 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
11939 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
11940 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
11941 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
11942 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
11943 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
11944 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
11945 v4di __builtin_ia32_pxor256 (v4di,v4di)
11946 v4di __builtin_ia32_movntdqa256 (pv4di)
11947 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
11948 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
11949 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
11950 v4di __builtin_ia32_vbroadcastsi256 (v2di)
11951 v4si __builtin_ia32_pblendd128 (v4si,v4si)
11952 v8si __builtin_ia32_pblendd256 (v8si,v8si)
11953 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
11954 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
11955 v8si __builtin_ia32_pbroadcastd256 (v4si)
11956 v4di __builtin_ia32_pbroadcastq256 (v2di)
11957 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
11958 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
11959 v4si __builtin_ia32_pbroadcastd128 (v4si)
11960 v2di __builtin_ia32_pbroadcastq128 (v2di)
11961 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
11962 v4df __builtin_ia32_permdf256 (v4df,int)
11963 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
11964 v4di __builtin_ia32_permdi256 (v4di,int)
11965 v4di __builtin_ia32_permti256 (v4di,v4di,int)
11966 v4di __builtin_ia32_extract128i256 (v4di,int)
11967 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
11968 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
11969 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
11970 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
11971 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
11972 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
11973 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
11974 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
11975 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
11976 v8si __builtin_ia32_psllv8si (v8si,v8si)
11977 v4si __builtin_ia32_psllv4si (v4si,v4si)
11978 v4di __builtin_ia32_psllv4di (v4di,v4di)
11979 v2di __builtin_ia32_psllv2di (v2di,v2di)
11980 v8si __builtin_ia32_psrav8si (v8si,v8si)
11981 v4si __builtin_ia32_psrav4si (v4si,v4si)
11982 v8si __builtin_ia32_psrlv8si (v8si,v8si)
11983 v4si __builtin_ia32_psrlv4si (v4si,v4si)
11984 v4di __builtin_ia32_psrlv4di (v4di,v4di)
11985 v2di __builtin_ia32_psrlv2di (v2di,v2di)
11986 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
11987 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
11988 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
11989 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
11990 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
11991 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
11992 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
11993 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
11994 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
11995 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
11996 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
11997 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
11998 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
11999 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12000 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12001 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12002 @end smallexample
12004 The following built-in functions are available when @option{-maes} is
12005 used.  All of them generate the machine instruction that is part of the
12006 name.
12008 @smallexample
12009 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12010 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12011 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12012 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12013 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12014 v2di __builtin_ia32_aesimc128 (v2di)
12015 @end smallexample
12017 The following built-in function is available when @option{-mpclmul} is
12018 used.
12020 @table @code
12021 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12022 Generates the @code{pclmulqdq} machine instruction.
12023 @end table
12025 The following built-in function is available when @option{-mfsgsbase} is
12026 used.  All of them generate the machine instruction that is part of the
12027 name.
12029 @smallexample
12030 unsigned int __builtin_ia32_rdfsbase32 (void)
12031 unsigned long long __builtin_ia32_rdfsbase64 (void)
12032 unsigned int __builtin_ia32_rdgsbase32 (void)
12033 unsigned long long __builtin_ia32_rdgsbase64 (void)
12034 void _writefsbase_u32 (unsigned int)
12035 void _writefsbase_u64 (unsigned long long)
12036 void _writegsbase_u32 (unsigned int)
12037 void _writegsbase_u64 (unsigned long long)
12038 @end smallexample
12040 The following built-in function is available when @option{-mrdrnd} is
12041 used.  All of them generate the machine instruction that is part of the
12042 name.
12044 @smallexample
12045 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12046 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12047 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12048 @end smallexample
12050 The following built-in functions are available when @option{-msse4a} is used.
12051 All of them generate the machine instruction that is part of the name.
12053 @smallexample
12054 void __builtin_ia32_movntsd (double *, v2df)
12055 void __builtin_ia32_movntss (float *, v4sf)
12056 v2di __builtin_ia32_extrq  (v2di, v16qi)
12057 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12058 v2di __builtin_ia32_insertq (v2di, v2di)
12059 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12060 @end smallexample
12062 The following built-in functions are available when @option{-mxop} is used.
12063 @smallexample
12064 v2df __builtin_ia32_vfrczpd (v2df)
12065 v4sf __builtin_ia32_vfrczps (v4sf)
12066 v2df __builtin_ia32_vfrczsd (v2df, v2df)
12067 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
12068 v4df __builtin_ia32_vfrczpd256 (v4df)
12069 v8sf __builtin_ia32_vfrczps256 (v8sf)
12070 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12071 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12072 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12073 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12074 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12075 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12076 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12077 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12078 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12079 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12080 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12081 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12082 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12083 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12084 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12085 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12086 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12087 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12088 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12089 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12090 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12091 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12092 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12093 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12094 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12095 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12096 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12097 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12098 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12099 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12100 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12101 v4si __builtin_ia32_vpcomged (v4si, v4si)
12102 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12103 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12104 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12105 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12106 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12107 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12108 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12109 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12110 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12111 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12112 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12113 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12114 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12115 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12116 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12117 v4si __builtin_ia32_vpcomled (v4si, v4si)
12118 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12119 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12120 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12121 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12122 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12123 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12124 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12125 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12126 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12127 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12128 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12129 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12130 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12131 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12132 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12133 v4si __builtin_ia32_vpcomned (v4si, v4si)
12134 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12135 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12136 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12137 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12138 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12139 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12140 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12141 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12142 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12143 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12144 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12145 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12146 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12147 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12148 v4si __builtin_ia32_vphaddbd (v16qi)
12149 v2di __builtin_ia32_vphaddbq (v16qi)
12150 v8hi __builtin_ia32_vphaddbw (v16qi)
12151 v2di __builtin_ia32_vphadddq (v4si)
12152 v4si __builtin_ia32_vphaddubd (v16qi)
12153 v2di __builtin_ia32_vphaddubq (v16qi)
12154 v8hi __builtin_ia32_vphaddubw (v16qi)
12155 v2di __builtin_ia32_vphaddudq (v4si)
12156 v4si __builtin_ia32_vphadduwd (v8hi)
12157 v2di __builtin_ia32_vphadduwq (v8hi)
12158 v4si __builtin_ia32_vphaddwd (v8hi)
12159 v2di __builtin_ia32_vphaddwq (v8hi)
12160 v8hi __builtin_ia32_vphsubbw (v16qi)
12161 v2di __builtin_ia32_vphsubdq (v4si)
12162 v4si __builtin_ia32_vphsubwd (v8hi)
12163 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12164 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12165 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12166 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12167 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12168 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12169 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12170 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12171 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12172 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12173 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12174 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12175 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12176 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12177 v4si __builtin_ia32_vprotd (v4si, v4si)
12178 v2di __builtin_ia32_vprotq (v2di, v2di)
12179 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12180 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12181 v4si __builtin_ia32_vpshad (v4si, v4si)
12182 v2di __builtin_ia32_vpshaq (v2di, v2di)
12183 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12184 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12185 v4si __builtin_ia32_vpshld (v4si, v4si)
12186 v2di __builtin_ia32_vpshlq (v2di, v2di)
12187 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12188 @end smallexample
12190 The following built-in functions are available when @option{-mfma4} is used.
12191 All of them generate the machine instruction that is part of the name.
12193 @smallexample
12194 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12195 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12196 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12197 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12198 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12199 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12200 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12201 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12202 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12203 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12204 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12205 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12206 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12207 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12208 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12209 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12210 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
12211 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
12212 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
12213 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
12214 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12215 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12216 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12217 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12218 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12219 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12220 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12221 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12222 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12223 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12224 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12225 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12227 @end smallexample
12229 The following built-in functions are available when @option{-mlwp} is used.
12231 @smallexample
12232 void __builtin_ia32_llwpcb16 (void *);
12233 void __builtin_ia32_llwpcb32 (void *);
12234 void __builtin_ia32_llwpcb64 (void *);
12235 void * __builtin_ia32_llwpcb16 (void);
12236 void * __builtin_ia32_llwpcb32 (void);
12237 void * __builtin_ia32_llwpcb64 (void);
12238 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12239 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12240 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12241 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12242 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12243 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12244 @end smallexample
12246 The following built-in functions are available when @option{-mbmi} is used.
12247 All of them generate the machine instruction that is part of the name.
12248 @smallexample
12249 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12250 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12251 @end smallexample
12253 The following built-in functions are available when @option{-mbmi2} is used.
12254 All of them generate the machine instruction that is part of the name.
12255 @smallexample
12256 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12257 unsigned int _pdep_u32 (unsigned int, unsigned int)
12258 unsigned int _pext_u32 (unsigned int, unsigned int)
12259 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12260 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12261 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12262 @end smallexample
12264 The following built-in functions are available when @option{-mlzcnt} is used.
12265 All of them generate the machine instruction that is part of the name.
12266 @smallexample
12267 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12268 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12269 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12270 @end smallexample
12272 The following built-in functions are available when @option{-mfxsr} is used.
12273 All of them generate the machine instruction that is part of the name.
12274 @smallexample
12275 void __builtin_ia32_fxsave (void *)
12276 void __builtin_ia32_fxrstor (void *)
12277 void __builtin_ia32_fxsave64 (void *)
12278 void __builtin_ia32_fxrstor64 (void *)
12279 @end smallexample
12281 The following built-in functions are available when @option{-mxsave} is used.
12282 All of them generate the machine instruction that is part of the name.
12283 @smallexample
12284 void __builtin_ia32_xsave (void *, long long)
12285 void __builtin_ia32_xrstor (void *, long long)
12286 void __builtin_ia32_xsave64 (void *, long long)
12287 void __builtin_ia32_xrstor64 (void *, long long)
12288 @end smallexample
12290 The following built-in functions are available when @option{-mxsaveopt} is used.
12291 All of them generate the machine instruction that is part of the name.
12292 @smallexample
12293 void __builtin_ia32_xsaveopt (void *, long long)
12294 void __builtin_ia32_xsaveopt64 (void *, long long)
12295 @end smallexample
12297 The following built-in functions are available when @option{-mtbm} is used.
12298 Both of them generate the immediate form of the bextr machine instruction.
12299 @smallexample
12300 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12301 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12302 @end smallexample
12305 The following built-in functions are available when @option{-m3dnow} is used.
12306 All of them generate the machine instruction that is part of the name.
12308 @smallexample
12309 void __builtin_ia32_femms (void)
12310 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12311 v2si __builtin_ia32_pf2id (v2sf)
12312 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12313 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12314 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12315 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12316 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12317 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12318 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12319 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12320 v2sf __builtin_ia32_pfrcp (v2sf)
12321 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12322 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12323 v2sf __builtin_ia32_pfrsqrt (v2sf)
12324 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12325 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12326 v2sf __builtin_ia32_pi2fd (v2si)
12327 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12328 @end smallexample
12330 The following built-in functions are available when both @option{-m3dnow}
12331 and @option{-march=athlon} are used.  All of them generate the machine
12332 instruction that is part of the name.
12334 @smallexample
12335 v2si __builtin_ia32_pf2iw (v2sf)
12336 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12337 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12338 v2sf __builtin_ia32_pi2fw (v2si)
12339 v2sf __builtin_ia32_pswapdsf (v2sf)
12340 v2si __builtin_ia32_pswapdsi (v2si)
12341 @end smallexample
12343 The following built-in functions are available when @option{-mrtm} is used
12344 They are used for restricted transactional memory. These are the internal
12345 low level functions. Normally the functions in 
12346 @ref{X86 transactional memory intrinsics} should be used instead.
12348 @smallexample
12349 int __builtin_ia32_xbegin ()
12350 void __builtin_ia32_xend ()
12351 void __builtin_ia32_xabort (status)
12352 int __builtin_ia32_xtest ()
12353 @end smallexample
12355 @node X86 transactional memory intrinsics
12356 @subsection X86 transaction memory intrinsics
12358 Hardware transactional memory intrinsics for i386. These allow to use
12359 memory transactions with RTM (Restricted Transactional Memory).
12360 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12361 This support is enabled with the @option{-mrtm} option.
12363 A memory transaction commits all changes to memory in an atomic way,
12364 as visible to other threads. If the transaction fails it is rolled back
12365 and all side effects discarded.
12367 Generally there is no guarantee that a memory transaction ever succeeds
12368 and suitable fallback code always needs to be supplied.
12370 @deftypefn {RTM Function} {unsigned} _xbegin ()
12371 Start a RTM (Restricted Transactional Memory) transaction. 
12372 Returns _XBEGIN_STARTED when the transaction
12373 started successfully (note this is not 0, so the constant has to be 
12374 explicitely tested). When the transaction aborts all side effects
12375 are undone and an abort code is returned. There is no guarantee
12376 any transaction ever succeeds, so there always needs to be a valid
12377 tested fallback path.
12378 @end deftypefn
12380 @smallexample
12381 #include <immintrin.h>
12383 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12384     ... transaction code...
12385     _xend ();
12386 @} else @{
12387     ... non transactional fallback path...
12389 @end smallexample
12391 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12393 @table @code
12394 @item _XABORT_EXPLICIT
12395 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12396 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12397 @item _XABORT_RETRY
12398 Transaction retry is possible.
12399 @item _XABORT_CONFLICT
12400 Transaction abort due to a memory conflict with another thread
12401 @item _XABORT_CAPACITY
12402 Transaction abort due to the transaction using too much memory
12403 @item _XABORT_DEBUG
12404 Transaction abort due to a debug trap
12405 @item _XABORT_NESTED
12406 Transaction abort in a inner nested transaction
12407 @end table
12409 @deftypefn {RTM Function} {void} _xend ()
12410 Commit the current transaction. When no transaction is active this will
12411 fault. All memory side effects of the transactions will become visible
12412 to other threads in an atomic matter.
12413 @end deftypefn
12415 @deftypefn {RTM Function} {int} _xtest ()
12416 Return a value not zero when a transaction is currently active, otherwise 0.
12417 @end deftypefn
12419 @deftypefn {RTM Function} {void} _xabort (status)
12420 Abort the current transaction. When no transaction is active this is a no-op.
12421 status must be a 8bit constant, that is included in the status code returned
12422 by @code{_xbegin}
12423 @end deftypefn
12425 @node MIPS DSP Built-in Functions
12426 @subsection MIPS DSP Built-in Functions
12428 The MIPS DSP Application-Specific Extension (ASE) includes new
12429 instructions that are designed to improve the performance of DSP and
12430 media applications.  It provides instructions that operate on packed
12431 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12433 GCC supports MIPS DSP operations using both the generic
12434 vector extensions (@pxref{Vector Extensions}) and a collection of
12435 MIPS-specific built-in functions.  Both kinds of support are
12436 enabled by the @option{-mdsp} command-line option.
12438 Revision 2 of the ASE was introduced in the second half of 2006.
12439 This revision adds extra instructions to the original ASE, but is
12440 otherwise backwards-compatible with it.  You can select revision 2
12441 using the command-line option @option{-mdspr2}; this option implies
12442 @option{-mdsp}.
12444 The SCOUNT and POS bits of the DSP control register are global.  The
12445 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12446 POS bits.  During optimization, the compiler does not delete these
12447 instructions and it does not delete calls to functions containing
12448 these instructions.
12450 At present, GCC only provides support for operations on 32-bit
12451 vectors.  The vector type associated with 8-bit integer data is
12452 usually called @code{v4i8}, the vector type associated with Q7
12453 is usually called @code{v4q7}, the vector type associated with 16-bit
12454 integer data is usually called @code{v2i16}, and the vector type
12455 associated with Q15 is usually called @code{v2q15}.  They can be
12456 defined in C as follows:
12458 @smallexample
12459 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12460 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12461 typedef short v2i16 __attribute__ ((vector_size(4)));
12462 typedef short v2q15 __attribute__ ((vector_size(4)));
12463 @end smallexample
12465 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12466 initialized in the same way as aggregates.  For example:
12468 @smallexample
12469 v4i8 a = @{1, 2, 3, 4@};
12470 v4i8 b;
12471 b = (v4i8) @{5, 6, 7, 8@};
12473 v2q15 c = @{0x0fcb, 0x3a75@};
12474 v2q15 d;
12475 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12476 @end smallexample
12478 @emph{Note:} The CPU's endianness determines the order in which values
12479 are packed.  On little-endian targets, the first value is the least
12480 significant and the last value is the most significant.  The opposite
12481 order applies to big-endian targets.  For example, the code above
12482 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12483 and @code{4} on big-endian targets.
12485 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12486 representation.  As shown in this example, the integer representation
12487 of a Q7 value can be obtained by multiplying the fractional value by
12488 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
12489 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
12490 @code{0x1.0p31}.
12492 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12493 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
12494 and @code{c} and @code{d} are @code{v2q15} values.
12496 @multitable @columnfractions .50 .50
12497 @item C code @tab MIPS instruction
12498 @item @code{a + b} @tab @code{addu.qb}
12499 @item @code{c + d} @tab @code{addq.ph}
12500 @item @code{a - b} @tab @code{subu.qb}
12501 @item @code{c - d} @tab @code{subq.ph}
12502 @end multitable
12504 The table below lists the @code{v2i16} operation for which
12505 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
12506 @code{v2i16} values.
12508 @multitable @columnfractions .50 .50
12509 @item C code @tab MIPS instruction
12510 @item @code{e * f} @tab @code{mul.ph}
12511 @end multitable
12513 It is easier to describe the DSP built-in functions if we first define
12514 the following types:
12516 @smallexample
12517 typedef int q31;
12518 typedef int i32;
12519 typedef unsigned int ui32;
12520 typedef long long a64;
12521 @end smallexample
12523 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12524 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12525 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
12526 @code{long long}, but we use @code{a64} to indicate values that are
12527 placed in one of the four DSP accumulators (@code{$ac0},
12528 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12530 Also, some built-in functions prefer or require immediate numbers as
12531 parameters, because the corresponding DSP instructions accept both immediate
12532 numbers and register operands, or accept immediate numbers only.  The
12533 immediate parameters are listed as follows.
12535 @smallexample
12536 imm0_3: 0 to 3.
12537 imm0_7: 0 to 7.
12538 imm0_15: 0 to 15.
12539 imm0_31: 0 to 31.
12540 imm0_63: 0 to 63.
12541 imm0_255: 0 to 255.
12542 imm_n32_31: -32 to 31.
12543 imm_n512_511: -512 to 511.
12544 @end smallexample
12546 The following built-in functions map directly to a particular MIPS DSP
12547 instruction.  Please refer to the architecture specification
12548 for details on what each instruction does.
12550 @smallexample
12551 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12552 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12553 q31 __builtin_mips_addq_s_w (q31, q31)
12554 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12555 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12556 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12557 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12558 q31 __builtin_mips_subq_s_w (q31, q31)
12559 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12560 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12561 i32 __builtin_mips_addsc (i32, i32)
12562 i32 __builtin_mips_addwc (i32, i32)
12563 i32 __builtin_mips_modsub (i32, i32)
12564 i32 __builtin_mips_raddu_w_qb (v4i8)
12565 v2q15 __builtin_mips_absq_s_ph (v2q15)
12566 q31 __builtin_mips_absq_s_w (q31)
12567 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12568 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12569 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12570 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12571 q31 __builtin_mips_preceq_w_phl (v2q15)
12572 q31 __builtin_mips_preceq_w_phr (v2q15)
12573 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12574 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12575 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12576 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12577 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12578 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12579 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12580 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12581 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12582 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12583 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12584 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12585 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12586 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12587 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12588 q31 __builtin_mips_shll_s_w (q31, i32)
12589 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12590 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12591 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12592 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12593 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12594 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12595 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12596 q31 __builtin_mips_shra_r_w (q31, i32)
12597 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12598 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12599 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12600 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12601 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12602 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12603 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12604 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12605 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12606 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12607 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12608 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12609 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12610 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12611 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12612 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12613 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12614 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12615 i32 __builtin_mips_bitrev (i32)
12616 i32 __builtin_mips_insv (i32, i32)
12617 v4i8 __builtin_mips_repl_qb (imm0_255)
12618 v4i8 __builtin_mips_repl_qb (i32)
12619 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12620 v2q15 __builtin_mips_repl_ph (i32)
12621 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12622 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12623 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12624 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12625 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12626 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12627 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12628 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12629 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12630 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12631 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12632 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12633 i32 __builtin_mips_extr_w (a64, imm0_31)
12634 i32 __builtin_mips_extr_w (a64, i32)
12635 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12636 i32 __builtin_mips_extr_s_h (a64, i32)
12637 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12638 i32 __builtin_mips_extr_rs_w (a64, i32)
12639 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12640 i32 __builtin_mips_extr_r_w (a64, i32)
12641 i32 __builtin_mips_extp (a64, imm0_31)
12642 i32 __builtin_mips_extp (a64, i32)
12643 i32 __builtin_mips_extpdp (a64, imm0_31)
12644 i32 __builtin_mips_extpdp (a64, i32)
12645 a64 __builtin_mips_shilo (a64, imm_n32_31)
12646 a64 __builtin_mips_shilo (a64, i32)
12647 a64 __builtin_mips_mthlip (a64, i32)
12648 void __builtin_mips_wrdsp (i32, imm0_63)
12649 i32 __builtin_mips_rddsp (imm0_63)
12650 i32 __builtin_mips_lbux (void *, i32)
12651 i32 __builtin_mips_lhx (void *, i32)
12652 i32 __builtin_mips_lwx (void *, i32)
12653 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12654 i32 __builtin_mips_bposge32 (void)
12655 a64 __builtin_mips_madd (a64, i32, i32);
12656 a64 __builtin_mips_maddu (a64, ui32, ui32);
12657 a64 __builtin_mips_msub (a64, i32, i32);
12658 a64 __builtin_mips_msubu (a64, ui32, ui32);
12659 a64 __builtin_mips_mult (i32, i32);
12660 a64 __builtin_mips_multu (ui32, ui32);
12661 @end smallexample
12663 The following built-in functions map directly to a particular MIPS DSP REV 2
12664 instruction.  Please refer to the architecture specification
12665 for details on what each instruction does.
12667 @smallexample
12668 v4q7 __builtin_mips_absq_s_qb (v4q7);
12669 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12670 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12671 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12672 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12673 i32 __builtin_mips_append (i32, i32, imm0_31);
12674 i32 __builtin_mips_balign (i32, i32, imm0_3);
12675 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12676 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12677 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12678 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12679 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12680 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12681 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12682 q31 __builtin_mips_mulq_rs_w (q31, q31);
12683 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12684 q31 __builtin_mips_mulq_s_w (q31, q31);
12685 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12686 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12687 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12688 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12689 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12690 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12691 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12692 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12693 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12694 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12695 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12696 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12697 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12698 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12699 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12700 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12701 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12702 q31 __builtin_mips_addqh_w (q31, q31);
12703 q31 __builtin_mips_addqh_r_w (q31, q31);
12704 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12705 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12706 q31 __builtin_mips_subqh_w (q31, q31);
12707 q31 __builtin_mips_subqh_r_w (q31, q31);
12708 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12709 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12710 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12711 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12712 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12713 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12714 @end smallexample
12717 @node MIPS Paired-Single Support
12718 @subsection MIPS Paired-Single Support
12720 The MIPS64 architecture includes a number of instructions that
12721 operate on pairs of single-precision floating-point values.
12722 Each pair is packed into a 64-bit floating-point register,
12723 with one element being designated the ``upper half'' and
12724 the other being designated the ``lower half''.
12726 GCC supports paired-single operations using both the generic
12727 vector extensions (@pxref{Vector Extensions}) and a collection of
12728 MIPS-specific built-in functions.  Both kinds of support are
12729 enabled by the @option{-mpaired-single} command-line option.
12731 The vector type associated with paired-single values is usually
12732 called @code{v2sf}.  It can be defined in C as follows:
12734 @smallexample
12735 typedef float v2sf __attribute__ ((vector_size (8)));
12736 @end smallexample
12738 @code{v2sf} values are initialized in the same way as aggregates.
12739 For example:
12741 @smallexample
12742 v2sf a = @{1.5, 9.1@};
12743 v2sf b;
12744 float e, f;
12745 b = (v2sf) @{e, f@};
12746 @end smallexample
12748 @emph{Note:} The CPU's endianness determines which value is stored in
12749 the upper half of a register and which value is stored in the lower half.
12750 On little-endian targets, the first value is the lower one and the second
12751 value is the upper one.  The opposite order applies to big-endian targets.
12752 For example, the code above sets the lower half of @code{a} to
12753 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12755 @node MIPS Loongson Built-in Functions
12756 @subsection MIPS Loongson Built-in Functions
12758 GCC provides intrinsics to access the SIMD instructions provided by the
12759 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
12760 available after inclusion of the @code{loongson.h} header file,
12761 operate on the following 64-bit vector types:
12763 @itemize
12764 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12765 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12766 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12767 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12768 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12769 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12770 @end itemize
12772 The intrinsics provided are listed below; each is named after the
12773 machine instruction to which it corresponds, with suffixes added as
12774 appropriate to distinguish intrinsics that expand to the same machine
12775 instruction yet have different argument types.  Refer to the architecture
12776 documentation for a description of the functionality of each
12777 instruction.
12779 @smallexample
12780 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12781 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12782 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12783 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12784 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12785 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12786 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12787 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12788 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12789 uint64_t paddd_u (uint64_t s, uint64_t t);
12790 int64_t paddd_s (int64_t s, int64_t t);
12791 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12792 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12793 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12794 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12795 uint64_t pandn_ud (uint64_t s, uint64_t t);
12796 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12797 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12798 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12799 int64_t pandn_sd (int64_t s, int64_t t);
12800 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12801 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12802 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12803 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12804 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12805 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12806 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12807 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12808 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12809 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12810 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12811 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12812 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12813 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12814 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12815 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12816 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12817 uint16x4_t pextrh_u (uint16x4_t s, int field);
12818 int16x4_t pextrh_s (int16x4_t s, int field);
12819 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12820 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12821 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12822 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12823 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12824 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12825 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12826 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12827 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12828 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12829 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12830 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12831 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12832 uint8x8_t pmovmskb_u (uint8x8_t s);
12833 int8x8_t pmovmskb_s (int8x8_t s);
12834 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12835 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12836 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12837 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12838 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12839 uint16x4_t biadd (uint8x8_t s);
12840 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12841 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12842 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12843 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12844 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12845 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12846 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12847 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12848 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12849 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12850 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12851 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12852 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12853 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12854 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12855 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12856 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12857 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12858 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12859 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12860 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12861 uint64_t psubd_u (uint64_t s, uint64_t t);
12862 int64_t psubd_s (int64_t s, int64_t t);
12863 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12864 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12865 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12866 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12867 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12868 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12869 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12870 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12871 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12872 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12873 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12874 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12875 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12876 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12877 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12878 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12879 @end smallexample
12881 @menu
12882 * Paired-Single Arithmetic::
12883 * Paired-Single Built-in Functions::
12884 * MIPS-3D Built-in Functions::
12885 @end menu
12887 @node Paired-Single Arithmetic
12888 @subsubsection Paired-Single Arithmetic
12890 The table below lists the @code{v2sf} operations for which hardware
12891 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
12892 values and @code{x} is an integral value.
12894 @multitable @columnfractions .50 .50
12895 @item C code @tab MIPS instruction
12896 @item @code{a + b} @tab @code{add.ps}
12897 @item @code{a - b} @tab @code{sub.ps}
12898 @item @code{-a} @tab @code{neg.ps}
12899 @item @code{a * b} @tab @code{mul.ps}
12900 @item @code{a * b + c} @tab @code{madd.ps}
12901 @item @code{a * b - c} @tab @code{msub.ps}
12902 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
12903 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
12904 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
12905 @end multitable
12907 Note that the multiply-accumulate instructions can be disabled
12908 using the command-line option @code{-mno-fused-madd}.
12910 @node Paired-Single Built-in Functions
12911 @subsubsection Paired-Single Built-in Functions
12913 The following paired-single functions map directly to a particular
12914 MIPS instruction.  Please refer to the architecture specification
12915 for details on what each instruction does.
12917 @table @code
12918 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
12919 Pair lower lower (@code{pll.ps}).
12921 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
12922 Pair upper lower (@code{pul.ps}).
12924 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
12925 Pair lower upper (@code{plu.ps}).
12927 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
12928 Pair upper upper (@code{puu.ps}).
12930 @item v2sf __builtin_mips_cvt_ps_s (float, float)
12931 Convert pair to paired single (@code{cvt.ps.s}).
12933 @item float __builtin_mips_cvt_s_pl (v2sf)
12934 Convert pair lower to single (@code{cvt.s.pl}).
12936 @item float __builtin_mips_cvt_s_pu (v2sf)
12937 Convert pair upper to single (@code{cvt.s.pu}).
12939 @item v2sf __builtin_mips_abs_ps (v2sf)
12940 Absolute value (@code{abs.ps}).
12942 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12943 Align variable (@code{alnv.ps}).
12945 @emph{Note:} The value of the third parameter must be 0 or 4
12946 modulo 8, otherwise the result is unpredictable.  Please read the
12947 instruction description for details.
12948 @end table
12950 The following multi-instruction functions are also available.
12951 In each case, @var{cond} can be any of the 16 floating-point conditions:
12952 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12953 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12954 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12956 @table @code
12957 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12958 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12959 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12960 @code{movt.ps}/@code{movf.ps}).
12962 The @code{movt} functions return the value @var{x} computed by:
12964 @smallexample
12965 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12966 mov.ps @var{x},@var{c}
12967 movt.ps @var{x},@var{d},@var{cc}
12968 @end smallexample
12970 The @code{movf} functions are similar but use @code{movf.ps} instead
12971 of @code{movt.ps}.
12973 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12974 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12975 Comparison of two paired-single values (@code{c.@var{cond}.ps},
12976 @code{bc1t}/@code{bc1f}).
12978 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12979 and return either the upper or lower half of the result.  For example:
12981 @smallexample
12982 v2sf a, b;
12983 if (__builtin_mips_upper_c_eq_ps (a, b))
12984   upper_halves_are_equal ();
12985 else
12986   upper_halves_are_unequal ();
12988 if (__builtin_mips_lower_c_eq_ps (a, b))
12989   lower_halves_are_equal ();
12990 else
12991   lower_halves_are_unequal ();
12992 @end smallexample
12993 @end table
12995 @node MIPS-3D Built-in Functions
12996 @subsubsection MIPS-3D Built-in Functions
12998 The MIPS-3D Application-Specific Extension (ASE) includes additional
12999 paired-single instructions that are designed to improve the performance
13000 of 3D graphics operations.  Support for these instructions is controlled
13001 by the @option{-mips3d} command-line option.
13003 The functions listed below map directly to a particular MIPS-3D
13004 instruction.  Please refer to the architecture specification for
13005 more details on what each instruction does.
13007 @table @code
13008 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13009 Reduction add (@code{addr.ps}).
13011 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13012 Reduction multiply (@code{mulr.ps}).
13014 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13015 Convert paired single to paired word (@code{cvt.pw.ps}).
13017 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13018 Convert paired word to paired single (@code{cvt.ps.pw}).
13020 @item float __builtin_mips_recip1_s (float)
13021 @itemx double __builtin_mips_recip1_d (double)
13022 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13023 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13025 @item float __builtin_mips_recip2_s (float, float)
13026 @itemx double __builtin_mips_recip2_d (double, double)
13027 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13028 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13030 @item float __builtin_mips_rsqrt1_s (float)
13031 @itemx double __builtin_mips_rsqrt1_d (double)
13032 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13033 Reduced-precision reciprocal square root (sequence step 1)
13034 (@code{rsqrt1.@var{fmt}}).
13036 @item float __builtin_mips_rsqrt2_s (float, float)
13037 @itemx double __builtin_mips_rsqrt2_d (double, double)
13038 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13039 Reduced-precision reciprocal square root (sequence step 2)
13040 (@code{rsqrt2.@var{fmt}}).
13041 @end table
13043 The following multi-instruction functions are also available.
13044 In each case, @var{cond} can be any of the 16 floating-point conditions:
13045 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13046 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13047 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13049 @table @code
13050 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13051 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13052 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13053 @code{bc1t}/@code{bc1f}).
13055 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13056 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13057 For example:
13059 @smallexample
13060 float a, b;
13061 if (__builtin_mips_cabs_eq_s (a, b))
13062   true ();
13063 else
13064   false ();
13065 @end smallexample
13067 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13068 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13069 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13070 @code{bc1t}/@code{bc1f}).
13072 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13073 and return either the upper or lower half of the result.  For example:
13075 @smallexample
13076 v2sf a, b;
13077 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13078   upper_halves_are_equal ();
13079 else
13080   upper_halves_are_unequal ();
13082 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13083   lower_halves_are_equal ();
13084 else
13085   lower_halves_are_unequal ();
13086 @end smallexample
13088 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13089 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13090 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13091 @code{movt.ps}/@code{movf.ps}).
13093 The @code{movt} functions return the value @var{x} computed by:
13095 @smallexample
13096 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13097 mov.ps @var{x},@var{c}
13098 movt.ps @var{x},@var{d},@var{cc}
13099 @end smallexample
13101 The @code{movf} functions are similar but use @code{movf.ps} instead
13102 of @code{movt.ps}.
13104 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13105 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13106 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13107 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13108 Comparison of two paired-single values
13109 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13110 @code{bc1any2t}/@code{bc1any2f}).
13112 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13113 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13114 result is true and the @code{all} forms return true if both results are true.
13115 For example:
13117 @smallexample
13118 v2sf a, b;
13119 if (__builtin_mips_any_c_eq_ps (a, b))
13120   one_is_true ();
13121 else
13122   both_are_false ();
13124 if (__builtin_mips_all_c_eq_ps (a, b))
13125   both_are_true ();
13126 else
13127   one_is_false ();
13128 @end smallexample
13130 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13131 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13132 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13133 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13134 Comparison of four paired-single values
13135 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13136 @code{bc1any4t}/@code{bc1any4f}).
13138 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13139 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13140 The @code{any} forms return true if any of the four results are true
13141 and the @code{all} forms return true if all four results are true.
13142 For example:
13144 @smallexample
13145 v2sf a, b, c, d;
13146 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13147   some_are_true ();
13148 else
13149   all_are_false ();
13151 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13152   all_are_true ();
13153 else
13154   some_are_false ();
13155 @end smallexample
13156 @end table
13158 @node Other MIPS Built-in Functions
13159 @subsection Other MIPS Built-in Functions
13161 GCC provides other MIPS-specific built-in functions:
13163 @table @code
13164 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13165 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13166 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13167 when this function is available.
13169 @item unsigned int __builtin_mips_get_fcsr (void)
13170 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13171 Get and set the contents of the floating-point control and status register
13172 (FPU control register 31).  These functions are only available in hard-float
13173 code but can be called in both MIPS16 and non-MIPS16 contexts.
13175 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13176 register except the condition codes, which GCC assumes are preserved.
13177 @end table
13179 @node MSP430 Built-in Functions
13180 @subsection MSP430 Built-in Functions
13182 GCC provides a couple of special builtin functions to aid in the
13183 writing of interrupt handlers in C.
13185 @table @code
13186 @item __bic_SR_register_on_exit (int @var{mask})
13187 This clears the indicated bits in the saved copy of the status register
13188 currently residing on the stack.  This only works inside interrupt
13189 handlers and the changes to the status register will only take affect
13190 once the handler returns.
13192 @item __bis_SR_register_on_exit (int @var{mask})
13193 This sets the indicated bits in the saved copy of the status register
13194 currently residing on the stack.  This only works inside interrupt
13195 handlers and the changes to the status register will only take affect
13196 once the handler returns.
13198 @item __delay_cycles (long long @var{cycles})
13199 This inserts an instruction sequence that takes exactly @var{cycles}
13200 cycles (between 0 and about 17E9) to complete.  The inserted sequence
13201 may use jumps, loops, or no-ops, and does not interfere with any other
13202 instructions.  Note that @var{cycles} must be a compile-time constant
13203 integer - that is, you must pass a number, not a variable that may be
13204 optimized to a constant later.  The number of cycles delayed by this
13205 builtin is exact.
13206 @end table
13208 @node NDS32 Built-in Functions
13209 @subsection NDS32 Built-in Functions
13211 These built-in functions are available for the NDS32 target:
13213 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13214 Insert an ISYNC instruction into the instruction stream where
13215 @var{addr} is an instruction address for serialization.
13216 @end deftypefn
13218 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13219 Insert an ISB instruction into the instruction stream.
13220 @end deftypefn
13222 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13223 Return the content of a system register which is mapped by @var{sr}.
13224 @end deftypefn
13226 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13227 Return the content of a user space register which is mapped by @var{usr}.
13228 @end deftypefn
13230 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13231 Move the @var{value} to a system register which is mapped by @var{sr}.
13232 @end deftypefn
13234 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13235 Move the @var{value} to a user space register which is mapped by @var{usr}.
13236 @end deftypefn
13238 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13239 Enable global interrupt.
13240 @end deftypefn
13242 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13243 Disable global interrupt.
13244 @end deftypefn
13246 @node picoChip Built-in Functions
13247 @subsection picoChip Built-in Functions
13249 GCC provides an interface to selected machine instructions from the
13250 picoChip instruction set.
13252 @table @code
13253 @item int __builtin_sbc (int @var{value})
13254 Sign bit count.  Return the number of consecutive bits in @var{value}
13255 that have the same value as the sign bit.  The result is the number of
13256 leading sign bits minus one, giving the number of redundant sign bits in
13257 @var{value}.
13259 @item int __builtin_byteswap (int @var{value})
13260 Byte swap.  Return the result of swapping the upper and lower bytes of
13261 @var{value}.
13263 @item int __builtin_brev (int @var{value})
13264 Bit reversal.  Return the result of reversing the bits in
13265 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13266 and so on.
13268 @item int __builtin_adds (int @var{x}, int @var{y})
13269 Saturating addition.  Return the result of adding @var{x} and @var{y},
13270 storing the value 32767 if the result overflows.
13272 @item int __builtin_subs (int @var{x}, int @var{y})
13273 Saturating subtraction.  Return the result of subtracting @var{y} from
13274 @var{x}, storing the value @minus{}32768 if the result overflows.
13276 @item void __builtin_halt (void)
13277 Halt.  The processor stops execution.  This built-in is useful for
13278 implementing assertions.
13280 @end table
13282 @node PowerPC Built-in Functions
13283 @subsection PowerPC Built-in Functions
13285 These built-in functions are available for the PowerPC family of
13286 processors:
13287 @smallexample
13288 float __builtin_recipdivf (float, float);
13289 float __builtin_rsqrtf (float);
13290 double __builtin_recipdiv (double, double);
13291 double __builtin_rsqrt (double);
13292 uint64_t __builtin_ppc_get_timebase ();
13293 unsigned long __builtin_ppc_mftb ();
13294 double __builtin_unpack_longdouble (long double, int);
13295 double __builtin_longdouble_dw0 (long double);
13296 double __builtin_longdouble_dw1 (long double);
13297 long double __builtin_pack_longdouble (double, double);
13298 @end smallexample
13300 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13301 @code{__builtin_rsqrtf} functions generate multiple instructions to
13302 implement the reciprocal sqrt functionality using reciprocal sqrt
13303 estimate instructions.
13305 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13306 functions generate multiple instructions to implement division using
13307 the reciprocal estimate instructions.
13309 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13310 functions generate instructions to read the Time Base Register.  The
13311 @code{__builtin_ppc_get_timebase} function may generate multiple
13312 instructions and always returns the 64 bits of the Time Base Register.
13313 The @code{__builtin_ppc_mftb} function always generates one instruction and
13314 returns the Time Base Register value as an unsigned long, throwing away
13315 the most significant word on 32-bit environments.
13317 The following built-in functions are available for the PowerPC family
13318 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13319 or @option{-mpopcntd}):
13320 @smallexample
13321 long __builtin_bpermd (long, long);
13322 int __builtin_divwe (int, int);
13323 int __builtin_divweo (int, int);
13324 unsigned int __builtin_divweu (unsigned int, unsigned int);
13325 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13326 long __builtin_divde (long, long);
13327 long __builtin_divdeo (long, long);
13328 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13329 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13330 unsigned int cdtbcd (unsigned int);
13331 unsigned int cbcdtd (unsigned int);
13332 unsigned int addg6s (unsigned int, unsigned int);
13333 @end smallexample
13335 The @code{__builtin_divde}, @code{__builtin_divdeo},
13336 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13337 64-bit environment support ISA 2.06 or later.
13339 The following built-in functions are available for the PowerPC family
13340 of processors when hardware decimal floating point
13341 (@option{-mhard-dfp}) is available:
13342 @smallexample
13343 _Decimal64 __builtin_dxex (_Decimal64);
13344 _Decimal128 __builtin_dxexq (_Decimal128);
13345 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13346 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13347 _Decimal64 __builtin_denbcd (int, _Decimal64);
13348 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13349 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13350 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13351 _Decimal64 __builtin_dscli (_Decimal64, int);
13352 _Decimal128 __builitn_dscliq (_Decimal128, int);
13353 _Decimal64 __builtin_dscri (_Decimal64, int);
13354 _Decimal128 __builitn_dscriq (_Decimal128, int);
13355 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13356 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13357 @end smallexample
13359 The following built-in functions are available for the PowerPC family
13360 of processors when the Vector Scalar (vsx) instruction set is
13361 available:
13362 @smallexample
13363 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13364 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13365                                                 unsigned long long);
13366 @end smallexample
13368 @node PowerPC AltiVec/VSX Built-in Functions
13369 @subsection PowerPC AltiVec Built-in Functions
13371 GCC provides an interface for the PowerPC family of processors to access
13372 the AltiVec operations described in Motorola's AltiVec Programming
13373 Interface Manual.  The interface is made available by including
13374 @code{<altivec.h>} and using @option{-maltivec} and
13375 @option{-mabi=altivec}.  The interface supports the following vector
13376 types.
13378 @smallexample
13379 vector unsigned char
13380 vector signed char
13381 vector bool char
13383 vector unsigned short
13384 vector signed short
13385 vector bool short
13386 vector pixel
13388 vector unsigned int
13389 vector signed int
13390 vector bool int
13391 vector float
13392 @end smallexample
13394 If @option{-mvsx} is used the following additional vector types are
13395 implemented.
13397 @smallexample
13398 vector unsigned long
13399 vector signed long
13400 vector double
13401 @end smallexample
13403 The long types are only implemented for 64-bit code generation, and
13404 the long type is only used in the floating point/integer conversion
13405 instructions.
13407 GCC's implementation of the high-level language interface available from
13408 C and C++ code differs from Motorola's documentation in several ways.
13410 @itemize @bullet
13412 @item
13413 A vector constant is a list of constant expressions within curly braces.
13415 @item
13416 A vector initializer requires no cast if the vector constant is of the
13417 same type as the variable it is initializing.
13419 @item
13420 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13421 vector type is the default signedness of the base type.  The default
13422 varies depending on the operating system, so a portable program should
13423 always specify the signedness.
13425 @item
13426 Compiling with @option{-maltivec} adds keywords @code{__vector},
13427 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13428 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13429 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13430 disabled.  To use them, you must include @code{<altivec.h>} instead.
13432 @item
13433 GCC allows using a @code{typedef} name as the type specifier for a
13434 vector type.
13436 @item
13437 For C, overloaded functions are implemented with macros so the following
13438 does not work:
13440 @smallexample
13441   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13442 @end smallexample
13444 @noindent
13445 Since @code{vec_add} is a macro, the vector constant in the example
13446 is treated as four separate arguments.  Wrap the entire argument in
13447 parentheses for this to work.
13448 @end itemize
13450 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13451 Internally, GCC uses built-in functions to achieve the functionality in
13452 the aforementioned header file, but they are not supported and are
13453 subject to change without notice.
13455 The following interfaces are supported for the generic and specific
13456 AltiVec operations and the AltiVec predicates.  In cases where there
13457 is a direct mapping between generic and specific operations, only the
13458 generic names are shown here, although the specific operations can also
13459 be used.
13461 Arguments that are documented as @code{const int} require literal
13462 integral values within the range required for that operation.
13464 @smallexample
13465 vector signed char vec_abs (vector signed char);
13466 vector signed short vec_abs (vector signed short);
13467 vector signed int vec_abs (vector signed int);
13468 vector float vec_abs (vector float);
13470 vector signed char vec_abss (vector signed char);
13471 vector signed short vec_abss (vector signed short);
13472 vector signed int vec_abss (vector signed int);
13474 vector signed char vec_add (vector bool char, vector signed char);
13475 vector signed char vec_add (vector signed char, vector bool char);
13476 vector signed char vec_add (vector signed char, vector signed char);
13477 vector unsigned char vec_add (vector bool char, vector unsigned char);
13478 vector unsigned char vec_add (vector unsigned char, vector bool char);
13479 vector unsigned char vec_add (vector unsigned char,
13480                               vector unsigned char);
13481 vector signed short vec_add (vector bool short, vector signed short);
13482 vector signed short vec_add (vector signed short, vector bool short);
13483 vector signed short vec_add (vector signed short, vector signed short);
13484 vector unsigned short vec_add (vector bool short,
13485                                vector unsigned short);
13486 vector unsigned short vec_add (vector unsigned short,
13487                                vector bool short);
13488 vector unsigned short vec_add (vector unsigned short,
13489                                vector unsigned short);
13490 vector signed int vec_add (vector bool int, vector signed int);
13491 vector signed int vec_add (vector signed int, vector bool int);
13492 vector signed int vec_add (vector signed int, vector signed int);
13493 vector unsigned int vec_add (vector bool int, vector unsigned int);
13494 vector unsigned int vec_add (vector unsigned int, vector bool int);
13495 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13496 vector float vec_add (vector float, vector float);
13498 vector float vec_vaddfp (vector float, vector float);
13500 vector signed int vec_vadduwm (vector bool int, vector signed int);
13501 vector signed int vec_vadduwm (vector signed int, vector bool int);
13502 vector signed int vec_vadduwm (vector signed int, vector signed int);
13503 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13504 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13505 vector unsigned int vec_vadduwm (vector unsigned int,
13506                                  vector unsigned int);
13508 vector signed short vec_vadduhm (vector bool short,
13509                                  vector signed short);
13510 vector signed short vec_vadduhm (vector signed short,
13511                                  vector bool short);
13512 vector signed short vec_vadduhm (vector signed short,
13513                                  vector signed short);
13514 vector unsigned short vec_vadduhm (vector bool short,
13515                                    vector unsigned short);
13516 vector unsigned short vec_vadduhm (vector unsigned short,
13517                                    vector bool short);
13518 vector unsigned short vec_vadduhm (vector unsigned short,
13519                                    vector unsigned short);
13521 vector signed char vec_vaddubm (vector bool char, vector signed char);
13522 vector signed char vec_vaddubm (vector signed char, vector bool char);
13523 vector signed char vec_vaddubm (vector signed char, vector signed char);
13524 vector unsigned char vec_vaddubm (vector bool char,
13525                                   vector unsigned char);
13526 vector unsigned char vec_vaddubm (vector unsigned char,
13527                                   vector bool char);
13528 vector unsigned char vec_vaddubm (vector unsigned char,
13529                                   vector unsigned char);
13531 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13533 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13534 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13535 vector unsigned char vec_adds (vector unsigned char,
13536                                vector unsigned char);
13537 vector signed char vec_adds (vector bool char, vector signed char);
13538 vector signed char vec_adds (vector signed char, vector bool char);
13539 vector signed char vec_adds (vector signed char, vector signed char);
13540 vector unsigned short vec_adds (vector bool short,
13541                                 vector unsigned short);
13542 vector unsigned short vec_adds (vector unsigned short,
13543                                 vector bool short);
13544 vector unsigned short vec_adds (vector unsigned short,
13545                                 vector unsigned short);
13546 vector signed short vec_adds (vector bool short, vector signed short);
13547 vector signed short vec_adds (vector signed short, vector bool short);
13548 vector signed short vec_adds (vector signed short, vector signed short);
13549 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13550 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13551 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13552 vector signed int vec_adds (vector bool int, vector signed int);
13553 vector signed int vec_adds (vector signed int, vector bool int);
13554 vector signed int vec_adds (vector signed int, vector signed int);
13556 vector signed int vec_vaddsws (vector bool int, vector signed int);
13557 vector signed int vec_vaddsws (vector signed int, vector bool int);
13558 vector signed int vec_vaddsws (vector signed int, vector signed int);
13560 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13561 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13562 vector unsigned int vec_vadduws (vector unsigned int,
13563                                  vector unsigned int);
13565 vector signed short vec_vaddshs (vector bool short,
13566                                  vector signed short);
13567 vector signed short vec_vaddshs (vector signed short,
13568                                  vector bool short);
13569 vector signed short vec_vaddshs (vector signed short,
13570                                  vector signed short);
13572 vector unsigned short vec_vadduhs (vector bool short,
13573                                    vector unsigned short);
13574 vector unsigned short vec_vadduhs (vector unsigned short,
13575                                    vector bool short);
13576 vector unsigned short vec_vadduhs (vector unsigned short,
13577                                    vector unsigned short);
13579 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13580 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13581 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13583 vector unsigned char vec_vaddubs (vector bool char,
13584                                   vector unsigned char);
13585 vector unsigned char vec_vaddubs (vector unsigned char,
13586                                   vector bool char);
13587 vector unsigned char vec_vaddubs (vector unsigned char,
13588                                   vector unsigned char);
13590 vector float vec_and (vector float, vector float);
13591 vector float vec_and (vector float, vector bool int);
13592 vector float vec_and (vector bool int, vector float);
13593 vector bool int vec_and (vector bool int, vector bool int);
13594 vector signed int vec_and (vector bool int, vector signed int);
13595 vector signed int vec_and (vector signed int, vector bool int);
13596 vector signed int vec_and (vector signed int, vector signed int);
13597 vector unsigned int vec_and (vector bool int, vector unsigned int);
13598 vector unsigned int vec_and (vector unsigned int, vector bool int);
13599 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13600 vector bool short vec_and (vector bool short, vector bool short);
13601 vector signed short vec_and (vector bool short, vector signed short);
13602 vector signed short vec_and (vector signed short, vector bool short);
13603 vector signed short vec_and (vector signed short, vector signed short);
13604 vector unsigned short vec_and (vector bool short,
13605                                vector unsigned short);
13606 vector unsigned short vec_and (vector unsigned short,
13607                                vector bool short);
13608 vector unsigned short vec_and (vector unsigned short,
13609                                vector unsigned short);
13610 vector signed char vec_and (vector bool char, vector signed char);
13611 vector bool char vec_and (vector bool char, vector bool char);
13612 vector signed char vec_and (vector signed char, vector bool char);
13613 vector signed char vec_and (vector signed char, vector signed char);
13614 vector unsigned char vec_and (vector bool char, vector unsigned char);
13615 vector unsigned char vec_and (vector unsigned char, vector bool char);
13616 vector unsigned char vec_and (vector unsigned char,
13617                               vector unsigned char);
13619 vector float vec_andc (vector float, vector float);
13620 vector float vec_andc (vector float, vector bool int);
13621 vector float vec_andc (vector bool int, vector float);
13622 vector bool int vec_andc (vector bool int, vector bool int);
13623 vector signed int vec_andc (vector bool int, vector signed int);
13624 vector signed int vec_andc (vector signed int, vector bool int);
13625 vector signed int vec_andc (vector signed int, vector signed int);
13626 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13627 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13628 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13629 vector bool short vec_andc (vector bool short, vector bool short);
13630 vector signed short vec_andc (vector bool short, vector signed short);
13631 vector signed short vec_andc (vector signed short, vector bool short);
13632 vector signed short vec_andc (vector signed short, vector signed short);
13633 vector unsigned short vec_andc (vector bool short,
13634                                 vector unsigned short);
13635 vector unsigned short vec_andc (vector unsigned short,
13636                                 vector bool short);
13637 vector unsigned short vec_andc (vector unsigned short,
13638                                 vector unsigned short);
13639 vector signed char vec_andc (vector bool char, vector signed char);
13640 vector bool char vec_andc (vector bool char, vector bool char);
13641 vector signed char vec_andc (vector signed char, vector bool char);
13642 vector signed char vec_andc (vector signed char, vector signed char);
13643 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13644 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13645 vector unsigned char vec_andc (vector unsigned char,
13646                                vector unsigned char);
13648 vector unsigned char vec_avg (vector unsigned char,
13649                               vector unsigned char);
13650 vector signed char vec_avg (vector signed char, vector signed char);
13651 vector unsigned short vec_avg (vector unsigned short,
13652                                vector unsigned short);
13653 vector signed short vec_avg (vector signed short, vector signed short);
13654 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13655 vector signed int vec_avg (vector signed int, vector signed int);
13657 vector signed int vec_vavgsw (vector signed int, vector signed int);
13659 vector unsigned int vec_vavguw (vector unsigned int,
13660                                 vector unsigned int);
13662 vector signed short vec_vavgsh (vector signed short,
13663                                 vector signed short);
13665 vector unsigned short vec_vavguh (vector unsigned short,
13666                                   vector unsigned short);
13668 vector signed char vec_vavgsb (vector signed char, vector signed char);
13670 vector unsigned char vec_vavgub (vector unsigned char,
13671                                  vector unsigned char);
13673 vector float vec_copysign (vector float);
13675 vector float vec_ceil (vector float);
13677 vector signed int vec_cmpb (vector float, vector float);
13679 vector bool char vec_cmpeq (vector signed char, vector signed char);
13680 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13681 vector bool short vec_cmpeq (vector signed short, vector signed short);
13682 vector bool short vec_cmpeq (vector unsigned short,
13683                              vector unsigned short);
13684 vector bool int vec_cmpeq (vector signed int, vector signed int);
13685 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13686 vector bool int vec_cmpeq (vector float, vector float);
13688 vector bool int vec_vcmpeqfp (vector float, vector float);
13690 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13691 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13693 vector bool short vec_vcmpequh (vector signed short,
13694                                 vector signed short);
13695 vector bool short vec_vcmpequh (vector unsigned short,
13696                                 vector unsigned short);
13698 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13699 vector bool char vec_vcmpequb (vector unsigned char,
13700                                vector unsigned char);
13702 vector bool int vec_cmpge (vector float, vector float);
13704 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13705 vector bool char vec_cmpgt (vector signed char, vector signed char);
13706 vector bool short vec_cmpgt (vector unsigned short,
13707                              vector unsigned short);
13708 vector bool short vec_cmpgt (vector signed short, vector signed short);
13709 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13710 vector bool int vec_cmpgt (vector signed int, vector signed int);
13711 vector bool int vec_cmpgt (vector float, vector float);
13713 vector bool int vec_vcmpgtfp (vector float, vector float);
13715 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13717 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13719 vector bool short vec_vcmpgtsh (vector signed short,
13720                                 vector signed short);
13722 vector bool short vec_vcmpgtuh (vector unsigned short,
13723                                 vector unsigned short);
13725 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13727 vector bool char vec_vcmpgtub (vector unsigned char,
13728                                vector unsigned char);
13730 vector bool int vec_cmple (vector float, vector float);
13732 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13733 vector bool char vec_cmplt (vector signed char, vector signed char);
13734 vector bool short vec_cmplt (vector unsigned short,
13735                              vector unsigned short);
13736 vector bool short vec_cmplt (vector signed short, vector signed short);
13737 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13738 vector bool int vec_cmplt (vector signed int, vector signed int);
13739 vector bool int vec_cmplt (vector float, vector float);
13741 vector float vec_ctf (vector unsigned int, const int);
13742 vector float vec_ctf (vector signed int, const int);
13744 vector float vec_vcfsx (vector signed int, const int);
13746 vector float vec_vcfux (vector unsigned int, const int);
13748 vector signed int vec_cts (vector float, const int);
13750 vector unsigned int vec_ctu (vector float, const int);
13752 void vec_dss (const int);
13754 void vec_dssall (void);
13756 void vec_dst (const vector unsigned char *, int, const int);
13757 void vec_dst (const vector signed char *, int, const int);
13758 void vec_dst (const vector bool char *, int, const int);
13759 void vec_dst (const vector unsigned short *, int, const int);
13760 void vec_dst (const vector signed short *, int, const int);
13761 void vec_dst (const vector bool short *, int, const int);
13762 void vec_dst (const vector pixel *, int, const int);
13763 void vec_dst (const vector unsigned int *, int, const int);
13764 void vec_dst (const vector signed int *, int, const int);
13765 void vec_dst (const vector bool int *, int, const int);
13766 void vec_dst (const vector float *, int, const int);
13767 void vec_dst (const unsigned char *, int, const int);
13768 void vec_dst (const signed char *, int, const int);
13769 void vec_dst (const unsigned short *, int, const int);
13770 void vec_dst (const short *, int, const int);
13771 void vec_dst (const unsigned int *, int, const int);
13772 void vec_dst (const int *, int, const int);
13773 void vec_dst (const unsigned long *, int, const int);
13774 void vec_dst (const long *, int, const int);
13775 void vec_dst (const float *, int, const int);
13777 void vec_dstst (const vector unsigned char *, int, const int);
13778 void vec_dstst (const vector signed char *, int, const int);
13779 void vec_dstst (const vector bool char *, int, const int);
13780 void vec_dstst (const vector unsigned short *, int, const int);
13781 void vec_dstst (const vector signed short *, int, const int);
13782 void vec_dstst (const vector bool short *, int, const int);
13783 void vec_dstst (const vector pixel *, int, const int);
13784 void vec_dstst (const vector unsigned int *, int, const int);
13785 void vec_dstst (const vector signed int *, int, const int);
13786 void vec_dstst (const vector bool int *, int, const int);
13787 void vec_dstst (const vector float *, int, const int);
13788 void vec_dstst (const unsigned char *, int, const int);
13789 void vec_dstst (const signed char *, int, const int);
13790 void vec_dstst (const unsigned short *, int, const int);
13791 void vec_dstst (const short *, int, const int);
13792 void vec_dstst (const unsigned int *, int, const int);
13793 void vec_dstst (const int *, int, const int);
13794 void vec_dstst (const unsigned long *, int, const int);
13795 void vec_dstst (const long *, int, const int);
13796 void vec_dstst (const float *, int, const int);
13798 void vec_dststt (const vector unsigned char *, int, const int);
13799 void vec_dststt (const vector signed char *, int, const int);
13800 void vec_dststt (const vector bool char *, int, const int);
13801 void vec_dststt (const vector unsigned short *, int, const int);
13802 void vec_dststt (const vector signed short *, int, const int);
13803 void vec_dststt (const vector bool short *, int, const int);
13804 void vec_dststt (const vector pixel *, int, const int);
13805 void vec_dststt (const vector unsigned int *, int, const int);
13806 void vec_dststt (const vector signed int *, int, const int);
13807 void vec_dststt (const vector bool int *, int, const int);
13808 void vec_dststt (const vector float *, int, const int);
13809 void vec_dststt (const unsigned char *, int, const int);
13810 void vec_dststt (const signed char *, int, const int);
13811 void vec_dststt (const unsigned short *, int, const int);
13812 void vec_dststt (const short *, int, const int);
13813 void vec_dststt (const unsigned int *, int, const int);
13814 void vec_dststt (const int *, int, const int);
13815 void vec_dststt (const unsigned long *, int, const int);
13816 void vec_dststt (const long *, int, const int);
13817 void vec_dststt (const float *, int, const int);
13819 void vec_dstt (const vector unsigned char *, int, const int);
13820 void vec_dstt (const vector signed char *, int, const int);
13821 void vec_dstt (const vector bool char *, int, const int);
13822 void vec_dstt (const vector unsigned short *, int, const int);
13823 void vec_dstt (const vector signed short *, int, const int);
13824 void vec_dstt (const vector bool short *, int, const int);
13825 void vec_dstt (const vector pixel *, int, const int);
13826 void vec_dstt (const vector unsigned int *, int, const int);
13827 void vec_dstt (const vector signed int *, int, const int);
13828 void vec_dstt (const vector bool int *, int, const int);
13829 void vec_dstt (const vector float *, int, const int);
13830 void vec_dstt (const unsigned char *, int, const int);
13831 void vec_dstt (const signed char *, int, const int);
13832 void vec_dstt (const unsigned short *, int, const int);
13833 void vec_dstt (const short *, int, const int);
13834 void vec_dstt (const unsigned int *, int, const int);
13835 void vec_dstt (const int *, int, const int);
13836 void vec_dstt (const unsigned long *, int, const int);
13837 void vec_dstt (const long *, int, const int);
13838 void vec_dstt (const float *, int, const int);
13840 vector float vec_expte (vector float);
13842 vector float vec_floor (vector float);
13844 vector float vec_ld (int, const vector float *);
13845 vector float vec_ld (int, const float *);
13846 vector bool int vec_ld (int, const vector bool int *);
13847 vector signed int vec_ld (int, const vector signed int *);
13848 vector signed int vec_ld (int, const int *);
13849 vector signed int vec_ld (int, const long *);
13850 vector unsigned int vec_ld (int, const vector unsigned int *);
13851 vector unsigned int vec_ld (int, const unsigned int *);
13852 vector unsigned int vec_ld (int, const unsigned long *);
13853 vector bool short vec_ld (int, const vector bool short *);
13854 vector pixel vec_ld (int, const vector pixel *);
13855 vector signed short vec_ld (int, const vector signed short *);
13856 vector signed short vec_ld (int, const short *);
13857 vector unsigned short vec_ld (int, const vector unsigned short *);
13858 vector unsigned short vec_ld (int, const unsigned short *);
13859 vector bool char vec_ld (int, const vector bool char *);
13860 vector signed char vec_ld (int, const vector signed char *);
13861 vector signed char vec_ld (int, const signed char *);
13862 vector unsigned char vec_ld (int, const vector unsigned char *);
13863 vector unsigned char vec_ld (int, const unsigned char *);
13865 vector signed char vec_lde (int, const signed char *);
13866 vector unsigned char vec_lde (int, const unsigned char *);
13867 vector signed short vec_lde (int, const short *);
13868 vector unsigned short vec_lde (int, const unsigned short *);
13869 vector float vec_lde (int, const float *);
13870 vector signed int vec_lde (int, const int *);
13871 vector unsigned int vec_lde (int, const unsigned int *);
13872 vector signed int vec_lde (int, const long *);
13873 vector unsigned int vec_lde (int, const unsigned long *);
13875 vector float vec_lvewx (int, float *);
13876 vector signed int vec_lvewx (int, int *);
13877 vector unsigned int vec_lvewx (int, unsigned int *);
13878 vector signed int vec_lvewx (int, long *);
13879 vector unsigned int vec_lvewx (int, unsigned long *);
13881 vector signed short vec_lvehx (int, short *);
13882 vector unsigned short vec_lvehx (int, unsigned short *);
13884 vector signed char vec_lvebx (int, char *);
13885 vector unsigned char vec_lvebx (int, unsigned char *);
13887 vector float vec_ldl (int, const vector float *);
13888 vector float vec_ldl (int, const float *);
13889 vector bool int vec_ldl (int, const vector bool int *);
13890 vector signed int vec_ldl (int, const vector signed int *);
13891 vector signed int vec_ldl (int, const int *);
13892 vector signed int vec_ldl (int, const long *);
13893 vector unsigned int vec_ldl (int, const vector unsigned int *);
13894 vector unsigned int vec_ldl (int, const unsigned int *);
13895 vector unsigned int vec_ldl (int, const unsigned long *);
13896 vector bool short vec_ldl (int, const vector bool short *);
13897 vector pixel vec_ldl (int, const vector pixel *);
13898 vector signed short vec_ldl (int, const vector signed short *);
13899 vector signed short vec_ldl (int, const short *);
13900 vector unsigned short vec_ldl (int, const vector unsigned short *);
13901 vector unsigned short vec_ldl (int, const unsigned short *);
13902 vector bool char vec_ldl (int, const vector bool char *);
13903 vector signed char vec_ldl (int, const vector signed char *);
13904 vector signed char vec_ldl (int, const signed char *);
13905 vector unsigned char vec_ldl (int, const vector unsigned char *);
13906 vector unsigned char vec_ldl (int, const unsigned char *);
13908 vector float vec_loge (vector float);
13910 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
13911 vector unsigned char vec_lvsl (int, const volatile signed char *);
13912 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
13913 vector unsigned char vec_lvsl (int, const volatile short *);
13914 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
13915 vector unsigned char vec_lvsl (int, const volatile int *);
13916 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
13917 vector unsigned char vec_lvsl (int, const volatile long *);
13918 vector unsigned char vec_lvsl (int, const volatile float *);
13920 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
13921 vector unsigned char vec_lvsr (int, const volatile signed char *);
13922 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
13923 vector unsigned char vec_lvsr (int, const volatile short *);
13924 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
13925 vector unsigned char vec_lvsr (int, const volatile int *);
13926 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
13927 vector unsigned char vec_lvsr (int, const volatile long *);
13928 vector unsigned char vec_lvsr (int, const volatile float *);
13930 vector float vec_madd (vector float, vector float, vector float);
13932 vector signed short vec_madds (vector signed short,
13933                                vector signed short,
13934                                vector signed short);
13936 vector unsigned char vec_max (vector bool char, vector unsigned char);
13937 vector unsigned char vec_max (vector unsigned char, vector bool char);
13938 vector unsigned char vec_max (vector unsigned char,
13939                               vector unsigned char);
13940 vector signed char vec_max (vector bool char, vector signed char);
13941 vector signed char vec_max (vector signed char, vector bool char);
13942 vector signed char vec_max (vector signed char, vector signed char);
13943 vector unsigned short vec_max (vector bool short,
13944                                vector unsigned short);
13945 vector unsigned short vec_max (vector unsigned short,
13946                                vector bool short);
13947 vector unsigned short vec_max (vector unsigned short,
13948                                vector unsigned short);
13949 vector signed short vec_max (vector bool short, vector signed short);
13950 vector signed short vec_max (vector signed short, vector bool short);
13951 vector signed short vec_max (vector signed short, vector signed short);
13952 vector unsigned int vec_max (vector bool int, vector unsigned int);
13953 vector unsigned int vec_max (vector unsigned int, vector bool int);
13954 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13955 vector signed int vec_max (vector bool int, vector signed int);
13956 vector signed int vec_max (vector signed int, vector bool int);
13957 vector signed int vec_max (vector signed int, vector signed int);
13958 vector float vec_max (vector float, vector float);
13960 vector float vec_vmaxfp (vector float, vector float);
13962 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13963 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13964 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13966 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13967 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13968 vector unsigned int vec_vmaxuw (vector unsigned int,
13969                                 vector unsigned int);
13971 vector signed short vec_vmaxsh (vector bool short, vector signed short);
13972 vector signed short vec_vmaxsh (vector signed short, vector bool short);
13973 vector signed short vec_vmaxsh (vector signed short,
13974                                 vector signed short);
13976 vector unsigned short vec_vmaxuh (vector bool short,
13977                                   vector unsigned short);
13978 vector unsigned short vec_vmaxuh (vector unsigned short,
13979                                   vector bool short);
13980 vector unsigned short vec_vmaxuh (vector unsigned short,
13981                                   vector unsigned short);
13983 vector signed char vec_vmaxsb (vector bool char, vector signed char);
13984 vector signed char vec_vmaxsb (vector signed char, vector bool char);
13985 vector signed char vec_vmaxsb (vector signed char, vector signed char);
13987 vector unsigned char vec_vmaxub (vector bool char,
13988                                  vector unsigned char);
13989 vector unsigned char vec_vmaxub (vector unsigned char,
13990                                  vector bool char);
13991 vector unsigned char vec_vmaxub (vector unsigned char,
13992                                  vector unsigned char);
13994 vector bool char vec_mergeh (vector bool char, vector bool char);
13995 vector signed char vec_mergeh (vector signed char, vector signed char);
13996 vector unsigned char vec_mergeh (vector unsigned char,
13997                                  vector unsigned char);
13998 vector bool short vec_mergeh (vector bool short, vector bool short);
13999 vector pixel vec_mergeh (vector pixel, vector pixel);
14000 vector signed short vec_mergeh (vector signed short,
14001                                 vector signed short);
14002 vector unsigned short vec_mergeh (vector unsigned short,
14003                                   vector unsigned short);
14004 vector float vec_mergeh (vector float, vector float);
14005 vector bool int vec_mergeh (vector bool int, vector bool int);
14006 vector signed int vec_mergeh (vector signed int, vector signed int);
14007 vector unsigned int vec_mergeh (vector unsigned int,
14008                                 vector unsigned int);
14010 vector float vec_vmrghw (vector float, vector float);
14011 vector bool int vec_vmrghw (vector bool int, vector bool int);
14012 vector signed int vec_vmrghw (vector signed int, vector signed int);
14013 vector unsigned int vec_vmrghw (vector unsigned int,
14014                                 vector unsigned int);
14016 vector bool short vec_vmrghh (vector bool short, vector bool short);
14017 vector signed short vec_vmrghh (vector signed short,
14018                                 vector signed short);
14019 vector unsigned short vec_vmrghh (vector unsigned short,
14020                                   vector unsigned short);
14021 vector pixel vec_vmrghh (vector pixel, vector pixel);
14023 vector bool char vec_vmrghb (vector bool char, vector bool char);
14024 vector signed char vec_vmrghb (vector signed char, vector signed char);
14025 vector unsigned char vec_vmrghb (vector unsigned char,
14026                                  vector unsigned char);
14028 vector bool char vec_mergel (vector bool char, vector bool char);
14029 vector signed char vec_mergel (vector signed char, vector signed char);
14030 vector unsigned char vec_mergel (vector unsigned char,
14031                                  vector unsigned char);
14032 vector bool short vec_mergel (vector bool short, vector bool short);
14033 vector pixel vec_mergel (vector pixel, vector pixel);
14034 vector signed short vec_mergel (vector signed short,
14035                                 vector signed short);
14036 vector unsigned short vec_mergel (vector unsigned short,
14037                                   vector unsigned short);
14038 vector float vec_mergel (vector float, vector float);
14039 vector bool int vec_mergel (vector bool int, vector bool int);
14040 vector signed int vec_mergel (vector signed int, vector signed int);
14041 vector unsigned int vec_mergel (vector unsigned int,
14042                                 vector unsigned int);
14044 vector float vec_vmrglw (vector float, vector float);
14045 vector signed int vec_vmrglw (vector signed int, vector signed int);
14046 vector unsigned int vec_vmrglw (vector unsigned int,
14047                                 vector unsigned int);
14048 vector bool int vec_vmrglw (vector bool int, vector bool int);
14050 vector bool short vec_vmrglh (vector bool short, vector bool short);
14051 vector signed short vec_vmrglh (vector signed short,
14052                                 vector signed short);
14053 vector unsigned short vec_vmrglh (vector unsigned short,
14054                                   vector unsigned short);
14055 vector pixel vec_vmrglh (vector pixel, vector pixel);
14057 vector bool char vec_vmrglb (vector bool char, vector bool char);
14058 vector signed char vec_vmrglb (vector signed char, vector signed char);
14059 vector unsigned char vec_vmrglb (vector unsigned char,
14060                                  vector unsigned char);
14062 vector unsigned short vec_mfvscr (void);
14064 vector unsigned char vec_min (vector bool char, vector unsigned char);
14065 vector unsigned char vec_min (vector unsigned char, vector bool char);
14066 vector unsigned char vec_min (vector unsigned char,
14067                               vector unsigned char);
14068 vector signed char vec_min (vector bool char, vector signed char);
14069 vector signed char vec_min (vector signed char, vector bool char);
14070 vector signed char vec_min (vector signed char, vector signed char);
14071 vector unsigned short vec_min (vector bool short,
14072                                vector unsigned short);
14073 vector unsigned short vec_min (vector unsigned short,
14074                                vector bool short);
14075 vector unsigned short vec_min (vector unsigned short,
14076                                vector unsigned short);
14077 vector signed short vec_min (vector bool short, vector signed short);
14078 vector signed short vec_min (vector signed short, vector bool short);
14079 vector signed short vec_min (vector signed short, vector signed short);
14080 vector unsigned int vec_min (vector bool int, vector unsigned int);
14081 vector unsigned int vec_min (vector unsigned int, vector bool int);
14082 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14083 vector signed int vec_min (vector bool int, vector signed int);
14084 vector signed int vec_min (vector signed int, vector bool int);
14085 vector signed int vec_min (vector signed int, vector signed int);
14086 vector float vec_min (vector float, vector float);
14088 vector float vec_vminfp (vector float, vector float);
14090 vector signed int vec_vminsw (vector bool int, vector signed int);
14091 vector signed int vec_vminsw (vector signed int, vector bool int);
14092 vector signed int vec_vminsw (vector signed int, vector signed int);
14094 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14095 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14096 vector unsigned int vec_vminuw (vector unsigned int,
14097                                 vector unsigned int);
14099 vector signed short vec_vminsh (vector bool short, vector signed short);
14100 vector signed short vec_vminsh (vector signed short, vector bool short);
14101 vector signed short vec_vminsh (vector signed short,
14102                                 vector signed short);
14104 vector unsigned short vec_vminuh (vector bool short,
14105                                   vector unsigned short);
14106 vector unsigned short vec_vminuh (vector unsigned short,
14107                                   vector bool short);
14108 vector unsigned short vec_vminuh (vector unsigned short,
14109                                   vector unsigned short);
14111 vector signed char vec_vminsb (vector bool char, vector signed char);
14112 vector signed char vec_vminsb (vector signed char, vector bool char);
14113 vector signed char vec_vminsb (vector signed char, vector signed char);
14115 vector unsigned char vec_vminub (vector bool char,
14116                                  vector unsigned char);
14117 vector unsigned char vec_vminub (vector unsigned char,
14118                                  vector bool char);
14119 vector unsigned char vec_vminub (vector unsigned char,
14120                                  vector unsigned char);
14122 vector signed short vec_mladd (vector signed short,
14123                                vector signed short,
14124                                vector signed short);
14125 vector signed short vec_mladd (vector signed short,
14126                                vector unsigned short,
14127                                vector unsigned short);
14128 vector signed short vec_mladd (vector unsigned short,
14129                                vector signed short,
14130                                vector signed short);
14131 vector unsigned short vec_mladd (vector unsigned short,
14132                                  vector unsigned short,
14133                                  vector unsigned short);
14135 vector signed short vec_mradds (vector signed short,
14136                                 vector signed short,
14137                                 vector signed short);
14139 vector unsigned int vec_msum (vector unsigned char,
14140                               vector unsigned char,
14141                               vector unsigned int);
14142 vector signed int vec_msum (vector signed char,
14143                             vector unsigned char,
14144                             vector signed int);
14145 vector unsigned int vec_msum (vector unsigned short,
14146                               vector unsigned short,
14147                               vector unsigned int);
14148 vector signed int vec_msum (vector signed short,
14149                             vector signed short,
14150                             vector signed int);
14152 vector signed int vec_vmsumshm (vector signed short,
14153                                 vector signed short,
14154                                 vector signed int);
14156 vector unsigned int vec_vmsumuhm (vector unsigned short,
14157                                   vector unsigned short,
14158                                   vector unsigned int);
14160 vector signed int vec_vmsummbm (vector signed char,
14161                                 vector unsigned char,
14162                                 vector signed int);
14164 vector unsigned int vec_vmsumubm (vector unsigned char,
14165                                   vector unsigned char,
14166                                   vector unsigned int);
14168 vector unsigned int vec_msums (vector unsigned short,
14169                                vector unsigned short,
14170                                vector unsigned int);
14171 vector signed int vec_msums (vector signed short,
14172                              vector signed short,
14173                              vector signed int);
14175 vector signed int vec_vmsumshs (vector signed short,
14176                                 vector signed short,
14177                                 vector signed int);
14179 vector unsigned int vec_vmsumuhs (vector unsigned short,
14180                                   vector unsigned short,
14181                                   vector unsigned int);
14183 void vec_mtvscr (vector signed int);
14184 void vec_mtvscr (vector unsigned int);
14185 void vec_mtvscr (vector bool int);
14186 void vec_mtvscr (vector signed short);
14187 void vec_mtvscr (vector unsigned short);
14188 void vec_mtvscr (vector bool short);
14189 void vec_mtvscr (vector pixel);
14190 void vec_mtvscr (vector signed char);
14191 void vec_mtvscr (vector unsigned char);
14192 void vec_mtvscr (vector bool char);
14194 vector unsigned short vec_mule (vector unsigned char,
14195                                 vector unsigned char);
14196 vector signed short vec_mule (vector signed char,
14197                               vector signed char);
14198 vector unsigned int vec_mule (vector unsigned short,
14199                               vector unsigned short);
14200 vector signed int vec_mule (vector signed short, vector signed short);
14202 vector signed int vec_vmulesh (vector signed short,
14203                                vector signed short);
14205 vector unsigned int vec_vmuleuh (vector unsigned short,
14206                                  vector unsigned short);
14208 vector signed short vec_vmulesb (vector signed char,
14209                                  vector signed char);
14211 vector unsigned short vec_vmuleub (vector unsigned char,
14212                                   vector unsigned char);
14214 vector unsigned short vec_mulo (vector unsigned char,
14215                                 vector unsigned char);
14216 vector signed short vec_mulo (vector signed char, vector signed char);
14217 vector unsigned int vec_mulo (vector unsigned short,
14218                               vector unsigned short);
14219 vector signed int vec_mulo (vector signed short, vector signed short);
14221 vector signed int vec_vmulosh (vector signed short,
14222                                vector signed short);
14224 vector unsigned int vec_vmulouh (vector unsigned short,
14225                                  vector unsigned short);
14227 vector signed short vec_vmulosb (vector signed char,
14228                                  vector signed char);
14230 vector unsigned short vec_vmuloub (vector unsigned char,
14231                                    vector unsigned char);
14233 vector float vec_nmsub (vector float, vector float, vector float);
14235 vector float vec_nor (vector float, vector float);
14236 vector signed int vec_nor (vector signed int, vector signed int);
14237 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14238 vector bool int vec_nor (vector bool int, vector bool int);
14239 vector signed short vec_nor (vector signed short, vector signed short);
14240 vector unsigned short vec_nor (vector unsigned short,
14241                                vector unsigned short);
14242 vector bool short vec_nor (vector bool short, vector bool short);
14243 vector signed char vec_nor (vector signed char, vector signed char);
14244 vector unsigned char vec_nor (vector unsigned char,
14245                               vector unsigned char);
14246 vector bool char vec_nor (vector bool char, vector bool char);
14248 vector float vec_or (vector float, vector float);
14249 vector float vec_or (vector float, vector bool int);
14250 vector float vec_or (vector bool int, vector float);
14251 vector bool int vec_or (vector bool int, vector bool int);
14252 vector signed int vec_or (vector bool int, vector signed int);
14253 vector signed int vec_or (vector signed int, vector bool int);
14254 vector signed int vec_or (vector signed int, vector signed int);
14255 vector unsigned int vec_or (vector bool int, vector unsigned int);
14256 vector unsigned int vec_or (vector unsigned int, vector bool int);
14257 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14258 vector bool short vec_or (vector bool short, vector bool short);
14259 vector signed short vec_or (vector bool short, vector signed short);
14260 vector signed short vec_or (vector signed short, vector bool short);
14261 vector signed short vec_or (vector signed short, vector signed short);
14262 vector unsigned short vec_or (vector bool short, vector unsigned short);
14263 vector unsigned short vec_or (vector unsigned short, vector bool short);
14264 vector unsigned short vec_or (vector unsigned short,
14265                               vector unsigned short);
14266 vector signed char vec_or (vector bool char, vector signed char);
14267 vector bool char vec_or (vector bool char, vector bool char);
14268 vector signed char vec_or (vector signed char, vector bool char);
14269 vector signed char vec_or (vector signed char, vector signed char);
14270 vector unsigned char vec_or (vector bool char, vector unsigned char);
14271 vector unsigned char vec_or (vector unsigned char, vector bool char);
14272 vector unsigned char vec_or (vector unsigned char,
14273                              vector unsigned char);
14275 vector signed char vec_pack (vector signed short, vector signed short);
14276 vector unsigned char vec_pack (vector unsigned short,
14277                                vector unsigned short);
14278 vector bool char vec_pack (vector bool short, vector bool short);
14279 vector signed short vec_pack (vector signed int, vector signed int);
14280 vector unsigned short vec_pack (vector unsigned int,
14281                                 vector unsigned int);
14282 vector bool short vec_pack (vector bool int, vector bool int);
14284 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14285 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14286 vector unsigned short vec_vpkuwum (vector unsigned int,
14287                                    vector unsigned int);
14289 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14290 vector signed char vec_vpkuhum (vector signed short,
14291                                 vector signed short);
14292 vector unsigned char vec_vpkuhum (vector unsigned short,
14293                                   vector unsigned short);
14295 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14297 vector unsigned char vec_packs (vector unsigned short,
14298                                 vector unsigned short);
14299 vector signed char vec_packs (vector signed short, vector signed short);
14300 vector unsigned short vec_packs (vector unsigned int,
14301                                  vector unsigned int);
14302 vector signed short vec_packs (vector signed int, vector signed int);
14304 vector signed short vec_vpkswss (vector signed int, vector signed int);
14306 vector unsigned short vec_vpkuwus (vector unsigned int,
14307                                    vector unsigned int);
14309 vector signed char vec_vpkshss (vector signed short,
14310                                 vector signed short);
14312 vector unsigned char vec_vpkuhus (vector unsigned short,
14313                                   vector unsigned short);
14315 vector unsigned char vec_packsu (vector unsigned short,
14316                                  vector unsigned short);
14317 vector unsigned char vec_packsu (vector signed short,
14318                                  vector signed short);
14319 vector unsigned short vec_packsu (vector unsigned int,
14320                                   vector unsigned int);
14321 vector unsigned short vec_packsu (vector signed int, vector signed int);
14323 vector unsigned short vec_vpkswus (vector signed int,
14324                                    vector signed int);
14326 vector unsigned char vec_vpkshus (vector signed short,
14327                                   vector signed short);
14329 vector float vec_perm (vector float,
14330                        vector float,
14331                        vector unsigned char);
14332 vector signed int vec_perm (vector signed int,
14333                             vector signed int,
14334                             vector unsigned char);
14335 vector unsigned int vec_perm (vector unsigned int,
14336                               vector unsigned int,
14337                               vector unsigned char);
14338 vector bool int vec_perm (vector bool int,
14339                           vector bool int,
14340                           vector unsigned char);
14341 vector signed short vec_perm (vector signed short,
14342                               vector signed short,
14343                               vector unsigned char);
14344 vector unsigned short vec_perm (vector unsigned short,
14345                                 vector unsigned short,
14346                                 vector unsigned char);
14347 vector bool short vec_perm (vector bool short,
14348                             vector bool short,
14349                             vector unsigned char);
14350 vector pixel vec_perm (vector pixel,
14351                        vector pixel,
14352                        vector unsigned char);
14353 vector signed char vec_perm (vector signed char,
14354                              vector signed char,
14355                              vector unsigned char);
14356 vector unsigned char vec_perm (vector unsigned char,
14357                                vector unsigned char,
14358                                vector unsigned char);
14359 vector bool char vec_perm (vector bool char,
14360                            vector bool char,
14361                            vector unsigned char);
14363 vector float vec_re (vector float);
14365 vector signed char vec_rl (vector signed char,
14366                            vector unsigned char);
14367 vector unsigned char vec_rl (vector unsigned char,
14368                              vector unsigned char);
14369 vector signed short vec_rl (vector signed short, vector unsigned short);
14370 vector unsigned short vec_rl (vector unsigned short,
14371                               vector unsigned short);
14372 vector signed int vec_rl (vector signed int, vector unsigned int);
14373 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14375 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14376 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14378 vector signed short vec_vrlh (vector signed short,
14379                               vector unsigned short);
14380 vector unsigned short vec_vrlh (vector unsigned short,
14381                                 vector unsigned short);
14383 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14384 vector unsigned char vec_vrlb (vector unsigned char,
14385                                vector unsigned char);
14387 vector float vec_round (vector float);
14389 vector float vec_recip (vector float, vector float);
14391 vector float vec_rsqrt (vector float);
14393 vector float vec_rsqrte (vector float);
14395 vector float vec_sel (vector float, vector float, vector bool int);
14396 vector float vec_sel (vector float, vector float, vector unsigned int);
14397 vector signed int vec_sel (vector signed int,
14398                            vector signed int,
14399                            vector bool int);
14400 vector signed int vec_sel (vector signed int,
14401                            vector signed int,
14402                            vector unsigned int);
14403 vector unsigned int vec_sel (vector unsigned int,
14404                              vector unsigned int,
14405                              vector bool int);
14406 vector unsigned int vec_sel (vector unsigned int,
14407                              vector unsigned int,
14408                              vector unsigned int);
14409 vector bool int vec_sel (vector bool int,
14410                          vector bool int,
14411                          vector bool int);
14412 vector bool int vec_sel (vector bool int,
14413                          vector bool int,
14414                          vector unsigned int);
14415 vector signed short vec_sel (vector signed short,
14416                              vector signed short,
14417                              vector bool short);
14418 vector signed short vec_sel (vector signed short,
14419                              vector signed short,
14420                              vector unsigned short);
14421 vector unsigned short vec_sel (vector unsigned short,
14422                                vector unsigned short,
14423                                vector bool short);
14424 vector unsigned short vec_sel (vector unsigned short,
14425                                vector unsigned short,
14426                                vector unsigned short);
14427 vector bool short vec_sel (vector bool short,
14428                            vector bool short,
14429                            vector bool short);
14430 vector bool short vec_sel (vector bool short,
14431                            vector bool short,
14432                            vector unsigned short);
14433 vector signed char vec_sel (vector signed char,
14434                             vector signed char,
14435                             vector bool char);
14436 vector signed char vec_sel (vector signed char,
14437                             vector signed char,
14438                             vector unsigned char);
14439 vector unsigned char vec_sel (vector unsigned char,
14440                               vector unsigned char,
14441                               vector bool char);
14442 vector unsigned char vec_sel (vector unsigned char,
14443                               vector unsigned char,
14444                               vector unsigned char);
14445 vector bool char vec_sel (vector bool char,
14446                           vector bool char,
14447                           vector bool char);
14448 vector bool char vec_sel (vector bool char,
14449                           vector bool char,
14450                           vector unsigned char);
14452 vector signed char vec_sl (vector signed char,
14453                            vector unsigned char);
14454 vector unsigned char vec_sl (vector unsigned char,
14455                              vector unsigned char);
14456 vector signed short vec_sl (vector signed short, vector unsigned short);
14457 vector unsigned short vec_sl (vector unsigned short,
14458                               vector unsigned short);
14459 vector signed int vec_sl (vector signed int, vector unsigned int);
14460 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14462 vector signed int vec_vslw (vector signed int, vector unsigned int);
14463 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14465 vector signed short vec_vslh (vector signed short,
14466                               vector unsigned short);
14467 vector unsigned short vec_vslh (vector unsigned short,
14468                                 vector unsigned short);
14470 vector signed char vec_vslb (vector signed char, vector unsigned char);
14471 vector unsigned char vec_vslb (vector unsigned char,
14472                                vector unsigned char);
14474 vector float vec_sld (vector float, vector float, const int);
14475 vector signed int vec_sld (vector signed int,
14476                            vector signed int,
14477                            const int);
14478 vector unsigned int vec_sld (vector unsigned int,
14479                              vector unsigned int,
14480                              const int);
14481 vector bool int vec_sld (vector bool int,
14482                          vector bool int,
14483                          const int);
14484 vector signed short vec_sld (vector signed short,
14485                              vector signed short,
14486                              const int);
14487 vector unsigned short vec_sld (vector unsigned short,
14488                                vector unsigned short,
14489                                const int);
14490 vector bool short vec_sld (vector bool short,
14491                            vector bool short,
14492                            const int);
14493 vector pixel vec_sld (vector pixel,
14494                       vector pixel,
14495                       const int);
14496 vector signed char vec_sld (vector signed char,
14497                             vector signed char,
14498                             const int);
14499 vector unsigned char vec_sld (vector unsigned char,
14500                               vector unsigned char,
14501                               const int);
14502 vector bool char vec_sld (vector bool char,
14503                           vector bool char,
14504                           const int);
14506 vector signed int vec_sll (vector signed int,
14507                            vector unsigned int);
14508 vector signed int vec_sll (vector signed int,
14509                            vector unsigned short);
14510 vector signed int vec_sll (vector signed int,
14511                            vector unsigned char);
14512 vector unsigned int vec_sll (vector unsigned int,
14513                              vector unsigned int);
14514 vector unsigned int vec_sll (vector unsigned int,
14515                              vector unsigned short);
14516 vector unsigned int vec_sll (vector unsigned int,
14517                              vector unsigned char);
14518 vector bool int vec_sll (vector bool int,
14519                          vector unsigned int);
14520 vector bool int vec_sll (vector bool int,
14521                          vector unsigned short);
14522 vector bool int vec_sll (vector bool int,
14523                          vector unsigned char);
14524 vector signed short vec_sll (vector signed short,
14525                              vector unsigned int);
14526 vector signed short vec_sll (vector signed short,
14527                              vector unsigned short);
14528 vector signed short vec_sll (vector signed short,
14529                              vector unsigned char);
14530 vector unsigned short vec_sll (vector unsigned short,
14531                                vector unsigned int);
14532 vector unsigned short vec_sll (vector unsigned short,
14533                                vector unsigned short);
14534 vector unsigned short vec_sll (vector unsigned short,
14535                                vector unsigned char);
14536 vector bool short vec_sll (vector bool short, vector unsigned int);
14537 vector bool short vec_sll (vector bool short, vector unsigned short);
14538 vector bool short vec_sll (vector bool short, vector unsigned char);
14539 vector pixel vec_sll (vector pixel, vector unsigned int);
14540 vector pixel vec_sll (vector pixel, vector unsigned short);
14541 vector pixel vec_sll (vector pixel, vector unsigned char);
14542 vector signed char vec_sll (vector signed char, vector unsigned int);
14543 vector signed char vec_sll (vector signed char, vector unsigned short);
14544 vector signed char vec_sll (vector signed char, vector unsigned char);
14545 vector unsigned char vec_sll (vector unsigned char,
14546                               vector unsigned int);
14547 vector unsigned char vec_sll (vector unsigned char,
14548                               vector unsigned short);
14549 vector unsigned char vec_sll (vector unsigned char,
14550                               vector unsigned char);
14551 vector bool char vec_sll (vector bool char, vector unsigned int);
14552 vector bool char vec_sll (vector bool char, vector unsigned short);
14553 vector bool char vec_sll (vector bool char, vector unsigned char);
14555 vector float vec_slo (vector float, vector signed char);
14556 vector float vec_slo (vector float, vector unsigned char);
14557 vector signed int vec_slo (vector signed int, vector signed char);
14558 vector signed int vec_slo (vector signed int, vector unsigned char);
14559 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14560 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14561 vector signed short vec_slo (vector signed short, vector signed char);
14562 vector signed short vec_slo (vector signed short, vector unsigned char);
14563 vector unsigned short vec_slo (vector unsigned short,
14564                                vector signed char);
14565 vector unsigned short vec_slo (vector unsigned short,
14566                                vector unsigned char);
14567 vector pixel vec_slo (vector pixel, vector signed char);
14568 vector pixel vec_slo (vector pixel, vector unsigned char);
14569 vector signed char vec_slo (vector signed char, vector signed char);
14570 vector signed char vec_slo (vector signed char, vector unsigned char);
14571 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14572 vector unsigned char vec_slo (vector unsigned char,
14573                               vector unsigned char);
14575 vector signed char vec_splat (vector signed char, const int);
14576 vector unsigned char vec_splat (vector unsigned char, const int);
14577 vector bool char vec_splat (vector bool char, const int);
14578 vector signed short vec_splat (vector signed short, const int);
14579 vector unsigned short vec_splat (vector unsigned short, const int);
14580 vector bool short vec_splat (vector bool short, const int);
14581 vector pixel vec_splat (vector pixel, const int);
14582 vector float vec_splat (vector float, const int);
14583 vector signed int vec_splat (vector signed int, const int);
14584 vector unsigned int vec_splat (vector unsigned int, const int);
14585 vector bool int vec_splat (vector bool int, const int);
14587 vector float vec_vspltw (vector float, const int);
14588 vector signed int vec_vspltw (vector signed int, const int);
14589 vector unsigned int vec_vspltw (vector unsigned int, const int);
14590 vector bool int vec_vspltw (vector bool int, const int);
14592 vector bool short vec_vsplth (vector bool short, const int);
14593 vector signed short vec_vsplth (vector signed short, const int);
14594 vector unsigned short vec_vsplth (vector unsigned short, const int);
14595 vector pixel vec_vsplth (vector pixel, const int);
14597 vector signed char vec_vspltb (vector signed char, const int);
14598 vector unsigned char vec_vspltb (vector unsigned char, const int);
14599 vector bool char vec_vspltb (vector bool char, const int);
14601 vector signed char vec_splat_s8 (const int);
14603 vector signed short vec_splat_s16 (const int);
14605 vector signed int vec_splat_s32 (const int);
14607 vector unsigned char vec_splat_u8 (const int);
14609 vector unsigned short vec_splat_u16 (const int);
14611 vector unsigned int vec_splat_u32 (const int);
14613 vector signed char vec_sr (vector signed char, vector unsigned char);
14614 vector unsigned char vec_sr (vector unsigned char,
14615                              vector unsigned char);
14616 vector signed short vec_sr (vector signed short,
14617                             vector unsigned short);
14618 vector unsigned short vec_sr (vector unsigned short,
14619                               vector unsigned short);
14620 vector signed int vec_sr (vector signed int, vector unsigned int);
14621 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14623 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14624 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14626 vector signed short vec_vsrh (vector signed short,
14627                               vector unsigned short);
14628 vector unsigned short vec_vsrh (vector unsigned short,
14629                                 vector unsigned short);
14631 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14632 vector unsigned char vec_vsrb (vector unsigned char,
14633                                vector unsigned char);
14635 vector signed char vec_sra (vector signed char, vector unsigned char);
14636 vector unsigned char vec_sra (vector unsigned char,
14637                               vector unsigned char);
14638 vector signed short vec_sra (vector signed short,
14639                              vector unsigned short);
14640 vector unsigned short vec_sra (vector unsigned short,
14641                                vector unsigned short);
14642 vector signed int vec_sra (vector signed int, vector unsigned int);
14643 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14645 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14646 vector unsigned int vec_vsraw (vector unsigned int,
14647                                vector unsigned int);
14649 vector signed short vec_vsrah (vector signed short,
14650                                vector unsigned short);
14651 vector unsigned short vec_vsrah (vector unsigned short,
14652                                  vector unsigned short);
14654 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14655 vector unsigned char vec_vsrab (vector unsigned char,
14656                                 vector unsigned char);
14658 vector signed int vec_srl (vector signed int, vector unsigned int);
14659 vector signed int vec_srl (vector signed int, vector unsigned short);
14660 vector signed int vec_srl (vector signed int, vector unsigned char);
14661 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14662 vector unsigned int vec_srl (vector unsigned int,
14663                              vector unsigned short);
14664 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14665 vector bool int vec_srl (vector bool int, vector unsigned int);
14666 vector bool int vec_srl (vector bool int, vector unsigned short);
14667 vector bool int vec_srl (vector bool int, vector unsigned char);
14668 vector signed short vec_srl (vector signed short, vector unsigned int);
14669 vector signed short vec_srl (vector signed short,
14670                              vector unsigned short);
14671 vector signed short vec_srl (vector signed short, vector unsigned char);
14672 vector unsigned short vec_srl (vector unsigned short,
14673                                vector unsigned int);
14674 vector unsigned short vec_srl (vector unsigned short,
14675                                vector unsigned short);
14676 vector unsigned short vec_srl (vector unsigned short,
14677                                vector unsigned char);
14678 vector bool short vec_srl (vector bool short, vector unsigned int);
14679 vector bool short vec_srl (vector bool short, vector unsigned short);
14680 vector bool short vec_srl (vector bool short, vector unsigned char);
14681 vector pixel vec_srl (vector pixel, vector unsigned int);
14682 vector pixel vec_srl (vector pixel, vector unsigned short);
14683 vector pixel vec_srl (vector pixel, vector unsigned char);
14684 vector signed char vec_srl (vector signed char, vector unsigned int);
14685 vector signed char vec_srl (vector signed char, vector unsigned short);
14686 vector signed char vec_srl (vector signed char, vector unsigned char);
14687 vector unsigned char vec_srl (vector unsigned char,
14688                               vector unsigned int);
14689 vector unsigned char vec_srl (vector unsigned char,
14690                               vector unsigned short);
14691 vector unsigned char vec_srl (vector unsigned char,
14692                               vector unsigned char);
14693 vector bool char vec_srl (vector bool char, vector unsigned int);
14694 vector bool char vec_srl (vector bool char, vector unsigned short);
14695 vector bool char vec_srl (vector bool char, vector unsigned char);
14697 vector float vec_sro (vector float, vector signed char);
14698 vector float vec_sro (vector float, vector unsigned char);
14699 vector signed int vec_sro (vector signed int, vector signed char);
14700 vector signed int vec_sro (vector signed int, vector unsigned char);
14701 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14702 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14703 vector signed short vec_sro (vector signed short, vector signed char);
14704 vector signed short vec_sro (vector signed short, vector unsigned char);
14705 vector unsigned short vec_sro (vector unsigned short,
14706                                vector signed char);
14707 vector unsigned short vec_sro (vector unsigned short,
14708                                vector unsigned char);
14709 vector pixel vec_sro (vector pixel, vector signed char);
14710 vector pixel vec_sro (vector pixel, vector unsigned char);
14711 vector signed char vec_sro (vector signed char, vector signed char);
14712 vector signed char vec_sro (vector signed char, vector unsigned char);
14713 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14714 vector unsigned char vec_sro (vector unsigned char,
14715                               vector unsigned char);
14717 void vec_st (vector float, int, vector float *);
14718 void vec_st (vector float, int, float *);
14719 void vec_st (vector signed int, int, vector signed int *);
14720 void vec_st (vector signed int, int, int *);
14721 void vec_st (vector unsigned int, int, vector unsigned int *);
14722 void vec_st (vector unsigned int, int, unsigned int *);
14723 void vec_st (vector bool int, int, vector bool int *);
14724 void vec_st (vector bool int, int, unsigned int *);
14725 void vec_st (vector bool int, int, int *);
14726 void vec_st (vector signed short, int, vector signed short *);
14727 void vec_st (vector signed short, int, short *);
14728 void vec_st (vector unsigned short, int, vector unsigned short *);
14729 void vec_st (vector unsigned short, int, unsigned short *);
14730 void vec_st (vector bool short, int, vector bool short *);
14731 void vec_st (vector bool short, int, unsigned short *);
14732 void vec_st (vector pixel, int, vector pixel *);
14733 void vec_st (vector pixel, int, unsigned short *);
14734 void vec_st (vector pixel, int, short *);
14735 void vec_st (vector bool short, int, short *);
14736 void vec_st (vector signed char, int, vector signed char *);
14737 void vec_st (vector signed char, int, signed char *);
14738 void vec_st (vector unsigned char, int, vector unsigned char *);
14739 void vec_st (vector unsigned char, int, unsigned char *);
14740 void vec_st (vector bool char, int, vector bool char *);
14741 void vec_st (vector bool char, int, unsigned char *);
14742 void vec_st (vector bool char, int, signed char *);
14744 void vec_ste (vector signed char, int, signed char *);
14745 void vec_ste (vector unsigned char, int, unsigned char *);
14746 void vec_ste (vector bool char, int, signed char *);
14747 void vec_ste (vector bool char, int, unsigned char *);
14748 void vec_ste (vector signed short, int, short *);
14749 void vec_ste (vector unsigned short, int, unsigned short *);
14750 void vec_ste (vector bool short, int, short *);
14751 void vec_ste (vector bool short, int, unsigned short *);
14752 void vec_ste (vector pixel, int, short *);
14753 void vec_ste (vector pixel, int, unsigned short *);
14754 void vec_ste (vector float, int, float *);
14755 void vec_ste (vector signed int, int, int *);
14756 void vec_ste (vector unsigned int, int, unsigned int *);
14757 void vec_ste (vector bool int, int, int *);
14758 void vec_ste (vector bool int, int, unsigned int *);
14760 void vec_stvewx (vector float, int, float *);
14761 void vec_stvewx (vector signed int, int, int *);
14762 void vec_stvewx (vector unsigned int, int, unsigned int *);
14763 void vec_stvewx (vector bool int, int, int *);
14764 void vec_stvewx (vector bool int, int, unsigned int *);
14766 void vec_stvehx (vector signed short, int, short *);
14767 void vec_stvehx (vector unsigned short, int, unsigned short *);
14768 void vec_stvehx (vector bool short, int, short *);
14769 void vec_stvehx (vector bool short, int, unsigned short *);
14770 void vec_stvehx (vector pixel, int, short *);
14771 void vec_stvehx (vector pixel, int, unsigned short *);
14773 void vec_stvebx (vector signed char, int, signed char *);
14774 void vec_stvebx (vector unsigned char, int, unsigned char *);
14775 void vec_stvebx (vector bool char, int, signed char *);
14776 void vec_stvebx (vector bool char, int, unsigned char *);
14778 void vec_stl (vector float, int, vector float *);
14779 void vec_stl (vector float, int, float *);
14780 void vec_stl (vector signed int, int, vector signed int *);
14781 void vec_stl (vector signed int, int, int *);
14782 void vec_stl (vector unsigned int, int, vector unsigned int *);
14783 void vec_stl (vector unsigned int, int, unsigned int *);
14784 void vec_stl (vector bool int, int, vector bool int *);
14785 void vec_stl (vector bool int, int, unsigned int *);
14786 void vec_stl (vector bool int, int, int *);
14787 void vec_stl (vector signed short, int, vector signed short *);
14788 void vec_stl (vector signed short, int, short *);
14789 void vec_stl (vector unsigned short, int, vector unsigned short *);
14790 void vec_stl (vector unsigned short, int, unsigned short *);
14791 void vec_stl (vector bool short, int, vector bool short *);
14792 void vec_stl (vector bool short, int, unsigned short *);
14793 void vec_stl (vector bool short, int, short *);
14794 void vec_stl (vector pixel, int, vector pixel *);
14795 void vec_stl (vector pixel, int, unsigned short *);
14796 void vec_stl (vector pixel, int, short *);
14797 void vec_stl (vector signed char, int, vector signed char *);
14798 void vec_stl (vector signed char, int, signed char *);
14799 void vec_stl (vector unsigned char, int, vector unsigned char *);
14800 void vec_stl (vector unsigned char, int, unsigned char *);
14801 void vec_stl (vector bool char, int, vector bool char *);
14802 void vec_stl (vector bool char, int, unsigned char *);
14803 void vec_stl (vector bool char, int, signed char *);
14805 vector signed char vec_sub (vector bool char, vector signed char);
14806 vector signed char vec_sub (vector signed char, vector bool char);
14807 vector signed char vec_sub (vector signed char, vector signed char);
14808 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14809 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14810 vector unsigned char vec_sub (vector unsigned char,
14811                               vector unsigned char);
14812 vector signed short vec_sub (vector bool short, vector signed short);
14813 vector signed short vec_sub (vector signed short, vector bool short);
14814 vector signed short vec_sub (vector signed short, vector signed short);
14815 vector unsigned short vec_sub (vector bool short,
14816                                vector unsigned short);
14817 vector unsigned short vec_sub (vector unsigned short,
14818                                vector bool short);
14819 vector unsigned short vec_sub (vector unsigned short,
14820                                vector unsigned short);
14821 vector signed int vec_sub (vector bool int, vector signed int);
14822 vector signed int vec_sub (vector signed int, vector bool int);
14823 vector signed int vec_sub (vector signed int, vector signed int);
14824 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14825 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14826 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14827 vector float vec_sub (vector float, vector float);
14829 vector float vec_vsubfp (vector float, vector float);
14831 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14832 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14833 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14834 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14835 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14836 vector unsigned int vec_vsubuwm (vector unsigned int,
14837                                  vector unsigned int);
14839 vector signed short vec_vsubuhm (vector bool short,
14840                                  vector signed short);
14841 vector signed short vec_vsubuhm (vector signed short,
14842                                  vector bool short);
14843 vector signed short vec_vsubuhm (vector signed short,
14844                                  vector signed short);
14845 vector unsigned short vec_vsubuhm (vector bool short,
14846                                    vector unsigned short);
14847 vector unsigned short vec_vsubuhm (vector unsigned short,
14848                                    vector bool short);
14849 vector unsigned short vec_vsubuhm (vector unsigned short,
14850                                    vector unsigned short);
14852 vector signed char vec_vsububm (vector bool char, vector signed char);
14853 vector signed char vec_vsububm (vector signed char, vector bool char);
14854 vector signed char vec_vsububm (vector signed char, vector signed char);
14855 vector unsigned char vec_vsububm (vector bool char,
14856                                   vector unsigned char);
14857 vector unsigned char vec_vsububm (vector unsigned char,
14858                                   vector bool char);
14859 vector unsigned char vec_vsububm (vector unsigned char,
14860                                   vector unsigned char);
14862 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14864 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14865 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14866 vector unsigned char vec_subs (vector unsigned char,
14867                                vector unsigned char);
14868 vector signed char vec_subs (vector bool char, vector signed char);
14869 vector signed char vec_subs (vector signed char, vector bool char);
14870 vector signed char vec_subs (vector signed char, vector signed char);
14871 vector unsigned short vec_subs (vector bool short,
14872                                 vector unsigned short);
14873 vector unsigned short vec_subs (vector unsigned short,
14874                                 vector bool short);
14875 vector unsigned short vec_subs (vector unsigned short,
14876                                 vector unsigned short);
14877 vector signed short vec_subs (vector bool short, vector signed short);
14878 vector signed short vec_subs (vector signed short, vector bool short);
14879 vector signed short vec_subs (vector signed short, vector signed short);
14880 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14881 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14882 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14883 vector signed int vec_subs (vector bool int, vector signed int);
14884 vector signed int vec_subs (vector signed int, vector bool int);
14885 vector signed int vec_subs (vector signed int, vector signed int);
14887 vector signed int vec_vsubsws (vector bool int, vector signed int);
14888 vector signed int vec_vsubsws (vector signed int, vector bool int);
14889 vector signed int vec_vsubsws (vector signed int, vector signed int);
14891 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14892 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
14893 vector unsigned int vec_vsubuws (vector unsigned int,
14894                                  vector unsigned int);
14896 vector signed short vec_vsubshs (vector bool short,
14897                                  vector signed short);
14898 vector signed short vec_vsubshs (vector signed short,
14899                                  vector bool short);
14900 vector signed short vec_vsubshs (vector signed short,
14901                                  vector signed short);
14903 vector unsigned short vec_vsubuhs (vector bool short,
14904                                    vector unsigned short);
14905 vector unsigned short vec_vsubuhs (vector unsigned short,
14906                                    vector bool short);
14907 vector unsigned short vec_vsubuhs (vector unsigned short,
14908                                    vector unsigned short);
14910 vector signed char vec_vsubsbs (vector bool char, vector signed char);
14911 vector signed char vec_vsubsbs (vector signed char, vector bool char);
14912 vector signed char vec_vsubsbs (vector signed char, vector signed char);
14914 vector unsigned char vec_vsububs (vector bool char,
14915                                   vector unsigned char);
14916 vector unsigned char vec_vsububs (vector unsigned char,
14917                                   vector bool char);
14918 vector unsigned char vec_vsububs (vector unsigned char,
14919                                   vector unsigned char);
14921 vector unsigned int vec_sum4s (vector unsigned char,
14922                                vector unsigned int);
14923 vector signed int vec_sum4s (vector signed char, vector signed int);
14924 vector signed int vec_sum4s (vector signed short, vector signed int);
14926 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14928 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14930 vector unsigned int vec_vsum4ubs (vector unsigned char,
14931                                   vector unsigned int);
14933 vector signed int vec_sum2s (vector signed int, vector signed int);
14935 vector signed int vec_sums (vector signed int, vector signed int);
14937 vector float vec_trunc (vector float);
14939 vector signed short vec_unpackh (vector signed char);
14940 vector bool short vec_unpackh (vector bool char);
14941 vector signed int vec_unpackh (vector signed short);
14942 vector bool int vec_unpackh (vector bool short);
14943 vector unsigned int vec_unpackh (vector pixel);
14945 vector bool int vec_vupkhsh (vector bool short);
14946 vector signed int vec_vupkhsh (vector signed short);
14948 vector unsigned int vec_vupkhpx (vector pixel);
14950 vector bool short vec_vupkhsb (vector bool char);
14951 vector signed short vec_vupkhsb (vector signed char);
14953 vector signed short vec_unpackl (vector signed char);
14954 vector bool short vec_unpackl (vector bool char);
14955 vector unsigned int vec_unpackl (vector pixel);
14956 vector signed int vec_unpackl (vector signed short);
14957 vector bool int vec_unpackl (vector bool short);
14959 vector unsigned int vec_vupklpx (vector pixel);
14961 vector bool int vec_vupklsh (vector bool short);
14962 vector signed int vec_vupklsh (vector signed short);
14964 vector bool short vec_vupklsb (vector bool char);
14965 vector signed short vec_vupklsb (vector signed char);
14967 vector float vec_xor (vector float, vector float);
14968 vector float vec_xor (vector float, vector bool int);
14969 vector float vec_xor (vector bool int, vector float);
14970 vector bool int vec_xor (vector bool int, vector bool int);
14971 vector signed int vec_xor (vector bool int, vector signed int);
14972 vector signed int vec_xor (vector signed int, vector bool int);
14973 vector signed int vec_xor (vector signed int, vector signed int);
14974 vector unsigned int vec_xor (vector bool int, vector unsigned int);
14975 vector unsigned int vec_xor (vector unsigned int, vector bool int);
14976 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
14977 vector bool short vec_xor (vector bool short, vector bool short);
14978 vector signed short vec_xor (vector bool short, vector signed short);
14979 vector signed short vec_xor (vector signed short, vector bool short);
14980 vector signed short vec_xor (vector signed short, vector signed short);
14981 vector unsigned short vec_xor (vector bool short,
14982                                vector unsigned short);
14983 vector unsigned short vec_xor (vector unsigned short,
14984                                vector bool short);
14985 vector unsigned short vec_xor (vector unsigned short,
14986                                vector unsigned short);
14987 vector signed char vec_xor (vector bool char, vector signed char);
14988 vector bool char vec_xor (vector bool char, vector bool char);
14989 vector signed char vec_xor (vector signed char, vector bool char);
14990 vector signed char vec_xor (vector signed char, vector signed char);
14991 vector unsigned char vec_xor (vector bool char, vector unsigned char);
14992 vector unsigned char vec_xor (vector unsigned char, vector bool char);
14993 vector unsigned char vec_xor (vector unsigned char,
14994                               vector unsigned char);
14996 int vec_all_eq (vector signed char, vector bool char);
14997 int vec_all_eq (vector signed char, vector signed char);
14998 int vec_all_eq (vector unsigned char, vector bool char);
14999 int vec_all_eq (vector unsigned char, vector unsigned char);
15000 int vec_all_eq (vector bool char, vector bool char);
15001 int vec_all_eq (vector bool char, vector unsigned char);
15002 int vec_all_eq (vector bool char, vector signed char);
15003 int vec_all_eq (vector signed short, vector bool short);
15004 int vec_all_eq (vector signed short, vector signed short);
15005 int vec_all_eq (vector unsigned short, vector bool short);
15006 int vec_all_eq (vector unsigned short, vector unsigned short);
15007 int vec_all_eq (vector bool short, vector bool short);
15008 int vec_all_eq (vector bool short, vector unsigned short);
15009 int vec_all_eq (vector bool short, vector signed short);
15010 int vec_all_eq (vector pixel, vector pixel);
15011 int vec_all_eq (vector signed int, vector bool int);
15012 int vec_all_eq (vector signed int, vector signed int);
15013 int vec_all_eq (vector unsigned int, vector bool int);
15014 int vec_all_eq (vector unsigned int, vector unsigned int);
15015 int vec_all_eq (vector bool int, vector bool int);
15016 int vec_all_eq (vector bool int, vector unsigned int);
15017 int vec_all_eq (vector bool int, vector signed int);
15018 int vec_all_eq (vector float, vector float);
15020 int vec_all_ge (vector bool char, vector unsigned char);
15021 int vec_all_ge (vector unsigned char, vector bool char);
15022 int vec_all_ge (vector unsigned char, vector unsigned char);
15023 int vec_all_ge (vector bool char, vector signed char);
15024 int vec_all_ge (vector signed char, vector bool char);
15025 int vec_all_ge (vector signed char, vector signed char);
15026 int vec_all_ge (vector bool short, vector unsigned short);
15027 int vec_all_ge (vector unsigned short, vector bool short);
15028 int vec_all_ge (vector unsigned short, vector unsigned short);
15029 int vec_all_ge (vector signed short, vector signed short);
15030 int vec_all_ge (vector bool short, vector signed short);
15031 int vec_all_ge (vector signed short, vector bool short);
15032 int vec_all_ge (vector bool int, vector unsigned int);
15033 int vec_all_ge (vector unsigned int, vector bool int);
15034 int vec_all_ge (vector unsigned int, vector unsigned int);
15035 int vec_all_ge (vector bool int, vector signed int);
15036 int vec_all_ge (vector signed int, vector bool int);
15037 int vec_all_ge (vector signed int, vector signed int);
15038 int vec_all_ge (vector float, vector float);
15040 int vec_all_gt (vector bool char, vector unsigned char);
15041 int vec_all_gt (vector unsigned char, vector bool char);
15042 int vec_all_gt (vector unsigned char, vector unsigned char);
15043 int vec_all_gt (vector bool char, vector signed char);
15044 int vec_all_gt (vector signed char, vector bool char);
15045 int vec_all_gt (vector signed char, vector signed char);
15046 int vec_all_gt (vector bool short, vector unsigned short);
15047 int vec_all_gt (vector unsigned short, vector bool short);
15048 int vec_all_gt (vector unsigned short, vector unsigned short);
15049 int vec_all_gt (vector bool short, vector signed short);
15050 int vec_all_gt (vector signed short, vector bool short);
15051 int vec_all_gt (vector signed short, vector signed short);
15052 int vec_all_gt (vector bool int, vector unsigned int);
15053 int vec_all_gt (vector unsigned int, vector bool int);
15054 int vec_all_gt (vector unsigned int, vector unsigned int);
15055 int vec_all_gt (vector bool int, vector signed int);
15056 int vec_all_gt (vector signed int, vector bool int);
15057 int vec_all_gt (vector signed int, vector signed int);
15058 int vec_all_gt (vector float, vector float);
15060 int vec_all_in (vector float, vector float);
15062 int vec_all_le (vector bool char, vector unsigned char);
15063 int vec_all_le (vector unsigned char, vector bool char);
15064 int vec_all_le (vector unsigned char, vector unsigned char);
15065 int vec_all_le (vector bool char, vector signed char);
15066 int vec_all_le (vector signed char, vector bool char);
15067 int vec_all_le (vector signed char, vector signed char);
15068 int vec_all_le (vector bool short, vector unsigned short);
15069 int vec_all_le (vector unsigned short, vector bool short);
15070 int vec_all_le (vector unsigned short, vector unsigned short);
15071 int vec_all_le (vector bool short, vector signed short);
15072 int vec_all_le (vector signed short, vector bool short);
15073 int vec_all_le (vector signed short, vector signed short);
15074 int vec_all_le (vector bool int, vector unsigned int);
15075 int vec_all_le (vector unsigned int, vector bool int);
15076 int vec_all_le (vector unsigned int, vector unsigned int);
15077 int vec_all_le (vector bool int, vector signed int);
15078 int vec_all_le (vector signed int, vector bool int);
15079 int vec_all_le (vector signed int, vector signed int);
15080 int vec_all_le (vector float, vector float);
15082 int vec_all_lt (vector bool char, vector unsigned char);
15083 int vec_all_lt (vector unsigned char, vector bool char);
15084 int vec_all_lt (vector unsigned char, vector unsigned char);
15085 int vec_all_lt (vector bool char, vector signed char);
15086 int vec_all_lt (vector signed char, vector bool char);
15087 int vec_all_lt (vector signed char, vector signed char);
15088 int vec_all_lt (vector bool short, vector unsigned short);
15089 int vec_all_lt (vector unsigned short, vector bool short);
15090 int vec_all_lt (vector unsigned short, vector unsigned short);
15091 int vec_all_lt (vector bool short, vector signed short);
15092 int vec_all_lt (vector signed short, vector bool short);
15093 int vec_all_lt (vector signed short, vector signed short);
15094 int vec_all_lt (vector bool int, vector unsigned int);
15095 int vec_all_lt (vector unsigned int, vector bool int);
15096 int vec_all_lt (vector unsigned int, vector unsigned int);
15097 int vec_all_lt (vector bool int, vector signed int);
15098 int vec_all_lt (vector signed int, vector bool int);
15099 int vec_all_lt (vector signed int, vector signed int);
15100 int vec_all_lt (vector float, vector float);
15102 int vec_all_nan (vector float);
15104 int vec_all_ne (vector signed char, vector bool char);
15105 int vec_all_ne (vector signed char, vector signed char);
15106 int vec_all_ne (vector unsigned char, vector bool char);
15107 int vec_all_ne (vector unsigned char, vector unsigned char);
15108 int vec_all_ne (vector bool char, vector bool char);
15109 int vec_all_ne (vector bool char, vector unsigned char);
15110 int vec_all_ne (vector bool char, vector signed char);
15111 int vec_all_ne (vector signed short, vector bool short);
15112 int vec_all_ne (vector signed short, vector signed short);
15113 int vec_all_ne (vector unsigned short, vector bool short);
15114 int vec_all_ne (vector unsigned short, vector unsigned short);
15115 int vec_all_ne (vector bool short, vector bool short);
15116 int vec_all_ne (vector bool short, vector unsigned short);
15117 int vec_all_ne (vector bool short, vector signed short);
15118 int vec_all_ne (vector pixel, vector pixel);
15119 int vec_all_ne (vector signed int, vector bool int);
15120 int vec_all_ne (vector signed int, vector signed int);
15121 int vec_all_ne (vector unsigned int, vector bool int);
15122 int vec_all_ne (vector unsigned int, vector unsigned int);
15123 int vec_all_ne (vector bool int, vector bool int);
15124 int vec_all_ne (vector bool int, vector unsigned int);
15125 int vec_all_ne (vector bool int, vector signed int);
15126 int vec_all_ne (vector float, vector float);
15128 int vec_all_nge (vector float, vector float);
15130 int vec_all_ngt (vector float, vector float);
15132 int vec_all_nle (vector float, vector float);
15134 int vec_all_nlt (vector float, vector float);
15136 int vec_all_numeric (vector float);
15138 int vec_any_eq (vector signed char, vector bool char);
15139 int vec_any_eq (vector signed char, vector signed char);
15140 int vec_any_eq (vector unsigned char, vector bool char);
15141 int vec_any_eq (vector unsigned char, vector unsigned char);
15142 int vec_any_eq (vector bool char, vector bool char);
15143 int vec_any_eq (vector bool char, vector unsigned char);
15144 int vec_any_eq (vector bool char, vector signed char);
15145 int vec_any_eq (vector signed short, vector bool short);
15146 int vec_any_eq (vector signed short, vector signed short);
15147 int vec_any_eq (vector unsigned short, vector bool short);
15148 int vec_any_eq (vector unsigned short, vector unsigned short);
15149 int vec_any_eq (vector bool short, vector bool short);
15150 int vec_any_eq (vector bool short, vector unsigned short);
15151 int vec_any_eq (vector bool short, vector signed short);
15152 int vec_any_eq (vector pixel, vector pixel);
15153 int vec_any_eq (vector signed int, vector bool int);
15154 int vec_any_eq (vector signed int, vector signed int);
15155 int vec_any_eq (vector unsigned int, vector bool int);
15156 int vec_any_eq (vector unsigned int, vector unsigned int);
15157 int vec_any_eq (vector bool int, vector bool int);
15158 int vec_any_eq (vector bool int, vector unsigned int);
15159 int vec_any_eq (vector bool int, vector signed int);
15160 int vec_any_eq (vector float, vector float);
15162 int vec_any_ge (vector signed char, vector bool char);
15163 int vec_any_ge (vector unsigned char, vector bool char);
15164 int vec_any_ge (vector unsigned char, vector unsigned char);
15165 int vec_any_ge (vector signed char, vector signed char);
15166 int vec_any_ge (vector bool char, vector unsigned char);
15167 int vec_any_ge (vector bool char, vector signed char);
15168 int vec_any_ge (vector unsigned short, vector bool short);
15169 int vec_any_ge (vector unsigned short, vector unsigned short);
15170 int vec_any_ge (vector signed short, vector signed short);
15171 int vec_any_ge (vector signed short, vector bool short);
15172 int vec_any_ge (vector bool short, vector unsigned short);
15173 int vec_any_ge (vector bool short, vector signed short);
15174 int vec_any_ge (vector signed int, vector bool int);
15175 int vec_any_ge (vector unsigned int, vector bool int);
15176 int vec_any_ge (vector unsigned int, vector unsigned int);
15177 int vec_any_ge (vector signed int, vector signed int);
15178 int vec_any_ge (vector bool int, vector unsigned int);
15179 int vec_any_ge (vector bool int, vector signed int);
15180 int vec_any_ge (vector float, vector float);
15182 int vec_any_gt (vector bool char, vector unsigned char);
15183 int vec_any_gt (vector unsigned char, vector bool char);
15184 int vec_any_gt (vector unsigned char, vector unsigned char);
15185 int vec_any_gt (vector bool char, vector signed char);
15186 int vec_any_gt (vector signed char, vector bool char);
15187 int vec_any_gt (vector signed char, vector signed char);
15188 int vec_any_gt (vector bool short, vector unsigned short);
15189 int vec_any_gt (vector unsigned short, vector bool short);
15190 int vec_any_gt (vector unsigned short, vector unsigned short);
15191 int vec_any_gt (vector bool short, vector signed short);
15192 int vec_any_gt (vector signed short, vector bool short);
15193 int vec_any_gt (vector signed short, vector signed short);
15194 int vec_any_gt (vector bool int, vector unsigned int);
15195 int vec_any_gt (vector unsigned int, vector bool int);
15196 int vec_any_gt (vector unsigned int, vector unsigned int);
15197 int vec_any_gt (vector bool int, vector signed int);
15198 int vec_any_gt (vector signed int, vector bool int);
15199 int vec_any_gt (vector signed int, vector signed int);
15200 int vec_any_gt (vector float, vector float);
15202 int vec_any_le (vector bool char, vector unsigned char);
15203 int vec_any_le (vector unsigned char, vector bool char);
15204 int vec_any_le (vector unsigned char, vector unsigned char);
15205 int vec_any_le (vector bool char, vector signed char);
15206 int vec_any_le (vector signed char, vector bool char);
15207 int vec_any_le (vector signed char, vector signed char);
15208 int vec_any_le (vector bool short, vector unsigned short);
15209 int vec_any_le (vector unsigned short, vector bool short);
15210 int vec_any_le (vector unsigned short, vector unsigned short);
15211 int vec_any_le (vector bool short, vector signed short);
15212 int vec_any_le (vector signed short, vector bool short);
15213 int vec_any_le (vector signed short, vector signed short);
15214 int vec_any_le (vector bool int, vector unsigned int);
15215 int vec_any_le (vector unsigned int, vector bool int);
15216 int vec_any_le (vector unsigned int, vector unsigned int);
15217 int vec_any_le (vector bool int, vector signed int);
15218 int vec_any_le (vector signed int, vector bool int);
15219 int vec_any_le (vector signed int, vector signed int);
15220 int vec_any_le (vector float, vector float);
15222 int vec_any_lt (vector bool char, vector unsigned char);
15223 int vec_any_lt (vector unsigned char, vector bool char);
15224 int vec_any_lt (vector unsigned char, vector unsigned char);
15225 int vec_any_lt (vector bool char, vector signed char);
15226 int vec_any_lt (vector signed char, vector bool char);
15227 int vec_any_lt (vector signed char, vector signed char);
15228 int vec_any_lt (vector bool short, vector unsigned short);
15229 int vec_any_lt (vector unsigned short, vector bool short);
15230 int vec_any_lt (vector unsigned short, vector unsigned short);
15231 int vec_any_lt (vector bool short, vector signed short);
15232 int vec_any_lt (vector signed short, vector bool short);
15233 int vec_any_lt (vector signed short, vector signed short);
15234 int vec_any_lt (vector bool int, vector unsigned int);
15235 int vec_any_lt (vector unsigned int, vector bool int);
15236 int vec_any_lt (vector unsigned int, vector unsigned int);
15237 int vec_any_lt (vector bool int, vector signed int);
15238 int vec_any_lt (vector signed int, vector bool int);
15239 int vec_any_lt (vector signed int, vector signed int);
15240 int vec_any_lt (vector float, vector float);
15242 int vec_any_nan (vector float);
15244 int vec_any_ne (vector signed char, vector bool char);
15245 int vec_any_ne (vector signed char, vector signed char);
15246 int vec_any_ne (vector unsigned char, vector bool char);
15247 int vec_any_ne (vector unsigned char, vector unsigned char);
15248 int vec_any_ne (vector bool char, vector bool char);
15249 int vec_any_ne (vector bool char, vector unsigned char);
15250 int vec_any_ne (vector bool char, vector signed char);
15251 int vec_any_ne (vector signed short, vector bool short);
15252 int vec_any_ne (vector signed short, vector signed short);
15253 int vec_any_ne (vector unsigned short, vector bool short);
15254 int vec_any_ne (vector unsigned short, vector unsigned short);
15255 int vec_any_ne (vector bool short, vector bool short);
15256 int vec_any_ne (vector bool short, vector unsigned short);
15257 int vec_any_ne (vector bool short, vector signed short);
15258 int vec_any_ne (vector pixel, vector pixel);
15259 int vec_any_ne (vector signed int, vector bool int);
15260 int vec_any_ne (vector signed int, vector signed int);
15261 int vec_any_ne (vector unsigned int, vector bool int);
15262 int vec_any_ne (vector unsigned int, vector unsigned int);
15263 int vec_any_ne (vector bool int, vector bool int);
15264 int vec_any_ne (vector bool int, vector unsigned int);
15265 int vec_any_ne (vector bool int, vector signed int);
15266 int vec_any_ne (vector float, vector float);
15268 int vec_any_nge (vector float, vector float);
15270 int vec_any_ngt (vector float, vector float);
15272 int vec_any_nle (vector float, vector float);
15274 int vec_any_nlt (vector float, vector float);
15276 int vec_any_numeric (vector float);
15278 int vec_any_out (vector float, vector float);
15279 @end smallexample
15281 If the vector/scalar (VSX) instruction set is available, the following
15282 additional functions are available:
15284 @smallexample
15285 vector double vec_abs (vector double);
15286 vector double vec_add (vector double, vector double);
15287 vector double vec_and (vector double, vector double);
15288 vector double vec_and (vector double, vector bool long);
15289 vector double vec_and (vector bool long, vector double);
15290 vector double vec_andc (vector double, vector double);
15291 vector double vec_andc (vector double, vector bool long);
15292 vector double vec_andc (vector bool long, vector double);
15293 vector double vec_ceil (vector double);
15294 vector bool long vec_cmpeq (vector double, vector double);
15295 vector bool long vec_cmpge (vector double, vector double);
15296 vector bool long vec_cmpgt (vector double, vector double);
15297 vector bool long vec_cmple (vector double, vector double);
15298 vector bool long vec_cmplt (vector double, vector double);
15299 vector float vec_div (vector float, vector float);
15300 vector double vec_div (vector double, vector double);
15301 vector double vec_floor (vector double);
15302 vector double vec_ld (int, const vector double *);
15303 vector double vec_ld (int, const double *);
15304 vector double vec_ldl (int, const vector double *);
15305 vector double vec_ldl (int, const double *);
15306 vector unsigned char vec_lvsl (int, const volatile double *);
15307 vector unsigned char vec_lvsr (int, const volatile double *);
15308 vector double vec_madd (vector double, vector double, vector double);
15309 vector double vec_max (vector double, vector double);
15310 vector double vec_min (vector double, vector double);
15311 vector float vec_msub (vector float, vector float, vector float);
15312 vector double vec_msub (vector double, vector double, vector double);
15313 vector float vec_mul (vector float, vector float);
15314 vector double vec_mul (vector double, vector double);
15315 vector float vec_nearbyint (vector float);
15316 vector double vec_nearbyint (vector double);
15317 vector float vec_nmadd (vector float, vector float, vector float);
15318 vector double vec_nmadd (vector double, vector double, vector double);
15319 vector double vec_nmsub (vector double, vector double, vector double);
15320 vector double vec_nor (vector double, vector double);
15321 vector double vec_or (vector double, vector double);
15322 vector double vec_or (vector double, vector bool long);
15323 vector double vec_or (vector bool long, vector double);
15324 vector double vec_perm (vector double,
15325                         vector double,
15326                         vector unsigned char);
15327 vector double vec_rint (vector double);
15328 vector double vec_recip (vector double, vector double);
15329 vector double vec_rsqrt (vector double);
15330 vector double vec_rsqrte (vector double);
15331 vector double vec_sel (vector double, vector double, vector bool long);
15332 vector double vec_sel (vector double, vector double, vector unsigned long);
15333 vector double vec_sub (vector double, vector double);
15334 vector float vec_sqrt (vector float);
15335 vector double vec_sqrt (vector double);
15336 void vec_st (vector double, int, vector double *);
15337 void vec_st (vector double, int, double *);
15338 vector double vec_trunc (vector double);
15339 vector double vec_xor (vector double, vector double);
15340 vector double vec_xor (vector double, vector bool long);
15341 vector double vec_xor (vector bool long, vector double);
15342 int vec_all_eq (vector double, vector double);
15343 int vec_all_ge (vector double, vector double);
15344 int vec_all_gt (vector double, vector double);
15345 int vec_all_le (vector double, vector double);
15346 int vec_all_lt (vector double, vector double);
15347 int vec_all_nan (vector double);
15348 int vec_all_ne (vector double, vector double);
15349 int vec_all_nge (vector double, vector double);
15350 int vec_all_ngt (vector double, vector double);
15351 int vec_all_nle (vector double, vector double);
15352 int vec_all_nlt (vector double, vector double);
15353 int vec_all_numeric (vector double);
15354 int vec_any_eq (vector double, vector double);
15355 int vec_any_ge (vector double, vector double);
15356 int vec_any_gt (vector double, vector double);
15357 int vec_any_le (vector double, vector double);
15358 int vec_any_lt (vector double, vector double);
15359 int vec_any_nan (vector double);
15360 int vec_any_ne (vector double, vector double);
15361 int vec_any_nge (vector double, vector double);
15362 int vec_any_ngt (vector double, vector double);
15363 int vec_any_nle (vector double, vector double);
15364 int vec_any_nlt (vector double, vector double);
15365 int vec_any_numeric (vector double);
15367 vector double vec_vsx_ld (int, const vector double *);
15368 vector double vec_vsx_ld (int, const double *);
15369 vector float vec_vsx_ld (int, const vector float *);
15370 vector float vec_vsx_ld (int, const float *);
15371 vector bool int vec_vsx_ld (int, const vector bool int *);
15372 vector signed int vec_vsx_ld (int, const vector signed int *);
15373 vector signed int vec_vsx_ld (int, const int *);
15374 vector signed int vec_vsx_ld (int, const long *);
15375 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15376 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15377 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15378 vector bool short vec_vsx_ld (int, const vector bool short *);
15379 vector pixel vec_vsx_ld (int, const vector pixel *);
15380 vector signed short vec_vsx_ld (int, const vector signed short *);
15381 vector signed short vec_vsx_ld (int, const short *);
15382 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15383 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15384 vector bool char vec_vsx_ld (int, const vector bool char *);
15385 vector signed char vec_vsx_ld (int, const vector signed char *);
15386 vector signed char vec_vsx_ld (int, const signed char *);
15387 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15388 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15390 void vec_vsx_st (vector double, int, vector double *);
15391 void vec_vsx_st (vector double, int, double *);
15392 void vec_vsx_st (vector float, int, vector float *);
15393 void vec_vsx_st (vector float, int, float *);
15394 void vec_vsx_st (vector signed int, int, vector signed int *);
15395 void vec_vsx_st (vector signed int, int, int *);
15396 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15397 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15398 void vec_vsx_st (vector bool int, int, vector bool int *);
15399 void vec_vsx_st (vector bool int, int, unsigned int *);
15400 void vec_vsx_st (vector bool int, int, int *);
15401 void vec_vsx_st (vector signed short, int, vector signed short *);
15402 void vec_vsx_st (vector signed short, int, short *);
15403 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15404 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15405 void vec_vsx_st (vector bool short, int, vector bool short *);
15406 void vec_vsx_st (vector bool short, int, unsigned short *);
15407 void vec_vsx_st (vector pixel, int, vector pixel *);
15408 void vec_vsx_st (vector pixel, int, unsigned short *);
15409 void vec_vsx_st (vector pixel, int, short *);
15410 void vec_vsx_st (vector bool short, int, short *);
15411 void vec_vsx_st (vector signed char, int, vector signed char *);
15412 void vec_vsx_st (vector signed char, int, signed char *);
15413 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15414 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15415 void vec_vsx_st (vector bool char, int, vector bool char *);
15416 void vec_vsx_st (vector bool char, int, unsigned char *);
15417 void vec_vsx_st (vector bool char, int, signed char *);
15419 vector double vec_xxpermdi (vector double, vector double, int);
15420 vector float vec_xxpermdi (vector float, vector float, int);
15421 vector long long vec_xxpermdi (vector long long, vector long long, int);
15422 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15423                                         vector unsigned long long, int);
15424 vector int vec_xxpermdi (vector int, vector int, int);
15425 vector unsigned int vec_xxpermdi (vector unsigned int,
15426                                   vector unsigned int, int);
15427 vector short vec_xxpermdi (vector short, vector short, int);
15428 vector unsigned short vec_xxpermdi (vector unsigned short,
15429                                     vector unsigned short, int);
15430 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15431 vector unsigned char vec_xxpermdi (vector unsigned char,
15432                                    vector unsigned char, int);
15434 vector double vec_xxsldi (vector double, vector double, int);
15435 vector float vec_xxsldi (vector float, vector float, int);
15436 vector long long vec_xxsldi (vector long long, vector long long, int);
15437 vector unsigned long long vec_xxsldi (vector unsigned long long,
15438                                       vector unsigned long long, int);
15439 vector int vec_xxsldi (vector int, vector int, int);
15440 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15441 vector short vec_xxsldi (vector short, vector short, int);
15442 vector unsigned short vec_xxsldi (vector unsigned short,
15443                                   vector unsigned short, int);
15444 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15445 vector unsigned char vec_xxsldi (vector unsigned char,
15446                                  vector unsigned char, int);
15447 @end smallexample
15449 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15450 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15451 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
15452 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15453 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15455 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15456 instruction set is available, the following additional functions are
15457 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
15458 can use @var{vector long} instead of @var{vector long long},
15459 @var{vector bool long} instead of @var{vector bool long long}, and
15460 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15462 @smallexample
15463 vector long long vec_abs (vector long long);
15465 vector long long vec_add (vector long long, vector long long);
15466 vector unsigned long long vec_add (vector unsigned long long,
15467                                    vector unsigned long long);
15469 int vec_all_eq (vector long long, vector long long);
15470 int vec_all_ge (vector long long, vector long long);
15471 int vec_all_gt (vector long long, vector long long);
15472 int vec_all_le (vector long long, vector long long);
15473 int vec_all_lt (vector long long, vector long long);
15474 int vec_all_ne (vector long long, vector long long);
15475 int vec_any_eq (vector long long, vector long long);
15476 int vec_any_ge (vector long long, vector long long);
15477 int vec_any_gt (vector long long, vector long long);
15478 int vec_any_le (vector long long, vector long long);
15479 int vec_any_lt (vector long long, vector long long);
15480 int vec_any_ne (vector long long, vector long long);
15482 vector long long vec_eqv (vector long long, vector long long);
15483 vector long long vec_eqv (vector bool long long, vector long long);
15484 vector long long vec_eqv (vector long long, vector bool long long);
15485 vector unsigned long long vec_eqv (vector unsigned long long,
15486                                    vector unsigned long long);
15487 vector unsigned long long vec_eqv (vector bool long long,
15488                                    vector unsigned long long);
15489 vector unsigned long long vec_eqv (vector unsigned long long,
15490                                    vector bool long long);
15491 vector int vec_eqv (vector int, vector int);
15492 vector int vec_eqv (vector bool int, vector int);
15493 vector int vec_eqv (vector int, vector bool int);
15494 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15495 vector unsigned int vec_eqv (vector bool unsigned int,
15496                              vector unsigned int);
15497 vector unsigned int vec_eqv (vector unsigned int,
15498                              vector bool unsigned int);
15499 vector short vec_eqv (vector short, vector short);
15500 vector short vec_eqv (vector bool short, vector short);
15501 vector short vec_eqv (vector short, vector bool short);
15502 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15503 vector unsigned short vec_eqv (vector bool unsigned short,
15504                                vector unsigned short);
15505 vector unsigned short vec_eqv (vector unsigned short,
15506                                vector bool unsigned short);
15507 vector signed char vec_eqv (vector signed char, vector signed char);
15508 vector signed char vec_eqv (vector bool signed char, vector signed char);
15509 vector signed char vec_eqv (vector signed char, vector bool signed char);
15510 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15511 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15512 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15514 vector long long vec_max (vector long long, vector long long);
15515 vector unsigned long long vec_max (vector unsigned long long,
15516                                    vector unsigned long long);
15518 vector long long vec_min (vector long long, vector long long);
15519 vector unsigned long long vec_min (vector unsigned long long,
15520                                    vector unsigned long long);
15522 vector long long vec_nand (vector long long, vector long long);
15523 vector long long vec_nand (vector bool long long, vector long long);
15524 vector long long vec_nand (vector long long, vector bool long long);
15525 vector unsigned long long vec_nand (vector unsigned long long,
15526                                     vector unsigned long long);
15527 vector unsigned long long vec_nand (vector bool long long,
15528                                    vector unsigned long long);
15529 vector unsigned long long vec_nand (vector unsigned long long,
15530                                     vector bool long long);
15531 vector int vec_nand (vector int, vector int);
15532 vector int vec_nand (vector bool int, vector int);
15533 vector int vec_nand (vector int, vector bool int);
15534 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15535 vector unsigned int vec_nand (vector bool unsigned int,
15536                               vector unsigned int);
15537 vector unsigned int vec_nand (vector unsigned int,
15538                               vector bool unsigned int);
15539 vector short vec_nand (vector short, vector short);
15540 vector short vec_nand (vector bool short, vector short);
15541 vector short vec_nand (vector short, vector bool short);
15542 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15543 vector unsigned short vec_nand (vector bool unsigned short,
15544                                 vector unsigned short);
15545 vector unsigned short vec_nand (vector unsigned short,
15546                                 vector bool unsigned short);
15547 vector signed char vec_nand (vector signed char, vector signed char);
15548 vector signed char vec_nand (vector bool signed char, vector signed char);
15549 vector signed char vec_nand (vector signed char, vector bool signed char);
15550 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15551 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15552 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15554 vector long long vec_orc (vector long long, vector long long);
15555 vector long long vec_orc (vector bool long long, vector long long);
15556 vector long long vec_orc (vector long long, vector bool long long);
15557 vector unsigned long long vec_orc (vector unsigned long long,
15558                                    vector unsigned long long);
15559 vector unsigned long long vec_orc (vector bool long long,
15560                                    vector unsigned long long);
15561 vector unsigned long long vec_orc (vector unsigned long long,
15562                                    vector bool long long);
15563 vector int vec_orc (vector int, vector int);
15564 vector int vec_orc (vector bool int, vector int);
15565 vector int vec_orc (vector int, vector bool int);
15566 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15567 vector unsigned int vec_orc (vector bool unsigned int,
15568                              vector unsigned int);
15569 vector unsigned int vec_orc (vector unsigned int,
15570                              vector bool unsigned int);
15571 vector short vec_orc (vector short, vector short);
15572 vector short vec_orc (vector bool short, vector short);
15573 vector short vec_orc (vector short, vector bool short);
15574 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15575 vector unsigned short vec_orc (vector bool unsigned short,
15576                                vector unsigned short);
15577 vector unsigned short vec_orc (vector unsigned short,
15578                                vector bool unsigned short);
15579 vector signed char vec_orc (vector signed char, vector signed char);
15580 vector signed char vec_orc (vector bool signed char, vector signed char);
15581 vector signed char vec_orc (vector signed char, vector bool signed char);
15582 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15583 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15584 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15586 vector int vec_pack (vector long long, vector long long);
15587 vector unsigned int vec_pack (vector unsigned long long,
15588                               vector unsigned long long);
15589 vector bool int vec_pack (vector bool long long, vector bool long long);
15591 vector int vec_packs (vector long long, vector long long);
15592 vector unsigned int vec_packs (vector unsigned long long,
15593                                vector unsigned long long);
15595 vector unsigned int vec_packsu (vector long long, vector long long);
15597 vector long long vec_rl (vector long long,
15598                          vector unsigned long long);
15599 vector long long vec_rl (vector unsigned long long,
15600                          vector unsigned long long);
15602 vector long long vec_sl (vector long long, vector unsigned long long);
15603 vector long long vec_sl (vector unsigned long long,
15604                          vector unsigned long long);
15606 vector long long vec_sr (vector long long, vector unsigned long long);
15607 vector unsigned long long char vec_sr (vector unsigned long long,
15608                                        vector unsigned long long);
15610 vector long long vec_sra (vector long long, vector unsigned long long);
15611 vector unsigned long long vec_sra (vector unsigned long long,
15612                                    vector unsigned long long);
15614 vector long long vec_sub (vector long long, vector long long);
15615 vector unsigned long long vec_sub (vector unsigned long long,
15616                                    vector unsigned long long);
15618 vector long long vec_unpackh (vector int);
15619 vector unsigned long long vec_unpackh (vector unsigned int);
15621 vector long long vec_unpackl (vector int);
15622 vector unsigned long long vec_unpackl (vector unsigned int);
15624 vector long long vec_vaddudm (vector long long, vector long long);
15625 vector long long vec_vaddudm (vector bool long long, vector long long);
15626 vector long long vec_vaddudm (vector long long, vector bool long long);
15627 vector unsigned long long vec_vaddudm (vector unsigned long long,
15628                                        vector unsigned long long);
15629 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15630                                        vector unsigned long long);
15631 vector unsigned long long vec_vaddudm (vector unsigned long long,
15632                                        vector bool unsigned long long);
15634 vector long long vec_vbpermq (vector signed char, vector signed char);
15635 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15637 vector long long vec_vclz (vector long long);
15638 vector unsigned long long vec_vclz (vector unsigned long long);
15639 vector int vec_vclz (vector int);
15640 vector unsigned int vec_vclz (vector int);
15641 vector short vec_vclz (vector short);
15642 vector unsigned short vec_vclz (vector unsigned short);
15643 vector signed char vec_vclz (vector signed char);
15644 vector unsigned char vec_vclz (vector unsigned char);
15646 vector signed char vec_vclzb (vector signed char);
15647 vector unsigned char vec_vclzb (vector unsigned char);
15649 vector long long vec_vclzd (vector long long);
15650 vector unsigned long long vec_vclzd (vector unsigned long long);
15652 vector short vec_vclzh (vector short);
15653 vector unsigned short vec_vclzh (vector unsigned short);
15655 vector int vec_vclzw (vector int);
15656 vector unsigned int vec_vclzw (vector int);
15658 vector signed char vec_vgbbd (vector signed char);
15659 vector unsigned char vec_vgbbd (vector unsigned char);
15661 vector long long vec_vmaxsd (vector long long, vector long long);
15663 vector unsigned long long vec_vmaxud (vector unsigned long long,
15664                                       unsigned vector long long);
15666 vector long long vec_vminsd (vector long long, vector long long);
15668 vector unsigned long long vec_vminud (vector long long,
15669                                       vector long long);
15671 vector int vec_vpksdss (vector long long, vector long long);
15672 vector unsigned int vec_vpksdss (vector long long, vector long long);
15674 vector unsigned int vec_vpkudus (vector unsigned long long,
15675                                  vector unsigned long long);
15677 vector int vec_vpkudum (vector long long, vector long long);
15678 vector unsigned int vec_vpkudum (vector unsigned long long,
15679                                  vector unsigned long long);
15680 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15682 vector long long vec_vpopcnt (vector long long);
15683 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15684 vector int vec_vpopcnt (vector int);
15685 vector unsigned int vec_vpopcnt (vector int);
15686 vector short vec_vpopcnt (vector short);
15687 vector unsigned short vec_vpopcnt (vector unsigned short);
15688 vector signed char vec_vpopcnt (vector signed char);
15689 vector unsigned char vec_vpopcnt (vector unsigned char);
15691 vector signed char vec_vpopcntb (vector signed char);
15692 vector unsigned char vec_vpopcntb (vector unsigned char);
15694 vector long long vec_vpopcntd (vector long long);
15695 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15697 vector short vec_vpopcnth (vector short);
15698 vector unsigned short vec_vpopcnth (vector unsigned short);
15700 vector int vec_vpopcntw (vector int);
15701 vector unsigned int vec_vpopcntw (vector int);
15703 vector long long vec_vrld (vector long long, vector unsigned long long);
15704 vector unsigned long long vec_vrld (vector unsigned long long,
15705                                     vector unsigned long long);
15707 vector long long vec_vsld (vector long long, vector unsigned long long);
15708 vector long long vec_vsld (vector unsigned long long,
15709                            vector unsigned long long);
15711 vector long long vec_vsrad (vector long long, vector unsigned long long);
15712 vector unsigned long long vec_vsrad (vector unsigned long long,
15713                                      vector unsigned long long);
15715 vector long long vec_vsrd (vector long long, vector unsigned long long);
15716 vector unsigned long long char vec_vsrd (vector unsigned long long,
15717                                          vector unsigned long long);
15719 vector long long vec_vsubudm (vector long long, vector long long);
15720 vector long long vec_vsubudm (vector bool long long, vector long long);
15721 vector long long vec_vsubudm (vector long long, vector bool long long);
15722 vector unsigned long long vec_vsubudm (vector unsigned long long,
15723                                        vector unsigned long long);
15724 vector unsigned long long vec_vsubudm (vector bool long long,
15725                                        vector unsigned long long);
15726 vector unsigned long long vec_vsubudm (vector unsigned long long,
15727                                        vector bool long long);
15729 vector long long vec_vupkhsw (vector int);
15730 vector unsigned long long vec_vupkhsw (vector unsigned int);
15732 vector long long vec_vupklsw (vector int);
15733 vector unsigned long long vec_vupklsw (vector int);
15734 @end smallexample
15736 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15737 instruction set is available, the following additional functions are
15738 available for 64-bit targets.  New vector types
15739 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
15740 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
15741 builtins.
15743 The normal vector extract, and set operations work on
15744 @var{vector __int128_t} and @var{vector __uint128_t} types,
15745 but the index value must be 0.
15747 @smallexample
15748 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15749 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15751 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
15752 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
15754 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
15755                                 vector __int128_t);
15756 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
15757                                  vector __uint128_t);
15759 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
15760                                 vector __int128_t);
15761 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
15762                                  vector __uint128_t);
15764 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
15765                                 vector __int128_t);
15766 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
15767                                  vector __uint128_t);
15769 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
15770                                 vector __int128_t);
15771 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
15772                                  vector __uint128_t);
15774 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
15775 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
15777 __int128_t vec_vsubuqm (__int128_t, __int128_t);
15778 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
15780 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
15781 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
15782 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
15783 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
15784 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
15785 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
15786 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
15787 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
15788 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
15789 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
15790 @end smallexample
15792 If the cryptographic instructions are enabled (@option{-mcrypto} or
15793 @option{-mcpu=power8}), the following builtins are enabled.
15795 @smallexample
15796 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
15798 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
15799                                                     vector unsigned long long);
15801 vector unsigned long long __builtin_crypto_vcipherlast
15802                                      (vector unsigned long long,
15803                                       vector unsigned long long);
15805 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
15806                                                      vector unsigned long long);
15808 vector unsigned long long __builtin_crypto_vncipherlast
15809                                      (vector unsigned long long,
15810                                       vector unsigned long long);
15812 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
15813                                                 vector unsigned char,
15814                                                 vector unsigned char);
15816 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
15817                                                  vector unsigned short,
15818                                                  vector unsigned short);
15820 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
15821                                                vector unsigned int,
15822                                                vector unsigned int);
15824 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
15825                                                      vector unsigned long long,
15826                                                      vector unsigned long long);
15828 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
15829                                                vector unsigned char);
15831 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15832                                                 vector unsigned short);
15834 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15835                                               vector unsigned int);
15837 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15838                                                     vector unsigned long long);
15840 vector unsigned long long __builtin_crypto_vshasigmad
15841                                (vector unsigned long long, int, int);
15843 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15844                                                  int, int);
15845 @end smallexample
15847 The second argument to the @var{__builtin_crypto_vshasigmad} and
15848 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15849 integer that is 0 or 1.  The third argument to these builtin functions
15850 must be a constant integer in the range of 0 to 15.
15852 @node PowerPC Hardware Transactional Memory Built-in Functions
15853 @subsection PowerPC Hardware Transactional Memory Built-in Functions
15854 GCC provides two interfaces for accessing the Hardware Transactional
15855 Memory (HTM) instructions available on some of the PowerPC family
15856 of prcoessors (eg, POWER8).  The two interfaces come in a low level
15857 interface, consisting of built-in functions specific to PowerPC and a
15858 higher level interface consisting of inline functions that are common
15859 between PowerPC and S/390.
15861 @subsubsection PowerPC HTM Low Level Built-in Functions
15863 The following low level built-in functions are available with
15864 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
15865 They all generate the machine instruction that is part of the name.
15867 The HTM built-ins return true or false depending on their success and
15868 their arguments match exactly the type and order of the associated
15869 hardware instruction's operands.  Refer to the ISA manual for a
15870 description of each instruction's operands.
15872 @smallexample
15873 unsigned int __builtin_tbegin (unsigned int)
15874 unsigned int __builtin_tend (unsigned int)
15876 unsigned int __builtin_tabort (unsigned int)
15877 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
15878 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
15879 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
15880 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
15882 unsigned int __builtin_tcheck (unsigned int)
15883 unsigned int __builtin_treclaim (unsigned int)
15884 unsigned int __builtin_trechkpt (void)
15885 unsigned int __builtin_tsr (unsigned int)
15886 @end smallexample
15888 In addition to the above HTM built-ins, we have added built-ins for
15889 some common extended mnemonics of the HTM instructions:
15891 @smallexample
15892 unsigned int __builtin_tendall (void)
15893 unsigned int __builtin_tresume (void)
15894 unsigned int __builtin_tsuspend (void)
15895 @end smallexample
15897 The following set of built-in functions are available to gain access
15898 to the HTM specific special purpose registers.
15900 @smallexample
15901 unsigned long __builtin_get_texasr (void)
15902 unsigned long __builtin_get_texasru (void)
15903 unsigned long __builtin_get_tfhar (void)
15904 unsigned long __builtin_get_tfiar (void)
15906 void __builtin_set_texasr (unsigned long);
15907 void __builtin_set_texasru (unsigned long);
15908 void __builtin_set_tfhar (unsigned long);
15909 void __builtin_set_tfiar (unsigned long);
15910 @end smallexample
15912 Example usage of these low level built-in functions may look like:
15914 @smallexample
15915 #include <htmintrin.h>
15917 int num_retries = 10;
15919 while (1)
15920   @{
15921     if (__builtin_tbegin (0))
15922       @{
15923         /* Transaction State Initiated.  */
15924         if (is_locked (lock))
15925           __builtin_tabort (0);
15926         ... transaction code...
15927         __builtin_tend (0);
15928         break;
15929       @}
15930     else
15931       @{
15932         /* Transaction State Failed.  Use locks if the transaction
15933            failure is "persistent" or we've tried too many times.  */
15934         if (num_retries-- <= 0
15935             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
15936           @{
15937             acquire_lock (lock);
15938             ... non transactional fallback path...
15939             release_lock (lock);
15940             break;
15941           @}
15942       @}
15943   @}
15944 @end smallexample
15946 One final built-in function has been added that returns the value of
15947 the 2-bit Transaction State field of the Machine Status Register (MSR)
15948 as stored in @code{CR0}.
15950 @smallexample
15951 unsigned long __builtin_ttest (void)
15952 @end smallexample
15954 This built-in can be used to determine the current transaction state
15955 using the following code example:
15957 @smallexample
15958 #include <htmintrin.h>
15960 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
15962 if (tx_state == _HTM_TRANSACTIONAL)
15963   @{
15964     /* Code to use in transactional state.  */
15965   @}
15966 else if (tx_state == _HTM_NONTRANSACTIONAL)
15967   @{
15968     /* Code to use in non-transactional state.  */
15969   @}
15970 else if (tx_state == _HTM_SUSPENDED)
15971   @{
15972     /* Code to use in transaction suspended state.  */
15973   @}
15974 @end smallexample
15976 @subsubsection PowerPC HTM High Level Inline Functions
15978 The following high level HTM interface is made available by including
15979 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
15980 where CPU is `power8' or later.  This interface is common between PowerPC
15981 and S/390, allowing users to write one HTM source implementation that
15982 can be compiled and executed on either system.
15984 @smallexample
15985 long __TM_simple_begin (void)
15986 long __TM_begin (void* const TM_buff)
15987 long __TM_end (void)
15988 void __TM_abort (void)
15989 void __TM_named_abort (unsigned char const code)
15990 void __TM_resume (void)
15991 void __TM_suspend (void)
15993 long __TM_is_user_abort (void* const TM_buff)
15994 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
15995 long __TM_is_illegal (void* const TM_buff)
15996 long __TM_is_footprint_exceeded (void* const TM_buff)
15997 long __TM_nesting_depth (void* const TM_buff)
15998 long __TM_is_nested_too_deep(void* const TM_buff)
15999 long __TM_is_conflict(void* const TM_buff)
16000 long __TM_is_failure_persistent(void* const TM_buff)
16001 long __TM_failure_address(void* const TM_buff)
16002 long long __TM_failure_code(void* const TM_buff)
16003 @end smallexample
16005 Using these common set of HTM inline functions, we can create
16006 a more portable version of the HTM example in the previous
16007 section that will work on either PowerPC or S/390:
16009 @smallexample
16010 #include <htmxlintrin.h>
16012 int num_retries = 10;
16013 TM_buff_type TM_buff;
16015 while (1)
16016   @{
16017     if (__TM_begin (TM_buff))
16018       @{
16019         /* Transaction State Initiated.  */
16020         if (is_locked (lock))
16021           __TM_abort ();
16022         ... transaction code...
16023         __TM_end ();
16024         break;
16025       @}
16026     else
16027       @{
16028         /* Transaction State Failed.  Use locks if the transaction
16029            failure is "persistent" or we've tried too many times.  */
16030         if (num_retries-- <= 0
16031             || __TM_is_failure_persistent (TM_buff))
16032           @{
16033             acquire_lock (lock);
16034             ... non transactional fallback path...
16035             release_lock (lock);
16036             break;
16037           @}
16038       @}
16039   @}
16040 @end smallexample
16042 @node RX Built-in Functions
16043 @subsection RX Built-in Functions
16044 GCC supports some of the RX instructions which cannot be expressed in
16045 the C programming language via the use of built-in functions.  The
16046 following functions are supported:
16048 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
16049 Generates the @code{brk} machine instruction.
16050 @end deftypefn
16052 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
16053 Generates the @code{clrpsw} machine instruction to clear the specified
16054 bit in the processor status word.
16055 @end deftypefn
16057 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
16058 Generates the @code{int} machine instruction to generate an interrupt
16059 with the specified value.
16060 @end deftypefn
16062 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
16063 Generates the @code{machi} machine instruction to add the result of
16064 multiplying the top 16 bits of the two arguments into the
16065 accumulator.
16066 @end deftypefn
16068 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
16069 Generates the @code{maclo} machine instruction to add the result of
16070 multiplying the bottom 16 bits of the two arguments into the
16071 accumulator.
16072 @end deftypefn
16074 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
16075 Generates the @code{mulhi} machine instruction to place the result of
16076 multiplying the top 16 bits of the two arguments into the
16077 accumulator.
16078 @end deftypefn
16080 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
16081 Generates the @code{mullo} machine instruction to place the result of
16082 multiplying the bottom 16 bits of the two arguments into the
16083 accumulator.
16084 @end deftypefn
16086 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
16087 Generates the @code{mvfachi} machine instruction to read the top
16088 32 bits of the accumulator.
16089 @end deftypefn
16091 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
16092 Generates the @code{mvfacmi} machine instruction to read the middle
16093 32 bits of the accumulator.
16094 @end deftypefn
16096 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
16097 Generates the @code{mvfc} machine instruction which reads the control
16098 register specified in its argument and returns its value.
16099 @end deftypefn
16101 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
16102 Generates the @code{mvtachi} machine instruction to set the top
16103 32 bits of the accumulator.
16104 @end deftypefn
16106 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
16107 Generates the @code{mvtaclo} machine instruction to set the bottom
16108 32 bits of the accumulator.
16109 @end deftypefn
16111 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
16112 Generates the @code{mvtc} machine instruction which sets control
16113 register number @code{reg} to @code{val}.
16114 @end deftypefn
16116 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
16117 Generates the @code{mvtipl} machine instruction set the interrupt
16118 priority level.
16119 @end deftypefn
16121 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
16122 Generates the @code{racw} machine instruction to round the accumulator
16123 according to the specified mode.
16124 @end deftypefn
16126 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
16127 Generates the @code{revw} machine instruction which swaps the bytes in
16128 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16129 and also bits 16--23 occupy bits 24--31 and vice versa.
16130 @end deftypefn
16132 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
16133 Generates the @code{rmpa} machine instruction which initiates a
16134 repeated multiply and accumulate sequence.
16135 @end deftypefn
16137 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
16138 Generates the @code{round} machine instruction which returns the
16139 floating-point argument rounded according to the current rounding mode
16140 set in the floating-point status word register.
16141 @end deftypefn
16143 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
16144 Generates the @code{sat} machine instruction which returns the
16145 saturated value of the argument.
16146 @end deftypefn
16148 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
16149 Generates the @code{setpsw} machine instruction to set the specified
16150 bit in the processor status word.
16151 @end deftypefn
16153 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
16154 Generates the @code{wait} machine instruction.
16155 @end deftypefn
16157 @node S/390 System z Built-in Functions
16158 @subsection S/390 System z Built-in Functions
16159 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16160 Generates the @code{tbegin} machine instruction starting a
16161 non-constraint hardware transaction.  If the parameter is non-NULL the
16162 memory area is used to store the transaction diagnostic buffer and
16163 will be passed as first operand to @code{tbegin}.  This buffer can be
16164 defined using the @code{struct __htm_tdb} C struct defined in
16165 @code{htmintrin.h} and must reside on a double-word boundary.  The
16166 second tbegin operand is set to @code{0xff0c}. This enables
16167 save/restore of all GPRs and disables aborts for FPR and AR
16168 manipulations inside the transaction body.  The condition code set by
16169 the tbegin instruction is returned as integer value.  The tbegin
16170 instruction by definition overwrites the content of all FPRs.  The
16171 compiler will generate code which saves and restores the FPRs.  For
16172 soft-float code it is recommended to used the @code{*_nofloat}
16173 variant.  In order to prevent a TDB from being written it is required
16174 to pass an constant zero value as parameter.  Passing the zero value
16175 through a variable is not sufficient.  Although modifications of
16176 access registers inside the transaction will not trigger an
16177 transaction abort it is not supported to actually modify them.  Access
16178 registers do not get saved when entering a transaction. They will have
16179 undefined state when reaching the abort code.
16180 @end deftypefn
16182 Macros for the possible return codes of tbegin are defined in the
16183 @code{htmintrin.h} header file:
16185 @table @code
16186 @item _HTM_TBEGIN_STARTED
16187 @code{tbegin} has been executed as part of normal processing.  The
16188 transaction body is supposed to be executed.
16189 @item _HTM_TBEGIN_INDETERMINATE
16190 The transaction was aborted due to an indeterminate condition which
16191 might be persistent.
16192 @item _HTM_TBEGIN_TRANSIENT
16193 The transaction aborted due to a transient failure.  The transaction
16194 should be re-executed in that case.
16195 @item _HTM_TBEGIN_PERSISTENT
16196 The transaction aborted due to a persistent failure.  Re-execution
16197 under same circumstances will not be productive.
16198 @end table
16200 @defmac _HTM_FIRST_USER_ABORT_CODE
16201 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16202 specifies the first abort code which can be used for
16203 @code{__builtin_tabort}.  Values below this threshold are reserved for
16204 machine use.
16205 @end defmac
16207 @deftp {Data type} {struct __htm_tdb}
16208 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16209 the structure of the transaction diagnostic block as specified in the
16210 Principles of Operation manual chapter 5-91.
16211 @end deftp
16213 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16214 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16215 Using this variant in code making use of FPRs will leave the FPRs in
16216 undefined state when entering the transaction abort handler code.
16217 @end deftypefn
16219 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16220 In addition to @code{__builtin_tbegin} a loop for transient failures
16221 is generated.  If tbegin returns a condition code of 2 the transaction
16222 will be retried as often as specified in the second argument.  The
16223 perform processor assist instruction is used to tell the CPU about the
16224 number of fails so far.
16225 @end deftypefn
16227 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16228 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16229 restores.  Using this variant in code making use of FPRs will leave
16230 the FPRs in undefined state when entering the transaction abort
16231 handler code.
16232 @end deftypefn
16234 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16235 Generates the @code{tbeginc} machine instruction starting a constraint
16236 hardware transaction.  The second operand is set to @code{0xff08}.
16237 @end deftypefn
16239 @deftypefn {Built-in Function} int __builtin_tend (void)
16240 Generates the @code{tend} machine instruction finishing a transaction
16241 and making the changes visible to other threads.  The condition code
16242 generated by tend is returned as integer value.
16243 @end deftypefn
16245 @deftypefn {Built-in Function} void __builtin_tabort (int)
16246 Generates the @code{tabort} machine instruction with the specified
16247 abort code.  Abort codes from 0 through 255 are reserved and will
16248 result in an error message.
16249 @end deftypefn
16251 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16252 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16253 integer parameter is loaded into rX and a value of zero is loaded into
16254 rY.  The integer parameter specifies the number of times the
16255 transaction repeatedly aborted.
16256 @end deftypefn
16258 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16259 Generates the @code{etnd} machine instruction.  The current nesting
16260 depth is returned as integer value.  For a nesting depth of 0 the code
16261 is not executed as part of an transaction.
16262 @end deftypefn
16264 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16266 Generates the @code{ntstg} machine instruction.  The second argument
16267 is written to the first arguments location.  The store operation will
16268 not be rolled-back in case of an transaction abort.
16269 @end deftypefn
16271 @node SH Built-in Functions
16272 @subsection SH Built-in Functions
16273 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16274 families of processors:
16276 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16277 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16278 used by system code that manages threads and execution contexts.  The compiler
16279 normally does not generate code that modifies the contents of @samp{GBR} and
16280 thus the value is preserved across function calls.  Changing the @samp{GBR}
16281 value in user code must be done with caution, since the compiler might use
16282 @samp{GBR} in order to access thread local variables.
16284 @end deftypefn
16286 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16287 Returns the value that is currently set in the @samp{GBR} register.
16288 Memory loads and stores that use the thread pointer as a base address are
16289 turned into @samp{GBR} based displacement loads and stores, if possible.
16290 For example:
16291 @smallexample
16292 struct my_tcb
16294    int a, b, c, d, e;
16297 int get_tcb_value (void)
16299   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16300   return ((my_tcb*)__builtin_thread_pointer ())->c;
16303 @end smallexample
16304 @end deftypefn
16306 @node SPARC VIS Built-in Functions
16307 @subsection SPARC VIS Built-in Functions
16309 GCC supports SIMD operations on the SPARC using both the generic vector
16310 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16311 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16312 switch, the VIS extension is exposed as the following built-in functions:
16314 @smallexample
16315 typedef int v1si __attribute__ ((vector_size (4)));
16316 typedef int v2si __attribute__ ((vector_size (8)));
16317 typedef short v4hi __attribute__ ((vector_size (8)));
16318 typedef short v2hi __attribute__ ((vector_size (4)));
16319 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16320 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16322 void __builtin_vis_write_gsr (int64_t);
16323 int64_t __builtin_vis_read_gsr (void);
16325 void * __builtin_vis_alignaddr (void *, long);
16326 void * __builtin_vis_alignaddrl (void *, long);
16327 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16328 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16329 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16330 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16332 v4hi __builtin_vis_fexpand (v4qi);
16334 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16335 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16336 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16337 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16338 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16339 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16340 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16342 v4qi __builtin_vis_fpack16 (v4hi);
16343 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16344 v2hi __builtin_vis_fpackfix (v2si);
16345 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16347 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16349 long __builtin_vis_edge8 (void *, void *);
16350 long __builtin_vis_edge8l (void *, void *);
16351 long __builtin_vis_edge16 (void *, void *);
16352 long __builtin_vis_edge16l (void *, void *);
16353 long __builtin_vis_edge32 (void *, void *);
16354 long __builtin_vis_edge32l (void *, void *);
16356 long __builtin_vis_fcmple16 (v4hi, v4hi);
16357 long __builtin_vis_fcmple32 (v2si, v2si);
16358 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16359 long __builtin_vis_fcmpne32 (v2si, v2si);
16360 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16361 long __builtin_vis_fcmpgt32 (v2si, v2si);
16362 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16363 long __builtin_vis_fcmpeq32 (v2si, v2si);
16365 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16366 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16367 v2si __builtin_vis_fpadd32 (v2si, v2si);
16368 v1si __builtin_vis_fpadd32s (v1si, v1si);
16369 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16370 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16371 v2si __builtin_vis_fpsub32 (v2si, v2si);
16372 v1si __builtin_vis_fpsub32s (v1si, v1si);
16374 long __builtin_vis_array8 (long, long);
16375 long __builtin_vis_array16 (long, long);
16376 long __builtin_vis_array32 (long, long);
16377 @end smallexample
16379 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16380 functions also become available:
16382 @smallexample
16383 long __builtin_vis_bmask (long, long);
16384 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16385 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16386 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16387 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16389 long __builtin_vis_edge8n (void *, void *);
16390 long __builtin_vis_edge8ln (void *, void *);
16391 long __builtin_vis_edge16n (void *, void *);
16392 long __builtin_vis_edge16ln (void *, void *);
16393 long __builtin_vis_edge32n (void *, void *);
16394 long __builtin_vis_edge32ln (void *, void *);
16395 @end smallexample
16397 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16398 functions also become available:
16400 @smallexample
16401 void __builtin_vis_cmask8 (long);
16402 void __builtin_vis_cmask16 (long);
16403 void __builtin_vis_cmask32 (long);
16405 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16407 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16408 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16409 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16410 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16411 v2si __builtin_vis_fsll16 (v2si, v2si);
16412 v2si __builtin_vis_fslas16 (v2si, v2si);
16413 v2si __builtin_vis_fsrl16 (v2si, v2si);
16414 v2si __builtin_vis_fsra16 (v2si, v2si);
16416 long __builtin_vis_pdistn (v8qi, v8qi);
16418 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16420 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16421 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16423 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16424 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16425 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16426 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16427 v2si __builtin_vis_fpadds32 (v2si, v2si);
16428 v1si __builtin_vis_fpadds32s (v1si, v1si);
16429 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16430 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16432 long __builtin_vis_fucmple8 (v8qi, v8qi);
16433 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16434 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16435 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16437 float __builtin_vis_fhadds (float, float);
16438 double __builtin_vis_fhaddd (double, double);
16439 float __builtin_vis_fhsubs (float, float);
16440 double __builtin_vis_fhsubd (double, double);
16441 float __builtin_vis_fnhadds (float, float);
16442 double __builtin_vis_fnhaddd (double, double);
16444 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16445 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16446 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16447 @end smallexample
16449 @node SPU Built-in Functions
16450 @subsection SPU Built-in Functions
16452 GCC provides extensions for the SPU processor as described in the
16453 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16454 found at @uref{http://cell.scei.co.jp/} or
16455 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
16456 implementation differs in several ways.
16458 @itemize @bullet
16460 @item
16461 The optional extension of specifying vector constants in parentheses is
16462 not supported.
16464 @item
16465 A vector initializer requires no cast if the vector constant is of the
16466 same type as the variable it is initializing.
16468 @item
16469 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16470 vector type is the default signedness of the base type.  The default
16471 varies depending on the operating system, so a portable program should
16472 always specify the signedness.
16474 @item
16475 By default, the keyword @code{__vector} is added. The macro
16476 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16477 undefined.
16479 @item
16480 GCC allows using a @code{typedef} name as the type specifier for a
16481 vector type.
16483 @item
16484 For C, overloaded functions are implemented with macros so the following
16485 does not work:
16487 @smallexample
16488   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16489 @end smallexample
16491 @noindent
16492 Since @code{spu_add} is a macro, the vector constant in the example
16493 is treated as four separate arguments.  Wrap the entire argument in
16494 parentheses for this to work.
16496 @item
16497 The extended version of @code{__builtin_expect} is not supported.
16499 @end itemize
16501 @emph{Note:} Only the interface described in the aforementioned
16502 specification is supported. Internally, GCC uses built-in functions to
16503 implement the required functionality, but these are not supported and
16504 are subject to change without notice.
16506 @node TI C6X Built-in Functions
16507 @subsection TI C6X Built-in Functions
16509 GCC provides intrinsics to access certain instructions of the TI C6X
16510 processors.  These intrinsics, listed below, are available after
16511 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
16512 to C6X instructions.
16514 @smallexample
16516 int _sadd (int, int)
16517 int _ssub (int, int)
16518 int _sadd2 (int, int)
16519 int _ssub2 (int, int)
16520 long long _mpy2 (int, int)
16521 long long _smpy2 (int, int)
16522 int _add4 (int, int)
16523 int _sub4 (int, int)
16524 int _saddu4 (int, int)
16526 int _smpy (int, int)
16527 int _smpyh (int, int)
16528 int _smpyhl (int, int)
16529 int _smpylh (int, int)
16531 int _sshl (int, int)
16532 int _subc (int, int)
16534 int _avg2 (int, int)
16535 int _avgu4 (int, int)
16537 int _clrr (int, int)
16538 int _extr (int, int)
16539 int _extru (int, int)
16540 int _abs (int)
16541 int _abs2 (int)
16543 @end smallexample
16545 @node TILE-Gx Built-in Functions
16546 @subsection TILE-Gx Built-in Functions
16548 GCC provides intrinsics to access every instruction of the TILE-Gx
16549 processor.  The intrinsics are of the form:
16551 @smallexample
16553 unsigned long long __insn_@var{op} (...)
16555 @end smallexample
16557 Where @var{op} is the name of the instruction.  Refer to the ISA manual
16558 for the complete list of instructions.
16560 GCC also provides intrinsics to directly access the network registers.
16561 The intrinsics are:
16563 @smallexample
16565 unsigned long long __tile_idn0_receive (void)
16566 unsigned long long __tile_idn1_receive (void)
16567 unsigned long long __tile_udn0_receive (void)
16568 unsigned long long __tile_udn1_receive (void)
16569 unsigned long long __tile_udn2_receive (void)
16570 unsigned long long __tile_udn3_receive (void)
16571 void __tile_idn_send (unsigned long long)
16572 void __tile_udn_send (unsigned long long)
16574 @end smallexample
16576 The intrinsic @code{void __tile_network_barrier (void)} is used to
16577 guarantee that no network operations before it are reordered with
16578 those after it.
16580 @node TILEPro Built-in Functions
16581 @subsection TILEPro Built-in Functions
16583 GCC provides intrinsics to access every instruction of the TILEPro
16584 processor.  The intrinsics are of the form:
16586 @smallexample
16588 unsigned __insn_@var{op} (...)
16590 @end smallexample
16592 @noindent
16593 where @var{op} is the name of the instruction.  Refer to the ISA manual
16594 for the complete list of instructions.
16596 GCC also provides intrinsics to directly access the network registers.
16597 The intrinsics are:
16599 @smallexample
16601 unsigned __tile_idn0_receive (void)
16602 unsigned __tile_idn1_receive (void)
16603 unsigned __tile_sn_receive (void)
16604 unsigned __tile_udn0_receive (void)
16605 unsigned __tile_udn1_receive (void)
16606 unsigned __tile_udn2_receive (void)
16607 unsigned __tile_udn3_receive (void)
16608 void __tile_idn_send (unsigned)
16609 void __tile_sn_send (unsigned)
16610 void __tile_udn_send (unsigned)
16612 @end smallexample
16614 The intrinsic @code{void __tile_network_barrier (void)} is used to
16615 guarantee that no network operations before it are reordered with
16616 those after it.
16618 @node Target Format Checks
16619 @section Format Checks Specific to Particular Target Machines
16621 For some target machines, GCC supports additional options to the
16622 format attribute
16623 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
16625 @menu
16626 * Solaris Format Checks::
16627 * Darwin Format Checks::
16628 @end menu
16630 @node Solaris Format Checks
16631 @subsection Solaris Format Checks
16633 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
16634 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
16635 conversions, and the two-argument @code{%b} conversion for displaying
16636 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
16638 @node Darwin Format Checks
16639 @subsection Darwin Format Checks
16641 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
16642 attribute context.  Declarations made with such attribution are parsed for correct syntax
16643 and format argument types.  However, parsing of the format string itself is currently undefined
16644 and is not carried out by this version of the compiler.
16646 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
16647 also be used as format arguments.  Note that the relevant headers are only likely to be
16648 available on Darwin (OSX) installations.  On such installations, the XCode and system
16649 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
16650 associated functions.
16652 @node Pragmas
16653 @section Pragmas Accepted by GCC
16654 @cindex pragmas
16655 @cindex @code{#pragma}
16657 GCC supports several types of pragmas, primarily in order to compile
16658 code originally written for other compilers.  Note that in general
16659 we do not recommend the use of pragmas; @xref{Function Attributes},
16660 for further explanation.
16662 @menu
16663 * ARM Pragmas::
16664 * M32C Pragmas::
16665 * MeP Pragmas::
16666 * RS/6000 and PowerPC Pragmas::
16667 * Darwin Pragmas::
16668 * Solaris Pragmas::
16669 * Symbol-Renaming Pragmas::
16670 * Structure-Packing Pragmas::
16671 * Weak Pragmas::
16672 * Diagnostic Pragmas::
16673 * Visibility Pragmas::
16674 * Push/Pop Macro Pragmas::
16675 * Function Specific Option Pragmas::
16676 * Loop-Specific Pragmas::
16677 @end menu
16679 @node ARM Pragmas
16680 @subsection ARM Pragmas
16682 The ARM target defines pragmas for controlling the default addition of
16683 @code{long_call} and @code{short_call} attributes to functions.
16684 @xref{Function Attributes}, for information about the effects of these
16685 attributes.
16687 @table @code
16688 @item long_calls
16689 @cindex pragma, long_calls
16690 Set all subsequent functions to have the @code{long_call} attribute.
16692 @item no_long_calls
16693 @cindex pragma, no_long_calls
16694 Set all subsequent functions to have the @code{short_call} attribute.
16696 @item long_calls_off
16697 @cindex pragma, long_calls_off
16698 Do not affect the @code{long_call} or @code{short_call} attributes of
16699 subsequent functions.
16700 @end table
16702 @node M32C Pragmas
16703 @subsection M32C Pragmas
16705 @table @code
16706 @item GCC memregs @var{number}
16707 @cindex pragma, memregs
16708 Overrides the command-line option @code{-memregs=} for the current
16709 file.  Use with care!  This pragma must be before any function in the
16710 file, and mixing different memregs values in different objects may
16711 make them incompatible.  This pragma is useful when a
16712 performance-critical function uses a memreg for temporary values,
16713 as it may allow you to reduce the number of memregs used.
16715 @item ADDRESS @var{name} @var{address}
16716 @cindex pragma, address
16717 For any declared symbols matching @var{name}, this does three things
16718 to that symbol: it forces the symbol to be located at the given
16719 address (a number), it forces the symbol to be volatile, and it
16720 changes the symbol's scope to be static.  This pragma exists for
16721 compatibility with other compilers, but note that the common
16722 @code{1234H} numeric syntax is not supported (use @code{0x1234}
16723 instead).  Example:
16725 @smallexample
16726 #pragma ADDRESS port3 0x103
16727 char port3;
16728 @end smallexample
16730 @end table
16732 @node MeP Pragmas
16733 @subsection MeP Pragmas
16735 @table @code
16737 @item custom io_volatile (on|off)
16738 @cindex pragma, custom io_volatile
16739 Overrides the command-line option @code{-mio-volatile} for the current
16740 file.  Note that for compatibility with future GCC releases, this
16741 option should only be used once before any @code{io} variables in each
16742 file.
16744 @item GCC coprocessor available @var{registers}
16745 @cindex pragma, coprocessor available
16746 Specifies which coprocessor registers are available to the register
16747 allocator.  @var{registers} may be a single register, register range
16748 separated by ellipses, or comma-separated list of those.  Example:
16750 @smallexample
16751 #pragma GCC coprocessor available $c0...$c10, $c28
16752 @end smallexample
16754 @item GCC coprocessor call_saved @var{registers}
16755 @cindex pragma, coprocessor call_saved
16756 Specifies which coprocessor registers are to be saved and restored by
16757 any function using them.  @var{registers} may be a single register,
16758 register range separated by ellipses, or comma-separated list of
16759 those.  Example:
16761 @smallexample
16762 #pragma GCC coprocessor call_saved $c4...$c6, $c31
16763 @end smallexample
16765 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
16766 @cindex pragma, coprocessor subclass
16767 Creates and defines a register class.  These register classes can be
16768 used by inline @code{asm} constructs.  @var{registers} may be a single
16769 register, register range separated by ellipses, or comma-separated
16770 list of those.  Example:
16772 @smallexample
16773 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
16775 asm ("cpfoo %0" : "=B" (x));
16776 @end smallexample
16778 @item GCC disinterrupt @var{name} , @var{name} @dots{}
16779 @cindex pragma, disinterrupt
16780 For the named functions, the compiler adds code to disable interrupts
16781 for the duration of those functions.  If any functions so named 
16782 are not encountered in the source, a warning is emitted that the pragma is
16783 not used.  Examples:
16785 @smallexample
16786 #pragma disinterrupt foo
16787 #pragma disinterrupt bar, grill
16788 int foo () @{ @dots{} @}
16789 @end smallexample
16791 @item GCC call @var{name} , @var{name} @dots{}
16792 @cindex pragma, call
16793 For the named functions, the compiler always uses a register-indirect
16794 call model when calling the named functions.  Examples:
16796 @smallexample
16797 extern int foo ();
16798 #pragma call foo
16799 @end smallexample
16801 @end table
16803 @node RS/6000 and PowerPC Pragmas
16804 @subsection RS/6000 and PowerPC Pragmas
16806 The RS/6000 and PowerPC targets define one pragma for controlling
16807 whether or not the @code{longcall} attribute is added to function
16808 declarations by default.  This pragma overrides the @option{-mlongcall}
16809 option, but not the @code{longcall} and @code{shortcall} attributes.
16810 @xref{RS/6000 and PowerPC Options}, for more information about when long
16811 calls are and are not necessary.
16813 @table @code
16814 @item longcall (1)
16815 @cindex pragma, longcall
16816 Apply the @code{longcall} attribute to all subsequent function
16817 declarations.
16819 @item longcall (0)
16820 Do not apply the @code{longcall} attribute to subsequent function
16821 declarations.
16822 @end table
16824 @c Describe h8300 pragmas here.
16825 @c Describe sh pragmas here.
16826 @c Describe v850 pragmas here.
16828 @node Darwin Pragmas
16829 @subsection Darwin Pragmas
16831 The following pragmas are available for all architectures running the
16832 Darwin operating system.  These are useful for compatibility with other
16833 Mac OS compilers.
16835 @table @code
16836 @item mark @var{tokens}@dots{}
16837 @cindex pragma, mark
16838 This pragma is accepted, but has no effect.
16840 @item options align=@var{alignment}
16841 @cindex pragma, options align
16842 This pragma sets the alignment of fields in structures.  The values of
16843 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
16844 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
16845 properly; to restore the previous setting, use @code{reset} for the
16846 @var{alignment}.
16848 @item segment @var{tokens}@dots{}
16849 @cindex pragma, segment
16850 This pragma is accepted, but has no effect.
16852 @item unused (@var{var} [, @var{var}]@dots{})
16853 @cindex pragma, unused
16854 This pragma declares variables to be possibly unused.  GCC does not
16855 produce warnings for the listed variables.  The effect is similar to
16856 that of the @code{unused} attribute, except that this pragma may appear
16857 anywhere within the variables' scopes.
16858 @end table
16860 @node Solaris Pragmas
16861 @subsection Solaris Pragmas
16863 The Solaris target supports @code{#pragma redefine_extname}
16864 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
16865 @code{#pragma} directives for compatibility with the system compiler.
16867 @table @code
16868 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
16869 @cindex pragma, align
16871 Increase the minimum alignment of each @var{variable} to @var{alignment}.
16872 This is the same as GCC's @code{aligned} attribute @pxref{Variable
16873 Attributes}).  Macro expansion occurs on the arguments to this pragma
16874 when compiling C and Objective-C@.  It does not currently occur when
16875 compiling C++, but this is a bug which may be fixed in a future
16876 release.
16878 @item fini (@var{function} [, @var{function}]...)
16879 @cindex pragma, fini
16881 This pragma causes each listed @var{function} to be called after
16882 main, or during shared module unloading, by adding a call to the
16883 @code{.fini} section.
16885 @item init (@var{function} [, @var{function}]...)
16886 @cindex pragma, init
16888 This pragma causes each listed @var{function} to be called during
16889 initialization (before @code{main}) or during shared module loading, by
16890 adding a call to the @code{.init} section.
16892 @end table
16894 @node Symbol-Renaming Pragmas
16895 @subsection Symbol-Renaming Pragmas
16897 GCC supports a @code{#pragma} directive that changes the name used in
16898 assembly for a given declaration. This effect can also be achieved
16899 using the asm labels extension (@pxref{Asm Labels}).
16901 @table @code
16902 @item redefine_extname @var{oldname} @var{newname}
16903 @cindex pragma, redefine_extname
16905 This pragma gives the C function @var{oldname} the assembly symbol
16906 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
16907 is defined if this pragma is available (currently on all platforms).
16908 @end table
16910 This pragma and the asm labels extension interact in a complicated
16911 manner.  Here are some corner cases you may want to be aware of:
16913 @enumerate
16914 @item This pragma silently applies only to declarations with external
16915 linkage.  Asm labels do not have this restriction.
16917 @item In C++, this pragma silently applies only to declarations with
16918 ``C'' linkage.  Again, asm labels do not have this restriction.
16920 @item If either of the ways of changing the assembly name of a
16921 declaration are applied to a declaration whose assembly name has
16922 already been determined (either by a previous use of one of these
16923 features, or because the compiler needed the assembly name in order to
16924 generate code), and the new name is different, a warning issues and
16925 the name does not change.
16927 @item The @var{oldname} used by @code{#pragma redefine_extname} is
16928 always the C-language name.
16929 @end enumerate
16931 @node Structure-Packing Pragmas
16932 @subsection Structure-Packing Pragmas
16934 For compatibility with Microsoft Windows compilers, GCC supports a
16935 set of @code{#pragma} directives that change the maximum alignment of
16936 members of structures (other than zero-width bit-fields), unions, and
16937 classes subsequently defined. The @var{n} value below always is required
16938 to be a small power of two and specifies the new alignment in bytes.
16940 @enumerate
16941 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
16942 @item @code{#pragma pack()} sets the alignment to the one that was in
16943 effect when compilation started (see also command-line option
16944 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
16945 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
16946 setting on an internal stack and then optionally sets the new alignment.
16947 @item @code{#pragma pack(pop)} restores the alignment setting to the one
16948 saved at the top of the internal stack (and removes that stack entry).
16949 Note that @code{#pragma pack([@var{n}])} does not influence this internal
16950 stack; thus it is possible to have @code{#pragma pack(push)} followed by
16951 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
16952 @code{#pragma pack(pop)}.
16953 @end enumerate
16955 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
16956 @code{#pragma} which lays out a structure as the documented
16957 @code{__attribute__ ((ms_struct))}.
16958 @enumerate
16959 @item @code{#pragma ms_struct on} turns on the layout for structures
16960 declared.
16961 @item @code{#pragma ms_struct off} turns off the layout for structures
16962 declared.
16963 @item @code{#pragma ms_struct reset} goes back to the default layout.
16964 @end enumerate
16966 @node Weak Pragmas
16967 @subsection Weak Pragmas
16969 For compatibility with SVR4, GCC supports a set of @code{#pragma}
16970 directives for declaring symbols to be weak, and defining weak
16971 aliases.
16973 @table @code
16974 @item #pragma weak @var{symbol}
16975 @cindex pragma, weak
16976 This pragma declares @var{symbol} to be weak, as if the declaration
16977 had the attribute of the same name.  The pragma may appear before
16978 or after the declaration of @var{symbol}.  It is not an error for
16979 @var{symbol} to never be defined at all.
16981 @item #pragma weak @var{symbol1} = @var{symbol2}
16982 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
16983 It is an error if @var{symbol2} is not defined in the current
16984 translation unit.
16985 @end table
16987 @node Diagnostic Pragmas
16988 @subsection Diagnostic Pragmas
16990 GCC allows the user to selectively enable or disable certain types of
16991 diagnostics, and change the kind of the diagnostic.  For example, a
16992 project's policy might require that all sources compile with
16993 @option{-Werror} but certain files might have exceptions allowing
16994 specific types of warnings.  Or, a project might selectively enable
16995 diagnostics and treat them as errors depending on which preprocessor
16996 macros are defined.
16998 @table @code
16999 @item #pragma GCC diagnostic @var{kind} @var{option}
17000 @cindex pragma, diagnostic
17002 Modifies the disposition of a diagnostic.  Note that not all
17003 diagnostics are modifiable; at the moment only warnings (normally
17004 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17005 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17006 are controllable and which option controls them.
17008 @var{kind} is @samp{error} to treat this diagnostic as an error,
17009 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17010 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17011 @var{option} is a double quoted string that matches the command-line
17012 option.
17014 @smallexample
17015 #pragma GCC diagnostic warning "-Wformat"
17016 #pragma GCC diagnostic error "-Wformat"
17017 #pragma GCC diagnostic ignored "-Wformat"
17018 @end smallexample
17020 Note that these pragmas override any command-line options.  GCC keeps
17021 track of the location of each pragma, and issues diagnostics according
17022 to the state as of that point in the source file.  Thus, pragmas occurring
17023 after a line do not affect diagnostics caused by that line.
17025 @item #pragma GCC diagnostic push
17026 @itemx #pragma GCC diagnostic pop
17028 Causes GCC to remember the state of the diagnostics as of each
17029 @code{push}, and restore to that point at each @code{pop}.  If a
17030 @code{pop} has no matching @code{push}, the command-line options are
17031 restored.
17033 @smallexample
17034 #pragma GCC diagnostic error "-Wuninitialized"
17035   foo(a);                       /* error is given for this one */
17036 #pragma GCC diagnostic push
17037 #pragma GCC diagnostic ignored "-Wuninitialized"
17038   foo(b);                       /* no diagnostic for this one */
17039 #pragma GCC diagnostic pop
17040   foo(c);                       /* error is given for this one */
17041 #pragma GCC diagnostic pop
17042   foo(d);                       /* depends on command-line options */
17043 @end smallexample
17045 @end table
17047 GCC also offers a simple mechanism for printing messages during
17048 compilation.
17050 @table @code
17051 @item #pragma message @var{string}
17052 @cindex pragma, diagnostic
17054 Prints @var{string} as a compiler message on compilation.  The message
17055 is informational only, and is neither a compilation warning nor an error.
17057 @smallexample
17058 #pragma message "Compiling " __FILE__ "..."
17059 @end smallexample
17061 @var{string} may be parenthesized, and is printed with location
17062 information.  For example,
17064 @smallexample
17065 #define DO_PRAGMA(x) _Pragma (#x)
17066 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17068 TODO(Remember to fix this)
17069 @end smallexample
17071 @noindent
17072 prints @samp{/tmp/file.c:4: note: #pragma message:
17073 TODO - Remember to fix this}.
17075 @end table
17077 @node Visibility Pragmas
17078 @subsection Visibility Pragmas
17080 @table @code
17081 @item #pragma GCC visibility push(@var{visibility})
17082 @itemx #pragma GCC visibility pop
17083 @cindex pragma, visibility
17085 This pragma allows the user to set the visibility for multiple
17086 declarations without having to give each a visibility attribute
17087 (@pxref{Function Attributes}).
17089 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17090 declarations.  Class members and template specializations are not
17091 affected; if you want to override the visibility for a particular
17092 member or instantiation, you must use an attribute.
17094 @end table
17097 @node Push/Pop Macro Pragmas
17098 @subsection Push/Pop Macro Pragmas
17100 For compatibility with Microsoft Windows compilers, GCC supports
17101 @samp{#pragma push_macro(@var{"macro_name"})}
17102 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17104 @table @code
17105 @item #pragma push_macro(@var{"macro_name"})
17106 @cindex pragma, push_macro
17107 This pragma saves the value of the macro named as @var{macro_name} to
17108 the top of the stack for this macro.
17110 @item #pragma pop_macro(@var{"macro_name"})
17111 @cindex pragma, pop_macro
17112 This pragma sets the value of the macro named as @var{macro_name} to
17113 the value on top of the stack for this macro. If the stack for
17114 @var{macro_name} is empty, the value of the macro remains unchanged.
17115 @end table
17117 For example:
17119 @smallexample
17120 #define X  1
17121 #pragma push_macro("X")
17122 #undef X
17123 #define X -1
17124 #pragma pop_macro("X")
17125 int x [X];
17126 @end smallexample
17128 @noindent
17129 In this example, the definition of X as 1 is saved by @code{#pragma
17130 push_macro} and restored by @code{#pragma pop_macro}.
17132 @node Function Specific Option Pragmas
17133 @subsection Function Specific Option Pragmas
17135 @table @code
17136 @item #pragma GCC target (@var{"string"}...)
17137 @cindex pragma GCC target
17139 This pragma allows you to set target specific options for functions
17140 defined later in the source file.  One or more strings can be
17141 specified.  Each function that is defined after this point is as
17142 if @code{attribute((target("STRING")))} was specified for that
17143 function.  The parenthesis around the options is optional.
17144 @xref{Function Attributes}, for more information about the
17145 @code{target} attribute and the attribute syntax.
17147 The @code{#pragma GCC target} pragma is presently implemented for
17148 i386/x86_64, PowerPC, and Nios II targets only.
17149 @end table
17151 @table @code
17152 @item #pragma GCC optimize (@var{"string"}...)
17153 @cindex pragma GCC optimize
17155 This pragma allows you to set global optimization options for functions
17156 defined later in the source file.  One or more strings can be
17157 specified.  Each function that is defined after this point is as
17158 if @code{attribute((optimize("STRING")))} was specified for that
17159 function.  The parenthesis around the options is optional.
17160 @xref{Function Attributes}, for more information about the
17161 @code{optimize} attribute and the attribute syntax.
17163 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17164 versions earlier than 4.4.
17165 @end table
17167 @table @code
17168 @item #pragma GCC push_options
17169 @itemx #pragma GCC pop_options
17170 @cindex pragma GCC push_options
17171 @cindex pragma GCC pop_options
17173 These pragmas maintain a stack of the current target and optimization
17174 options.  It is intended for include files where you temporarily want
17175 to switch to using a different @samp{#pragma GCC target} or
17176 @samp{#pragma GCC optimize} and then to pop back to the previous
17177 options.
17179 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17180 pragmas are not implemented in GCC versions earlier than 4.4.
17181 @end table
17183 @table @code
17184 @item #pragma GCC reset_options
17185 @cindex pragma GCC reset_options
17187 This pragma clears the current @code{#pragma GCC target} and
17188 @code{#pragma GCC optimize} to use the default switches as specified
17189 on the command line.
17191 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17192 versions earlier than 4.4.
17193 @end table
17195 @node Loop-Specific Pragmas
17196 @subsection Loop-Specific Pragmas
17198 @table @code
17199 @item #pragma GCC ivdep
17200 @cindex pragma GCC ivdep
17201 @end table
17203 With this pragma, the programmer asserts that there are no loop-carried
17204 dependencies which would prevent that consecutive iterations of
17205 the following loop can be executed concurrently with SIMD
17206 (single instruction multiple data) instructions.
17208 For example, the compiler can only unconditionally vectorize the following
17209 loop with the pragma:
17211 @smallexample
17212 void foo (int n, int *a, int *b, int *c)
17214   int i, j;
17215 #pragma GCC ivdep
17216   for (i = 0; i < n; ++i)
17217     a[i] = b[i] + c[i];
17219 @end smallexample
17221 @noindent
17222 In this example, using the @code{restrict} qualifier had the same
17223 effect. In the following example, that would not be possible. Assume
17224 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17225 that it can unconditionally vectorize the following loop:
17227 @smallexample
17228 void ignore_vec_dep (int *a, int k, int c, int m)
17230 #pragma GCC ivdep
17231   for (int i = 0; i < m; i++)
17232     a[i] = a[i + k] * c;
17234 @end smallexample
17237 @node Unnamed Fields
17238 @section Unnamed struct/union fields within structs/unions
17239 @cindex @code{struct}
17240 @cindex @code{union}
17242 As permitted by ISO C11 and for compatibility with other compilers,
17243 GCC allows you to define
17244 a structure or union that contains, as fields, structures and unions
17245 without names.  For example:
17247 @smallexample
17248 struct @{
17249   int a;
17250   union @{
17251     int b;
17252     float c;
17253   @};
17254   int d;
17255 @} foo;
17256 @end smallexample
17258 @noindent
17259 In this example, you are able to access members of the unnamed
17260 union with code like @samp{foo.b}.  Note that only unnamed structs and
17261 unions are allowed, you may not have, for example, an unnamed
17262 @code{int}.
17264 You must never create such structures that cause ambiguous field definitions.
17265 For example, in this structure:
17267 @smallexample
17268 struct @{
17269   int a;
17270   struct @{
17271     int a;
17272   @};
17273 @} foo;
17274 @end smallexample
17276 @noindent
17277 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17278 The compiler gives errors for such constructs.
17280 @opindex fms-extensions
17281 Unless @option{-fms-extensions} is used, the unnamed field must be a
17282 structure or union definition without a tag (for example, @samp{struct
17283 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
17284 also be a definition with a tag such as @samp{struct foo @{ int a;
17285 @};}, a reference to a previously defined structure or union such as
17286 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17287 previously defined structure or union type.
17289 @opindex fplan9-extensions
17290 The option @option{-fplan9-extensions} enables
17291 @option{-fms-extensions} as well as two other extensions.  First, a
17292 pointer to a structure is automatically converted to a pointer to an
17293 anonymous field for assignments and function calls.  For example:
17295 @smallexample
17296 struct s1 @{ int a; @};
17297 struct s2 @{ struct s1; @};
17298 extern void f1 (struct s1 *);
17299 void f2 (struct s2 *p) @{ f1 (p); @}
17300 @end smallexample
17302 @noindent
17303 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17304 converted into a pointer to the anonymous field.
17306 Second, when the type of an anonymous field is a @code{typedef} for a
17307 @code{struct} or @code{union}, code may refer to the field using the
17308 name of the @code{typedef}.
17310 @smallexample
17311 typedef struct @{ int a; @} s1;
17312 struct s2 @{ s1; @};
17313 s1 f1 (struct s2 *p) @{ return p->s1; @}
17314 @end smallexample
17316 These usages are only permitted when they are not ambiguous.
17318 @node Thread-Local
17319 @section Thread-Local Storage
17320 @cindex Thread-Local Storage
17321 @cindex @acronym{TLS}
17322 @cindex @code{__thread}
17324 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17325 are allocated such that there is one instance of the variable per extant
17326 thread.  The runtime model GCC uses to implement this originates
17327 in the IA-64 processor-specific ABI, but has since been migrated
17328 to other processors as well.  It requires significant support from
17329 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17330 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17331 is not available everywhere.
17333 At the user level, the extension is visible with a new storage
17334 class keyword: @code{__thread}.  For example:
17336 @smallexample
17337 __thread int i;
17338 extern __thread struct state s;
17339 static __thread char *p;
17340 @end smallexample
17342 The @code{__thread} specifier may be used alone, with the @code{extern}
17343 or @code{static} specifiers, but with no other storage class specifier.
17344 When used with @code{extern} or @code{static}, @code{__thread} must appear
17345 immediately after the other storage class specifier.
17347 The @code{__thread} specifier may be applied to any global, file-scoped
17348 static, function-scoped static, or static data member of a class.  It may
17349 not be applied to block-scoped automatic or non-static data member.
17351 When the address-of operator is applied to a thread-local variable, it is
17352 evaluated at run time and returns the address of the current thread's
17353 instance of that variable.  An address so obtained may be used by any
17354 thread.  When a thread terminates, any pointers to thread-local variables
17355 in that thread become invalid.
17357 No static initialization may refer to the address of a thread-local variable.
17359 In C++, if an initializer is present for a thread-local variable, it must
17360 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
17361 standard.
17363 See @uref{http://www.akkadia.org/drepper/tls.pdf,
17364 ELF Handling For Thread-Local Storage} for a detailed explanation of
17365 the four thread-local storage addressing models, and how the runtime
17366 is expected to function.
17368 @menu
17369 * C99 Thread-Local Edits::
17370 * C++98 Thread-Local Edits::
17371 @end menu
17373 @node C99 Thread-Local Edits
17374 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
17376 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
17377 that document the exact semantics of the language extension.
17379 @itemize @bullet
17380 @item
17381 @cite{5.1.2  Execution environments}
17383 Add new text after paragraph 1
17385 @quotation
17386 Within either execution environment, a @dfn{thread} is a flow of
17387 control within a program.  It is implementation defined whether
17388 or not there may be more than one thread associated with a program.
17389 It is implementation defined how threads beyond the first are
17390 created, the name and type of the function called at thread
17391 startup, and how threads may be terminated.  However, objects
17392 with thread storage duration shall be initialized before thread
17393 startup.
17394 @end quotation
17396 @item
17397 @cite{6.2.4  Storage durations of objects}
17399 Add new text before paragraph 3
17401 @quotation
17402 An object whose identifier is declared with the storage-class
17403 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
17404 Its lifetime is the entire execution of the thread, and its
17405 stored value is initialized only once, prior to thread startup.
17406 @end quotation
17408 @item
17409 @cite{6.4.1  Keywords}
17411 Add @code{__thread}.
17413 @item
17414 @cite{6.7.1  Storage-class specifiers}
17416 Add @code{__thread} to the list of storage class specifiers in
17417 paragraph 1.
17419 Change paragraph 2 to
17421 @quotation
17422 With the exception of @code{__thread}, at most one storage-class
17423 specifier may be given [@dots{}].  The @code{__thread} specifier may
17424 be used alone, or immediately following @code{extern} or
17425 @code{static}.
17426 @end quotation
17428 Add new text after paragraph 6
17430 @quotation
17431 The declaration of an identifier for a variable that has
17432 block scope that specifies @code{__thread} shall also
17433 specify either @code{extern} or @code{static}.
17435 The @code{__thread} specifier shall be used only with
17436 variables.
17437 @end quotation
17438 @end itemize
17440 @node C++98 Thread-Local Edits
17441 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
17443 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
17444 that document the exact semantics of the language extension.
17446 @itemize @bullet
17447 @item
17448 @b{[intro.execution]}
17450 New text after paragraph 4
17452 @quotation
17453 A @dfn{thread} is a flow of control within the abstract machine.
17454 It is implementation defined whether or not there may be more than
17455 one thread.
17456 @end quotation
17458 New text after paragraph 7
17460 @quotation
17461 It is unspecified whether additional action must be taken to
17462 ensure when and whether side effects are visible to other threads.
17463 @end quotation
17465 @item
17466 @b{[lex.key]}
17468 Add @code{__thread}.
17470 @item
17471 @b{[basic.start.main]}
17473 Add after paragraph 5
17475 @quotation
17476 The thread that begins execution at the @code{main} function is called
17477 the @dfn{main thread}.  It is implementation defined how functions
17478 beginning threads other than the main thread are designated or typed.
17479 A function so designated, as well as the @code{main} function, is called
17480 a @dfn{thread startup function}.  It is implementation defined what
17481 happens if a thread startup function returns.  It is implementation
17482 defined what happens to other threads when any thread calls @code{exit}.
17483 @end quotation
17485 @item
17486 @b{[basic.start.init]}
17488 Add after paragraph 4
17490 @quotation
17491 The storage for an object of thread storage duration shall be
17492 statically initialized before the first statement of the thread startup
17493 function.  An object of thread storage duration shall not require
17494 dynamic initialization.
17495 @end quotation
17497 @item
17498 @b{[basic.start.term]}
17500 Add after paragraph 3
17502 @quotation
17503 The type of an object with thread storage duration shall not have a
17504 non-trivial destructor, nor shall it be an array type whose elements
17505 (directly or indirectly) have non-trivial destructors.
17506 @end quotation
17508 @item
17509 @b{[basic.stc]}
17511 Add ``thread storage duration'' to the list in paragraph 1.
17513 Change paragraph 2
17515 @quotation
17516 Thread, static, and automatic storage durations are associated with
17517 objects introduced by declarations [@dots{}].
17518 @end quotation
17520 Add @code{__thread} to the list of specifiers in paragraph 3.
17522 @item
17523 @b{[basic.stc.thread]}
17525 New section before @b{[basic.stc.static]}
17527 @quotation
17528 The keyword @code{__thread} applied to a non-local object gives the
17529 object thread storage duration.
17531 A local variable or class data member declared both @code{static}
17532 and @code{__thread} gives the variable or member thread storage
17533 duration.
17534 @end quotation
17536 @item
17537 @b{[basic.stc.static]}
17539 Change paragraph 1
17541 @quotation
17542 All objects that have neither thread storage duration, dynamic
17543 storage duration nor are local [@dots{}].
17544 @end quotation
17546 @item
17547 @b{[dcl.stc]}
17549 Add @code{__thread} to the list in paragraph 1.
17551 Change paragraph 1
17553 @quotation
17554 With the exception of @code{__thread}, at most one
17555 @var{storage-class-specifier} shall appear in a given
17556 @var{decl-specifier-seq}.  The @code{__thread} specifier may
17557 be used alone, or immediately following the @code{extern} or
17558 @code{static} specifiers.  [@dots{}]
17559 @end quotation
17561 Add after paragraph 5
17563 @quotation
17564 The @code{__thread} specifier can be applied only to the names of objects
17565 and to anonymous unions.
17566 @end quotation
17568 @item
17569 @b{[class.mem]}
17571 Add after paragraph 6
17573 @quotation
17574 Non-@code{static} members shall not be @code{__thread}.
17575 @end quotation
17576 @end itemize
17578 @node Binary constants
17579 @section Binary constants using the @samp{0b} prefix
17580 @cindex Binary constants using the @samp{0b} prefix
17582 Integer constants can be written as binary constants, consisting of a
17583 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
17584 @samp{0B}.  This is particularly useful in environments that operate a
17585 lot on the bit level (like microcontrollers).
17587 The following statements are identical:
17589 @smallexample
17590 i =       42;
17591 i =     0x2a;
17592 i =      052;
17593 i = 0b101010;
17594 @end smallexample
17596 The type of these constants follows the same rules as for octal or
17597 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
17598 can be applied.
17600 @node C++ Extensions
17601 @chapter Extensions to the C++ Language
17602 @cindex extensions, C++ language
17603 @cindex C++ language extensions
17605 The GNU compiler provides these extensions to the C++ language (and you
17606 can also use most of the C language extensions in your C++ programs).  If you
17607 want to write code that checks whether these features are available, you can
17608 test for the GNU compiler the same way as for C programs: check for a
17609 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
17610 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
17611 Predefined Macros,cpp,The GNU C Preprocessor}).
17613 @menu
17614 * C++ Volatiles::       What constitutes an access to a volatile object.
17615 * Restricted Pointers:: C99 restricted pointers and references.
17616 * Vague Linkage::       Where G++ puts inlines, vtables and such.
17617 * C++ Interface::       You can use a single C++ header file for both
17618                         declarations and definitions.
17619 * Template Instantiation:: Methods for ensuring that exactly one copy of
17620                         each needed template instantiation is emitted.
17621 * Bound member functions:: You can extract a function pointer to the
17622                         method denoted by a @samp{->*} or @samp{.*} expression.
17623 * C++ Attributes::      Variable, function, and type attributes for C++ only.
17624 * Function Multiversioning::   Declaring multiple function versions.
17625 * Namespace Association:: Strong using-directives for namespace association.
17626 * Type Traits::         Compiler support for type traits
17627 * Java Exceptions::     Tweaking exception handling to work with Java.
17628 * Deprecated Features:: Things will disappear from G++.
17629 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
17630 @end menu
17632 @node C++ Volatiles
17633 @section When is a Volatile C++ Object Accessed?
17634 @cindex accessing volatiles
17635 @cindex volatile read
17636 @cindex volatile write
17637 @cindex volatile access
17639 The C++ standard differs from the C standard in its treatment of
17640 volatile objects.  It fails to specify what constitutes a volatile
17641 access, except to say that C++ should behave in a similar manner to C
17642 with respect to volatiles, where possible.  However, the different
17643 lvalueness of expressions between C and C++ complicate the behavior.
17644 G++ behaves the same as GCC for volatile access, @xref{C
17645 Extensions,,Volatiles}, for a description of GCC's behavior.
17647 The C and C++ language specifications differ when an object is
17648 accessed in a void context:
17650 @smallexample
17651 volatile int *src = @var{somevalue};
17652 *src;
17653 @end smallexample
17655 The C++ standard specifies that such expressions do not undergo lvalue
17656 to rvalue conversion, and that the type of the dereferenced object may
17657 be incomplete.  The C++ standard does not specify explicitly that it
17658 is lvalue to rvalue conversion that is responsible for causing an
17659 access.  There is reason to believe that it is, because otherwise
17660 certain simple expressions become undefined.  However, because it
17661 would surprise most programmers, G++ treats dereferencing a pointer to
17662 volatile object of complete type as GCC would do for an equivalent
17663 type in C@.  When the object has incomplete type, G++ issues a
17664 warning; if you wish to force an error, you must force a conversion to
17665 rvalue with, for instance, a static cast.
17667 When using a reference to volatile, G++ does not treat equivalent
17668 expressions as accesses to volatiles, but instead issues a warning that
17669 no volatile is accessed.  The rationale for this is that otherwise it
17670 becomes difficult to determine where volatile access occur, and not
17671 possible to ignore the return value from functions returning volatile
17672 references.  Again, if you wish to force a read, cast the reference to
17673 an rvalue.
17675 G++ implements the same behavior as GCC does when assigning to a
17676 volatile object---there is no reread of the assigned-to object, the
17677 assigned rvalue is reused.  Note that in C++ assignment expressions
17678 are lvalues, and if used as an lvalue, the volatile object is
17679 referred to.  For instance, @var{vref} refers to @var{vobj}, as
17680 expected, in the following example:
17682 @smallexample
17683 volatile int vobj;
17684 volatile int &vref = vobj = @var{something};
17685 @end smallexample
17687 @node Restricted Pointers
17688 @section Restricting Pointer Aliasing
17689 @cindex restricted pointers
17690 @cindex restricted references
17691 @cindex restricted this pointer
17693 As with the C front end, G++ understands the C99 feature of restricted pointers,
17694 specified with the @code{__restrict__}, or @code{__restrict} type
17695 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
17696 language flag, @code{restrict} is not a keyword in C++.
17698 In addition to allowing restricted pointers, you can specify restricted
17699 references, which indicate that the reference is not aliased in the local
17700 context.
17702 @smallexample
17703 void fn (int *__restrict__ rptr, int &__restrict__ rref)
17705   /* @r{@dots{}} */
17707 @end smallexample
17709 @noindent
17710 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
17711 @var{rref} refers to a (different) unaliased integer.
17713 You may also specify whether a member function's @var{this} pointer is
17714 unaliased by using @code{__restrict__} as a member function qualifier.
17716 @smallexample
17717 void T::fn () __restrict__
17719   /* @r{@dots{}} */
17721 @end smallexample
17723 @noindent
17724 Within the body of @code{T::fn}, @var{this} has the effective
17725 definition @code{T *__restrict__ const this}.  Notice that the
17726 interpretation of a @code{__restrict__} member function qualifier is
17727 different to that of @code{const} or @code{volatile} qualifier, in that it
17728 is applied to the pointer rather than the object.  This is consistent with
17729 other compilers that implement restricted pointers.
17731 As with all outermost parameter qualifiers, @code{__restrict__} is
17732 ignored in function definition matching.  This means you only need to
17733 specify @code{__restrict__} in a function definition, rather than
17734 in a function prototype as well.
17736 @node Vague Linkage
17737 @section Vague Linkage
17738 @cindex vague linkage
17740 There are several constructs in C++ that require space in the object
17741 file but are not clearly tied to a single translation unit.  We say that
17742 these constructs have ``vague linkage''.  Typically such constructs are
17743 emitted wherever they are needed, though sometimes we can be more
17744 clever.
17746 @table @asis
17747 @item Inline Functions
17748 Inline functions are typically defined in a header file which can be
17749 included in many different compilations.  Hopefully they can usually be
17750 inlined, but sometimes an out-of-line copy is necessary, if the address
17751 of the function is taken or if inlining fails.  In general, we emit an
17752 out-of-line copy in all translation units where one is needed.  As an
17753 exception, we only emit inline virtual functions with the vtable, since
17754 it always requires a copy.
17756 Local static variables and string constants used in an inline function
17757 are also considered to have vague linkage, since they must be shared
17758 between all inlined and out-of-line instances of the function.
17760 @item VTables
17761 @cindex vtable
17762 C++ virtual functions are implemented in most compilers using a lookup
17763 table, known as a vtable.  The vtable contains pointers to the virtual
17764 functions provided by a class, and each object of the class contains a
17765 pointer to its vtable (or vtables, in some multiple-inheritance
17766 situations).  If the class declares any non-inline, non-pure virtual
17767 functions, the first one is chosen as the ``key method'' for the class,
17768 and the vtable is only emitted in the translation unit where the key
17769 method is defined.
17771 @emph{Note:} If the chosen key method is later defined as inline, the
17772 vtable is still emitted in every translation unit that defines it.
17773 Make sure that any inline virtuals are declared inline in the class
17774 body, even if they are not defined there.
17776 @item @code{type_info} objects
17777 @cindex @code{type_info}
17778 @cindex RTTI
17779 C++ requires information about types to be written out in order to
17780 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
17781 For polymorphic classes (classes with virtual functions), the @samp{type_info}
17782 object is written out along with the vtable so that @samp{dynamic_cast}
17783 can determine the dynamic type of a class object at run time.  For all
17784 other types, we write out the @samp{type_info} object when it is used: when
17785 applying @samp{typeid} to an expression, throwing an object, or
17786 referring to a type in a catch clause or exception specification.
17788 @item Template Instantiations
17789 Most everything in this section also applies to template instantiations,
17790 but there are other options as well.
17791 @xref{Template Instantiation,,Where's the Template?}.
17793 @end table
17795 When used with GNU ld version 2.8 or later on an ELF system such as
17796 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
17797 these constructs will be discarded at link time.  This is known as
17798 COMDAT support.
17800 On targets that don't support COMDAT, but do support weak symbols, GCC
17801 uses them.  This way one copy overrides all the others, but
17802 the unused copies still take up space in the executable.
17804 For targets that do not support either COMDAT or weak symbols,
17805 most entities with vague linkage are emitted as local symbols to
17806 avoid duplicate definition errors from the linker.  This does not happen
17807 for local statics in inlines, however, as having multiple copies
17808 almost certainly breaks things.
17810 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
17811 another way to control placement of these constructs.
17813 @node C++ Interface
17814 @section #pragma interface and implementation
17816 @cindex interface and implementation headers, C++
17817 @cindex C++ interface and implementation headers
17818 @cindex pragmas, interface and implementation
17820 @code{#pragma interface} and @code{#pragma implementation} provide the
17821 user with a way of explicitly directing the compiler to emit entities
17822 with vague linkage (and debugging information) in a particular
17823 translation unit.
17825 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
17826 most cases, because of COMDAT support and the ``key method'' heuristic
17827 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
17828 program to grow due to unnecessary out-of-line copies of inline
17829 functions.  Currently (3.4) the only benefit of these
17830 @code{#pragma}s is reduced duplication of debugging information, and
17831 that should be addressed soon on DWARF 2 targets with the use of
17832 COMDAT groups.
17834 @table @code
17835 @item #pragma interface
17836 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
17837 @kindex #pragma interface
17838 Use this directive in @emph{header files} that define object classes, to save
17839 space in most of the object files that use those classes.  Normally,
17840 local copies of certain information (backup copies of inline member
17841 functions, debugging information, and the internal tables that implement
17842 virtual functions) must be kept in each object file that includes class
17843 definitions.  You can use this pragma to avoid such duplication.  When a
17844 header file containing @samp{#pragma interface} is included in a
17845 compilation, this auxiliary information is not generated (unless
17846 the main input source file itself uses @samp{#pragma implementation}).
17847 Instead, the object files contain references to be resolved at link
17848 time.
17850 The second form of this directive is useful for the case where you have
17851 multiple headers with the same name in different directories.  If you
17852 use this form, you must specify the same string to @samp{#pragma
17853 implementation}.
17855 @item #pragma implementation
17856 @itemx #pragma implementation "@var{objects}.h"
17857 @kindex #pragma implementation
17858 Use this pragma in a @emph{main input file}, when you want full output from
17859 included header files to be generated (and made globally visible).  The
17860 included header file, in turn, should use @samp{#pragma interface}.
17861 Backup copies of inline member functions, debugging information, and the
17862 internal tables used to implement virtual functions are all generated in
17863 implementation files.
17865 @cindex implied @code{#pragma implementation}
17866 @cindex @code{#pragma implementation}, implied
17867 @cindex naming convention, implementation headers
17868 If you use @samp{#pragma implementation} with no argument, it applies to
17869 an include file with the same basename@footnote{A file's @dfn{basename}
17870 is the name stripped of all leading path information and of trailing
17871 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
17872 file.  For example, in @file{allclass.cc}, giving just
17873 @samp{#pragma implementation}
17874 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
17876 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
17877 an implementation file whenever you would include it from
17878 @file{allclass.cc} even if you never specified @samp{#pragma
17879 implementation}.  This was deemed to be more trouble than it was worth,
17880 however, and disabled.
17882 Use the string argument if you want a single implementation file to
17883 include code from multiple header files.  (You must also use
17884 @samp{#include} to include the header file; @samp{#pragma
17885 implementation} only specifies how to use the file---it doesn't actually
17886 include it.)
17888 There is no way to split up the contents of a single header file into
17889 multiple implementation files.
17890 @end table
17892 @cindex inlining and C++ pragmas
17893 @cindex C++ pragmas, effect on inlining
17894 @cindex pragmas in C++, effect on inlining
17895 @samp{#pragma implementation} and @samp{#pragma interface} also have an
17896 effect on function inlining.
17898 If you define a class in a header file marked with @samp{#pragma
17899 interface}, the effect on an inline function defined in that class is
17900 similar to an explicit @code{extern} declaration---the compiler emits
17901 no code at all to define an independent version of the function.  Its
17902 definition is used only for inlining with its callers.
17904 @opindex fno-implement-inlines
17905 Conversely, when you include the same header file in a main source file
17906 that declares it as @samp{#pragma implementation}, the compiler emits
17907 code for the function itself; this defines a version of the function
17908 that can be found via pointers (or by callers compiled without
17909 inlining).  If all calls to the function can be inlined, you can avoid
17910 emitting the function by compiling with @option{-fno-implement-inlines}.
17911 If any calls are not inlined, you will get linker errors.
17913 @node Template Instantiation
17914 @section Where's the Template?
17915 @cindex template instantiation
17917 C++ templates are the first language feature to require more
17918 intelligence from the environment than one usually finds on a UNIX
17919 system.  Somehow the compiler and linker have to make sure that each
17920 template instance occurs exactly once in the executable if it is needed,
17921 and not at all otherwise.  There are two basic approaches to this
17922 problem, which are referred to as the Borland model and the Cfront model.
17924 @table @asis
17925 @item Borland model
17926 Borland C++ solved the template instantiation problem by adding the code
17927 equivalent of common blocks to their linker; the compiler emits template
17928 instances in each translation unit that uses them, and the linker
17929 collapses them together.  The advantage of this model is that the linker
17930 only has to consider the object files themselves; there is no external
17931 complexity to worry about.  This disadvantage is that compilation time
17932 is increased because the template code is being compiled repeatedly.
17933 Code written for this model tends to include definitions of all
17934 templates in the header file, since they must be seen to be
17935 instantiated.
17937 @item Cfront model
17938 The AT&T C++ translator, Cfront, solved the template instantiation
17939 problem by creating the notion of a template repository, an
17940 automatically maintained place where template instances are stored.  A
17941 more modern version of the repository works as follows: As individual
17942 object files are built, the compiler places any template definitions and
17943 instantiations encountered in the repository.  At link time, the link
17944 wrapper adds in the objects in the repository and compiles any needed
17945 instances that were not previously emitted.  The advantages of this
17946 model are more optimal compilation speed and the ability to use the
17947 system linker; to implement the Borland model a compiler vendor also
17948 needs to replace the linker.  The disadvantages are vastly increased
17949 complexity, and thus potential for error; for some code this can be
17950 just as transparent, but in practice it can been very difficult to build
17951 multiple programs in one directory and one program in multiple
17952 directories.  Code written for this model tends to separate definitions
17953 of non-inline member templates into a separate file, which should be
17954 compiled separately.
17955 @end table
17957 When used with GNU ld version 2.8 or later on an ELF system such as
17958 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
17959 Borland model.  On other systems, G++ implements neither automatic
17960 model.
17962 You have the following options for dealing with template instantiations:
17964 @enumerate
17965 @item
17966 @opindex frepo
17967 Compile your template-using code with @option{-frepo}.  The compiler
17968 generates files with the extension @samp{.rpo} listing all of the
17969 template instantiations used in the corresponding object files that
17970 could be instantiated there; the link wrapper, @samp{collect2},
17971 then updates the @samp{.rpo} files to tell the compiler where to place
17972 those instantiations and rebuild any affected object files.  The
17973 link-time overhead is negligible after the first pass, as the compiler
17974 continues to place the instantiations in the same files.
17976 This is your best option for application code written for the Borland
17977 model, as it just works.  Code written for the Cfront model 
17978 needs to be modified so that the template definitions are available at
17979 one or more points of instantiation; usually this is as simple as adding
17980 @code{#include <tmethods.cc>} to the end of each template header.
17982 For library code, if you want the library to provide all of the template
17983 instantiations it needs, just try to link all of its object files
17984 together; the link will fail, but cause the instantiations to be
17985 generated as a side effect.  Be warned, however, that this may cause
17986 conflicts if multiple libraries try to provide the same instantiations.
17987 For greater control, use explicit instantiation as described in the next
17988 option.
17990 @item
17991 @opindex fno-implicit-templates
17992 Compile your code with @option{-fno-implicit-templates} to disable the
17993 implicit generation of template instances, and explicitly instantiate
17994 all the ones you use.  This approach requires more knowledge of exactly
17995 which instances you need than do the others, but it's less
17996 mysterious and allows greater control.  You can scatter the explicit
17997 instantiations throughout your program, perhaps putting them in the
17998 translation units where the instances are used or the translation units
17999 that define the templates themselves; you can put all of the explicit
18000 instantiations you need into one big file; or you can create small files
18001 like
18003 @smallexample
18004 #include "Foo.h"
18005 #include "Foo.cc"
18007 template class Foo<int>;
18008 template ostream& operator <<
18009                 (ostream&, const Foo<int>&);
18010 @end smallexample
18012 @noindent
18013 for each of the instances you need, and create a template instantiation
18014 library from those.
18016 If you are using Cfront-model code, you can probably get away with not
18017 using @option{-fno-implicit-templates} when compiling files that don't
18018 @samp{#include} the member template definitions.
18020 If you use one big file to do the instantiations, you may want to
18021 compile it without @option{-fno-implicit-templates} so you get all of the
18022 instances required by your explicit instantiations (but not by any
18023 other files) without having to specify them as well.
18025 The ISO C++ 2011 standard allows forward declaration of explicit
18026 instantiations (with @code{extern}). G++ supports explicit instantiation
18027 declarations in C++98 mode and has extended the template instantiation
18028 syntax to support instantiation of the compiler support data for a
18029 template class (i.e.@: the vtable) without instantiating any of its
18030 members (with @code{inline}), and instantiation of only the static data
18031 members of a template class, without the support data or member
18032 functions (with (@code{static}):
18034 @smallexample
18035 extern template int max (int, int);
18036 inline template class Foo<int>;
18037 static template class Foo<int>;
18038 @end smallexample
18040 @item
18041 Do nothing.  Pretend G++ does implement automatic instantiation
18042 management.  Code written for the Borland model works fine, but
18043 each translation unit contains instances of each of the templates it
18044 uses.  In a large program, this can lead to an unacceptable amount of code
18045 duplication.
18046 @end enumerate
18048 @node Bound member functions
18049 @section Extracting the function pointer from a bound pointer to member function
18050 @cindex pmf
18051 @cindex pointer to member function
18052 @cindex bound pointer to member function
18054 In C++, pointer to member functions (PMFs) are implemented using a wide
18055 pointer of sorts to handle all the possible call mechanisms; the PMF
18056 needs to store information about how to adjust the @samp{this} pointer,
18057 and if the function pointed to is virtual, where to find the vtable, and
18058 where in the vtable to look for the member function.  If you are using
18059 PMFs in an inner loop, you should really reconsider that decision.  If
18060 that is not an option, you can extract the pointer to the function that
18061 would be called for a given object/PMF pair and call it directly inside
18062 the inner loop, to save a bit of time.
18064 Note that you still pay the penalty for the call through a
18065 function pointer; on most modern architectures, such a call defeats the
18066 branch prediction features of the CPU@.  This is also true of normal
18067 virtual function calls.
18069 The syntax for this extension is
18071 @smallexample
18072 extern A a;
18073 extern int (A::*fp)();
18074 typedef int (*fptr)(A *);
18076 fptr p = (fptr)(a.*fp);
18077 @end smallexample
18079 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18080 no object is needed to obtain the address of the function.  They can be
18081 converted to function pointers directly:
18083 @smallexample
18084 fptr p1 = (fptr)(&A::foo);
18085 @end smallexample
18087 @opindex Wno-pmf-conversions
18088 You must specify @option{-Wno-pmf-conversions} to use this extension.
18090 @node C++ Attributes
18091 @section C++-Specific Variable, Function, and Type Attributes
18093 Some attributes only make sense for C++ programs.
18095 @table @code
18096 @item abi_tag ("@var{tag}", ...)
18097 @cindex @code{abi_tag} attribute
18098 The @code{abi_tag} attribute can be applied to a function or class
18099 declaration.  It modifies the mangled name of the function or class to
18100 incorporate the tag name, in order to distinguish the function or
18101 class from an earlier version with a different ABI; perhaps the class
18102 has changed size, or the function has a different return type that is
18103 not encoded in the mangled name.
18105 The argument can be a list of strings of arbitrary length.  The
18106 strings are sorted on output, so the order of the list is
18107 unimportant.
18109 A redeclaration of a function or class must not add new ABI tags,
18110 since doing so would change the mangled name.
18112 The ABI tags apply to a name, so all instantiations and
18113 specializations of a template have the same tags.  The attribute will
18114 be ignored if applied to an explicit specialization or instantiation.
18116 The @option{-Wabi-tag} flag enables a warning about a class which does
18117 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18118 that needs to coexist with an earlier ABI, using this option can help
18119 to find all affected types that need to be tagged.
18121 @item init_priority (@var{priority})
18122 @cindex @code{init_priority} attribute
18125 In Standard C++, objects defined at namespace scope are guaranteed to be
18126 initialized in an order in strict accordance with that of their definitions
18127 @emph{in a given translation unit}.  No guarantee is made for initializations
18128 across translation units.  However, GNU C++ allows users to control the
18129 order of initialization of objects defined at namespace scope with the
18130 @code{init_priority} attribute by specifying a relative @var{priority},
18131 a constant integral expression currently bounded between 101 and 65535
18132 inclusive.  Lower numbers indicate a higher priority.
18134 In the following example, @code{A} would normally be created before
18135 @code{B}, but the @code{init_priority} attribute reverses that order:
18137 @smallexample
18138 Some_Class  A  __attribute__ ((init_priority (2000)));
18139 Some_Class  B  __attribute__ ((init_priority (543)));
18140 @end smallexample
18142 @noindent
18143 Note that the particular values of @var{priority} do not matter; only their
18144 relative ordering.
18146 @item java_interface
18147 @cindex @code{java_interface} attribute
18149 This type attribute informs C++ that the class is a Java interface.  It may
18150 only be applied to classes declared within an @code{extern "Java"} block.
18151 Calls to methods declared in this interface are dispatched using GCJ's
18152 interface table mechanism, instead of regular virtual table dispatch.
18154 @item warn_unused
18155 @cindex @code{warn_unused} attribute
18157 For C++ types with non-trivial constructors and/or destructors it is
18158 impossible for the compiler to determine whether a variable of this
18159 type is truly unused if it is not referenced. This type attribute
18160 informs the compiler that variables of this type should be warned
18161 about if they appear to be unused, just like variables of fundamental
18162 types.
18164 This attribute is appropriate for types which just represent a value,
18165 such as @code{std::string}; it is not appropriate for types which
18166 control a resource, such as @code{std::mutex}.
18168 This attribute is also accepted in C, but it is unnecessary because C
18169 does not have constructors or destructors.
18171 @end table
18173 See also @ref{Namespace Association}.
18175 @node Function Multiversioning
18176 @section Function Multiversioning
18177 @cindex function versions
18179 With the GNU C++ front end, for target i386, you may specify multiple
18180 versions of a function, where each function is specialized for a
18181 specific target feature.  At runtime, the appropriate version of the
18182 function is automatically executed depending on the characteristics of
18183 the execution platform.  Here is an example.
18185 @smallexample
18186 __attribute__ ((target ("default")))
18187 int foo ()
18189   // The default version of foo.
18190   return 0;
18193 __attribute__ ((target ("sse4.2")))
18194 int foo ()
18196   // foo version for SSE4.2
18197   return 1;
18200 __attribute__ ((target ("arch=atom")))
18201 int foo ()
18203   // foo version for the Intel ATOM processor
18204   return 2;
18207 __attribute__ ((target ("arch=amdfam10")))
18208 int foo ()
18210   // foo version for the AMD Family 0x10 processors.
18211   return 3;
18214 int main ()
18216   int (*p)() = &foo;
18217   assert ((*p) () == foo ());
18218   return 0;
18220 @end smallexample
18222 In the above example, four versions of function foo are created. The
18223 first version of foo with the target attribute "default" is the default
18224 version.  This version gets executed when no other target specific
18225 version qualifies for execution on a particular platform. A new version
18226 of foo is created by using the same function signature but with a
18227 different target string.  Function foo is called or a pointer to it is
18228 taken just like a regular function.  GCC takes care of doing the
18229 dispatching to call the right version at runtime.  Refer to the
18230 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18231 Function Multiversioning} for more details.
18233 @node Namespace Association
18234 @section Namespace Association
18236 @strong{Caution:} The semantics of this extension are equivalent
18237 to C++ 2011 inline namespaces.  Users should use inline namespaces
18238 instead as this extension will be removed in future versions of G++.
18240 A using-directive with @code{__attribute ((strong))} is stronger
18241 than a normal using-directive in two ways:
18243 @itemize @bullet
18244 @item
18245 Templates from the used namespace can be specialized and explicitly
18246 instantiated as though they were members of the using namespace.
18248 @item
18249 The using namespace is considered an associated namespace of all
18250 templates in the used namespace for purposes of argument-dependent
18251 name lookup.
18252 @end itemize
18254 The used namespace must be nested within the using namespace so that
18255 normal unqualified lookup works properly.
18257 This is useful for composing a namespace transparently from
18258 implementation namespaces.  For example:
18260 @smallexample
18261 namespace std @{
18262   namespace debug @{
18263     template <class T> struct A @{ @};
18264   @}
18265   using namespace debug __attribute ((__strong__));
18266   template <> struct A<int> @{ @};   // @r{OK to specialize}
18268   template <class T> void f (A<T>);
18271 int main()
18273   f (std::A<float>());             // @r{lookup finds} std::f
18274   f (std::A<int>());
18276 @end smallexample
18278 @node Type Traits
18279 @section Type Traits
18281 The C++ front end implements syntactic extensions that allow
18282 compile-time determination of 
18283 various characteristics of a type (or of a
18284 pair of types).
18286 @table @code
18287 @item __has_nothrow_assign (type)
18288 If @code{type} is const qualified or is a reference type then the trait is
18289 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18290 is true, else if @code{type} is a cv class or union type with copy assignment
18291 operators that are known not to throw an exception then the trait is true,
18292 else it is false.  Requires: @code{type} shall be a complete type,
18293 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18295 @item __has_nothrow_copy (type)
18296 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18297 @code{type} is a cv class or union type with copy constructors that
18298 are known not to throw an exception then the trait is true, else it is false.
18299 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18300 @code{void}, or an array of unknown bound.
18302 @item __has_nothrow_constructor (type)
18303 If @code{__has_trivial_constructor (type)} is true then the trait is
18304 true, else if @code{type} is a cv class or union type (or array
18305 thereof) with a default constructor that is known not to throw an
18306 exception then the trait is true, else it is false.  Requires:
18307 @code{type} shall be a complete type, (possibly cv-qualified)
18308 @code{void}, or an array of unknown bound.
18310 @item __has_trivial_assign (type)
18311 If @code{type} is const qualified or is a reference type then the trait is
18312 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
18313 true, else if @code{type} is a cv class or union type with a trivial
18314 copy assignment ([class.copy]) then the trait is true, else it is
18315 false.  Requires: @code{type} shall be a complete type, (possibly
18316 cv-qualified) @code{void}, or an array of unknown bound.
18318 @item __has_trivial_copy (type)
18319 If @code{__is_pod (type)} is true or @code{type} is a reference type
18320 then the trait is true, else if @code{type} is a cv class or union type
18321 with a trivial copy constructor ([class.copy]) then the trait
18322 is true, else it is false.  Requires: @code{type} shall be a complete
18323 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18325 @item __has_trivial_constructor (type)
18326 If @code{__is_pod (type)} is true then the trait is true, else if
18327 @code{type} is a cv class or union type (or array thereof) with a
18328 trivial default constructor ([class.ctor]) then the trait is true,
18329 else it is false.  Requires: @code{type} shall be a complete
18330 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18332 @item __has_trivial_destructor (type)
18333 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18334 the trait is true, else if @code{type} is a cv class or union type (or
18335 array thereof) with a trivial destructor ([class.dtor]) then the trait
18336 is true, else it is false.  Requires: @code{type} shall be a complete
18337 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18339 @item __has_virtual_destructor (type)
18340 If @code{type} is a class type with a virtual destructor
18341 ([class.dtor]) then the trait is true, else it is false.  Requires:
18342 @code{type} shall be a complete type, (possibly cv-qualified)
18343 @code{void}, or an array of unknown bound.
18345 @item __is_abstract (type)
18346 If @code{type} is an abstract class ([class.abstract]) then the trait
18347 is true, else it is false.  Requires: @code{type} shall be a complete
18348 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18350 @item __is_base_of (base_type, derived_type)
18351 If @code{base_type} is a base class of @code{derived_type}
18352 ([class.derived]) then the trait is true, otherwise it is false.
18353 Top-level cv qualifications of @code{base_type} and
18354 @code{derived_type} are ignored.  For the purposes of this trait, a
18355 class type is considered is own base.  Requires: if @code{__is_class
18356 (base_type)} and @code{__is_class (derived_type)} are true and
18357 @code{base_type} and @code{derived_type} are not the same type
18358 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
18359 type.  Diagnostic is produced if this requirement is not met.
18361 @item __is_class (type)
18362 If @code{type} is a cv class type, and not a union type
18363 ([basic.compound]) the trait is true, else it is false.
18365 @item __is_empty (type)
18366 If @code{__is_class (type)} is false then the trait is false.
18367 Otherwise @code{type} is considered empty if and only if: @code{type}
18368 has no non-static data members, or all non-static data members, if
18369 any, are bit-fields of length 0, and @code{type} has no virtual
18370 members, and @code{type} has no virtual base classes, and @code{type}
18371 has no base classes @code{base_type} for which
18372 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
18373 be a complete type, (possibly cv-qualified) @code{void}, or an array
18374 of unknown bound.
18376 @item __is_enum (type)
18377 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
18378 true, else it is false.
18380 @item __is_literal_type (type)
18381 If @code{type} is a literal type ([basic.types]) the trait is
18382 true, else it is false.  Requires: @code{type} shall be a complete type,
18383 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18385 @item __is_pod (type)
18386 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
18387 else it is false.  Requires: @code{type} shall be a complete type,
18388 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18390 @item __is_polymorphic (type)
18391 If @code{type} is a polymorphic class ([class.virtual]) then the trait
18392 is true, else it is false.  Requires: @code{type} shall be a complete
18393 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18395 @item __is_standard_layout (type)
18396 If @code{type} is a standard-layout type ([basic.types]) the trait is
18397 true, else it is false.  Requires: @code{type} shall be a complete
18398 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18400 @item __is_trivial (type)
18401 If @code{type} is a trivial type ([basic.types]) the trait is
18402 true, else it is false.  Requires: @code{type} shall be a complete
18403 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18405 @item __is_union (type)
18406 If @code{type} is a cv union type ([basic.compound]) the trait is
18407 true, else it is false.
18409 @item __underlying_type (type)
18410 The underlying type of @code{type}.  Requires: @code{type} shall be
18411 an enumeration type ([dcl.enum]).
18413 @end table
18415 @node Java Exceptions
18416 @section Java Exceptions
18418 The Java language uses a slightly different exception handling model
18419 from C++.  Normally, GNU C++ automatically detects when you are
18420 writing C++ code that uses Java exceptions, and handle them
18421 appropriately.  However, if C++ code only needs to execute destructors
18422 when Java exceptions are thrown through it, GCC guesses incorrectly.
18423 Sample problematic code is:
18425 @smallexample
18426   struct S @{ ~S(); @};
18427   extern void bar();    // @r{is written in Java, and may throw exceptions}
18428   void foo()
18429   @{
18430     S s;
18431     bar();
18432   @}
18433 @end smallexample
18435 @noindent
18436 The usual effect of an incorrect guess is a link failure, complaining of
18437 a missing routine called @samp{__gxx_personality_v0}.
18439 You can inform the compiler that Java exceptions are to be used in a
18440 translation unit, irrespective of what it might think, by writing
18441 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
18442 @samp{#pragma} must appear before any functions that throw or catch
18443 exceptions, or run destructors when exceptions are thrown through them.
18445 You cannot mix Java and C++ exceptions in the same translation unit.  It
18446 is believed to be safe to throw a C++ exception from one file through
18447 another file compiled for the Java exception model, or vice versa, but
18448 there may be bugs in this area.
18450 @node Deprecated Features
18451 @section Deprecated Features
18453 In the past, the GNU C++ compiler was extended to experiment with new
18454 features, at a time when the C++ language was still evolving.  Now that
18455 the C++ standard is complete, some of those features are superseded by
18456 superior alternatives.  Using the old features might cause a warning in
18457 some cases that the feature will be dropped in the future.  In other
18458 cases, the feature might be gone already.
18460 While the list below is not exhaustive, it documents some of the options
18461 that are now deprecated:
18463 @table @code
18464 @item -fexternal-templates
18465 @itemx -falt-external-templates
18466 These are two of the many ways for G++ to implement template
18467 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
18468 defines how template definitions have to be organized across
18469 implementation units.  G++ has an implicit instantiation mechanism that
18470 should work just fine for standard-conforming code.
18472 @item -fstrict-prototype
18473 @itemx -fno-strict-prototype
18474 Previously it was possible to use an empty prototype parameter list to
18475 indicate an unspecified number of parameters (like C), rather than no
18476 parameters, as C++ demands.  This feature has been removed, except where
18477 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
18478 @end table
18480 G++ allows a virtual function returning @samp{void *} to be overridden
18481 by one returning a different pointer type.  This extension to the
18482 covariant return type rules is now deprecated and will be removed from a
18483 future version.
18485 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
18486 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
18487 and are now removed from G++.  Code using these operators should be
18488 modified to use @code{std::min} and @code{std::max} instead.
18490 The named return value extension has been deprecated, and is now
18491 removed from G++.
18493 The use of initializer lists with new expressions has been deprecated,
18494 and is now removed from G++.
18496 Floating and complex non-type template parameters have been deprecated,
18497 and are now removed from G++.
18499 The implicit typename extension has been deprecated and is now
18500 removed from G++.
18502 The use of default arguments in function pointers, function typedefs
18503 and other places where they are not permitted by the standard is
18504 deprecated and will be removed from a future version of G++.
18506 G++ allows floating-point literals to appear in integral constant expressions,
18507 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
18508 This extension is deprecated and will be removed from a future version.
18510 G++ allows static data members of const floating-point type to be declared
18511 with an initializer in a class definition. The standard only allows
18512 initializers for static members of const integral types and const
18513 enumeration types so this extension has been deprecated and will be removed
18514 from a future version.
18516 @node Backwards Compatibility
18517 @section Backwards Compatibility
18518 @cindex Backwards Compatibility
18519 @cindex ARM [Annotated C++ Reference Manual]
18521 Now that there is a definitive ISO standard C++, G++ has a specification
18522 to adhere to.  The C++ language evolved over time, and features that
18523 used to be acceptable in previous drafts of the standard, such as the ARM
18524 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
18525 compilation of C++ written to such drafts, G++ contains some backwards
18526 compatibilities.  @emph{All such backwards compatibility features are
18527 liable to disappear in future versions of G++.} They should be considered
18528 deprecated.   @xref{Deprecated Features}.
18530 @table @code
18531 @item For scope
18532 If a variable is declared at for scope, it used to remain in scope until
18533 the end of the scope that contained the for statement (rather than just
18534 within the for scope).  G++ retains this, but issues a warning, if such a
18535 variable is accessed outside the for scope.
18537 @item Implicit C language
18538 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
18539 scope to set the language.  On such systems, all header files are
18540 implicitly scoped inside a C language scope.  Also, an empty prototype
18541 @code{()} is treated as an unspecified number of arguments, rather
18542 than no arguments, as C++ demands.
18543 @end table
18545 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
18546 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign