2015-05-01 Sandra Loosemore <sandra@codesourcery.com>
[official-gcc.git] / gcc / doc / extend.texi
blob1f6bbd539a8667b876e4b8041c143fc767d36c02
1 @c Copyright (C) 1988-2015 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Label Attributes::    Specifying attributes on labels.
60 * Attribute Syntax::    Formal syntax for attributes.
61 * Function Prototypes:: Prototype declarations and old-style definitions.
62 * C++ Comments::        C++ comments are recognized.
63 * Dollar Signs::        Dollar sign is allowed in identifiers.
64 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
65 * Variable Attributes:: Specifying attributes of variables.
66 * Type Attributes::     Specifying attributes of types.
67 * Alignment::           Inquiring about the alignment of a type or variable.
68 * Inline::              Defining inline functions (as fast as macros).
69 * Volatiles::           What constitutes an access to a volatile object.
70 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
71 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
72 * Incomplete Enums::    @code{enum foo;}, with details to follow.
73 * Function Names::      Printable strings which are the name of the current
74                         function.
75 * Return Address::      Getting the return or frame address of a function.
76 * Vector Extensions::   Using vector instructions through built-in functions.
77 * Offsetof::            Special syntax for implementing @code{offsetof}.
78 * __sync Builtins::     Legacy built-in functions for atomic memory access.
79 * __atomic Builtins::   Atomic built-in functions with memory model.
80 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
81                         arithmetic overflow checking.
82 * x86 specific memory model extensions for transactional memory:: x86 memory models.
83 * Object Size Checking:: Built-in functions for limited buffer overflow
84                         checking.
85 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
86 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
87 * Other Builtins::      Other built-in functions.
88 * Target Builtins::     Built-in functions specific to particular targets.
89 * Target Format Checks:: Format checks specific to particular targets.
90 * Pragmas::             Pragmas accepted by GCC.
91 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
92 * Thread-Local::        Per-thread variables.
93 * Binary constants::    Binary constants using the @samp{0b} prefix.
94 @end menu
96 @node Statement Exprs
97 @section Statements and Declarations in Expressions
98 @cindex statements inside expressions
99 @cindex declarations inside expressions
100 @cindex expressions containing statements
101 @cindex macros, statements in expressions
103 @c the above section title wrapped and causes an underfull hbox.. i
104 @c changed it from "within" to "in". --mew 4feb93
105 A compound statement enclosed in parentheses may appear as an expression
106 in GNU C@.  This allows you to use loops, switches, and local variables
107 within an expression.
109 Recall that a compound statement is a sequence of statements surrounded
110 by braces; in this construct, parentheses go around the braces.  For
111 example:
113 @smallexample
114 (@{ int y = foo (); int z;
115    if (y > 0) z = y;
116    else z = - y;
117    z; @})
118 @end smallexample
120 @noindent
121 is a valid (though slightly more complex than necessary) expression
122 for the absolute value of @code{foo ()}.
124 The last thing in the compound statement should be an expression
125 followed by a semicolon; the value of this subexpression serves as the
126 value of the entire construct.  (If you use some other kind of statement
127 last within the braces, the construct has type @code{void}, and thus
128 effectively no value.)
130 This feature is especially useful in making macro definitions ``safe'' (so
131 that they evaluate each operand exactly once).  For example, the
132 ``maximum'' function is commonly defined as a macro in standard C as
133 follows:
135 @smallexample
136 #define max(a,b) ((a) > (b) ? (a) : (b))
137 @end smallexample
139 @noindent
140 @cindex side effects, macro argument
141 But this definition computes either @var{a} or @var{b} twice, with bad
142 results if the operand has side effects.  In GNU C, if you know the
143 type of the operands (here taken as @code{int}), you can define
144 the macro safely as follows:
146 @smallexample
147 #define maxint(a,b) \
148   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
149 @end smallexample
151 Embedded statements are not allowed in constant expressions, such as
152 the value of an enumeration constant, the width of a bit-field, or
153 the initial value of a static variable.
155 If you don't know the type of the operand, you can still do this, but you
156 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158 In G++, the result value of a statement expression undergoes array and
159 function pointer decay, and is returned by value to the enclosing
160 expression.  For instance, if @code{A} is a class, then
162 @smallexample
163         A a;
165         (@{a;@}).Foo ()
166 @end smallexample
168 @noindent
169 constructs a temporary @code{A} object to hold the result of the
170 statement expression, and that is used to invoke @code{Foo}.
171 Therefore the @code{this} pointer observed by @code{Foo} is not the
172 address of @code{a}.
174 In a statement expression, any temporaries created within a statement
175 are destroyed at that statement's end.  This makes statement
176 expressions inside macros slightly different from function calls.  In
177 the latter case temporaries introduced during argument evaluation are
178 destroyed at the end of the statement that includes the function
179 call.  In the statement expression case they are destroyed during
180 the statement expression.  For instance,
182 @smallexample
183 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
184 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186 void foo ()
188   macro (X ());
189   function (X ());
191 @end smallexample
193 @noindent
194 has different places where temporaries are destroyed.  For the
195 @code{macro} case, the temporary @code{X} is destroyed just after
196 the initialization of @code{b}.  In the @code{function} case that
197 temporary is destroyed when the function returns.
199 These considerations mean that it is probably a bad idea to use
200 statement expressions of this form in header files that are designed to
201 work with C++.  (Note that some versions of the GNU C Library contained
202 header files using statement expressions that lead to precisely this
203 bug.)
205 Jumping into a statement expression with @code{goto} or using a
206 @code{switch} statement outside the statement expression with a
207 @code{case} or @code{default} label inside the statement expression is
208 not permitted.  Jumping into a statement expression with a computed
209 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
210 Jumping out of a statement expression is permitted, but if the
211 statement expression is part of a larger expression then it is
212 unspecified which other subexpressions of that expression have been
213 evaluated except where the language definition requires certain
214 subexpressions to be evaluated before or after the statement
215 expression.  In any case, as with a function call, the evaluation of a
216 statement expression is not interleaved with the evaluation of other
217 parts of the containing expression.  For example,
219 @smallexample
220   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
221 @end smallexample
223 @noindent
224 calls @code{foo} and @code{bar1} and does not call @code{baz} but
225 may or may not call @code{bar2}.  If @code{bar2} is called, it is
226 called after @code{foo} and before @code{bar1}.
228 @node Local Labels
229 @section Locally Declared Labels
230 @cindex local labels
231 @cindex macros, local labels
233 GCC allows you to declare @dfn{local labels} in any nested block
234 scope.  A local label is just like an ordinary label, but you can
235 only reference it (with a @code{goto} statement, or by taking its
236 address) within the block in which it is declared.
238 A local label declaration looks like this:
240 @smallexample
241 __label__ @var{label};
242 @end smallexample
244 @noindent
247 @smallexample
248 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
249 @end smallexample
251 Local label declarations must come at the beginning of the block,
252 before any ordinary declarations or statements.
254 The label declaration defines the label @emph{name}, but does not define
255 the label itself.  You must do this in the usual way, with
256 @code{@var{label}:}, within the statements of the statement expression.
258 The local label feature is useful for complex macros.  If a macro
259 contains nested loops, a @code{goto} can be useful for breaking out of
260 them.  However, an ordinary label whose scope is the whole function
261 cannot be used: if the macro can be expanded several times in one
262 function, the label is multiply defined in that function.  A
263 local label avoids this problem.  For example:
265 @smallexample
266 #define SEARCH(value, array, target)              \
267 do @{                                              \
268   __label__ found;                                \
269   typeof (target) _SEARCH_target = (target);      \
270   typeof (*(array)) *_SEARCH_array = (array);     \
271   int i, j;                                       \
272   int value;                                      \
273   for (i = 0; i < max; i++)                       \
274     for (j = 0; j < max; j++)                     \
275       if (_SEARCH_array[i][j] == _SEARCH_target)  \
276         @{ (value) = i; goto found; @}              \
277   (value) = -1;                                   \
278  found:;                                          \
279 @} while (0)
280 @end smallexample
282 This could also be written using a statement expression:
284 @smallexample
285 #define SEARCH(array, target)                     \
286 (@{                                                \
287   __label__ found;                                \
288   typeof (target) _SEARCH_target = (target);      \
289   typeof (*(array)) *_SEARCH_array = (array);     \
290   int i, j;                                       \
291   int value;                                      \
292   for (i = 0; i < max; i++)                       \
293     for (j = 0; j < max; j++)                     \
294       if (_SEARCH_array[i][j] == _SEARCH_target)  \
295         @{ value = i; goto found; @}                \
296   value = -1;                                     \
297  found:                                           \
298   value;                                          \
300 @end smallexample
302 Local label declarations also make the labels they declare visible to
303 nested functions, if there are any.  @xref{Nested Functions}, for details.
305 @node Labels as Values
306 @section Labels as Values
307 @cindex labels as values
308 @cindex computed gotos
309 @cindex goto with computed label
310 @cindex address of a label
312 You can get the address of a label defined in the current function
313 (or a containing function) with the unary operator @samp{&&}.  The
314 value has type @code{void *}.  This value is a constant and can be used
315 wherever a constant of that type is valid.  For example:
317 @smallexample
318 void *ptr;
319 /* @r{@dots{}} */
320 ptr = &&foo;
321 @end smallexample
323 To use these values, you need to be able to jump to one.  This is done
324 with the computed goto statement@footnote{The analogous feature in
325 Fortran is called an assigned goto, but that name seems inappropriate in
326 C, where one can do more than simply store label addresses in label
327 variables.}, @code{goto *@var{exp};}.  For example,
329 @smallexample
330 goto *ptr;
331 @end smallexample
333 @noindent
334 Any expression of type @code{void *} is allowed.
336 One way of using these constants is in initializing a static array that
337 serves as a jump table:
339 @smallexample
340 static void *array[] = @{ &&foo, &&bar, &&hack @};
341 @end smallexample
343 @noindent
344 Then you can select a label with indexing, like this:
346 @smallexample
347 goto *array[i];
348 @end smallexample
350 @noindent
351 Note that this does not check whether the subscript is in bounds---array
352 indexing in C never does that.
354 Such an array of label values serves a purpose much like that of the
355 @code{switch} statement.  The @code{switch} statement is cleaner, so
356 use that rather than an array unless the problem does not fit a
357 @code{switch} statement very well.
359 Another use of label values is in an interpreter for threaded code.
360 The labels within the interpreter function can be stored in the
361 threaded code for super-fast dispatching.
363 You may not use this mechanism to jump to code in a different function.
364 If you do that, totally unpredictable things happen.  The best way to
365 avoid this is to store the label address only in automatic variables and
366 never pass it as an argument.
368 An alternate way to write the above example is
370 @smallexample
371 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
372                              &&hack - &&foo @};
373 goto *(&&foo + array[i]);
374 @end smallexample
376 @noindent
377 This is more friendly to code living in shared libraries, as it reduces
378 the number of dynamic relocations that are needed, and by consequence,
379 allows the data to be read-only.
380 This alternative with label differences is not supported for the AVR target,
381 please use the first approach for AVR programs.
383 The @code{&&foo} expressions for the same label might have different
384 values if the containing function is inlined or cloned.  If a program
385 relies on them being always the same,
386 @code{__attribute__((__noinline__,__noclone__))} should be used to
387 prevent inlining and cloning.  If @code{&&foo} is used in a static
388 variable initializer, inlining and cloning is forbidden.
390 @node Nested Functions
391 @section Nested Functions
392 @cindex nested functions
393 @cindex downward funargs
394 @cindex thunks
396 A @dfn{nested function} is a function defined inside another function.
397 Nested functions are supported as an extension in GNU C, but are not
398 supported by GNU C++.
400 The nested function's name is local to the block where it is defined.
401 For example, here we define a nested function named @code{square}, and
402 call it twice:
404 @smallexample
405 @group
406 foo (double a, double b)
408   double square (double z) @{ return z * z; @}
410   return square (a) + square (b);
412 @end group
413 @end smallexample
415 The nested function can access all the variables of the containing
416 function that are visible at the point of its definition.  This is
417 called @dfn{lexical scoping}.  For example, here we show a nested
418 function which uses an inherited variable named @code{offset}:
420 @smallexample
421 @group
422 bar (int *array, int offset, int size)
424   int access (int *array, int index)
425     @{ return array[index + offset]; @}
426   int i;
427   /* @r{@dots{}} */
428   for (i = 0; i < size; i++)
429     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @end group
432 @end smallexample
434 Nested function definitions are permitted within functions in the places
435 where variable definitions are allowed; that is, in any block, mixed
436 with the other declarations and statements in the block.
438 It is possible to call the nested function from outside the scope of its
439 name by storing its address or passing the address to another function:
441 @smallexample
442 hack (int *array, int size)
444   void store (int index, int value)
445     @{ array[index] = value; @}
447   intermediate (store, size);
449 @end smallexample
451 Here, the function @code{intermediate} receives the address of
452 @code{store} as an argument.  If @code{intermediate} calls @code{store},
453 the arguments given to @code{store} are used to store into @code{array}.
454 But this technique works only so long as the containing function
455 (@code{hack}, in this example) does not exit.
457 If you try to call the nested function through its address after the
458 containing function exits, all hell breaks loose.  If you try
459 to call it after a containing scope level exits, and if it refers
460 to some of the variables that are no longer in scope, you may be lucky,
461 but it's not wise to take the risk.  If, however, the nested function
462 does not refer to anything that has gone out of scope, you should be
463 safe.
465 GCC implements taking the address of a nested function using a technique
466 called @dfn{trampolines}.  This technique was described in
467 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
468 C++ Conference Proceedings, October 17-21, 1988).
470 A nested function can jump to a label inherited from a containing
471 function, provided the label is explicitly declared in the containing
472 function (@pxref{Local Labels}).  Such a jump returns instantly to the
473 containing function, exiting the nested function that did the
474 @code{goto} and any intermediate functions as well.  Here is an example:
476 @smallexample
477 @group
478 bar (int *array, int offset, int size)
480   __label__ failure;
481   int access (int *array, int index)
482     @{
483       if (index > size)
484         goto failure;
485       return array[index + offset];
486     @}
487   int i;
488   /* @r{@dots{}} */
489   for (i = 0; i < size; i++)
490     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
491   /* @r{@dots{}} */
492   return 0;
494  /* @r{Control comes here from @code{access}
495     if it detects an error.}  */
496  failure:
497   return -1;
499 @end group
500 @end smallexample
502 A nested function always has no linkage.  Declaring one with
503 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
504 before its definition, use @code{auto} (which is otherwise meaningless
505 for function declarations).
507 @smallexample
508 bar (int *array, int offset, int size)
510   __label__ failure;
511   auto int access (int *, int);
512   /* @r{@dots{}} */
513   int access (int *array, int index)
514     @{
515       if (index > size)
516         goto failure;
517       return array[index + offset];
518     @}
519   /* @r{@dots{}} */
521 @end smallexample
523 @node Constructing Calls
524 @section Constructing Function Calls
525 @cindex constructing calls
526 @cindex forwarding calls
528 Using the built-in functions described below, you can record
529 the arguments a function received, and call another function
530 with the same arguments, without knowing the number or types
531 of the arguments.
533 You can also record the return value of that function call,
534 and later return that value, without knowing what data type
535 the function tried to return (as long as your caller expects
536 that data type).
538 However, these built-in functions may interact badly with some
539 sophisticated features or other extensions of the language.  It
540 is, therefore, not recommended to use them outside very simple
541 functions acting as mere forwarders for their arguments.
543 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
544 This built-in function returns a pointer to data
545 describing how to perform a call with the same arguments as are passed
546 to the current function.
548 The function saves the arg pointer register, structure value address,
549 and all registers that might be used to pass arguments to a function
550 into a block of memory allocated on the stack.  Then it returns the
551 address of that block.
552 @end deftypefn
554 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
555 This built-in function invokes @var{function}
556 with a copy of the parameters described by @var{arguments}
557 and @var{size}.
559 The value of @var{arguments} should be the value returned by
560 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
561 of the stack argument data, in bytes.
563 This function returns a pointer to data describing
564 how to return whatever value is returned by @var{function}.  The data
565 is saved in a block of memory allocated on the stack.
567 It is not always simple to compute the proper value for @var{size}.  The
568 value is used by @code{__builtin_apply} to compute the amount of data
569 that should be pushed on the stack and copied from the incoming argument
570 area.
571 @end deftypefn
573 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
574 This built-in function returns the value described by @var{result} from
575 the containing function.  You should specify, for @var{result}, a value
576 returned by @code{__builtin_apply}.
577 @end deftypefn
579 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
580 This built-in function represents all anonymous arguments of an inline
581 function.  It can be used only in inline functions that are always
582 inlined, never compiled as a separate function, such as those using
583 @code{__attribute__ ((__always_inline__))} or
584 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
585 It must be only passed as last argument to some other function
586 with variable arguments.  This is useful for writing small wrapper
587 inlines for variable argument functions, when using preprocessor
588 macros is undesirable.  For example:
589 @smallexample
590 extern int myprintf (FILE *f, const char *format, ...);
591 extern inline __attribute__ ((__gnu_inline__)) int
592 myprintf (FILE *f, const char *format, ...)
594   int r = fprintf (f, "myprintf: ");
595   if (r < 0)
596     return r;
597   int s = fprintf (f, format, __builtin_va_arg_pack ());
598   if (s < 0)
599     return s;
600   return r + s;
602 @end smallexample
603 @end deftypefn
605 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
606 This built-in function returns the number of anonymous arguments of
607 an inline function.  It can be used only in inline functions that
608 are always inlined, never compiled as a separate function, such
609 as those using @code{__attribute__ ((__always_inline__))} or
610 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
611 For example following does link- or run-time checking of open
612 arguments for optimized code:
613 @smallexample
614 #ifdef __OPTIMIZE__
615 extern inline __attribute__((__gnu_inline__)) int
616 myopen (const char *path, int oflag, ...)
618   if (__builtin_va_arg_pack_len () > 1)
619     warn_open_too_many_arguments ();
621   if (__builtin_constant_p (oflag))
622     @{
623       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
624         @{
625           warn_open_missing_mode ();
626           return __open_2 (path, oflag);
627         @}
628       return open (path, oflag, __builtin_va_arg_pack ());
629     @}
631   if (__builtin_va_arg_pack_len () < 1)
632     return __open_2 (path, oflag);
634   return open (path, oflag, __builtin_va_arg_pack ());
636 #endif
637 @end smallexample
638 @end deftypefn
640 @node Typeof
641 @section Referring to a Type with @code{typeof}
642 @findex typeof
643 @findex sizeof
644 @cindex macros, types of arguments
646 Another way to refer to the type of an expression is with @code{typeof}.
647 The syntax of using of this keyword looks like @code{sizeof}, but the
648 construct acts semantically like a type name defined with @code{typedef}.
650 There are two ways of writing the argument to @code{typeof}: with an
651 expression or with a type.  Here is an example with an expression:
653 @smallexample
654 typeof (x[0](1))
655 @end smallexample
657 @noindent
658 This assumes that @code{x} is an array of pointers to functions;
659 the type described is that of the values of the functions.
661 Here is an example with a typename as the argument:
663 @smallexample
664 typeof (int *)
665 @end smallexample
667 @noindent
668 Here the type described is that of pointers to @code{int}.
670 If you are writing a header file that must work when included in ISO C
671 programs, write @code{__typeof__} instead of @code{typeof}.
672 @xref{Alternate Keywords}.
674 A @code{typeof} construct can be used anywhere a typedef name can be
675 used.  For example, you can use it in a declaration, in a cast, or inside
676 of @code{sizeof} or @code{typeof}.
678 The operand of @code{typeof} is evaluated for its side effects if and
679 only if it is an expression of variably modified type or the name of
680 such a type.
682 @code{typeof} is often useful in conjunction with
683 statement expressions (@pxref{Statement Exprs}).
684 Here is how the two together can
685 be used to define a safe ``maximum'' macro which operates on any
686 arithmetic type and evaluates each of its arguments exactly once:
688 @smallexample
689 #define max(a,b) \
690   (@{ typeof (a) _a = (a); \
691       typeof (b) _b = (b); \
692     _a > _b ? _a : _b; @})
693 @end smallexample
695 @cindex underscores in variables in macros
696 @cindex @samp{_} in variables in macros
697 @cindex local variables in macros
698 @cindex variables, local, in macros
699 @cindex macros, local variables in
701 The reason for using names that start with underscores for the local
702 variables is to avoid conflicts with variable names that occur within the
703 expressions that are substituted for @code{a} and @code{b}.  Eventually we
704 hope to design a new form of declaration syntax that allows you to declare
705 variables whose scopes start only after their initializers; this will be a
706 more reliable way to prevent such conflicts.
708 @noindent
709 Some more examples of the use of @code{typeof}:
711 @itemize @bullet
712 @item
713 This declares @code{y} with the type of what @code{x} points to.
715 @smallexample
716 typeof (*x) y;
717 @end smallexample
719 @item
720 This declares @code{y} as an array of such values.
722 @smallexample
723 typeof (*x) y[4];
724 @end smallexample
726 @item
727 This declares @code{y} as an array of pointers to characters:
729 @smallexample
730 typeof (typeof (char *)[4]) y;
731 @end smallexample
733 @noindent
734 It is equivalent to the following traditional C declaration:
736 @smallexample
737 char *y[4];
738 @end smallexample
740 To see the meaning of the declaration using @code{typeof}, and why it
741 might be a useful way to write, rewrite it with these macros:
743 @smallexample
744 #define pointer(T)  typeof(T *)
745 #define array(T, N) typeof(T [N])
746 @end smallexample
748 @noindent
749 Now the declaration can be rewritten this way:
751 @smallexample
752 array (pointer (char), 4) y;
753 @end smallexample
755 @noindent
756 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
757 pointers to @code{char}.
758 @end itemize
760 In GNU C, but not GNU C++, you may also declare the type of a variable
761 as @code{__auto_type}.  In that case, the declaration must declare
762 only one variable, whose declarator must just be an identifier, the
763 declaration must be initialized, and the type of the variable is
764 determined by the initializer; the name of the variable is not in
765 scope until after the initializer.  (In C++, you should use C++11
766 @code{auto} for this purpose.)  Using @code{__auto_type}, the
767 ``maximum'' macro above could be written as:
769 @smallexample
770 #define max(a,b) \
771   (@{ __auto_type _a = (a); \
772       __auto_type _b = (b); \
773     _a > _b ? _a : _b; @})
774 @end smallexample
776 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778 @itemize @bullet
779 @item Each argument to the macro appears only once in the expansion of
780 the macro.  This prevents the size of the macro expansion growing
781 exponentially when calls to such macros are nested inside arguments of
782 such macros.
784 @item If the argument to the macro has variably modified type, it is
785 evaluated only once when using @code{__auto_type}, but twice if
786 @code{typeof} is used.
787 @end itemize
789 @node Conditionals
790 @section Conditionals with Omitted Operands
791 @cindex conditional expressions, extensions
792 @cindex omitted middle-operands
793 @cindex middle-operands, omitted
794 @cindex extensions, @code{?:}
795 @cindex @code{?:} extensions
797 The middle operand in a conditional expression may be omitted.  Then
798 if the first operand is nonzero, its value is the value of the conditional
799 expression.
801 Therefore, the expression
803 @smallexample
804 x ? : y
805 @end smallexample
807 @noindent
808 has the value of @code{x} if that is nonzero; otherwise, the value of
809 @code{y}.
811 This example is perfectly equivalent to
813 @smallexample
814 x ? x : y
815 @end smallexample
817 @cindex side effect in @code{?:}
818 @cindex @code{?:} side effect
819 @noindent
820 In this simple case, the ability to omit the middle operand is not
821 especially useful.  When it becomes useful is when the first operand does,
822 or may (if it is a macro argument), contain a side effect.  Then repeating
823 the operand in the middle would perform the side effect twice.  Omitting
824 the middle operand uses the value already computed without the undesirable
825 effects of recomputing it.
827 @node __int128
828 @section 128-bit Integers
829 @cindex @code{__int128} data types
831 As an extension the integer scalar type @code{__int128} is supported for
832 targets which have an integer mode wide enough to hold 128 bits.
833 Simply write @code{__int128} for a signed 128-bit integer, or
834 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
835 support in GCC for expressing an integer constant of type @code{__int128}
836 for targets with @code{long long} integer less than 128 bits wide.
838 @node Long Long
839 @section Double-Word Integers
840 @cindex @code{long long} data types
841 @cindex double-word arithmetic
842 @cindex multiprecision arithmetic
843 @cindex @code{LL} integer suffix
844 @cindex @code{ULL} integer suffix
846 ISO C99 supports data types for integers that are at least 64 bits wide,
847 and as an extension GCC supports them in C90 mode and in C++.
848 Simply write @code{long long int} for a signed integer, or
849 @code{unsigned long long int} for an unsigned integer.  To make an
850 integer constant of type @code{long long int}, add the suffix @samp{LL}
851 to the integer.  To make an integer constant of type @code{unsigned long
852 long int}, add the suffix @samp{ULL} to the integer.
854 You can use these types in arithmetic like any other integer types.
855 Addition, subtraction, and bitwise boolean operations on these types
856 are open-coded on all types of machines.  Multiplication is open-coded
857 if the machine supports a fullword-to-doubleword widening multiply
858 instruction.  Division and shifts are open-coded only on machines that
859 provide special support.  The operations that are not open-coded use
860 special library routines that come with GCC@.
862 There may be pitfalls when you use @code{long long} types for function
863 arguments without function prototypes.  If a function
864 expects type @code{int} for its argument, and you pass a value of type
865 @code{long long int}, confusion results because the caller and the
866 subroutine disagree about the number of bytes for the argument.
867 Likewise, if the function expects @code{long long int} and you pass
868 @code{int}.  The best way to avoid such problems is to use prototypes.
870 @node Complex
871 @section Complex Numbers
872 @cindex complex numbers
873 @cindex @code{_Complex} keyword
874 @cindex @code{__complex__} keyword
876 ISO C99 supports complex floating data types, and as an extension GCC
877 supports them in C90 mode and in C++.  GCC also supports complex integer data
878 types which are not part of ISO C99.  You can declare complex types
879 using the keyword @code{_Complex}.  As an extension, the older GNU
880 keyword @code{__complex__} is also supported.
882 For example, @samp{_Complex double x;} declares @code{x} as a
883 variable whose real part and imaginary part are both of type
884 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
885 have real and imaginary parts of type @code{short int}; this is not
886 likely to be useful, but it shows that the set of complex types is
887 complete.
889 To write a constant with a complex data type, use the suffix @samp{i} or
890 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
891 has type @code{_Complex float} and @code{3i} has type
892 @code{_Complex int}.  Such a constant always has a pure imaginary
893 value, but you can form any complex value you like by adding one to a
894 real constant.  This is a GNU extension; if you have an ISO C99
895 conforming C library (such as the GNU C Library), and want to construct complex
896 constants of floating type, you should include @code{<complex.h>} and
897 use the macros @code{I} or @code{_Complex_I} instead.
899 @cindex @code{__real__} keyword
900 @cindex @code{__imag__} keyword
901 To extract the real part of a complex-valued expression @var{exp}, write
902 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
903 extract the imaginary part.  This is a GNU extension; for values of
904 floating type, you should use the ISO C99 functions @code{crealf},
905 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
906 @code{cimagl}, declared in @code{<complex.h>} and also provided as
907 built-in functions by GCC@.
909 @cindex complex conjugation
910 The operator @samp{~} performs complex conjugation when used on a value
911 with a complex type.  This is a GNU extension; for values of
912 floating type, you should use the ISO C99 functions @code{conjf},
913 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
914 provided as built-in functions by GCC@.
916 GCC can allocate complex automatic variables in a noncontiguous
917 fashion; it's even possible for the real part to be in a register while
918 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
919 debug info format can represent this, so use of DWARF 2 is recommended.
920 If you are using the stabs debug info format, GCC describes a noncontiguous
921 complex variable as if it were two separate variables of noncomplex type.
922 If the variable's actual name is @code{foo}, the two fictitious
923 variables are named @code{foo$real} and @code{foo$imag}.  You can
924 examine and set these two fictitious variables with your debugger.
926 @node Floating Types
927 @section Additional Floating Types
928 @cindex additional floating types
929 @cindex @code{__float80} data type
930 @cindex @code{__float128} data type
931 @cindex @code{w} floating point suffix
932 @cindex @code{q} floating point suffix
933 @cindex @code{W} floating point suffix
934 @cindex @code{Q} floating point suffix
936 As an extension, GNU C supports additional floating
937 types, @code{__float80} and @code{__float128} to support 80-bit
938 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
939 Support for additional types includes the arithmetic operators:
940 add, subtract, multiply, divide; unary arithmetic operators;
941 relational operators; equality operators; and conversions to and from
942 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
943 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
944 for @code{_float128}.  You can declare complex types using the
945 corresponding internal complex type, @code{XCmode} for @code{__float80}
946 type and @code{TCmode} for @code{__float128} type:
948 @smallexample
949 typedef _Complex float __attribute__((mode(TC))) _Complex128;
950 typedef _Complex float __attribute__((mode(XC))) _Complex80;
951 @end smallexample
953 Not all targets support additional floating-point types.  @code{__float80}
954 and @code{__float128} types are supported on x86 and IA-64 targets.
955 The @code{__float128} type is supported on hppa HP-UX targets.
957 @node Half-Precision
958 @section Half-Precision Floating Point
959 @cindex half-precision floating point
960 @cindex @code{__fp16} data type
962 On ARM targets, GCC supports half-precision (16-bit) floating point via
963 the @code{__fp16} type.  You must enable this type explicitly
964 with the @option{-mfp16-format} command-line option in order to use it.
966 ARM supports two incompatible representations for half-precision
967 floating-point values.  You must choose one of the representations and
968 use it consistently in your program.
970 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
971 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
972 There are 11 bits of significand precision, approximately 3
973 decimal digits.
975 Specifying @option{-mfp16-format=alternative} selects the ARM
976 alternative format.  This representation is similar to the IEEE
977 format, but does not support infinities or NaNs.  Instead, the range
978 of exponents is extended, so that this format can represent normalized
979 values in the range of @math{2^{-14}} to 131008.
981 The @code{__fp16} type is a storage format only.  For purposes
982 of arithmetic and other operations, @code{__fp16} values in C or C++
983 expressions are automatically promoted to @code{float}.  In addition,
984 you cannot declare a function with a return value or parameters
985 of type @code{__fp16}.
987 Note that conversions from @code{double} to @code{__fp16}
988 involve an intermediate conversion to @code{float}.  Because
989 of rounding, this can sometimes produce a different result than a
990 direct conversion.
992 ARM provides hardware support for conversions between
993 @code{__fp16} and @code{float} values
994 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
995 code using these hardware instructions if you compile with
996 options to select an FPU that provides them;
997 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
998 in addition to the @option{-mfp16-format} option to select
999 a half-precision format.
1001 Language-level support for the @code{__fp16} data type is
1002 independent of whether GCC generates code using hardware floating-point
1003 instructions.  In cases where hardware support is not specified, GCC
1004 implements conversions between @code{__fp16} and @code{float} values
1005 as library calls.
1007 @node Decimal Float
1008 @section Decimal Floating Types
1009 @cindex decimal floating types
1010 @cindex @code{_Decimal32} data type
1011 @cindex @code{_Decimal64} data type
1012 @cindex @code{_Decimal128} data type
1013 @cindex @code{df} integer suffix
1014 @cindex @code{dd} integer suffix
1015 @cindex @code{dl} integer suffix
1016 @cindex @code{DF} integer suffix
1017 @cindex @code{DD} integer suffix
1018 @cindex @code{DL} integer suffix
1020 As an extension, GNU C supports decimal floating types as
1021 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1022 floating types in GCC will evolve as the draft technical report changes.
1023 Calling conventions for any target might also change.  Not all targets
1024 support decimal floating types.
1026 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1027 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1028 @code{float}, @code{double}, and @code{long double} whose radix is not
1029 specified by the C standard but is usually two.
1031 Support for decimal floating types includes the arithmetic operators
1032 add, subtract, multiply, divide; unary arithmetic operators;
1033 relational operators; equality operators; and conversions to and from
1034 integer and other floating types.  Use a suffix @samp{df} or
1035 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1036 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1037 @code{_Decimal128}.
1039 GCC support of decimal float as specified by the draft technical report
1040 is incomplete:
1042 @itemize @bullet
1043 @item
1044 When the value of a decimal floating type cannot be represented in the
1045 integer type to which it is being converted, the result is undefined
1046 rather than the result value specified by the draft technical report.
1048 @item
1049 GCC does not provide the C library functionality associated with
1050 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1051 @file{wchar.h}, which must come from a separate C library implementation.
1052 Because of this the GNU C compiler does not define macro
1053 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1054 the technical report.
1055 @end itemize
1057 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1058 are supported by the DWARF 2 debug information format.
1060 @node Hex Floats
1061 @section Hex Floats
1062 @cindex hex floats
1064 ISO C99 supports floating-point numbers written not only in the usual
1065 decimal notation, such as @code{1.55e1}, but also numbers such as
1066 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1067 supports this in C90 mode (except in some cases when strictly
1068 conforming) and in C++.  In that format the
1069 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1070 mandatory.  The exponent is a decimal number that indicates the power of
1071 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1072 @tex
1073 $1 {15\over16}$,
1074 @end tex
1075 @ifnottex
1076 1 15/16,
1077 @end ifnottex
1078 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1079 is the same as @code{1.55e1}.
1081 Unlike for floating-point numbers in the decimal notation the exponent
1082 is always required in the hexadecimal notation.  Otherwise the compiler
1083 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1084 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1085 extension for floating-point constants of type @code{float}.
1087 @node Fixed-Point
1088 @section Fixed-Point Types
1089 @cindex fixed-point types
1090 @cindex @code{_Fract} data type
1091 @cindex @code{_Accum} data type
1092 @cindex @code{_Sat} data type
1093 @cindex @code{hr} fixed-suffix
1094 @cindex @code{r} fixed-suffix
1095 @cindex @code{lr} fixed-suffix
1096 @cindex @code{llr} fixed-suffix
1097 @cindex @code{uhr} fixed-suffix
1098 @cindex @code{ur} fixed-suffix
1099 @cindex @code{ulr} fixed-suffix
1100 @cindex @code{ullr} fixed-suffix
1101 @cindex @code{hk} fixed-suffix
1102 @cindex @code{k} fixed-suffix
1103 @cindex @code{lk} fixed-suffix
1104 @cindex @code{llk} fixed-suffix
1105 @cindex @code{uhk} fixed-suffix
1106 @cindex @code{uk} fixed-suffix
1107 @cindex @code{ulk} fixed-suffix
1108 @cindex @code{ullk} fixed-suffix
1109 @cindex @code{HR} fixed-suffix
1110 @cindex @code{R} fixed-suffix
1111 @cindex @code{LR} fixed-suffix
1112 @cindex @code{LLR} fixed-suffix
1113 @cindex @code{UHR} fixed-suffix
1114 @cindex @code{UR} fixed-suffix
1115 @cindex @code{ULR} fixed-suffix
1116 @cindex @code{ULLR} fixed-suffix
1117 @cindex @code{HK} fixed-suffix
1118 @cindex @code{K} fixed-suffix
1119 @cindex @code{LK} fixed-suffix
1120 @cindex @code{LLK} fixed-suffix
1121 @cindex @code{UHK} fixed-suffix
1122 @cindex @code{UK} fixed-suffix
1123 @cindex @code{ULK} fixed-suffix
1124 @cindex @code{ULLK} fixed-suffix
1126 As an extension, GNU C supports fixed-point types as
1127 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1128 types in GCC will evolve as the draft technical report changes.
1129 Calling conventions for any target might also change.  Not all targets
1130 support fixed-point types.
1132 The fixed-point types are
1133 @code{short _Fract},
1134 @code{_Fract},
1135 @code{long _Fract},
1136 @code{long long _Fract},
1137 @code{unsigned short _Fract},
1138 @code{unsigned _Fract},
1139 @code{unsigned long _Fract},
1140 @code{unsigned long long _Fract},
1141 @code{_Sat short _Fract},
1142 @code{_Sat _Fract},
1143 @code{_Sat long _Fract},
1144 @code{_Sat long long _Fract},
1145 @code{_Sat unsigned short _Fract},
1146 @code{_Sat unsigned _Fract},
1147 @code{_Sat unsigned long _Fract},
1148 @code{_Sat unsigned long long _Fract},
1149 @code{short _Accum},
1150 @code{_Accum},
1151 @code{long _Accum},
1152 @code{long long _Accum},
1153 @code{unsigned short _Accum},
1154 @code{unsigned _Accum},
1155 @code{unsigned long _Accum},
1156 @code{unsigned long long _Accum},
1157 @code{_Sat short _Accum},
1158 @code{_Sat _Accum},
1159 @code{_Sat long _Accum},
1160 @code{_Sat long long _Accum},
1161 @code{_Sat unsigned short _Accum},
1162 @code{_Sat unsigned _Accum},
1163 @code{_Sat unsigned long _Accum},
1164 @code{_Sat unsigned long long _Accum}.
1166 Fixed-point data values contain fractional and optional integral parts.
1167 The format of fixed-point data varies and depends on the target machine.
1169 Support for fixed-point types includes:
1170 @itemize @bullet
1171 @item
1172 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1173 @item
1174 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1175 @item
1176 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1177 @item
1178 binary shift operators (@code{<<}, @code{>>})
1179 @item
1180 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1181 @item
1182 equality operators (@code{==}, @code{!=})
1183 @item
1184 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1185 @code{<<=}, @code{>>=})
1186 @item
1187 conversions to and from integer, floating-point, or fixed-point types
1188 @end itemize
1190 Use a suffix in a fixed-point literal constant:
1191 @itemize
1192 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1193 @code{_Sat short _Fract}
1194 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1195 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1196 @code{_Sat long _Fract}
1197 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1198 @code{_Sat long long _Fract}
1199 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1200 @code{_Sat unsigned short _Fract}
1201 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1202 @code{_Sat unsigned _Fract}
1203 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1204 @code{_Sat unsigned long _Fract}
1205 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1206 and @code{_Sat unsigned long long _Fract}
1207 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1208 @code{_Sat short _Accum}
1209 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1210 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1211 @code{_Sat long _Accum}
1212 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1213 @code{_Sat long long _Accum}
1214 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1215 @code{_Sat unsigned short _Accum}
1216 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1217 @code{_Sat unsigned _Accum}
1218 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1219 @code{_Sat unsigned long _Accum}
1220 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1221 and @code{_Sat unsigned long long _Accum}
1222 @end itemize
1224 GCC support of fixed-point types as specified by the draft technical report
1225 is incomplete:
1227 @itemize @bullet
1228 @item
1229 Pragmas to control overflow and rounding behaviors are not implemented.
1230 @end itemize
1232 Fixed-point types are supported by the DWARF 2 debug information format.
1234 @node Named Address Spaces
1235 @section Named Address Spaces
1236 @cindex Named Address Spaces
1238 As an extension, GNU C supports named address spaces as
1239 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1240 address spaces in GCC will evolve as the draft technical report
1241 changes.  Calling conventions for any target might also change.  At
1242 present, only the AVR, SPU, M32C, and RL78 targets support address
1243 spaces other than the generic address space.
1245 Address space identifiers may be used exactly like any other C type
1246 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1247 document for more details.
1249 @anchor{AVR Named Address Spaces}
1250 @subsection AVR Named Address Spaces
1252 On the AVR target, there are several address spaces that can be used
1253 in order to put read-only data into the flash memory and access that
1254 data by means of the special instructions @code{LPM} or @code{ELPM}
1255 needed to read from flash.
1257 Per default, any data including read-only data is located in RAM
1258 (the generic address space) so that non-generic address spaces are
1259 needed to locate read-only data in flash memory
1260 @emph{and} to generate the right instructions to access this data
1261 without using (inline) assembler code.
1263 @table @code
1264 @item __flash
1265 @cindex @code{__flash} AVR Named Address Spaces
1266 The @code{__flash} qualifier locates data in the
1267 @code{.progmem.data} section. Data is read using the @code{LPM}
1268 instruction. Pointers to this address space are 16 bits wide.
1270 @item __flash1
1271 @itemx __flash2
1272 @itemx __flash3
1273 @itemx __flash4
1274 @itemx __flash5
1275 @cindex @code{__flash1} AVR Named Address Spaces
1276 @cindex @code{__flash2} AVR Named Address Spaces
1277 @cindex @code{__flash3} AVR Named Address Spaces
1278 @cindex @code{__flash4} AVR Named Address Spaces
1279 @cindex @code{__flash5} AVR Named Address Spaces
1280 These are 16-bit address spaces locating data in section
1281 @code{.progmem@var{N}.data} where @var{N} refers to
1282 address space @code{__flash@var{N}}.
1283 The compiler sets the @code{RAMPZ} segment register appropriately 
1284 before reading data by means of the @code{ELPM} instruction.
1286 @item __memx
1287 @cindex @code{__memx} AVR Named Address Spaces
1288 This is a 24-bit address space that linearizes flash and RAM:
1289 If the high bit of the address is set, data is read from
1290 RAM using the lower two bytes as RAM address.
1291 If the high bit of the address is clear, data is read from flash
1292 with @code{RAMPZ} set according to the high byte of the address.
1293 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1295 Objects in this address space are located in @code{.progmemx.data}.
1296 @end table
1298 @b{Example}
1300 @smallexample
1301 char my_read (const __flash char ** p)
1303     /* p is a pointer to RAM that points to a pointer to flash.
1304        The first indirection of p reads that flash pointer
1305        from RAM and the second indirection reads a char from this
1306        flash address.  */
1308     return **p;
1311 /* Locate array[] in flash memory */
1312 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1314 int i = 1;
1316 int main (void)
1318    /* Return 17 by reading from flash memory */
1319    return array[array[i]];
1321 @end smallexample
1323 @noindent
1324 For each named address space supported by avr-gcc there is an equally
1325 named but uppercase built-in macro defined. 
1326 The purpose is to facilitate testing if respective address space
1327 support is available or not:
1329 @smallexample
1330 #ifdef __FLASH
1331 const __flash int var = 1;
1333 int read_var (void)
1335     return var;
1337 #else
1338 #include <avr/pgmspace.h> /* From AVR-LibC */
1340 const int var PROGMEM = 1;
1342 int read_var (void)
1344     return (int) pgm_read_word (&var);
1346 #endif /* __FLASH */
1347 @end smallexample
1349 @noindent
1350 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1351 locates data in flash but
1352 accesses to these data read from generic address space, i.e.@:
1353 from RAM,
1354 so that you need special accessors like @code{pgm_read_byte}
1355 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1356 together with attribute @code{progmem}.
1358 @noindent
1359 @b{Limitations and caveats}
1361 @itemize
1362 @item
1363 Reading across the 64@tie{}KiB section boundary of
1364 the @code{__flash} or @code{__flash@var{N}} address spaces
1365 shows undefined behavior. The only address space that
1366 supports reading across the 64@tie{}KiB flash segment boundaries is
1367 @code{__memx}.
1369 @item
1370 If you use one of the @code{__flash@var{N}} address spaces
1371 you must arrange your linker script to locate the
1372 @code{.progmem@var{N}.data} sections according to your needs.
1374 @item
1375 Any data or pointers to the non-generic address spaces must
1376 be qualified as @code{const}, i.e.@: as read-only data.
1377 This still applies if the data in one of these address
1378 spaces like software version number or calibration lookup table are intended to
1379 be changed after load time by, say, a boot loader. In this case
1380 the right qualification is @code{const} @code{volatile} so that the compiler
1381 must not optimize away known values or insert them
1382 as immediates into operands of instructions.
1384 @item
1385 The following code initializes a variable @code{pfoo}
1386 located in static storage with a 24-bit address:
1387 @smallexample
1388 extern const __memx char foo;
1389 const __memx void *pfoo = &foo;
1390 @end smallexample
1392 @noindent
1393 Such code requires at least binutils 2.23, see
1394 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1396 @end itemize
1398 @subsection M32C Named Address Spaces
1399 @cindex @code{__far} M32C Named Address Spaces
1401 On the M32C target, with the R8C and M16C CPU variants, variables
1402 qualified with @code{__far} are accessed using 32-bit addresses in
1403 order to access memory beyond the first 64@tie{}Ki bytes.  If
1404 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1405 effect.
1407 @subsection RL78 Named Address Spaces
1408 @cindex @code{__far} RL78 Named Address Spaces
1410 On the RL78 target, variables qualified with @code{__far} are accessed
1411 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1412 addresses.  Non-far variables are assumed to appear in the topmost
1413 64@tie{}KiB of the address space.
1415 @subsection SPU Named Address Spaces
1416 @cindex @code{__ea} SPU Named Address Spaces
1418 On the SPU target variables may be declared as
1419 belonging to another address space by qualifying the type with the
1420 @code{__ea} address space identifier:
1422 @smallexample
1423 extern int __ea i;
1424 @end smallexample
1426 @noindent 
1427 The compiler generates special code to access the variable @code{i}.
1428 It may use runtime library
1429 support, or generate special machine instructions to access that address
1430 space.
1432 @node Zero Length
1433 @section Arrays of Length Zero
1434 @cindex arrays of length zero
1435 @cindex zero-length arrays
1436 @cindex length-zero arrays
1437 @cindex flexible array members
1439 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1440 last element of a structure that is really a header for a variable-length
1441 object:
1443 @smallexample
1444 struct line @{
1445   int length;
1446   char contents[0];
1449 struct line *thisline = (struct line *)
1450   malloc (sizeof (struct line) + this_length);
1451 thisline->length = this_length;
1452 @end smallexample
1454 In ISO C90, you would have to give @code{contents} a length of 1, which
1455 means either you waste space or complicate the argument to @code{malloc}.
1457 In ISO C99, you would use a @dfn{flexible array member}, which is
1458 slightly different in syntax and semantics:
1460 @itemize @bullet
1461 @item
1462 Flexible array members are written as @code{contents[]} without
1463 the @code{0}.
1465 @item
1466 Flexible array members have incomplete type, and so the @code{sizeof}
1467 operator may not be applied.  As a quirk of the original implementation
1468 of zero-length arrays, @code{sizeof} evaluates to zero.
1470 @item
1471 Flexible array members may only appear as the last member of a
1472 @code{struct} that is otherwise non-empty.
1474 @item
1475 A structure containing a flexible array member, or a union containing
1476 such a structure (possibly recursively), may not be a member of a
1477 structure or an element of an array.  (However, these uses are
1478 permitted by GCC as extensions.)
1479 @end itemize
1481 Non-empty initialization of zero-length
1482 arrays is treated like any case where there are more initializer
1483 elements than the array holds, in that a suitable warning about ``excess
1484 elements in array'' is given, and the excess elements (all of them, in
1485 this case) are ignored.
1487 GCC allows static initialization of flexible array members.
1488 This is equivalent to defining a new structure containing the original
1489 structure followed by an array of sufficient size to contain the data.
1490 E.g.@: in the following, @code{f1} is constructed as if it were declared
1491 like @code{f2}.
1493 @smallexample
1494 struct f1 @{
1495   int x; int y[];
1496 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1498 struct f2 @{
1499   struct f1 f1; int data[3];
1500 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1501 @end smallexample
1503 @noindent
1504 The convenience of this extension is that @code{f1} has the desired
1505 type, eliminating the need to consistently refer to @code{f2.f1}.
1507 This has symmetry with normal static arrays, in that an array of
1508 unknown size is also written with @code{[]}.
1510 Of course, this extension only makes sense if the extra data comes at
1511 the end of a top-level object, as otherwise we would be overwriting
1512 data at subsequent offsets.  To avoid undue complication and confusion
1513 with initialization of deeply nested arrays, we simply disallow any
1514 non-empty initialization except when the structure is the top-level
1515 object.  For example:
1517 @smallexample
1518 struct foo @{ int x; int y[]; @};
1519 struct bar @{ struct foo z; @};
1521 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1522 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1523 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1524 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1525 @end smallexample
1527 @node Empty Structures
1528 @section Structures with No Members
1529 @cindex empty structures
1530 @cindex zero-size structures
1532 GCC permits a C structure to have no members:
1534 @smallexample
1535 struct empty @{
1537 @end smallexample
1539 The structure has size zero.  In C++, empty structures are part
1540 of the language.  G++ treats empty structures as if they had a single
1541 member of type @code{char}.
1543 @node Variable Length
1544 @section Arrays of Variable Length
1545 @cindex variable-length arrays
1546 @cindex arrays of variable length
1547 @cindex VLAs
1549 Variable-length automatic arrays are allowed in ISO C99, and as an
1550 extension GCC accepts them in C90 mode and in C++.  These arrays are
1551 declared like any other automatic arrays, but with a length that is not
1552 a constant expression.  The storage is allocated at the point of
1553 declaration and deallocated when the block scope containing the declaration
1554 exits.  For
1555 example:
1557 @smallexample
1558 FILE *
1559 concat_fopen (char *s1, char *s2, char *mode)
1561   char str[strlen (s1) + strlen (s2) + 1];
1562   strcpy (str, s1);
1563   strcat (str, s2);
1564   return fopen (str, mode);
1566 @end smallexample
1568 @cindex scope of a variable length array
1569 @cindex variable-length array scope
1570 @cindex deallocating variable length arrays
1571 Jumping or breaking out of the scope of the array name deallocates the
1572 storage.  Jumping into the scope is not allowed; you get an error
1573 message for it.
1575 @cindex variable-length array in a structure
1576 As an extension, GCC accepts variable-length arrays as a member of
1577 a structure or a union.  For example:
1579 @smallexample
1580 void
1581 foo (int n)
1583   struct S @{ int x[n]; @};
1585 @end smallexample
1587 @cindex @code{alloca} vs variable-length arrays
1588 You can use the function @code{alloca} to get an effect much like
1589 variable-length arrays.  The function @code{alloca} is available in
1590 many other C implementations (but not in all).  On the other hand,
1591 variable-length arrays are more elegant.
1593 There are other differences between these two methods.  Space allocated
1594 with @code{alloca} exists until the containing @emph{function} returns.
1595 The space for a variable-length array is deallocated as soon as the array
1596 name's scope ends.  (If you use both variable-length arrays and
1597 @code{alloca} in the same function, deallocation of a variable-length array
1598 also deallocates anything more recently allocated with @code{alloca}.)
1600 You can also use variable-length arrays as arguments to functions:
1602 @smallexample
1603 struct entry
1604 tester (int len, char data[len][len])
1606   /* @r{@dots{}} */
1608 @end smallexample
1610 The length of an array is computed once when the storage is allocated
1611 and is remembered for the scope of the array in case you access it with
1612 @code{sizeof}.
1614 If you want to pass the array first and the length afterward, you can
1615 use a forward declaration in the parameter list---another GNU extension.
1617 @smallexample
1618 struct entry
1619 tester (int len; char data[len][len], int len)
1621   /* @r{@dots{}} */
1623 @end smallexample
1625 @cindex parameter forward declaration
1626 The @samp{int len} before the semicolon is a @dfn{parameter forward
1627 declaration}, and it serves the purpose of making the name @code{len}
1628 known when the declaration of @code{data} is parsed.
1630 You can write any number of such parameter forward declarations in the
1631 parameter list.  They can be separated by commas or semicolons, but the
1632 last one must end with a semicolon, which is followed by the ``real''
1633 parameter declarations.  Each forward declaration must match a ``real''
1634 declaration in parameter name and data type.  ISO C99 does not support
1635 parameter forward declarations.
1637 @node Variadic Macros
1638 @section Macros with a Variable Number of Arguments.
1639 @cindex variable number of arguments
1640 @cindex macro with variable arguments
1641 @cindex rest argument (in macro)
1642 @cindex variadic macros
1644 In the ISO C standard of 1999, a macro can be declared to accept a
1645 variable number of arguments much as a function can.  The syntax for
1646 defining the macro is similar to that of a function.  Here is an
1647 example:
1649 @smallexample
1650 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1651 @end smallexample
1653 @noindent
1654 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1655 such a macro, it represents the zero or more tokens until the closing
1656 parenthesis that ends the invocation, including any commas.  This set of
1657 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1658 wherever it appears.  See the CPP manual for more information.
1660 GCC has long supported variadic macros, and used a different syntax that
1661 allowed you to give a name to the variable arguments just like any other
1662 argument.  Here is an example:
1664 @smallexample
1665 #define debug(format, args...) fprintf (stderr, format, args)
1666 @end smallexample
1668 @noindent
1669 This is in all ways equivalent to the ISO C example above, but arguably
1670 more readable and descriptive.
1672 GNU CPP has two further variadic macro extensions, and permits them to
1673 be used with either of the above forms of macro definition.
1675 In standard C, you are not allowed to leave the variable argument out
1676 entirely; but you are allowed to pass an empty argument.  For example,
1677 this invocation is invalid in ISO C, because there is no comma after
1678 the string:
1680 @smallexample
1681 debug ("A message")
1682 @end smallexample
1684 GNU CPP permits you to completely omit the variable arguments in this
1685 way.  In the above examples, the compiler would complain, though since
1686 the expansion of the macro still has the extra comma after the format
1687 string.
1689 To help solve this problem, CPP behaves specially for variable arguments
1690 used with the token paste operator, @samp{##}.  If instead you write
1692 @smallexample
1693 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1694 @end smallexample
1696 @noindent
1697 and if the variable arguments are omitted or empty, the @samp{##}
1698 operator causes the preprocessor to remove the comma before it.  If you
1699 do provide some variable arguments in your macro invocation, GNU CPP
1700 does not complain about the paste operation and instead places the
1701 variable arguments after the comma.  Just like any other pasted macro
1702 argument, these arguments are not macro expanded.
1704 @node Escaped Newlines
1705 @section Slightly Looser Rules for Escaped Newlines
1706 @cindex escaped newlines
1707 @cindex newlines (escaped)
1709 The preprocessor treatment of escaped newlines is more relaxed 
1710 than that specified by the C90 standard, which requires the newline
1711 to immediately follow a backslash.  
1712 GCC's implementation allows whitespace in the form
1713 of spaces, horizontal and vertical tabs, and form feeds between the
1714 backslash and the subsequent newline.  The preprocessor issues a
1715 warning, but treats it as a valid escaped newline and combines the two
1716 lines to form a single logical line.  This works within comments and
1717 tokens, as well as between tokens.  Comments are @emph{not} treated as
1718 whitespace for the purposes of this relaxation, since they have not
1719 yet been replaced with spaces.
1721 @node Subscripting
1722 @section Non-Lvalue Arrays May Have Subscripts
1723 @cindex subscripting
1724 @cindex arrays, non-lvalue
1726 @cindex subscripting and function values
1727 In ISO C99, arrays that are not lvalues still decay to pointers, and
1728 may be subscripted, although they may not be modified or used after
1729 the next sequence point and the unary @samp{&} operator may not be
1730 applied to them.  As an extension, GNU C allows such arrays to be
1731 subscripted in C90 mode, though otherwise they do not decay to
1732 pointers outside C99 mode.  For example,
1733 this is valid in GNU C though not valid in C90:
1735 @smallexample
1736 @group
1737 struct foo @{int a[4];@};
1739 struct foo f();
1741 bar (int index)
1743   return f().a[index];
1745 @end group
1746 @end smallexample
1748 @node Pointer Arith
1749 @section Arithmetic on @code{void}- and Function-Pointers
1750 @cindex void pointers, arithmetic
1751 @cindex void, size of pointer to
1752 @cindex function pointers, arithmetic
1753 @cindex function, size of pointer to
1755 In GNU C, addition and subtraction operations are supported on pointers to
1756 @code{void} and on pointers to functions.  This is done by treating the
1757 size of a @code{void} or of a function as 1.
1759 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1760 and on function types, and returns 1.
1762 @opindex Wpointer-arith
1763 The option @option{-Wpointer-arith} requests a warning if these extensions
1764 are used.
1766 @node Pointers to Arrays
1767 @section Pointers to Arrays with Qualifiers Work as Expected
1768 @cindex pointers to arrays
1769 @cindex const qualifier
1771 In GNU C, pointers to arrays with qualifiers work similar to pointers
1772 to other qualified types. For example, a value of type @code{int (*)[5]}
1773 can be used to initialize a variable of type @code{const int (*)[5]}.
1774 These types are incompatible in ISO C because the @code{const} qualifier
1775 is formally attached to the element type of the array and not the
1776 array itself.
1778 @smallexample
1779 extern void
1780 transpose (int N, int M, double out[M][N], const double in[N][M]);
1781 double x[3][2];
1782 double y[2][3];
1783 @r{@dots{}}
1784 transpose(3, 2, y, x);
1785 @end smallexample
1787 @node Initializers
1788 @section Non-Constant Initializers
1789 @cindex initializers, non-constant
1790 @cindex non-constant initializers
1792 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1793 automatic variable are not required to be constant expressions in GNU C@.
1794 Here is an example of an initializer with run-time varying elements:
1796 @smallexample
1797 foo (float f, float g)
1799   float beat_freqs[2] = @{ f-g, f+g @};
1800   /* @r{@dots{}} */
1802 @end smallexample
1804 @node Compound Literals
1805 @section Compound Literals
1806 @cindex constructor expressions
1807 @cindex initializations in expressions
1808 @cindex structures, constructor expression
1809 @cindex expressions, constructor
1810 @cindex compound literals
1811 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1813 ISO C99 supports compound literals.  A compound literal looks like
1814 a cast containing an initializer.  Its value is an object of the
1815 type specified in the cast, containing the elements specified in
1816 the initializer; it is an lvalue.  As an extension, GCC supports
1817 compound literals in C90 mode and in C++, though the semantics are
1818 somewhat different in C++.
1820 Usually, the specified type is a structure.  Assume that
1821 @code{struct foo} and @code{structure} are declared as shown:
1823 @smallexample
1824 struct foo @{int a; char b[2];@} structure;
1825 @end smallexample
1827 @noindent
1828 Here is an example of constructing a @code{struct foo} with a compound literal:
1830 @smallexample
1831 structure = ((struct foo) @{x + y, 'a', 0@});
1832 @end smallexample
1834 @noindent
1835 This is equivalent to writing the following:
1837 @smallexample
1839   struct foo temp = @{x + y, 'a', 0@};
1840   structure = temp;
1842 @end smallexample
1844 You can also construct an array, though this is dangerous in C++, as
1845 explained below.  If all the elements of the compound literal are
1846 (made up of) simple constant expressions, suitable for use in
1847 initializers of objects of static storage duration, then the compound
1848 literal can be coerced to a pointer to its first element and used in
1849 such an initializer, as shown here:
1851 @smallexample
1852 char **foo = (char *[]) @{ "x", "y", "z" @};
1853 @end smallexample
1855 Compound literals for scalar types and union types are
1856 also allowed, but then the compound literal is equivalent
1857 to a cast.
1859 As a GNU extension, GCC allows initialization of objects with static storage
1860 duration by compound literals (which is not possible in ISO C99, because
1861 the initializer is not a constant).
1862 It is handled as if the object is initialized only with the bracket
1863 enclosed list if the types of the compound literal and the object match.
1864 The initializer list of the compound literal must be constant.
1865 If the object being initialized has array type of unknown size, the size is
1866 determined by compound literal size.
1868 @smallexample
1869 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1870 static int y[] = (int []) @{1, 2, 3@};
1871 static int z[] = (int [3]) @{1@};
1872 @end smallexample
1874 @noindent
1875 The above lines are equivalent to the following:
1876 @smallexample
1877 static struct foo x = @{1, 'a', 'b'@};
1878 static int y[] = @{1, 2, 3@};
1879 static int z[] = @{1, 0, 0@};
1880 @end smallexample
1882 In C, a compound literal designates an unnamed object with static or
1883 automatic storage duration.  In C++, a compound literal designates a
1884 temporary object, which only lives until the end of its
1885 full-expression.  As a result, well-defined C code that takes the
1886 address of a subobject of a compound literal can be undefined in C++,
1887 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1888 For instance, if the array compound literal example above appeared
1889 inside a function, any subsequent use of @samp{foo} in C++ has
1890 undefined behavior because the lifetime of the array ends after the
1891 declaration of @samp{foo}.  
1893 As an optimization, the C++ compiler sometimes gives array compound
1894 literals longer lifetimes: when the array either appears outside a
1895 function or has const-qualified type.  If @samp{foo} and its
1896 initializer had elements of @samp{char *const} type rather than
1897 @samp{char *}, or if @samp{foo} were a global variable, the array
1898 would have static storage duration.  But it is probably safest just to
1899 avoid the use of array compound literals in code compiled as C++.
1901 @node Designated Inits
1902 @section Designated Initializers
1903 @cindex initializers with labeled elements
1904 @cindex labeled elements in initializers
1905 @cindex case labels in initializers
1906 @cindex designated initializers
1908 Standard C90 requires the elements of an initializer to appear in a fixed
1909 order, the same as the order of the elements in the array or structure
1910 being initialized.
1912 In ISO C99 you can give the elements in any order, specifying the array
1913 indices or structure field names they apply to, and GNU C allows this as
1914 an extension in C90 mode as well.  This extension is not
1915 implemented in GNU C++.
1917 To specify an array index, write
1918 @samp{[@var{index}] =} before the element value.  For example,
1920 @smallexample
1921 int a[6] = @{ [4] = 29, [2] = 15 @};
1922 @end smallexample
1924 @noindent
1925 is equivalent to
1927 @smallexample
1928 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1929 @end smallexample
1931 @noindent
1932 The index values must be constant expressions, even if the array being
1933 initialized is automatic.
1935 An alternative syntax for this that has been obsolete since GCC 2.5 but
1936 GCC still accepts is to write @samp{[@var{index}]} before the element
1937 value, with no @samp{=}.
1939 To initialize a range of elements to the same value, write
1940 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1941 extension.  For example,
1943 @smallexample
1944 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1945 @end smallexample
1947 @noindent
1948 If the value in it has side-effects, the side-effects happen only once,
1949 not for each initialized field by the range initializer.
1951 @noindent
1952 Note that the length of the array is the highest value specified
1953 plus one.
1955 In a structure initializer, specify the name of a field to initialize
1956 with @samp{.@var{fieldname} =} before the element value.  For example,
1957 given the following structure,
1959 @smallexample
1960 struct point @{ int x, y; @};
1961 @end smallexample
1963 @noindent
1964 the following initialization
1966 @smallexample
1967 struct point p = @{ .y = yvalue, .x = xvalue @};
1968 @end smallexample
1970 @noindent
1971 is equivalent to
1973 @smallexample
1974 struct point p = @{ xvalue, yvalue @};
1975 @end smallexample
1977 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1978 @samp{@var{fieldname}:}, as shown here:
1980 @smallexample
1981 struct point p = @{ y: yvalue, x: xvalue @};
1982 @end smallexample
1984 Omitted field members are implicitly initialized the same as objects
1985 that have static storage duration.
1987 @cindex designators
1988 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1989 @dfn{designator}.  You can also use a designator (or the obsolete colon
1990 syntax) when initializing a union, to specify which element of the union
1991 should be used.  For example,
1993 @smallexample
1994 union foo @{ int i; double d; @};
1996 union foo f = @{ .d = 4 @};
1997 @end smallexample
1999 @noindent
2000 converts 4 to a @code{double} to store it in the union using
2001 the second element.  By contrast, casting 4 to type @code{union foo}
2002 stores it into the union as the integer @code{i}, since it is
2003 an integer.  (@xref{Cast to Union}.)
2005 You can combine this technique of naming elements with ordinary C
2006 initialization of successive elements.  Each initializer element that
2007 does not have a designator applies to the next consecutive element of the
2008 array or structure.  For example,
2010 @smallexample
2011 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2012 @end smallexample
2014 @noindent
2015 is equivalent to
2017 @smallexample
2018 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2019 @end smallexample
2021 Labeling the elements of an array initializer is especially useful
2022 when the indices are characters or belong to an @code{enum} type.
2023 For example:
2025 @smallexample
2026 int whitespace[256]
2027   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2028       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2029 @end smallexample
2031 @cindex designator lists
2032 You can also write a series of @samp{.@var{fieldname}} and
2033 @samp{[@var{index}]} designators before an @samp{=} to specify a
2034 nested subobject to initialize; the list is taken relative to the
2035 subobject corresponding to the closest surrounding brace pair.  For
2036 example, with the @samp{struct point} declaration above:
2038 @smallexample
2039 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2040 @end smallexample
2042 @noindent
2043 If the same field is initialized multiple times, it has the value from
2044 the last initialization.  If any such overridden initialization has
2045 side-effect, it is unspecified whether the side-effect happens or not.
2046 Currently, GCC discards them and issues a warning.
2048 @node Case Ranges
2049 @section Case Ranges
2050 @cindex case ranges
2051 @cindex ranges in case statements
2053 You can specify a range of consecutive values in a single @code{case} label,
2054 like this:
2056 @smallexample
2057 case @var{low} ... @var{high}:
2058 @end smallexample
2060 @noindent
2061 This has the same effect as the proper number of individual @code{case}
2062 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2064 This feature is especially useful for ranges of ASCII character codes:
2066 @smallexample
2067 case 'A' ... 'Z':
2068 @end smallexample
2070 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2071 it may be parsed wrong when you use it with integer values.  For example,
2072 write this:
2074 @smallexample
2075 case 1 ... 5:
2076 @end smallexample
2078 @noindent
2079 rather than this:
2081 @smallexample
2082 case 1...5:
2083 @end smallexample
2085 @node Cast to Union
2086 @section Cast to a Union Type
2087 @cindex cast to a union
2088 @cindex union, casting to a
2090 A cast to union type is similar to other casts, except that the type
2091 specified is a union type.  You can specify the type either with
2092 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2093 a constructor, not a cast, and hence does not yield an lvalue like
2094 normal casts.  (@xref{Compound Literals}.)
2096 The types that may be cast to the union type are those of the members
2097 of the union.  Thus, given the following union and variables:
2099 @smallexample
2100 union foo @{ int i; double d; @};
2101 int x;
2102 double y;
2103 @end smallexample
2105 @noindent
2106 both @code{x} and @code{y} can be cast to type @code{union foo}.
2108 Using the cast as the right-hand side of an assignment to a variable of
2109 union type is equivalent to storing in a member of the union:
2111 @smallexample
2112 union foo u;
2113 /* @r{@dots{}} */
2114 u = (union foo) x  @equiv{}  u.i = x
2115 u = (union foo) y  @equiv{}  u.d = y
2116 @end smallexample
2118 You can also use the union cast as a function argument:
2120 @smallexample
2121 void hack (union foo);
2122 /* @r{@dots{}} */
2123 hack ((union foo) x);
2124 @end smallexample
2126 @node Mixed Declarations
2127 @section Mixed Declarations and Code
2128 @cindex mixed declarations and code
2129 @cindex declarations, mixed with code
2130 @cindex code, mixed with declarations
2132 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2133 within compound statements.  As an extension, GNU C also allows this in
2134 C90 mode.  For example, you could do:
2136 @smallexample
2137 int i;
2138 /* @r{@dots{}} */
2139 i++;
2140 int j = i + 2;
2141 @end smallexample
2143 Each identifier is visible from where it is declared until the end of
2144 the enclosing block.
2146 @node Function Attributes
2147 @section Declaring Attributes of Functions
2148 @cindex function attributes
2149 @cindex declaring attributes of functions
2150 @cindex @code{volatile} applied to function
2151 @cindex @code{const} applied to function
2153 In GNU C, you can use function attributes to declare certain things
2154 about functions called in your program which help the compiler
2155 optimize calls and check your code more carefully.  For example, you
2156 can use attributes to declare that a function never returns
2157 (@code{noreturn}), returns a value depending only on its arguments
2158 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2160 You can also use attributes to control memory placement, code
2161 generation options or call/return conventions within the function
2162 being annotated.  Many of these attributes are target-specific.  For
2163 example, many targets support attributes for defining interrupt
2164 handler functions, which typically must follow special register usage
2165 and return conventions.
2167 Function attributes are introduced by the @code{__attribute__} keyword
2168 on a declaration, followed by an attribute specification inside double
2169 parentheses.  You can specify multiple attributes in a declaration by
2170 separating them by commas within the double parentheses or by
2171 immediately following an attribute declaration with another attribute
2172 declaration.  @xref{Attribute Syntax}, for the exact rules on
2173 attribute syntax and placement.
2175 GCC also supports attributes on
2176 variable declarations (@pxref{Variable Attributes}),
2177 labels (@pxref{Label Attributes}),
2178 and types (@pxref{Type Attributes}).
2180 There is some overlap between the purposes of attributes and pragmas
2181 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2182 found convenient to use @code{__attribute__} to achieve a natural
2183 attachment of attributes to their corresponding declarations, whereas
2184 @code{#pragma} is of use for compatibility with other compilers
2185 or constructs that do not naturally form part of the grammar.
2187 In addition to the attributes documented here,
2188 GCC plugins may provide their own attributes.
2190 @menu
2191 * Common Function Attributes::
2192 * ARC Function Attributes::
2193 * ARM Function Attributes::
2194 * AVR Function Attributes::
2195 * Blackfin Function Attributes::
2196 * CR16 Function Attributes::
2197 * Epiphany Function Attributes::
2198 * H8/300 Function Attributes::
2199 * IA-64 Function Attributes::
2200 * M32C Function Attributes::
2201 * M32R/D Function Attributes::
2202 * m68k Function Attributes::
2203 * MCORE Function Attributes::
2204 * MeP Function Attributes::
2205 * MicroBlaze Function Attributes::
2206 * Microsoft Windows Function Attributes::
2207 * MIPS Function Attributes::
2208 * MSP430 Function Attributes::
2209 * NDS32 Function Attributes::
2210 * Nios II Function Attributes::
2211 * PowerPC Function Attributes::
2212 * RL78 Function Attributes::
2213 * RX Function Attributes::
2214 * S/390 Function Attributes::
2215 * SH Function Attributes::
2216 * SPU Function Attributes::
2217 * Symbian OS Function Attributes::
2218 * Visium Function Attributes::
2219 * x86 Function Attributes::
2220 * Xstormy16 Function Attributes::
2221 @end menu
2223 @node Common Function Attributes
2224 @subsection Common Function Attributes
2226 The following attributes are supported on most targets.
2228 @table @code
2229 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2231 @item alias ("@var{target}")
2232 @cindex @code{alias} function attribute
2233 The @code{alias} attribute causes the declaration to be emitted as an
2234 alias for another symbol, which must be specified.  For instance,
2236 @smallexample
2237 void __f () @{ /* @r{Do something.} */; @}
2238 void f () __attribute__ ((weak, alias ("__f")));
2239 @end smallexample
2241 @noindent
2242 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2243 mangled name for the target must be used.  It is an error if @samp{__f}
2244 is not defined in the same translation unit.
2246 This attribute requires assembler and object file support,
2247 and may not be available on all targets.
2249 @item aligned (@var{alignment})
2250 @cindex @code{aligned} function attribute
2251 This attribute specifies a minimum alignment for the function,
2252 measured in bytes.
2254 You cannot use this attribute to decrease the alignment of a function,
2255 only to increase it.  However, when you explicitly specify a function
2256 alignment this overrides the effect of the
2257 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2258 function.
2260 Note that the effectiveness of @code{aligned} attributes may be
2261 limited by inherent limitations in your linker.  On many systems, the
2262 linker is only able to arrange for functions to be aligned up to a
2263 certain maximum alignment.  (For some linkers, the maximum supported
2264 alignment may be very very small.)  See your linker documentation for
2265 further information.
2267 The @code{aligned} attribute can also be used for variables and fields
2268 (@pxref{Variable Attributes}.)
2270 @item alloc_align
2271 @cindex @code{alloc_align} function attribute
2272 The @code{alloc_align} attribute is used to tell the compiler that the
2273 function return value points to memory, where the returned pointer minimum
2274 alignment is given by one of the functions parameters.  GCC uses this
2275 information to improve pointer alignment analysis.
2277 The function parameter denoting the allocated alignment is specified by
2278 one integer argument, whose number is the argument of the attribute.
2279 Argument numbering starts at one.
2281 For instance,
2283 @smallexample
2284 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2285 @end smallexample
2287 @noindent
2288 declares that @code{my_memalign} returns memory with minimum alignment
2289 given by parameter 1.
2291 @item alloc_size
2292 @cindex @code{alloc_size} function attribute
2293 The @code{alloc_size} attribute is used to tell the compiler that the
2294 function return value points to memory, where the size is given by
2295 one or two of the functions parameters.  GCC uses this
2296 information to improve the correctness of @code{__builtin_object_size}.
2298 The function parameter(s) denoting the allocated size are specified by
2299 one or two integer arguments supplied to the attribute.  The allocated size
2300 is either the value of the single function argument specified or the product
2301 of the two function arguments specified.  Argument numbering starts at
2302 one.
2304 For instance,
2306 @smallexample
2307 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2308 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2309 @end smallexample
2311 @noindent
2312 declares that @code{my_calloc} returns memory of the size given by
2313 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2314 of the size given by parameter 2.
2316 @item always_inline
2317 @cindex @code{always_inline} function attribute
2318 Generally, functions are not inlined unless optimization is specified.
2319 For functions declared inline, this attribute inlines the function
2320 independent of any restrictions that otherwise apply to inlining.
2321 Failure to inline such a function is diagnosed as an error.
2322 Note that if such a function is called indirectly the compiler may
2323 or may not inline it depending on optimization level and a failure
2324 to inline an indirect call may or may not be diagnosed.
2326 @item artificial
2327 @cindex @code{artificial} function attribute
2328 This attribute is useful for small inline wrappers that if possible
2329 should appear during debugging as a unit.  Depending on the debug
2330 info format it either means marking the function as artificial
2331 or using the caller location for all instructions within the inlined
2332 body.
2334 @item assume_aligned
2335 @cindex @code{assume_aligned} function attribute
2336 The @code{assume_aligned} attribute is used to tell the compiler that the
2337 function return value points to memory, where the returned pointer minimum
2338 alignment is given by the first argument.
2339 If the attribute has two arguments, the second argument is misalignment offset.
2341 For instance
2343 @smallexample
2344 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2345 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2346 @end smallexample
2348 @noindent
2349 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2350 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2351 to 8.
2353 @item bnd_instrument
2354 @cindex @code{bnd_instrument} function attribute
2355 The @code{bnd_instrument} attribute on functions is used to inform the
2356 compiler that the function should be instrumented when compiled
2357 with the @option{-fchkp-instrument-marked-only} option.
2359 @item bnd_legacy
2360 @cindex @code{bnd_legacy} function attribute
2361 @cindex Pointer Bounds Checker attributes
2362 The @code{bnd_legacy} attribute on functions is used to inform the
2363 compiler that the function should not be instrumented when compiled
2364 with the @option{-fcheck-pointer-bounds} option.
2366 @item cold
2367 @cindex @code{cold} function attribute
2368 The @code{cold} attribute on functions is used to inform the compiler that
2369 the function is unlikely to be executed.  The function is optimized for
2370 size rather than speed and on many targets it is placed into a special
2371 subsection of the text section so all cold functions appear close together,
2372 improving code locality of non-cold parts of program.  The paths leading
2373 to calls of cold functions within code are marked as unlikely by the branch
2374 prediction mechanism.  It is thus useful to mark functions used to handle
2375 unlikely conditions, such as @code{perror}, as cold to improve optimization
2376 of hot functions that do call marked functions in rare occasions.
2378 When profile feedback is available, via @option{-fprofile-use}, cold functions
2379 are automatically detected and this attribute is ignored.
2381 @item const
2382 @cindex @code{const} function attribute
2383 @cindex functions that have no side effects
2384 Many functions do not examine any values except their arguments, and
2385 have no effects except the return value.  Basically this is just slightly
2386 more strict class than the @code{pure} attribute below, since function is not
2387 allowed to read global memory.
2389 @cindex pointer arguments
2390 Note that a function that has pointer arguments and examines the data
2391 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2392 function that calls a non-@code{const} function usually must not be
2393 @code{const}.  It does not make sense for a @code{const} function to
2394 return @code{void}.
2396 @item constructor
2397 @itemx destructor
2398 @itemx constructor (@var{priority})
2399 @itemx destructor (@var{priority})
2400 @cindex @code{constructor} function attribute
2401 @cindex @code{destructor} function attribute
2402 The @code{constructor} attribute causes the function to be called
2403 automatically before execution enters @code{main ()}.  Similarly, the
2404 @code{destructor} attribute causes the function to be called
2405 automatically after @code{main ()} completes or @code{exit ()} is
2406 called.  Functions with these attributes are useful for
2407 initializing data that is used implicitly during the execution of
2408 the program.
2410 You may provide an optional integer priority to control the order in
2411 which constructor and destructor functions are run.  A constructor
2412 with a smaller priority number runs before a constructor with a larger
2413 priority number; the opposite relationship holds for destructors.  So,
2414 if you have a constructor that allocates a resource and a destructor
2415 that deallocates the same resource, both functions typically have the
2416 same priority.  The priorities for constructor and destructor
2417 functions are the same as those specified for namespace-scope C++
2418 objects (@pxref{C++ Attributes}).
2420 These attributes are not currently implemented for Objective-C@.
2422 @item deprecated
2423 @itemx deprecated (@var{msg})
2424 @cindex @code{deprecated} function attribute
2425 The @code{deprecated} attribute results in a warning if the function
2426 is used anywhere in the source file.  This is useful when identifying
2427 functions that are expected to be removed in a future version of a
2428 program.  The warning also includes the location of the declaration
2429 of the deprecated function, to enable users to easily find further
2430 information about why the function is deprecated, or what they should
2431 do instead.  Note that the warnings only occurs for uses:
2433 @smallexample
2434 int old_fn () __attribute__ ((deprecated));
2435 int old_fn ();
2436 int (*fn_ptr)() = old_fn;
2437 @end smallexample
2439 @noindent
2440 results in a warning on line 3 but not line 2.  The optional @var{msg}
2441 argument, which must be a string, is printed in the warning if
2442 present.
2444 The @code{deprecated} attribute can also be used for variables and
2445 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2447 @item error ("@var{message}")
2448 @itemx warning ("@var{message}")
2449 @cindex @code{error} function attribute
2450 @cindex @code{warning} function attribute
2451 If the @code{error} or @code{warning} attribute 
2452 is used on a function declaration and a call to such a function
2453 is not eliminated through dead code elimination or other optimizations, 
2454 an error or warning (respectively) that includes @var{message} is diagnosed.  
2455 This is useful
2456 for compile-time checking, especially together with @code{__builtin_constant_p}
2457 and inline functions where checking the inline function arguments is not
2458 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2460 While it is possible to leave the function undefined and thus invoke
2461 a link failure (to define the function with
2462 a message in @code{.gnu.warning*} section),
2463 when using these attributes the problem is diagnosed
2464 earlier and with exact location of the call even in presence of inline
2465 functions or when not emitting debugging information.
2467 @item externally_visible
2468 @cindex @code{externally_visible} function attribute
2469 This attribute, attached to a global variable or function, nullifies
2470 the effect of the @option{-fwhole-program} command-line option, so the
2471 object remains visible outside the current compilation unit.
2473 If @option{-fwhole-program} is used together with @option{-flto} and 
2474 @command{gold} is used as the linker plugin, 
2475 @code{externally_visible} attributes are automatically added to functions 
2476 (not variable yet due to a current @command{gold} issue) 
2477 that are accessed outside of LTO objects according to resolution file
2478 produced by @command{gold}.
2479 For other linkers that cannot generate resolution file,
2480 explicit @code{externally_visible} attributes are still necessary.
2482 @item flatten
2483 @cindex @code{flatten} function attribute
2484 Generally, inlining into a function is limited.  For a function marked with
2485 this attribute, every call inside this function is inlined, if possible.
2486 Whether the function itself is considered for inlining depends on its size and
2487 the current inlining parameters.
2489 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2490 @cindex @code{format} function attribute
2491 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2492 @opindex Wformat
2493 The @code{format} attribute specifies that a function takes @code{printf},
2494 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2495 should be type-checked against a format string.  For example, the
2496 declaration:
2498 @smallexample
2499 extern int
2500 my_printf (void *my_object, const char *my_format, ...)
2501       __attribute__ ((format (printf, 2, 3)));
2502 @end smallexample
2504 @noindent
2505 causes the compiler to check the arguments in calls to @code{my_printf}
2506 for consistency with the @code{printf} style format string argument
2507 @code{my_format}.
2509 The parameter @var{archetype} determines how the format string is
2510 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2511 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2512 @code{strfmon}.  (You can also use @code{__printf__},
2513 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2514 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2515 @code{ms_strftime} are also present.
2516 @var{archetype} values such as @code{printf} refer to the formats accepted
2517 by the system's C runtime library,
2518 while values prefixed with @samp{gnu_} always refer
2519 to the formats accepted by the GNU C Library.  On Microsoft Windows
2520 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2521 @file{msvcrt.dll} library.
2522 The parameter @var{string-index}
2523 specifies which argument is the format string argument (starting
2524 from 1), while @var{first-to-check} is the number of the first
2525 argument to check against the format string.  For functions
2526 where the arguments are not available to be checked (such as
2527 @code{vprintf}), specify the third parameter as zero.  In this case the
2528 compiler only checks the format string for consistency.  For
2529 @code{strftime} formats, the third parameter is required to be zero.
2530 Since non-static C++ methods have an implicit @code{this} argument, the
2531 arguments of such methods should be counted from two, not one, when
2532 giving values for @var{string-index} and @var{first-to-check}.
2534 In the example above, the format string (@code{my_format}) is the second
2535 argument of the function @code{my_print}, and the arguments to check
2536 start with the third argument, so the correct parameters for the format
2537 attribute are 2 and 3.
2539 @opindex ffreestanding
2540 @opindex fno-builtin
2541 The @code{format} attribute allows you to identify your own functions
2542 that take format strings as arguments, so that GCC can check the
2543 calls to these functions for errors.  The compiler always (unless
2544 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2545 for the standard library functions @code{printf}, @code{fprintf},
2546 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2547 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2548 warnings are requested (using @option{-Wformat}), so there is no need to
2549 modify the header file @file{stdio.h}.  In C99 mode, the functions
2550 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2551 @code{vsscanf} are also checked.  Except in strictly conforming C
2552 standard modes, the X/Open function @code{strfmon} is also checked as
2553 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2554 @xref{C Dialect Options,,Options Controlling C Dialect}.
2556 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2557 recognized in the same context.  Declarations including these format attributes
2558 are parsed for correct syntax, however the result of checking of such format
2559 strings is not yet defined, and is not carried out by this version of the
2560 compiler.
2562 The target may also provide additional types of format checks.
2563 @xref{Target Format Checks,,Format Checks Specific to Particular
2564 Target Machines}.
2566 @item format_arg (@var{string-index})
2567 @cindex @code{format_arg} function attribute
2568 @opindex Wformat-nonliteral
2569 The @code{format_arg} attribute specifies that a function takes a format
2570 string for a @code{printf}, @code{scanf}, @code{strftime} or
2571 @code{strfmon} style function and modifies it (for example, to translate
2572 it into another language), so the result can be passed to a
2573 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2574 function (with the remaining arguments to the format function the same
2575 as they would have been for the unmodified string).  For example, the
2576 declaration:
2578 @smallexample
2579 extern char *
2580 my_dgettext (char *my_domain, const char *my_format)
2581       __attribute__ ((format_arg (2)));
2582 @end smallexample
2584 @noindent
2585 causes the compiler to check the arguments in calls to a @code{printf},
2586 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2587 format string argument is a call to the @code{my_dgettext} function, for
2588 consistency with the format string argument @code{my_format}.  If the
2589 @code{format_arg} attribute had not been specified, all the compiler
2590 could tell in such calls to format functions would be that the format
2591 string argument is not constant; this would generate a warning when
2592 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2593 without the attribute.
2595 The parameter @var{string-index} specifies which argument is the format
2596 string argument (starting from one).  Since non-static C++ methods have
2597 an implicit @code{this} argument, the arguments of such methods should
2598 be counted from two.
2600 The @code{format_arg} attribute allows you to identify your own
2601 functions that modify format strings, so that GCC can check the
2602 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2603 type function whose operands are a call to one of your own function.
2604 The compiler always treats @code{gettext}, @code{dgettext}, and
2605 @code{dcgettext} in this manner except when strict ISO C support is
2606 requested by @option{-ansi} or an appropriate @option{-std} option, or
2607 @option{-ffreestanding} or @option{-fno-builtin}
2608 is used.  @xref{C Dialect Options,,Options
2609 Controlling C Dialect}.
2611 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2612 @code{NSString} reference for compatibility with the @code{format} attribute
2613 above.
2615 The target may also allow additional types in @code{format-arg} attributes.
2616 @xref{Target Format Checks,,Format Checks Specific to Particular
2617 Target Machines}.
2619 @item gnu_inline
2620 @cindex @code{gnu_inline} function attribute
2621 This attribute should be used with a function that is also declared
2622 with the @code{inline} keyword.  It directs GCC to treat the function
2623 as if it were defined in gnu90 mode even when compiling in C99 or
2624 gnu99 mode.
2626 If the function is declared @code{extern}, then this definition of the
2627 function is used only for inlining.  In no case is the function
2628 compiled as a standalone function, not even if you take its address
2629 explicitly.  Such an address becomes an external reference, as if you
2630 had only declared the function, and had not defined it.  This has
2631 almost the effect of a macro.  The way to use this is to put a
2632 function definition in a header file with this attribute, and put
2633 another copy of the function, without @code{extern}, in a library
2634 file.  The definition in the header file causes most calls to the
2635 function to be inlined.  If any uses of the function remain, they
2636 refer to the single copy in the library.  Note that the two
2637 definitions of the functions need not be precisely the same, although
2638 if they do not have the same effect your program may behave oddly.
2640 In C, if the function is neither @code{extern} nor @code{static}, then
2641 the function is compiled as a standalone function, as well as being
2642 inlined where possible.
2644 This is how GCC traditionally handled functions declared
2645 @code{inline}.  Since ISO C99 specifies a different semantics for
2646 @code{inline}, this function attribute is provided as a transition
2647 measure and as a useful feature in its own right.  This attribute is
2648 available in GCC 4.1.3 and later.  It is available if either of the
2649 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2650 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2651 Function is As Fast As a Macro}.
2653 In C++, this attribute does not depend on @code{extern} in any way,
2654 but it still requires the @code{inline} keyword to enable its special
2655 behavior.
2657 @item hot
2658 @cindex @code{hot} function attribute
2659 The @code{hot} attribute on a function is used to inform the compiler that
2660 the function is a hot spot of the compiled program.  The function is
2661 optimized more aggressively and on many targets it is placed into a special
2662 subsection of the text section so all hot functions appear close together,
2663 improving locality.
2665 When profile feedback is available, via @option{-fprofile-use}, hot functions
2666 are automatically detected and this attribute is ignored.
2668 @item ifunc ("@var{resolver}")
2669 @cindex @code{ifunc} function attribute
2670 @cindex indirect functions
2671 @cindex functions that are dynamically resolved
2672 The @code{ifunc} attribute is used to mark a function as an indirect
2673 function using the STT_GNU_IFUNC symbol type extension to the ELF
2674 standard.  This allows the resolution of the symbol value to be
2675 determined dynamically at load time, and an optimized version of the
2676 routine can be selected for the particular processor or other system
2677 characteristics determined then.  To use this attribute, first define
2678 the implementation functions available, and a resolver function that
2679 returns a pointer to the selected implementation function.  The
2680 implementation functions' declarations must match the API of the
2681 function being implemented, the resolver's declaration is be a
2682 function returning pointer to void function returning void:
2684 @smallexample
2685 void *my_memcpy (void *dst, const void *src, size_t len)
2687   @dots{}
2690 static void (*resolve_memcpy (void)) (void)
2692   return my_memcpy; // we'll just always select this routine
2694 @end smallexample
2696 @noindent
2697 The exported header file declaring the function the user calls would
2698 contain:
2700 @smallexample
2701 extern void *memcpy (void *, const void *, size_t);
2702 @end smallexample
2704 @noindent
2705 allowing the user to call this as a regular function, unaware of the
2706 implementation.  Finally, the indirect function needs to be defined in
2707 the same translation unit as the resolver function:
2709 @smallexample
2710 void *memcpy (void *, const void *, size_t)
2711      __attribute__ ((ifunc ("resolve_memcpy")));
2712 @end smallexample
2714 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2715 and GNU C Library version 2.11.1 are required to use this feature.
2717 @item interrupt
2718 @itemx interrupt_handler
2719 Many GCC back ends support attributes to indicate that a function is
2720 an interrupt handler, which tells the compiler to generate function
2721 entry and exit sequences that differ from those from regular
2722 functions.  The exact syntax and behavior are target-specific;
2723 refer to the following subsections for details.
2725 @item leaf
2726 @cindex @code{leaf} function attribute
2727 Calls to external functions with this attribute must return to the current
2728 compilation unit only by return or by exception handling.  In particular, leaf
2729 functions are not allowed to call callback function passed to it from the current
2730 compilation unit or directly call functions exported by the unit or longjmp
2731 into the unit.  Leaf function might still call functions from other compilation
2732 units and thus they are not necessarily leaf in the sense that they contain no
2733 function calls at all.
2735 The attribute is intended for library functions to improve dataflow analysis.
2736 The compiler takes the hint that any data not escaping the current compilation unit can
2737 not be used or modified by the leaf function.  For example, the @code{sin} function
2738 is a leaf function, but @code{qsort} is not.
2740 Note that leaf functions might invoke signals and signal handlers might be
2741 defined in the current compilation unit and use static variables.  The only
2742 compliant way to write such a signal handler is to declare such variables
2743 @code{volatile}.
2745 The attribute has no effect on functions defined within the current compilation
2746 unit.  This is to allow easy merging of multiple compilation units into one,
2747 for example, by using the link-time optimization.  For this reason the
2748 attribute is not allowed on types to annotate indirect calls.
2751 @item malloc
2752 @cindex @code{malloc} function attribute
2753 @cindex functions that behave like malloc
2754 This tells the compiler that a function is @code{malloc}-like, i.e.,
2755 that the pointer @var{P} returned by the function cannot alias any
2756 other pointer valid when the function returns, and moreover no
2757 pointers to valid objects occur in any storage addressed by @var{P}.
2759 Using this attribute can improve optimization.  Functions like
2760 @code{malloc} and @code{calloc} have this property because they return
2761 a pointer to uninitialized or zeroed-out storage.  However, functions
2762 like @code{realloc} do not have this property, as they can return a
2763 pointer to storage containing pointers.
2765 @item no_icf
2766 @cindex @code{no_icf} function attribute
2767 This function attribute prevents a functions from being merged with another
2768 semantically equivalent function.
2770 @item no_instrument_function
2771 @cindex @code{no_instrument_function} function attribute
2772 @opindex finstrument-functions
2773 If @option{-finstrument-functions} is given, profiling function calls are
2774 generated at entry and exit of most user-compiled functions.
2775 Functions with this attribute are not so instrumented.
2777 @item no_reorder
2778 @cindex @code{no_reorder} function attribute
2779 Do not reorder functions or variables marked @code{no_reorder}
2780 against each other or top level assembler statements the executable.
2781 The actual order in the program will depend on the linker command
2782 line. Static variables marked like this are also not removed.
2783 This has a similar effect
2784 as the @option{-fno-toplevel-reorder} option, but only applies to the
2785 marked symbols.
2787 @item no_sanitize_address
2788 @itemx no_address_safety_analysis
2789 @cindex @code{no_sanitize_address} function attribute
2790 The @code{no_sanitize_address} attribute on functions is used
2791 to inform the compiler that it should not instrument memory accesses
2792 in the function when compiling with the @option{-fsanitize=address} option.
2793 The @code{no_address_safety_analysis} is a deprecated alias of the
2794 @code{no_sanitize_address} attribute, new code should use
2795 @code{no_sanitize_address}.
2797 @item no_sanitize_thread
2798 @cindex @code{no_sanitize_thread} function attribute
2799 The @code{no_sanitize_thread} attribute on functions is used
2800 to inform the compiler that it should not instrument memory accesses
2801 in the function when compiling with the @option{-fsanitize=thread} option.
2803 @item no_sanitize_undefined
2804 @cindex @code{no_sanitize_undefined} function attribute
2805 The @code{no_sanitize_undefined} attribute on functions is used
2806 to inform the compiler that it should not check for undefined behavior
2807 in the function when compiling with the @option{-fsanitize=undefined} option.
2809 @item no_split_stack
2810 @cindex @code{no_split_stack} function attribute
2811 @opindex fsplit-stack
2812 If @option{-fsplit-stack} is given, functions have a small
2813 prologue which decides whether to split the stack.  Functions with the
2814 @code{no_split_stack} attribute do not have that prologue, and thus
2815 may run with only a small amount of stack space available.
2817 @item noclone
2818 @cindex @code{noclone} function attribute
2819 This function attribute prevents a function from being considered for
2820 cloning---a mechanism that produces specialized copies of functions
2821 and which is (currently) performed by interprocedural constant
2822 propagation.
2824 @item noinline
2825 @cindex @code{noinline} function attribute
2826 This function attribute prevents a function from being considered for
2827 inlining.
2828 @c Don't enumerate the optimizations by name here; we try to be
2829 @c future-compatible with this mechanism.
2830 If the function does not have side-effects, there are optimizations
2831 other than inlining that cause function calls to be optimized away,
2832 although the function call is live.  To keep such calls from being
2833 optimized away, put
2834 @smallexample
2835 asm ("");
2836 @end smallexample
2838 @noindent
2839 (@pxref{Extended Asm}) in the called function, to serve as a special
2840 side-effect.
2842 @item nonnull (@var{arg-index}, @dots{})
2843 @cindex @code{nonnull} function attribute
2844 @cindex functions with non-null pointer arguments
2845 The @code{nonnull} attribute specifies that some function parameters should
2846 be non-null pointers.  For instance, the declaration:
2848 @smallexample
2849 extern void *
2850 my_memcpy (void *dest, const void *src, size_t len)
2851         __attribute__((nonnull (1, 2)));
2852 @end smallexample
2854 @noindent
2855 causes the compiler to check that, in calls to @code{my_memcpy},
2856 arguments @var{dest} and @var{src} are non-null.  If the compiler
2857 determines that a null pointer is passed in an argument slot marked
2858 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2859 is issued.  The compiler may also choose to make optimizations based
2860 on the knowledge that certain function arguments will never be null.
2862 If no argument index list is given to the @code{nonnull} attribute,
2863 all pointer arguments are marked as non-null.  To illustrate, the
2864 following declaration is equivalent to the previous example:
2866 @smallexample
2867 extern void *
2868 my_memcpy (void *dest, const void *src, size_t len)
2869         __attribute__((nonnull));
2870 @end smallexample
2872 @item noreturn
2873 @cindex @code{noreturn} function attribute
2874 @cindex functions that never return
2875 A few standard library functions, such as @code{abort} and @code{exit},
2876 cannot return.  GCC knows this automatically.  Some programs define
2877 their own functions that never return.  You can declare them
2878 @code{noreturn} to tell the compiler this fact.  For example,
2880 @smallexample
2881 @group
2882 void fatal () __attribute__ ((noreturn));
2884 void
2885 fatal (/* @r{@dots{}} */)
2887   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2888   exit (1);
2890 @end group
2891 @end smallexample
2893 The @code{noreturn} keyword tells the compiler to assume that
2894 @code{fatal} cannot return.  It can then optimize without regard to what
2895 would happen if @code{fatal} ever did return.  This makes slightly
2896 better code.  More importantly, it helps avoid spurious warnings of
2897 uninitialized variables.
2899 The @code{noreturn} keyword does not affect the exceptional path when that
2900 applies: a @code{noreturn}-marked function may still return to the caller
2901 by throwing an exception or calling @code{longjmp}.
2903 Do not assume that registers saved by the calling function are
2904 restored before calling the @code{noreturn} function.
2906 It does not make sense for a @code{noreturn} function to have a return
2907 type other than @code{void}.
2909 @item nothrow
2910 @cindex @code{nothrow} function attribute
2911 The @code{nothrow} attribute is used to inform the compiler that a
2912 function cannot throw an exception.  For example, most functions in
2913 the standard C library can be guaranteed not to throw an exception
2914 with the notable exceptions of @code{qsort} and @code{bsearch} that
2915 take function pointer arguments.
2917 @item optimize
2918 @cindex @code{optimize} function attribute
2919 The @code{optimize} attribute is used to specify that a function is to
2920 be compiled with different optimization options than specified on the
2921 command line.  Arguments can either be numbers or strings.  Numbers
2922 are assumed to be an optimization level.  Strings that begin with
2923 @code{O} are assumed to be an optimization option, while other options
2924 are assumed to be used with a @code{-f} prefix.  You can also use the
2925 @samp{#pragma GCC optimize} pragma to set the optimization options
2926 that affect more than one function.
2927 @xref{Function Specific Option Pragmas}, for details about the
2928 @samp{#pragma GCC optimize} pragma.
2930 This can be used for instance to have frequently-executed functions
2931 compiled with more aggressive optimization options that produce faster
2932 and larger code, while other functions can be compiled with less
2933 aggressive options.
2935 @item pure
2936 @cindex @code{pure} function attribute
2937 @cindex functions that have no side effects
2938 Many functions have no effects except the return value and their
2939 return value depends only on the parameters and/or global variables.
2940 Such a function can be subject
2941 to common subexpression elimination and loop optimization just as an
2942 arithmetic operator would be.  These functions should be declared
2943 with the attribute @code{pure}.  For example,
2945 @smallexample
2946 int square (int) __attribute__ ((pure));
2947 @end smallexample
2949 @noindent
2950 says that the hypothetical function @code{square} is safe to call
2951 fewer times than the program says.
2953 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
2954 Interesting non-pure functions are functions with infinite loops or those
2955 depending on volatile memory or other system resource, that may change between
2956 two consecutive calls (such as @code{feof} in a multithreading environment).
2958 @item returns_nonnull
2959 @cindex @code{returns_nonnull} function attribute
2960 The @code{returns_nonnull} attribute specifies that the function
2961 return value should be a non-null pointer.  For instance, the declaration:
2963 @smallexample
2964 extern void *
2965 mymalloc (size_t len) __attribute__((returns_nonnull));
2966 @end smallexample
2968 @noindent
2969 lets the compiler optimize callers based on the knowledge
2970 that the return value will never be null.
2972 @item returns_twice
2973 @cindex @code{returns_twice} function attribute
2974 @cindex functions that return more than once
2975 The @code{returns_twice} attribute tells the compiler that a function may
2976 return more than one time.  The compiler ensures that all registers
2977 are dead before calling such a function and emits a warning about
2978 the variables that may be clobbered after the second return from the
2979 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
2980 The @code{longjmp}-like counterpart of such function, if any, might need
2981 to be marked with the @code{noreturn} attribute.
2983 @item section ("@var{section-name}")
2984 @cindex @code{section} function attribute
2985 @cindex functions in arbitrary sections
2986 Normally, the compiler places the code it generates in the @code{text} section.
2987 Sometimes, however, you need additional sections, or you need certain
2988 particular functions to appear in special sections.  The @code{section}
2989 attribute specifies that a function lives in a particular section.
2990 For example, the declaration:
2992 @smallexample
2993 extern void foobar (void) __attribute__ ((section ("bar")));
2994 @end smallexample
2996 @noindent
2997 puts the function @code{foobar} in the @code{bar} section.
2999 Some file formats do not support arbitrary sections so the @code{section}
3000 attribute is not available on all platforms.
3001 If you need to map the entire contents of a module to a particular
3002 section, consider using the facilities of the linker instead.
3004 @item sentinel
3005 @cindex @code{sentinel} function attribute
3006 This function attribute ensures that a parameter in a function call is
3007 an explicit @code{NULL}.  The attribute is only valid on variadic
3008 functions.  By default, the sentinel is located at position zero, the
3009 last parameter of the function call.  If an optional integer position
3010 argument P is supplied to the attribute, the sentinel must be located at
3011 position P counting backwards from the end of the argument list.
3013 @smallexample
3014 __attribute__ ((sentinel))
3015 is equivalent to
3016 __attribute__ ((sentinel(0)))
3017 @end smallexample
3019 The attribute is automatically set with a position of 0 for the built-in
3020 functions @code{execl} and @code{execlp}.  The built-in function
3021 @code{execle} has the attribute set with a position of 1.
3023 A valid @code{NULL} in this context is defined as zero with any pointer
3024 type.  If your system defines the @code{NULL} macro with an integer type
3025 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3026 with a copy that redefines NULL appropriately.
3028 The warnings for missing or incorrect sentinels are enabled with
3029 @option{-Wformat}.
3031 @item stack_protect
3032 @cindex @code{stack_protect} function attribute
3033 This function attribute make a stack protection of the function if 
3034 flags @option{fstack-protector} or @option{fstack-protector-strong}
3035 or @option{fstack-protector-explicit} are set.
3037 @item target (@var{options})
3038 @cindex @code{target} function attribute
3039 Multiple target back ends implement the @code{target} attribute
3040 to specify that a function is to
3041 be compiled with different target options than specified on the
3042 command line.  This can be used for instance to have functions
3043 compiled with a different ISA (instruction set architecture) than the
3044 default.  You can also use the @samp{#pragma GCC target} pragma to set
3045 more than one function to be compiled with specific target options.
3046 @xref{Function Specific Option Pragmas}, for details about the
3047 @samp{#pragma GCC target} pragma.
3049 For instance, on an x86, you could declare one function with the
3050 @code{target("sse4.1,arch=core2")} attribute and another with
3051 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3052 compiling the first function with @option{-msse4.1} and
3053 @option{-march=core2} options, and the second function with
3054 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3055 to make sure that a function is only invoked on a machine that
3056 supports the particular ISA it is compiled for (for example by using
3057 @code{cpuid} on x86 to determine what feature bits and architecture
3058 family are used).
3060 @smallexample
3061 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3062 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3063 @end smallexample
3065 You can either use multiple
3066 strings separated by commas to specify multiple options,
3067 or separate the options with a comma (@samp{,}) within a single string.
3069 The options supported are specific to each target; refer to @ref{x86
3070 Function Attributes}, @ref{PowerPC Function Attributes}, and
3071 @ref{Nios II Function Attributes}, for details.
3073 @item unused
3074 @cindex @code{unused} function attribute
3075 This attribute, attached to a function, means that the function is meant
3076 to be possibly unused.  GCC does not produce a warning for this
3077 function.
3079 @item used
3080 @cindex @code{used} function attribute
3081 This attribute, attached to a function, means that code must be emitted
3082 for the function even if it appears that the function is not referenced.
3083 This is useful, for example, when the function is referenced only in
3084 inline assembly.
3086 When applied to a member function of a C++ class template, the
3087 attribute also means that the function is instantiated if the
3088 class itself is instantiated.
3090 @item visibility ("@var{visibility_type}")
3091 @cindex @code{visibility} function attribute
3092 This attribute affects the linkage of the declaration to which it is attached.
3093 There are four supported @var{visibility_type} values: default,
3094 hidden, protected or internal visibility.
3096 @smallexample
3097 void __attribute__ ((visibility ("protected")))
3098 f () @{ /* @r{Do something.} */; @}
3099 int i __attribute__ ((visibility ("hidden")));
3100 @end smallexample
3102 The possible values of @var{visibility_type} correspond to the
3103 visibility settings in the ELF gABI.
3105 @table @code
3106 @c keep this list of visibilities in alphabetical order.
3108 @item default
3109 Default visibility is the normal case for the object file format.
3110 This value is available for the visibility attribute to override other
3111 options that may change the assumed visibility of entities.
3113 On ELF, default visibility means that the declaration is visible to other
3114 modules and, in shared libraries, means that the declared entity may be
3115 overridden.
3117 On Darwin, default visibility means that the declaration is visible to
3118 other modules.
3120 Default visibility corresponds to ``external linkage'' in the language.
3122 @item hidden
3123 Hidden visibility indicates that the entity declared has a new
3124 form of linkage, which we call ``hidden linkage''.  Two
3125 declarations of an object with hidden linkage refer to the same object
3126 if they are in the same shared object.
3128 @item internal
3129 Internal visibility is like hidden visibility, but with additional
3130 processor specific semantics.  Unless otherwise specified by the
3131 psABI, GCC defines internal visibility to mean that a function is
3132 @emph{never} called from another module.  Compare this with hidden
3133 functions which, while they cannot be referenced directly by other
3134 modules, can be referenced indirectly via function pointers.  By
3135 indicating that a function cannot be called from outside the module,
3136 GCC may for instance omit the load of a PIC register since it is known
3137 that the calling function loaded the correct value.
3139 @item protected
3140 Protected visibility is like default visibility except that it
3141 indicates that references within the defining module bind to the
3142 definition in that module.  That is, the declared entity cannot be
3143 overridden by another module.
3145 @end table
3147 All visibilities are supported on many, but not all, ELF targets
3148 (supported when the assembler supports the @samp{.visibility}
3149 pseudo-op).  Default visibility is supported everywhere.  Hidden
3150 visibility is supported on Darwin targets.
3152 The visibility attribute should be applied only to declarations that
3153 would otherwise have external linkage.  The attribute should be applied
3154 consistently, so that the same entity should not be declared with
3155 different settings of the attribute.
3157 In C++, the visibility attribute applies to types as well as functions
3158 and objects, because in C++ types have linkage.  A class must not have
3159 greater visibility than its non-static data member types and bases,
3160 and class members default to the visibility of their class.  Also, a
3161 declaration without explicit visibility is limited to the visibility
3162 of its type.
3164 In C++, you can mark member functions and static member variables of a
3165 class with the visibility attribute.  This is useful if you know a
3166 particular method or static member variable should only be used from
3167 one shared object; then you can mark it hidden while the rest of the
3168 class has default visibility.  Care must be taken to avoid breaking
3169 the One Definition Rule; for example, it is usually not useful to mark
3170 an inline method as hidden without marking the whole class as hidden.
3172 A C++ namespace declaration can also have the visibility attribute.
3174 @smallexample
3175 namespace nspace1 __attribute__ ((visibility ("protected")))
3176 @{ /* @r{Do something.} */; @}
3177 @end smallexample
3179 This attribute applies only to the particular namespace body, not to
3180 other definitions of the same namespace; it is equivalent to using
3181 @samp{#pragma GCC visibility} before and after the namespace
3182 definition (@pxref{Visibility Pragmas}).
3184 In C++, if a template argument has limited visibility, this
3185 restriction is implicitly propagated to the template instantiation.
3186 Otherwise, template instantiations and specializations default to the
3187 visibility of their template.
3189 If both the template and enclosing class have explicit visibility, the
3190 visibility from the template is used.
3192 @item warn_unused_result
3193 @cindex @code{warn_unused_result} function attribute
3194 The @code{warn_unused_result} attribute causes a warning to be emitted
3195 if a caller of the function with this attribute does not use its
3196 return value.  This is useful for functions where not checking
3197 the result is either a security problem or always a bug, such as
3198 @code{realloc}.
3200 @smallexample
3201 int fn () __attribute__ ((warn_unused_result));
3202 int foo ()
3204   if (fn () < 0) return -1;
3205   fn ();
3206   return 0;
3208 @end smallexample
3210 @noindent
3211 results in warning on line 5.
3213 @item weak
3214 @cindex @code{weak} function attribute
3215 The @code{weak} attribute causes the declaration to be emitted as a weak
3216 symbol rather than a global.  This is primarily useful in defining
3217 library functions that can be overridden in user code, though it can
3218 also be used with non-function declarations.  Weak symbols are supported
3219 for ELF targets, and also for a.out targets when using the GNU assembler
3220 and linker.
3222 @item weakref
3223 @itemx weakref ("@var{target}")
3224 @cindex @code{weakref} function attribute
3225 The @code{weakref} attribute marks a declaration as a weak reference.
3226 Without arguments, it should be accompanied by an @code{alias} attribute
3227 naming the target symbol.  Optionally, the @var{target} may be given as
3228 an argument to @code{weakref} itself.  In either case, @code{weakref}
3229 implicitly marks the declaration as @code{weak}.  Without a
3230 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3231 @code{weakref} is equivalent to @code{weak}.
3233 @smallexample
3234 static int x() __attribute__ ((weakref ("y")));
3235 /* is equivalent to... */
3236 static int x() __attribute__ ((weak, weakref, alias ("y")));
3237 /* and to... */
3238 static int x() __attribute__ ((weakref));
3239 static int x() __attribute__ ((alias ("y")));
3240 @end smallexample
3242 A weak reference is an alias that does not by itself require a
3243 definition to be given for the target symbol.  If the target symbol is
3244 only referenced through weak references, then it becomes a @code{weak}
3245 undefined symbol.  If it is directly referenced, however, then such
3246 strong references prevail, and a definition is required for the
3247 symbol, not necessarily in the same translation unit.
3249 The effect is equivalent to moving all references to the alias to a
3250 separate translation unit, renaming the alias to the aliased symbol,
3251 declaring it as weak, compiling the two separate translation units and
3252 performing a reloadable link on them.
3254 At present, a declaration to which @code{weakref} is attached can
3255 only be @code{static}.
3257 @end table
3259 @c This is the end of the target-independent attribute table
3262 @node ARC Function Attributes
3263 @subsection ARC Function Attributes
3265 These function attributes are supported by the ARC back end:
3267 @table @code
3268 @item interrupt
3269 @cindex @code{interrupt} function attribute, ARC
3270 Use this attribute to indicate
3271 that the specified function is an interrupt handler.  The compiler generates
3272 function entry and exit sequences suitable for use in an interrupt handler
3273 when this attribute is present.
3275 On the ARC, you must specify the kind of interrupt to be handled
3276 in a parameter to the interrupt attribute like this:
3278 @smallexample
3279 void f () __attribute__ ((interrupt ("ilink1")));
3280 @end smallexample
3282 Permissible values for this parameter are: @w{@code{ilink1}} and
3283 @w{@code{ilink2}}.
3285 @item long_call
3286 @itemx medium_call
3287 @itemx short_call
3288 @cindex @code{long_call} function attribute, ARC
3289 @cindex @code{medium_call} function attribute, ARC
3290 @cindex @code{short_call} function attribute, ARC
3291 @cindex indirect calls, ARC
3292 These attributes specify how a particular function is called.
3293 These attributes override the
3294 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3295 command-line switches and @code{#pragma long_calls} settings.
3297 For ARC, a function marked with the @code{long_call} attribute is
3298 always called using register-indirect jump-and-link instructions,
3299 thereby enabling the called function to be placed anywhere within the
3300 32-bit address space.  A function marked with the @code{medium_call}
3301 attribute will always be close enough to be called with an unconditional
3302 branch-and-link instruction, which has a 25-bit offset from
3303 the call site.  A function marked with the @code{short_call}
3304 attribute will always be close enough to be called with a conditional
3305 branch-and-link instruction, which has a 21-bit offset from
3306 the call site.
3307 @end table
3309 @node ARM Function Attributes
3310 @subsection ARM Function Attributes
3312 These function attributes are supported for ARM targets:
3314 @table @code
3315 @item interrupt
3316 @cindex @code{interrupt} function attribute, ARM
3317 Use this attribute to indicate
3318 that the specified function is an interrupt handler.  The compiler generates
3319 function entry and exit sequences suitable for use in an interrupt handler
3320 when this attribute is present.
3322 You can specify the kind of interrupt to be handled by
3323 adding an optional parameter to the interrupt attribute like this:
3325 @smallexample
3326 void f () __attribute__ ((interrupt ("IRQ")));
3327 @end smallexample
3329 @noindent
3330 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3331 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3333 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3334 may be called with a word-aligned stack pointer.
3336 @item isr
3337 @cindex @code{isr} function attribute, ARM
3338 Use this attribute on ARM to write Interrupt Service Routines. This is an
3339 alias to the @code{interrupt} attribute above.
3341 @item long_call
3342 @itemx short_call
3343 @cindex @code{long_call} function attribute, ARM
3344 @cindex @code{short_call} function attribute, ARM
3345 @cindex indirect calls, ARM
3346 These attributes specify how a particular function is called.
3347 These attributes override the
3348 @option{-mlong-calls} (@pxref{ARM Options})
3349 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3350 @code{long_call} attribute indicates that the function might be far
3351 away from the call site and require a different (more expensive)
3352 calling sequence.   The @code{short_call} attribute always places
3353 the offset to the function from the call site into the @samp{BL}
3354 instruction directly.
3356 @item naked
3357 @cindex @code{naked} function attribute, ARM
3358 This attribute allows the compiler to construct the
3359 requisite function declaration, while allowing the body of the
3360 function to be assembly code. The specified function will not have
3361 prologue/epilogue sequences generated by the compiler. Only basic
3362 @code{asm} statements can safely be included in naked functions
3363 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3364 basic @code{asm} and C code may appear to work, they cannot be
3365 depended upon to work reliably and are not supported.
3367 @item pcs
3368 @cindex @code{pcs} function attribute, ARM
3370 The @code{pcs} attribute can be used to control the calling convention
3371 used for a function on ARM.  The attribute takes an argument that specifies
3372 the calling convention to use.
3374 When compiling using the AAPCS ABI (or a variant of it) then valid
3375 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3376 order to use a variant other than @code{"aapcs"} then the compiler must
3377 be permitted to use the appropriate co-processor registers (i.e., the
3378 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3379 For example,
3381 @smallexample
3382 /* Argument passed in r0, and result returned in r0+r1.  */
3383 double f2d (float) __attribute__((pcs("aapcs")));
3384 @end smallexample
3386 Variadic functions always use the @code{"aapcs"} calling convention and
3387 the compiler rejects attempts to specify an alternative.
3388 @end table
3390 @node AVR Function Attributes
3391 @subsection AVR Function Attributes
3393 These function attributes are supported by the AVR back end:
3395 @table @code
3396 @item interrupt
3397 @cindex @code{interrupt} function attribute, AVR
3398 Use this attribute to indicate
3399 that the specified function is an interrupt handler.  The compiler generates
3400 function entry and exit sequences suitable for use in an interrupt handler
3401 when this attribute is present.
3403 On the AVR, the hardware globally disables interrupts when an
3404 interrupt is executed.  The first instruction of an interrupt handler
3405 declared with this attribute is a @code{SEI} instruction to
3406 re-enable interrupts.  See also the @code{signal} function attribute
3407 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3408 @code{interrupt} are specified for the same function, @code{signal}
3409 is silently ignored.
3411 @item naked
3412 @cindex @code{naked} function attribute, AVR
3413 This attribute allows the compiler to construct the
3414 requisite function declaration, while allowing the body of the
3415 function to be assembly code. The specified function will not have
3416 prologue/epilogue sequences generated by the compiler. Only basic
3417 @code{asm} statements can safely be included in naked functions
3418 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3419 basic @code{asm} and C code may appear to work, they cannot be
3420 depended upon to work reliably and are not supported.
3422 @item OS_main
3423 @itemx OS_task
3424 @cindex @code{OS_main} function attribute, AVR
3425 @cindex @code{OS_task} function attribute, AVR
3426 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3427 do not save/restore any call-saved register in their prologue/epilogue.
3429 The @code{OS_main} attribute can be used when there @emph{is
3430 guarantee} that interrupts are disabled at the time when the function
3431 is entered.  This saves resources when the stack pointer has to be
3432 changed to set up a frame for local variables.
3434 The @code{OS_task} attribute can be used when there is @emph{no
3435 guarantee} that interrupts are disabled at that time when the function
3436 is entered like for, e@.g@. task functions in a multi-threading operating
3437 system. In that case, changing the stack pointer register is
3438 guarded by save/clear/restore of the global interrupt enable flag.
3440 The differences to the @code{naked} function attribute are:
3441 @itemize @bullet
3442 @item @code{naked} functions do not have a return instruction whereas 
3443 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3444 @code{RETI} return instruction.
3445 @item @code{naked} functions do not set up a frame for local variables
3446 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3447 as needed.
3448 @end itemize
3450 @item signal
3451 @cindex @code{signal} function attribute, AVR
3452 Use this attribute on the AVR to indicate that the specified
3453 function is an interrupt handler.  The compiler generates function
3454 entry and exit sequences suitable for use in an interrupt handler when this
3455 attribute is present.
3457 See also the @code{interrupt} function attribute. 
3459 The AVR hardware globally disables interrupts when an interrupt is executed.
3460 Interrupt handler functions defined with the @code{signal} attribute
3461 do not re-enable interrupts.  It is save to enable interrupts in a
3462 @code{signal} handler.  This ``save'' only applies to the code
3463 generated by the compiler and not to the IRQ layout of the
3464 application which is responsibility of the application.
3466 If both @code{signal} and @code{interrupt} are specified for the same
3467 function, @code{signal} is silently ignored.
3468 @end table
3470 @node Blackfin Function Attributes
3471 @subsection Blackfin Function Attributes
3473 These function attributes are supported by the Blackfin back end:
3475 @table @code
3477 @item exception_handler
3478 @cindex @code{exception_handler} function attribute
3479 @cindex exception handler functions, Blackfin
3480 Use this attribute on the Blackfin to indicate that the specified function
3481 is an exception handler.  The compiler generates function entry and
3482 exit sequences suitable for use in an exception handler when this
3483 attribute is present.
3485 @item interrupt_handler
3486 @cindex @code{interrupt_handler} function attribute, Blackfin
3487 Use this attribute to
3488 indicate that the specified function is an interrupt handler.  The compiler
3489 generates function entry and exit sequences suitable for use in an
3490 interrupt handler when this attribute is present.
3492 @item kspisusp
3493 @cindex @code{kspisusp} function attribute, Blackfin
3494 @cindex User stack pointer in interrupts on the Blackfin
3495 When used together with @code{interrupt_handler}, @code{exception_handler}
3496 or @code{nmi_handler}, code is generated to load the stack pointer
3497 from the USP register in the function prologue.
3499 @item l1_text
3500 @cindex @code{l1_text} function attribute, Blackfin
3501 This attribute specifies a function to be placed into L1 Instruction
3502 SRAM@. The function is put into a specific section named @code{.l1.text}.
3503 With @option{-mfdpic}, function calls with a such function as the callee
3504 or caller uses inlined PLT.
3506 @item l2
3507 @cindex @code{l2} function attribute, Blackfin
3508 This attribute specifies a function to be placed into L2
3509 SRAM. The function is put into a specific section named
3510 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3511 an inlined PLT.
3513 @item longcall
3514 @itemx shortcall
3515 @cindex indirect calls, Blackfin
3516 @cindex @code{longcall} function attribute, Blackfin
3517 @cindex @code{shortcall} function attribute, Blackfin
3518 The @code{longcall} attribute
3519 indicates that the function might be far away from the call site and
3520 require a different (more expensive) calling sequence.  The
3521 @code{shortcall} attribute indicates that the function is always close
3522 enough for the shorter calling sequence to be used.  These attributes
3523 override the @option{-mlongcall} switch.
3525 @item nesting
3526 @cindex @code{nesting} function attribute, Blackfin
3527 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3528 Use this attribute together with @code{interrupt_handler},
3529 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3530 entry code should enable nested interrupts or exceptions.
3532 @item nmi_handler
3533 @cindex @code{nmi_handler} function attribute, Blackfin
3534 @cindex NMI handler functions on the Blackfin processor
3535 Use this attribute on the Blackfin to indicate that the specified function
3536 is an NMI handler.  The compiler generates function entry and
3537 exit sequences suitable for use in an NMI handler when this
3538 attribute is present.
3540 @item saveall
3541 @cindex @code{saveall} function attribute, Blackfin
3542 @cindex save all registers on the Blackfin
3543 Use this attribute to indicate that
3544 all registers except the stack pointer should be saved in the prologue
3545 regardless of whether they are used or not.
3546 @end table
3548 @node CR16 Function Attributes
3549 @subsection CR16 Function Attributes
3551 These function attributes are supported by the CR16 back end:
3553 @table @code
3554 @item interrupt
3555 @cindex @code{interrupt} function attribute, CR16
3556 Use this attribute to indicate
3557 that the specified function is an interrupt handler.  The compiler generates
3558 function entry and exit sequences suitable for use in an interrupt handler
3559 when this attribute is present.
3560 @end table
3562 @node Epiphany Function Attributes
3563 @subsection Epiphany Function Attributes
3565 These function attributes are supported by the Epiphany back end:
3567 @table @code
3568 @item disinterrupt
3569 @cindex @code{disinterrupt} function attribute, Epiphany
3570 This attribute causes the compiler to emit
3571 instructions to disable interrupts for the duration of the given
3572 function.
3574 @item forwarder_section
3575 @cindex @code{forwarder_section} function attribute, Epiphany
3576 This attribute modifies the behavior of an interrupt handler.
3577 The interrupt handler may be in external memory which cannot be
3578 reached by a branch instruction, so generate a local memory trampoline
3579 to transfer control.  The single parameter identifies the section where
3580 the trampoline is placed.
3582 @item interrupt
3583 @cindex @code{interrupt} function attribute, Epiphany
3584 Use this attribute to indicate
3585 that the specified function is an interrupt handler.  The compiler generates
3586 function entry and exit sequences suitable for use in an interrupt handler
3587 when this attribute is present.  It may also generate
3588 a special section with code to initialize the interrupt vector table.
3590 On Epiphany targets one or more optional parameters can be added like this:
3592 @smallexample
3593 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3594 @end smallexample
3596 Permissible values for these parameters are: @w{@code{reset}},
3597 @w{@code{software_exception}}, @w{@code{page_miss}},
3598 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3599 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3600 Multiple parameters indicate that multiple entries in the interrupt
3601 vector table should be initialized for this function, i.e.@: for each
3602 parameter @w{@var{name}}, a jump to the function is emitted in
3603 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3604 entirely, in which case no interrupt vector table entry is provided.
3606 Note that interrupts are enabled inside the function
3607 unless the @code{disinterrupt} attribute is also specified.
3609 The following examples are all valid uses of these attributes on
3610 Epiphany targets:
3611 @smallexample
3612 void __attribute__ ((interrupt)) universal_handler ();
3613 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3614 void __attribute__ ((interrupt ("dma0, dma1"))) 
3615   universal_dma_handler ();
3616 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3617   fast_timer_handler ();
3618 void __attribute__ ((interrupt ("dma0, dma1"), 
3619                      forwarder_section ("tramp")))
3620   external_dma_handler ();
3621 @end smallexample
3623 @item long_call
3624 @itemx short_call
3625 @cindex @code{long_call} function attribute, Epiphany
3626 @cindex @code{short_call} function attribute, Epiphany
3627 @cindex indirect calls, Epiphany
3628 These attributes specify how a particular function is called.
3629 These attributes override the
3630 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3631 command-line switch and @code{#pragma long_calls} settings.
3632 @end table
3635 @node H8/300 Function Attributes
3636 @subsection H8/300 Function Attributes
3638 These function attributes are available for H8/300 targets:
3640 @table @code
3641 @item function_vector
3642 @cindex @code{function_vector} function attribute, H8/300
3643 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
3644 that the specified function should be called through the function vector.
3645 Calling a function through the function vector reduces code size; however,
3646 the function vector has a limited size (maximum 128 entries on the H8/300
3647 and 64 entries on the H8/300H and H8S)
3648 and shares space with the interrupt vector.
3650 @item interrupt_handler
3651 @cindex @code{interrupt_handler} function attribute, H8/300
3652 Use this attribute on the H8/300, H8/300H, and H8S to
3653 indicate that the specified function is an interrupt handler.  The compiler
3654 generates function entry and exit sequences suitable for use in an
3655 interrupt handler when this attribute is present.
3657 @item saveall
3658 @cindex @code{saveall} function attribute, H8/300
3659 @cindex save all registers on the H8/300, H8/300H, and H8S
3660 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3661 all registers except the stack pointer should be saved in the prologue
3662 regardless of whether they are used or not.
3663 @end table
3665 @node IA-64 Function Attributes
3666 @subsection IA-64 Function Attributes
3668 These function attributes are supported on IA-64 targets:
3670 @table @code
3671 @item syscall_linkage
3672 @cindex @code{syscall_linkage} function attribute, IA-64
3673 This attribute is used to modify the IA-64 calling convention by marking
3674 all input registers as live at all function exits.  This makes it possible
3675 to restart a system call after an interrupt without having to save/restore
3676 the input registers.  This also prevents kernel data from leaking into
3677 application code.
3679 @item version_id
3680 @cindex @code{version_id} function attribute, IA-64
3681 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
3682 symbol to contain a version string, thus allowing for function level
3683 versioning.  HP-UX system header files may use function level versioning
3684 for some system calls.
3686 @smallexample
3687 extern int foo () __attribute__((version_id ("20040821")));
3688 @end smallexample
3690 @noindent
3691 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
3692 @end table
3694 @node M32C Function Attributes
3695 @subsection M32C Function Attributes
3697 These function attributes are supported by the M32C back end:
3699 @table @code
3700 @item bank_switch
3701 @cindex @code{bank_switch} function attribute, M32C
3702 When added to an interrupt handler with the M32C port, causes the
3703 prologue and epilogue to use bank switching to preserve the registers
3704 rather than saving them on the stack.
3706 @item fast_interrupt
3707 @cindex @code{fast_interrupt} function attribute, M32C
3708 Use this attribute on the M32C port to indicate that the specified
3709 function is a fast interrupt handler.  This is just like the
3710 @code{interrupt} attribute, except that @code{freit} is used to return
3711 instead of @code{reit}.
3713 @item function_vector
3714 @cindex @code{function_vector} function attribute, M16C/M32C
3715 On M16C/M32C targets, the @code{function_vector} attribute declares a
3716 special page subroutine call function. Use of this attribute reduces
3717 the code size by 2 bytes for each call generated to the
3718 subroutine. The argument to the attribute is the vector number entry
3719 from the special page vector table which contains the 16 low-order
3720 bits of the subroutine's entry address. Each vector table has special
3721 page number (18 to 255) that is used in @code{jsrs} instructions.
3722 Jump addresses of the routines are generated by adding 0x0F0000 (in
3723 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
3724 2-byte addresses set in the vector table. Therefore you need to ensure
3725 that all the special page vector routines should get mapped within the
3726 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
3727 (for M32C).
3729 In the following example 2 bytes are saved for each call to
3730 function @code{foo}.
3732 @smallexample
3733 void foo (void) __attribute__((function_vector(0x18)));
3734 void foo (void)
3738 void bar (void)
3740     foo();
3742 @end smallexample
3744 If functions are defined in one file and are called in another file,
3745 then be sure to write this declaration in both files.
3747 This attribute is ignored for R8C target.
3749 @item interrupt
3750 @cindex @code{interrupt} function attribute, M32C
3751 Use this attribute to indicate
3752 that the specified function is an interrupt handler.  The compiler generates
3753 function entry and exit sequences suitable for use in an interrupt handler
3754 when this attribute is present.
3755 @end table
3757 @node M32R/D Function Attributes
3758 @subsection M32R/D Function Attributes
3760 These function attributes are supported by the M32R/D back end:
3762 @table @code
3763 @item interrupt
3764 @cindex @code{interrupt} function attribute, M32R/D
3765 Use this attribute to indicate
3766 that the specified function is an interrupt handler.  The compiler generates
3767 function entry and exit sequences suitable for use in an interrupt handler
3768 when this attribute is present.
3770 @item model (@var{model-name})
3771 @cindex @code{model} function attribute, M32R/D
3772 @cindex function addressability on the M32R/D
3774 On the M32R/D, use this attribute to set the addressability of an
3775 object, and of the code generated for a function.  The identifier
3776 @var{model-name} is one of @code{small}, @code{medium}, or
3777 @code{large}, representing each of the code models.
3779 Small model objects live in the lower 16MB of memory (so that their
3780 addresses can be loaded with the @code{ld24} instruction), and are
3781 callable with the @code{bl} instruction.
3783 Medium model objects may live anywhere in the 32-bit address space (the
3784 compiler generates @code{seth/add3} instructions to load their addresses),
3785 and are callable with the @code{bl} instruction.
3787 Large model objects may live anywhere in the 32-bit address space (the
3788 compiler generates @code{seth/add3} instructions to load their addresses),
3789 and may not be reachable with the @code{bl} instruction (the compiler
3790 generates the much slower @code{seth/add3/jl} instruction sequence).
3791 @end table
3793 @node m68k Function Attributes
3794 @subsection m68k Function Attributes
3796 These function attributes are supported by the m68k back end:
3798 @table @code
3799 @item interrupt
3800 @itemx interrupt_handler
3801 @cindex @code{interrupt} function attribute, m68k
3802 @cindex @code{interrupt_handler} function attribute, m68k
3803 Use this attribute to
3804 indicate that the specified function is an interrupt handler.  The compiler
3805 generates function entry and exit sequences suitable for use in an
3806 interrupt handler when this attribute is present.  Either name may be used.
3808 @item interrupt_thread
3809 @cindex @code{interrupt_thread} function attribute, fido
3810 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3811 that the specified function is an interrupt handler that is designed
3812 to run as a thread.  The compiler omits generate prologue/epilogue
3813 sequences and replaces the return instruction with a @code{sleep}
3814 instruction.  This attribute is available only on fido.
3815 @end table
3817 @node MCORE Function Attributes
3818 @subsection MCORE Function Attributes
3820 These function attributes are supported by the MCORE back end:
3822 @table @code
3823 @item naked
3824 @cindex @code{naked} function attribute, MCORE
3825 This attribute allows the compiler to construct the
3826 requisite function declaration, while allowing the body of the
3827 function to be assembly code. The specified function will not have
3828 prologue/epilogue sequences generated by the compiler. Only basic
3829 @code{asm} statements can safely be included in naked functions
3830 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3831 basic @code{asm} and C code may appear to work, they cannot be
3832 depended upon to work reliably and are not supported.
3833 @end table
3835 @node MeP Function Attributes
3836 @subsection MeP Function Attributes
3838 These function attributes are supported by the MeP back end:
3840 @table @code
3841 @item disinterrupt
3842 @cindex @code{disinterrupt} function attribute, MeP
3843 On MeP targets, this attribute causes the compiler to emit
3844 instructions to disable interrupts for the duration of the given
3845 function.
3847 @item interrupt
3848 @cindex @code{interrupt} function attribute, MeP
3849 Use this attribute to indicate
3850 that the specified function is an interrupt handler.  The compiler generates
3851 function entry and exit sequences suitable for use in an interrupt handler
3852 when this attribute is present.
3854 @item near
3855 @cindex @code{near} function attribute, MeP
3856 This attribute causes the compiler to assume the called
3857 function is close enough to use the normal calling convention,
3858 overriding the @option{-mtf} command-line option.
3860 @item far
3861 @cindex @code{far} function attribute, MeP
3862 On MeP targets this causes the compiler to use a calling convention
3863 that assumes the called function is too far away for the built-in
3864 addressing modes.
3866 @item vliw
3867 @cindex @code{vliw} function attribute, MeP
3868 The @code{vliw} attribute tells the compiler to emit
3869 instructions in VLIW mode instead of core mode.  Note that this
3870 attribute is not allowed unless a VLIW coprocessor has been configured
3871 and enabled through command-line options.
3872 @end table
3874 @node MicroBlaze Function Attributes
3875 @subsection MicroBlaze Function Attributes
3877 These function attributes are supported on MicroBlaze targets:
3879 @table @code
3880 @item save_volatiles
3881 @cindex @code{save_volatiles} function attribute, MicroBlaze
3882 Use this attribute to indicate that the function is
3883 an interrupt handler.  All volatile registers (in addition to non-volatile
3884 registers) are saved in the function prologue.  If the function is a leaf
3885 function, only volatiles used by the function are saved.  A normal function
3886 return is generated instead of a return from interrupt.
3888 @item break_handler
3889 @cindex @code{break_handler} function attribute, MicroBlaze
3890 @cindex break handler functions
3891 Use this attribute to indicate that
3892 the specified function is a break handler.  The compiler generates function
3893 entry and exit sequences suitable for use in an break handler when this
3894 attribute is present. The return from @code{break_handler} is done through
3895 the @code{rtbd} instead of @code{rtsd}.
3897 @smallexample
3898 void f () __attribute__ ((break_handler));
3899 @end smallexample
3900 @end table
3902 @node Microsoft Windows Function Attributes
3903 @subsection Microsoft Windows Function Attributes
3905 The following attributes are available on Microsoft Windows and Symbian OS
3906 targets.
3908 @table @code
3909 @item dllexport
3910 @cindex @code{dllexport} function attribute
3911 @cindex @code{__declspec(dllexport)}
3912 On Microsoft Windows targets and Symbian OS targets the
3913 @code{dllexport} attribute causes the compiler to provide a global
3914 pointer to a pointer in a DLL, so that it can be referenced with the
3915 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
3916 name is formed by combining @code{_imp__} and the function or variable
3917 name.
3919 You can use @code{__declspec(dllexport)} as a synonym for
3920 @code{__attribute__ ((dllexport))} for compatibility with other
3921 compilers.
3923 On systems that support the @code{visibility} attribute, this
3924 attribute also implies ``default'' visibility.  It is an error to
3925 explicitly specify any other visibility.
3927 GCC's default behavior is to emit all inline functions with the
3928 @code{dllexport} attribute.  Since this can cause object file-size bloat,
3929 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
3930 ignore the attribute for inlined functions unless the 
3931 @option{-fkeep-inline-functions} flag is used instead.
3933 The attribute is ignored for undefined symbols.
3935 When applied to C++ classes, the attribute marks defined non-inlined
3936 member functions and static data members as exports.  Static consts
3937 initialized in-class are not marked unless they are also defined
3938 out-of-class.
3940 For Microsoft Windows targets there are alternative methods for
3941 including the symbol in the DLL's export table such as using a
3942 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
3943 the @option{--export-all} linker flag.
3945 @item dllimport
3946 @cindex @code{dllimport} function attribute
3947 @cindex @code{__declspec(dllimport)}
3948 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
3949 attribute causes the compiler to reference a function or variable via
3950 a global pointer to a pointer that is set up by the DLL exporting the
3951 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
3952 targets, the pointer name is formed by combining @code{_imp__} and the
3953 function or variable name.
3955 You can use @code{__declspec(dllimport)} as a synonym for
3956 @code{__attribute__ ((dllimport))} for compatibility with other
3957 compilers.
3959 On systems that support the @code{visibility} attribute, this
3960 attribute also implies ``default'' visibility.  It is an error to
3961 explicitly specify any other visibility.
3963 Currently, the attribute is ignored for inlined functions.  If the
3964 attribute is applied to a symbol @emph{definition}, an error is reported.
3965 If a symbol previously declared @code{dllimport} is later defined, the
3966 attribute is ignored in subsequent references, and a warning is emitted.
3967 The attribute is also overridden by a subsequent declaration as
3968 @code{dllexport}.
3970 When applied to C++ classes, the attribute marks non-inlined
3971 member functions and static data members as imports.  However, the
3972 attribute is ignored for virtual methods to allow creation of vtables
3973 using thunks.
3975 On the SH Symbian OS target the @code{dllimport} attribute also has
3976 another affect---it can cause the vtable and run-time type information
3977 for a class to be exported.  This happens when the class has a
3978 dllimported constructor or a non-inline, non-pure virtual function
3979 and, for either of those two conditions, the class also has an inline
3980 constructor or destructor and has a key function that is defined in
3981 the current translation unit.
3983 For Microsoft Windows targets the use of the @code{dllimport}
3984 attribute on functions is not necessary, but provides a small
3985 performance benefit by eliminating a thunk in the DLL@.  The use of the
3986 @code{dllimport} attribute on imported variables can be avoided by passing the
3987 @option{--enable-auto-import} switch to the GNU linker.  As with
3988 functions, using the attribute for a variable eliminates a thunk in
3989 the DLL@.
3991 One drawback to using this attribute is that a pointer to a
3992 @emph{variable} marked as @code{dllimport} cannot be used as a constant
3993 address. However, a pointer to a @emph{function} with the
3994 @code{dllimport} attribute can be used as a constant initializer; in
3995 this case, the address of a stub function in the import lib is
3996 referenced.  On Microsoft Windows targets, the attribute can be disabled
3997 for functions by setting the @option{-mnop-fun-dllimport} flag.
3998 @end table
4000 @node MIPS Function Attributes
4001 @subsection MIPS Function Attributes
4003 These function attributes are supported by the MIPS back end:
4005 @table @code
4006 @item interrupt
4007 @cindex @code{interrupt} function attribute, MIPS
4008 Use this attribute to indicate
4009 that the specified function is an interrupt handler.  The compiler generates
4010 function entry and exit sequences suitable for use in an interrupt handler
4011 when this attribute is present.
4013 You can use the following attributes to modify the behavior
4014 of an interrupt handler:
4015 @table @code
4016 @item use_shadow_register_set
4017 @cindex @code{use_shadow_register_set} function attribute, MIPS
4018 Assume that the handler uses a shadow register set, instead of
4019 the main general-purpose registers.
4021 @item keep_interrupts_masked
4022 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4023 Keep interrupts masked for the whole function.  Without this attribute,
4024 GCC tries to reenable interrupts for as much of the function as it can.
4026 @item use_debug_exception_return
4027 @cindex @code{use_debug_exception_return} function attribute, MIPS
4028 Return using the @code{deret} instruction.  Interrupt handlers that don't
4029 have this attribute return using @code{eret} instead.
4030 @end table
4032 You can use any combination of these attributes, as shown below:
4033 @smallexample
4034 void __attribute__ ((interrupt)) v0 ();
4035 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4036 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4037 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4038 void __attribute__ ((interrupt, use_shadow_register_set,
4039                      keep_interrupts_masked)) v4 ();
4040 void __attribute__ ((interrupt, use_shadow_register_set,
4041                      use_debug_exception_return)) v5 ();
4042 void __attribute__ ((interrupt, keep_interrupts_masked,
4043                      use_debug_exception_return)) v6 ();
4044 void __attribute__ ((interrupt, use_shadow_register_set,
4045                      keep_interrupts_masked,
4046                      use_debug_exception_return)) v7 ();
4047 @end smallexample
4049 @item long_call
4050 @itemx near
4051 @itemx far
4052 @cindex indirect calls, MIPS
4053 @cindex @code{long_call} function attribute, MIPS
4054 @cindex @code{near} function attribute, MIPS
4055 @cindex @code{far} function attribute, MIPS
4056 These attributes specify how a particular function is called on MIPS@.
4057 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4058 command-line switch.  The @code{long_call} and @code{far} attributes are
4059 synonyms, and cause the compiler to always call
4060 the function by first loading its address into a register, and then using
4061 the contents of that register.  The @code{near} attribute has the opposite
4062 effect; it specifies that non-PIC calls should be made using the more
4063 efficient @code{jal} instruction.
4065 @item mips16
4066 @itemx nomips16
4067 @cindex @code{mips16} function attribute, MIPS
4068 @cindex @code{nomips16} function attribute, MIPS
4070 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4071 function attributes to locally select or turn off MIPS16 code generation.
4072 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4073 while MIPS16 code generation is disabled for functions with the
4074 @code{nomips16} attribute.  These attributes override the
4075 @option{-mips16} and @option{-mno-mips16} options on the command line
4076 (@pxref{MIPS Options}).
4078 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4079 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4080 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4081 may interact badly with some GCC extensions such as @code{__builtin_apply}
4082 (@pxref{Constructing Calls}).
4084 @item micromips, MIPS
4085 @itemx nomicromips, MIPS
4086 @cindex @code{micromips} function attribute
4087 @cindex @code{nomicromips} function attribute
4089 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4090 function attributes to locally select or turn off microMIPS code generation.
4091 A function with the @code{micromips} attribute is emitted as microMIPS code,
4092 while microMIPS code generation is disabled for functions with the
4093 @code{nomicromips} attribute.  These attributes override the
4094 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4095 (@pxref{MIPS Options}).
4097 When compiling files containing mixed microMIPS and non-microMIPS code, the
4098 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4099 command line,
4100 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4101 may interact badly with some GCC extensions such as @code{__builtin_apply}
4102 (@pxref{Constructing Calls}).
4104 @item nocompression
4105 @cindex @code{nocompression} function attribute, MIPS
4106 On MIPS targets, you can use the @code{nocompression} function attribute
4107 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4108 overrides the @option{-mips16} and @option{-mmicromips} options on the
4109 command line (@pxref{MIPS Options}).
4110 @end table
4112 @node MSP430 Function Attributes
4113 @subsection MSP430 Function Attributes
4115 These function attributes are supported by the MSP430 back end:
4117 @table @code
4118 @item critical
4119 @cindex @code{critical} function attribute, MSP430
4120 Critical functions disable interrupts upon entry and restore the
4121 previous interrupt state upon exit.  Critical functions cannot also
4122 have the @code{naked} or @code{reentrant} attributes.  They can have
4123 the @code{interrupt} attribute.
4125 @item interrupt
4126 @cindex @code{interrupt} function attribute, MSP430
4127 Use this attribute to indicate
4128 that the specified function is an interrupt handler.  The compiler generates
4129 function entry and exit sequences suitable for use in an interrupt handler
4130 when this attribute is present.
4132 You can provide an argument to the interrupt
4133 attribute which specifies a name or number.  If the argument is a
4134 number it indicates the slot in the interrupt vector table (0 - 31) to
4135 which this handler should be assigned.  If the argument is a name it
4136 is treated as a symbolic name for the vector slot.  These names should
4137 match up with appropriate entries in the linker script.  By default
4138 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4139 @code{reset} for vector 31 are recognized.
4141 @item naked
4142 @cindex @code{naked} function attribute, MSP430
4143 This attribute allows the compiler to construct the
4144 requisite function declaration, while allowing the body of the
4145 function to be assembly code. The specified function will not have
4146 prologue/epilogue sequences generated by the compiler. Only basic
4147 @code{asm} statements can safely be included in naked functions
4148 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4149 basic @code{asm} and C code may appear to work, they cannot be
4150 depended upon to work reliably and are not supported.
4152 @item reentrant
4153 @cindex @code{reentrant} function attribute, MSP430
4154 Reentrant functions disable interrupts upon entry and enable them
4155 upon exit.  Reentrant functions cannot also have the @code{naked}
4156 or @code{critical} attributes.  They can have the @code{interrupt}
4157 attribute.
4159 @item wakeup
4160 @cindex @code{wakeup} function attribute, MSP430
4161 This attribute only applies to interrupt functions.  It is silently
4162 ignored if applied to a non-interrupt function.  A wakeup interrupt
4163 function will rouse the processor from any low-power state that it
4164 might be in when the function exits.
4165 @end table
4167 @node NDS32 Function Attributes
4168 @subsection NDS32 Function Attributes
4170 These function attributes are supported by the NDS32 back end:
4172 @table @code
4173 @item exception
4174 @cindex @code{exception} function attribute
4175 @cindex exception handler functions, NDS32
4176 Use this attribute on the NDS32 target to indicate that the specified function
4177 is an exception handler.  The compiler will generate corresponding sections
4178 for use in an exception handler.
4180 @item interrupt
4181 @cindex @code{interrupt} function attribute, NDS32
4182 On NDS32 target, this attribute indicates that the specified function
4183 is an interrupt handler.  The compiler generates corresponding sections
4184 for use in an interrupt handler.  You can use the following attributes
4185 to modify the behavior:
4186 @table @code
4187 @item nested
4188 @cindex @code{nested} function attribute, NDS32
4189 This interrupt service routine is interruptible.
4190 @item not_nested
4191 @cindex @code{not_nested} function attribute, NDS32
4192 This interrupt service routine is not interruptible.
4193 @item nested_ready
4194 @cindex @code{nested_ready} function attribute, NDS32
4195 This interrupt service routine is interruptible after @code{PSW.GIE}
4196 (global interrupt enable) is set.  This allows interrupt service routine to
4197 finish some short critical code before enabling interrupts.
4198 @item save_all
4199 @cindex @code{save_all} function attribute, NDS32
4200 The system will help save all registers into stack before entering
4201 interrupt handler.
4202 @item partial_save
4203 @cindex @code{partial_save} function attribute, NDS32
4204 The system will help save caller registers into stack before entering
4205 interrupt handler.
4206 @end table
4208 @item naked
4209 @cindex @code{naked} function attribute, NDS32
4210 This attribute allows the compiler to construct the
4211 requisite function declaration, while allowing the body of the
4212 function to be assembly code. The specified function will not have
4213 prologue/epilogue sequences generated by the compiler. Only basic
4214 @code{asm} statements can safely be included in naked functions
4215 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4216 basic @code{asm} and C code may appear to work, they cannot be
4217 depended upon to work reliably and are not supported.
4219 @item reset
4220 @cindex @code{reset} function attribute, NDS32
4221 @cindex reset handler functions
4222 Use this attribute on the NDS32 target to indicate that the specified function
4223 is a reset handler.  The compiler will generate corresponding sections
4224 for use in a reset handler.  You can use the following attributes
4225 to provide extra exception handling:
4226 @table @code
4227 @item nmi
4228 @cindex @code{nmi} function attribute, NDS32
4229 Provide a user-defined function to handle NMI exception.
4230 @item warm
4231 @cindex @code{warm} function attribute, NDS32
4232 Provide a user-defined function to handle warm reset exception.
4233 @end table
4234 @end table
4236 @node Nios II Function Attributes
4237 @subsection Nios II Function Attributes
4239 These function attributes are supported by the Nios II back end:
4241 @table @code
4242 @item target (@var{options})
4243 @cindex @code{target} function attribute
4244 As discussed in @ref{Common Function Attributes}, this attribute 
4245 allows specification of target-specific compilation options.
4247 When compiling for Nios II, the following options are allowed:
4249 @table @samp
4250 @item custom-@var{insn}=@var{N}
4251 @itemx no-custom-@var{insn}
4252 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4253 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4254 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4255 custom instruction with encoding @var{N} when generating code that uses 
4256 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4257 the custom instruction @var{insn}.
4258 These target attributes correspond to the
4259 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4260 command-line options, and support the same set of @var{insn} keywords.
4261 @xref{Nios II Options}, for more information.
4263 @item custom-fpu-cfg=@var{name}
4264 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4265 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4266 command-line option, to select a predefined set of custom instructions
4267 named @var{name}.
4268 @xref{Nios II Options}, for more information.
4269 @end table
4270 @end table
4272 @node PowerPC Function Attributes
4273 @subsection PowerPC Function Attributes
4275 These function attributes are supported by the PowerPC back end:
4277 @table @code
4278 @item longcall
4279 @itemx shortcall
4280 @cindex indirect calls, PowerPC
4281 @cindex @code{longcall} function attribute, PowerPC
4282 @cindex @code{shortcall} function attribute, PowerPC
4283 The @code{longcall} attribute
4284 indicates that the function might be far away from the call site and
4285 require a different (more expensive) calling sequence.  The
4286 @code{shortcall} attribute indicates that the function is always close
4287 enough for the shorter calling sequence to be used.  These attributes
4288 override both the @option{-mlongcall} switch and
4289 the @code{#pragma longcall} setting.
4291 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4292 calls are necessary.
4294 @item target (@var{options})
4295 @cindex @code{target} function attribute
4296 As discussed in @ref{Common Function Attributes}, this attribute 
4297 allows specification of target-specific compilation options.
4299 On the PowerPC, the following options are allowed:
4301 @table @samp
4302 @item altivec
4303 @itemx no-altivec
4304 @cindex @code{target("altivec")} function attribute, PowerPC
4305 Generate code that uses (does not use) AltiVec instructions.  In
4306 32-bit code, you cannot enable AltiVec instructions unless
4307 @option{-mabi=altivec} is used on the command line.
4309 @item cmpb
4310 @itemx no-cmpb
4311 @cindex @code{target("cmpb")} function attribute, PowerPC
4312 Generate code that uses (does not use) the compare bytes instruction
4313 implemented on the POWER6 processor and other processors that support
4314 the PowerPC V2.05 architecture.
4316 @item dlmzb
4317 @itemx no-dlmzb
4318 @cindex @code{target("dlmzb")} function attribute, PowerPC
4319 Generate code that uses (does not use) the string-search @samp{dlmzb}
4320 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4321 generated by default when targeting those processors.
4323 @item fprnd
4324 @itemx no-fprnd
4325 @cindex @code{target("fprnd")} function attribute, PowerPC
4326 Generate code that uses (does not use) the FP round to integer
4327 instructions implemented on the POWER5+ processor and other processors
4328 that support the PowerPC V2.03 architecture.
4330 @item hard-dfp
4331 @itemx no-hard-dfp
4332 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4333 Generate code that uses (does not use) the decimal floating-point
4334 instructions implemented on some POWER processors.
4336 @item isel
4337 @itemx no-isel
4338 @cindex @code{target("isel")} function attribute, PowerPC
4339 Generate code that uses (does not use) ISEL instruction.
4341 @item mfcrf
4342 @itemx no-mfcrf
4343 @cindex @code{target("mfcrf")} function attribute, PowerPC
4344 Generate code that uses (does not use) the move from condition
4345 register field instruction implemented on the POWER4 processor and
4346 other processors that support the PowerPC V2.01 architecture.
4348 @item mfpgpr
4349 @itemx no-mfpgpr
4350 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4351 Generate code that uses (does not use) the FP move to/from general
4352 purpose register instructions implemented on the POWER6X processor and
4353 other processors that support the extended PowerPC V2.05 architecture.
4355 @item mulhw
4356 @itemx no-mulhw
4357 @cindex @code{target("mulhw")} function attribute, PowerPC
4358 Generate code that uses (does not use) the half-word multiply and
4359 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4360 These instructions are generated by default when targeting those
4361 processors.
4363 @item multiple
4364 @itemx no-multiple
4365 @cindex @code{target("multiple")} function attribute, PowerPC
4366 Generate code that uses (does not use) the load multiple word
4367 instructions and the store multiple word instructions.
4369 @item update
4370 @itemx no-update
4371 @cindex @code{target("update")} function attribute, PowerPC
4372 Generate code that uses (does not use) the load or store instructions
4373 that update the base register to the address of the calculated memory
4374 location.
4376 @item popcntb
4377 @itemx no-popcntb
4378 @cindex @code{target("popcntb")} function attribute, PowerPC
4379 Generate code that uses (does not use) the popcount and double-precision
4380 FP reciprocal estimate instruction implemented on the POWER5
4381 processor and other processors that support the PowerPC V2.02
4382 architecture.
4384 @item popcntd
4385 @itemx no-popcntd
4386 @cindex @code{target("popcntd")} function attribute, PowerPC
4387 Generate code that uses (does not use) the popcount instruction
4388 implemented on the POWER7 processor and other processors that support
4389 the PowerPC V2.06 architecture.
4391 @item powerpc-gfxopt
4392 @itemx no-powerpc-gfxopt
4393 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4394 Generate code that uses (does not use) the optional PowerPC
4395 architecture instructions in the Graphics group, including
4396 floating-point select.
4398 @item powerpc-gpopt
4399 @itemx no-powerpc-gpopt
4400 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4401 Generate code that uses (does not use) the optional PowerPC
4402 architecture instructions in the General Purpose group, including
4403 floating-point square root.
4405 @item recip-precision
4406 @itemx no-recip-precision
4407 @cindex @code{target("recip-precision")} function attribute, PowerPC
4408 Assume (do not assume) that the reciprocal estimate instructions
4409 provide higher-precision estimates than is mandated by the PowerPC
4410 ABI.
4412 @item string
4413 @itemx no-string
4414 @cindex @code{target("string")} function attribute, PowerPC
4415 Generate code that uses (does not use) the load string instructions
4416 and the store string word instructions to save multiple registers and
4417 do small block moves.
4419 @item vsx
4420 @itemx no-vsx
4421 @cindex @code{target("vsx")} function attribute, PowerPC
4422 Generate code that uses (does not use) vector/scalar (VSX)
4423 instructions, and also enable the use of built-in functions that allow
4424 more direct access to the VSX instruction set.  In 32-bit code, you
4425 cannot enable VSX or AltiVec instructions unless
4426 @option{-mabi=altivec} is used on the command line.
4428 @item friz
4429 @itemx no-friz
4430 @cindex @code{target("friz")} function attribute, PowerPC
4431 Generate (do not generate) the @code{friz} instruction when the
4432 @option{-funsafe-math-optimizations} option is used to optimize
4433 rounding a floating-point value to 64-bit integer and back to floating
4434 point.  The @code{friz} instruction does not return the same value if
4435 the floating-point number is too large to fit in an integer.
4437 @item avoid-indexed-addresses
4438 @itemx no-avoid-indexed-addresses
4439 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4440 Generate code that tries to avoid (not avoid) the use of indexed load
4441 or store instructions.
4443 @item paired
4444 @itemx no-paired
4445 @cindex @code{target("paired")} function attribute, PowerPC
4446 Generate code that uses (does not use) the generation of PAIRED simd
4447 instructions.
4449 @item longcall
4450 @itemx no-longcall
4451 @cindex @code{target("longcall")} function attribute, PowerPC
4452 Generate code that assumes (does not assume) that all calls are far
4453 away so that a longer more expensive calling sequence is required.
4455 @item cpu=@var{CPU}
4456 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4457 Specify the architecture to generate code for when compiling the
4458 function.  If you select the @code{target("cpu=power7")} attribute when
4459 generating 32-bit code, VSX and AltiVec instructions are not generated
4460 unless you use the @option{-mabi=altivec} option on the command line.
4462 @item tune=@var{TUNE}
4463 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4464 Specify the architecture to tune for when compiling the function.  If
4465 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4466 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4467 compilation tunes for the @var{CPU} architecture, and not the
4468 default tuning specified on the command line.
4469 @end table
4471 On the PowerPC, the inliner does not inline a
4472 function that has different target options than the caller, unless the
4473 callee has a subset of the target options of the caller.
4474 @end table
4476 @node RL78 Function Attributes
4477 @subsection RL78 Function Attributes
4479 These function attributes are supported by the RL78 back end:
4481 @table @code
4482 @item interrupt
4483 @itemx brk_interrupt
4484 @cindex @code{interrupt} function attribute, RL78
4485 @cindex @code{brk_interrupt} function attribute, RL78
4486 These attributes indicate
4487 that the specified function is an interrupt handler.  The compiler generates
4488 function entry and exit sequences suitable for use in an interrupt handler
4489 when this attribute is present.
4491 Use @code{brk_interrupt} instead of @code{interrupt} for
4492 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4493 that must end with @code{RETB} instead of @code{RETI}).
4495 @item naked
4496 @cindex @code{naked} function attribute, RL78
4497 This attribute allows the compiler to construct the
4498 requisite function declaration, while allowing the body of the
4499 function to be assembly code. The specified function will not have
4500 prologue/epilogue sequences generated by the compiler. Only basic
4501 @code{asm} statements can safely be included in naked functions
4502 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4503 basic @code{asm} and C code may appear to work, they cannot be
4504 depended upon to work reliably and are not supported.
4505 @end table
4507 @node RX Function Attributes
4508 @subsection RX Function Attributes
4510 These function attributes are supported by the RX back end:
4512 @table @code
4513 @item fast_interrupt
4514 @cindex @code{fast_interrupt} function attribute, RX
4515 Use this attribute on the RX port to indicate that the specified
4516 function is a fast interrupt handler.  This is just like the
4517 @code{interrupt} attribute, except that @code{freit} is used to return
4518 instead of @code{reit}.
4520 @item interrupt
4521 @cindex @code{interrupt} function attribute, RX
4522 Use this attribute to indicate
4523 that the specified function is an interrupt handler.  The compiler generates
4524 function entry and exit sequences suitable for use in an interrupt handler
4525 when this attribute is present.
4527 On RX targets, you may specify one or more vector numbers as arguments
4528 to the attribute, as well as naming an alternate table name.
4529 Parameters are handled sequentially, so one handler can be assigned to
4530 multiple entries in multiple tables.  One may also pass the magic
4531 string @code{"$default"} which causes the function to be used for any
4532 unfilled slots in the current table.
4534 This example shows a simple assignment of a function to one vector in
4535 the default table (note that preprocessor macros may be used for
4536 chip-specific symbolic vector names):
4537 @smallexample
4538 void __attribute__ ((interrupt (5))) txd1_handler ();
4539 @end smallexample
4541 This example assigns a function to two slots in the default table
4542 (using preprocessor macros defined elsewhere) and makes it the default
4543 for the @code{dct} table:
4544 @smallexample
4545 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4546         txd1_handler ();
4547 @end smallexample
4549 @item naked
4550 @cindex @code{naked} function attribute, RX
4551 This attribute allows the compiler to construct the
4552 requisite function declaration, while allowing the body of the
4553 function to be assembly code. The specified function will not have
4554 prologue/epilogue sequences generated by the compiler. Only basic
4555 @code{asm} statements can safely be included in naked functions
4556 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4557 basic @code{asm} and C code may appear to work, they cannot be
4558 depended upon to work reliably and are not supported.
4560 @item vector
4561 @cindex @code{vector} function attribute, RX
4562 This RX attribute is similar to the @code{interrupt} attribute, including its
4563 parameters, but does not make the function an interrupt-handler type
4564 function (i.e. it retains the normal C function calling ABI).  See the
4565 @code{interrupt} attribute for a description of its arguments.
4566 @end table
4568 @node S/390 Function Attributes
4569 @subsection S/390 Function Attributes
4571 These function attributes are supported on the S/390:
4573 @table @code
4574 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4575 @cindex @code{hotpatch} function attribute, S/390
4577 On S/390 System z targets, you can use this function attribute to
4578 make GCC generate a ``hot-patching'' function prologue.  If the
4579 @option{-mhotpatch=} command-line option is used at the same time,
4580 the @code{hotpatch} attribute takes precedence.  The first of the
4581 two arguments specifies the number of halfwords to be added before
4582 the function label.  A second argument can be used to specify the
4583 number of halfwords to be added after the function label.  For
4584 both arguments the maximum allowed value is 1000000.
4586 If both arguments are zero, hotpatching is disabled.
4587 @end table
4589 @node SH Function Attributes
4590 @subsection SH Function Attributes
4592 These function attributes are supported on the SH family of processors:
4594 @table @code
4595 @item function_vector
4596 @cindex @code{function_vector} function attribute, SH
4597 @cindex calling functions through the function vector on SH2A
4598 On SH2A targets, this attribute declares a function to be called using the
4599 TBR relative addressing mode.  The argument to this attribute is the entry
4600 number of the same function in a vector table containing all the TBR
4601 relative addressable functions.  For correct operation the TBR must be setup
4602 accordingly to point to the start of the vector table before any functions with
4603 this attribute are invoked.  Usually a good place to do the initialization is
4604 the startup routine.  The TBR relative vector table can have at max 256 function
4605 entries.  The jumps to these functions are generated using a SH2A specific,
4606 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
4607 from GNU binutils version 2.7 or later for this attribute to work correctly.
4609 In an application, for a function being called once, this attribute
4610 saves at least 8 bytes of code; and if other successive calls are being
4611 made to the same function, it saves 2 bytes of code per each of these
4612 calls.
4614 @item interrupt_handler
4615 @cindex @code{interrupt_handler} function attribute, SH
4616 Use this attribute to
4617 indicate that the specified function is an interrupt handler.  The compiler
4618 generates function entry and exit sequences suitable for use in an
4619 interrupt handler when this attribute is present.
4621 @item nosave_low_regs
4622 @cindex @code{nosave_low_regs} function attribute, SH
4623 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
4624 function should not save and restore registers R0..R7.  This can be used on SH3*
4625 and SH4* targets that have a second R0..R7 register bank for non-reentrant
4626 interrupt handlers.
4628 @item renesas
4629 @cindex @code{renesas} function attribute, SH
4630 On SH targets this attribute specifies that the function or struct follows the
4631 Renesas ABI.
4633 @item resbank
4634 @cindex @code{resbank} function attribute, SH
4635 On the SH2A target, this attribute enables the high-speed register
4636 saving and restoration using a register bank for @code{interrupt_handler}
4637 routines.  Saving to the bank is performed automatically after the CPU
4638 accepts an interrupt that uses a register bank.
4640 The nineteen 32-bit registers comprising general register R0 to R14,
4641 control register GBR, and system registers MACH, MACL, and PR and the
4642 vector table address offset are saved into a register bank.  Register
4643 banks are stacked in first-in last-out (FILO) sequence.  Restoration
4644 from the bank is executed by issuing a RESBANK instruction.
4646 @item sp_switch
4647 @cindex @code{sp_switch} function attribute, SH
4648 Use this attribute on the SH to indicate an @code{interrupt_handler}
4649 function should switch to an alternate stack.  It expects a string
4650 argument that names a global variable holding the address of the
4651 alternate stack.
4653 @smallexample
4654 void *alt_stack;
4655 void f () __attribute__ ((interrupt_handler,
4656                           sp_switch ("alt_stack")));
4657 @end smallexample
4659 @item trap_exit
4660 @cindex @code{trap_exit} function attribute, SH
4661 Use this attribute on the SH for an @code{interrupt_handler} to return using
4662 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4663 argument specifying the trap number to be used.
4665 @item trapa_handler
4666 @cindex @code{trapa_handler} function attribute, SH
4667 On SH targets this function attribute is similar to @code{interrupt_handler}
4668 but it does not save and restore all registers.
4669 @end table
4671 @node SPU Function Attributes
4672 @subsection SPU Function Attributes
4674 These function attributes are supported by the SPU back end:
4676 @table @code
4677 @item naked
4678 @cindex @code{naked} function attribute, SPU
4679 This attribute allows the compiler to construct the
4680 requisite function declaration, while allowing the body of the
4681 function to be assembly code. The specified function will not have
4682 prologue/epilogue sequences generated by the compiler. Only basic
4683 @code{asm} statements can safely be included in naked functions
4684 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4685 basic @code{asm} and C code may appear to work, they cannot be
4686 depended upon to work reliably and are not supported.
4687 @end table
4689 @node Symbian OS Function Attributes
4690 @subsection Symbian OS Function Attributes
4692 @xref{Microsoft Windows Function Attributes}, for discussion of the
4693 @code{dllexport} and @code{dllimport} attributes.
4695 @node Visium Function Attributes
4696 @subsection Visium Function Attributes
4698 These function attributes are supported by the Visium back end:
4700 @table @code
4701 @item interrupt
4702 @cindex @code{interrupt} function attribute, Visium
4703 Use this attribute to indicate
4704 that the specified function is an interrupt handler.  The compiler generates
4705 function entry and exit sequences suitable for use in an interrupt handler
4706 when this attribute is present.
4707 @end table
4709 @node x86 Function Attributes
4710 @subsection x86 Function Attributes
4712 These function attributes are supported by the x86 back end:
4714 @table @code
4715 @item cdecl
4716 @cindex @code{cdecl} function attribute, x86-32
4717 @cindex functions that pop the argument stack on x86-32
4718 @opindex mrtd
4719 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
4720 assume that the calling function pops off the stack space used to
4721 pass arguments.  This is
4722 useful to override the effects of the @option{-mrtd} switch.
4724 @item fastcall
4725 @cindex @code{fastcall} function attribute, x86-32
4726 @cindex functions that pop the argument stack on x86-32
4727 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
4728 pass the first argument (if of integral type) in the register ECX and
4729 the second argument (if of integral type) in the register EDX@.  Subsequent
4730 and other typed arguments are passed on the stack.  The called function
4731 pops the arguments off the stack.  If the number of arguments is variable all
4732 arguments are pushed on the stack.
4734 @item thiscall
4735 @cindex @code{thiscall} function attribute, x86-32
4736 @cindex functions that pop the argument stack on x86-32
4737 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
4738 pass the first argument (if of integral type) in the register ECX.
4739 Subsequent and other typed arguments are passed on the stack. The called
4740 function pops the arguments off the stack.
4741 If the number of arguments is variable all arguments are pushed on the
4742 stack.
4743 The @code{thiscall} attribute is intended for C++ non-static member functions.
4744 As a GCC extension, this calling convention can be used for C functions
4745 and for static member methods.
4747 @item ms_abi
4748 @itemx sysv_abi
4749 @cindex @code{ms_abi} function attribute, x86
4750 @cindex @code{sysv_abi} function attribute, x86
4752 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
4753 to indicate which calling convention should be used for a function.  The
4754 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
4755 while the @code{sysv_abi} attribute tells the compiler to use the ABI
4756 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
4757 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
4759 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
4760 requires the @option{-maccumulate-outgoing-args} option.
4762 @item callee_pop_aggregate_return (@var{number})
4763 @cindex @code{callee_pop_aggregate_return} function attribute, x86
4765 On x86-32 targets, you can use this attribute to control how
4766 aggregates are returned in memory.  If the caller is responsible for
4767 popping the hidden pointer together with the rest of the arguments, specify
4768 @var{number} equal to zero.  If callee is responsible for popping the
4769 hidden pointer, specify @var{number} equal to one.  
4771 The default x86-32 ABI assumes that the callee pops the
4772 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
4773 the compiler assumes that the
4774 caller pops the stack for hidden pointer.
4776 @item ms_hook_prologue
4777 @cindex @code{ms_hook_prologue} function attribute, x86
4779 On 32-bit and 64-bit x86 targets, you can use
4780 this function attribute to make GCC generate the ``hot-patching'' function
4781 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
4782 and newer.
4784 @item regparm (@var{number})
4785 @cindex @code{regparm} function attribute, x86
4786 @cindex functions that are passed arguments in registers on x86-32
4787 On x86-32 targets, the @code{regparm} attribute causes the compiler to
4788 pass arguments number one to @var{number} if they are of integral type
4789 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
4790 take a variable number of arguments continue to be passed all of their
4791 arguments on the stack.
4793 Beware that on some ELF systems this attribute is unsuitable for
4794 global functions in shared libraries with lazy binding (which is the
4795 default).  Lazy binding sends the first call via resolving code in
4796 the loader, which might assume EAX, EDX and ECX can be clobbered, as
4797 per the standard calling conventions.  Solaris 8 is affected by this.
4798 Systems with the GNU C Library version 2.1 or higher
4799 and FreeBSD are believed to be
4800 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
4801 disabled with the linker or the loader if desired, to avoid the
4802 problem.)
4804 @item sseregparm
4805 @cindex @code{sseregparm} function attribute, x86
4806 On x86-32 targets with SSE support, the @code{sseregparm} attribute
4807 causes the compiler to pass up to 3 floating-point arguments in
4808 SSE registers instead of on the stack.  Functions that take a
4809 variable number of arguments continue to pass all of their
4810 floating-point arguments on the stack.
4812 @item force_align_arg_pointer
4813 @cindex @code{force_align_arg_pointer} function attribute, x86
4814 On x86 targets, the @code{force_align_arg_pointer} attribute may be
4815 applied to individual function definitions, generating an alternate
4816 prologue and epilogue that realigns the run-time stack if necessary.
4817 This supports mixing legacy codes that run with a 4-byte aligned stack
4818 with modern codes that keep a 16-byte stack for SSE compatibility.
4820 @item stdcall
4821 @cindex @code{stdcall} function attribute, x86-32
4822 @cindex functions that pop the argument stack on x86-32
4823 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
4824 assume that the called function pops off the stack space used to
4825 pass arguments, unless it takes a variable number of arguments.
4827 @item target (@var{options})
4828 @cindex @code{target} function attribute
4829 As discussed in @ref{Common Function Attributes}, this attribute 
4830 allows specification of target-specific compilation options.
4832 On the x86, the following options are allowed:
4833 @table @samp
4834 @item abm
4835 @itemx no-abm
4836 @cindex @code{target("abm")} function attribute, x86
4837 Enable/disable the generation of the advanced bit instructions.
4839 @item aes
4840 @itemx no-aes
4841 @cindex @code{target("aes")} function attribute, x86
4842 Enable/disable the generation of the AES instructions.
4844 @item default
4845 @cindex @code{target("default")} function attribute, x86
4846 @xref{Function Multiversioning}, where it is used to specify the
4847 default function version.
4849 @item mmx
4850 @itemx no-mmx
4851 @cindex @code{target("mmx")} function attribute, x86
4852 Enable/disable the generation of the MMX instructions.
4854 @item pclmul
4855 @itemx no-pclmul
4856 @cindex @code{target("pclmul")} function attribute, x86
4857 Enable/disable the generation of the PCLMUL instructions.
4859 @item popcnt
4860 @itemx no-popcnt
4861 @cindex @code{target("popcnt")} function attribute, x86
4862 Enable/disable the generation of the POPCNT instruction.
4864 @item sse
4865 @itemx no-sse
4866 @cindex @code{target("sse")} function attribute, x86
4867 Enable/disable the generation of the SSE instructions.
4869 @item sse2
4870 @itemx no-sse2
4871 @cindex @code{target("sse2")} function attribute, x86
4872 Enable/disable the generation of the SSE2 instructions.
4874 @item sse3
4875 @itemx no-sse3
4876 @cindex @code{target("sse3")} function attribute, x86
4877 Enable/disable the generation of the SSE3 instructions.
4879 @item sse4
4880 @itemx no-sse4
4881 @cindex @code{target("sse4")} function attribute, x86
4882 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4883 and SSE4.2).
4885 @item sse4.1
4886 @itemx no-sse4.1
4887 @cindex @code{target("sse4.1")} function attribute, x86
4888 Enable/disable the generation of the sse4.1 instructions.
4890 @item sse4.2
4891 @itemx no-sse4.2
4892 @cindex @code{target("sse4.2")} function attribute, x86
4893 Enable/disable the generation of the sse4.2 instructions.
4895 @item sse4a
4896 @itemx no-sse4a
4897 @cindex @code{target("sse4a")} function attribute, x86
4898 Enable/disable the generation of the SSE4A instructions.
4900 @item fma4
4901 @itemx no-fma4
4902 @cindex @code{target("fma4")} function attribute, x86
4903 Enable/disable the generation of the FMA4 instructions.
4905 @item xop
4906 @itemx no-xop
4907 @cindex @code{target("xop")} function attribute, x86
4908 Enable/disable the generation of the XOP instructions.
4910 @item lwp
4911 @itemx no-lwp
4912 @cindex @code{target("lwp")} function attribute, x86
4913 Enable/disable the generation of the LWP instructions.
4915 @item ssse3
4916 @itemx no-ssse3
4917 @cindex @code{target("ssse3")} function attribute, x86
4918 Enable/disable the generation of the SSSE3 instructions.
4920 @item cld
4921 @itemx no-cld
4922 @cindex @code{target("cld")} function attribute, x86
4923 Enable/disable the generation of the CLD before string moves.
4925 @item fancy-math-387
4926 @itemx no-fancy-math-387
4927 @cindex @code{target("fancy-math-387")} function attribute, x86
4928 Enable/disable the generation of the @code{sin}, @code{cos}, and
4929 @code{sqrt} instructions on the 387 floating-point unit.
4931 @item fused-madd
4932 @itemx no-fused-madd
4933 @cindex @code{target("fused-madd")} function attribute, x86
4934 Enable/disable the generation of the fused multiply/add instructions.
4936 @item ieee-fp
4937 @itemx no-ieee-fp
4938 @cindex @code{target("ieee-fp")} function attribute, x86
4939 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4941 @item inline-all-stringops
4942 @itemx no-inline-all-stringops
4943 @cindex @code{target("inline-all-stringops")} function attribute, x86
4944 Enable/disable inlining of string operations.
4946 @item inline-stringops-dynamically
4947 @itemx no-inline-stringops-dynamically
4948 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
4949 Enable/disable the generation of the inline code to do small string
4950 operations and calling the library routines for large operations.
4952 @item align-stringops
4953 @itemx no-align-stringops
4954 @cindex @code{target("align-stringops")} function attribute, x86
4955 Do/do not align destination of inlined string operations.
4957 @item recip
4958 @itemx no-recip
4959 @cindex @code{target("recip")} function attribute, x86
4960 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4961 instructions followed an additional Newton-Raphson step instead of
4962 doing a floating-point division.
4964 @item arch=@var{ARCH}
4965 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
4966 Specify the architecture to generate code for in compiling the function.
4968 @item tune=@var{TUNE}
4969 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
4970 Specify the architecture to tune for in compiling the function.
4972 @item fpmath=@var{FPMATH}
4973 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
4974 Specify which floating-point unit to use.  You must specify the
4975 @code{target("fpmath=sse,387")} option as
4976 @code{target("fpmath=sse+387")} because the comma would separate
4977 different options.
4978 @end table
4980 On the x86, the inliner does not inline a
4981 function that has different target options than the caller, unless the
4982 callee has a subset of the target options of the caller.  For example
4983 a function declared with @code{target("sse3")} can inline a function
4984 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4985 @end table
4987 @node Xstormy16 Function Attributes
4988 @subsection Xstormy16 Function Attributes
4990 These function attributes are supported by the Xstormy16 back end:
4992 @table @code
4993 @item interrupt
4994 @cindex @code{interrupt} function attribute, Xstormy16
4995 Use this attribute to indicate
4996 that the specified function is an interrupt handler.  The compiler generates
4997 function entry and exit sequences suitable for use in an interrupt handler
4998 when this attribute is present.
4999 @end table
5001 @node Label Attributes
5002 @section Label Attributes
5003 @cindex Label Attributes
5005 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
5006 details of the exact syntax for using attributes.  Other attributes are 
5007 available for functions (@pxref{Function Attributes}), variables 
5008 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
5010 This example uses the @code{cold} label attribute to indicate the 
5011 @code{ErrorHandling} branch is unlikely to be taken and that the
5012 @code{ErrorHandling} label is unused:
5014 @smallexample
5016    asm goto ("some asm" : : : : NoError);
5018 /* This branch (the fall-through from the asm) is less commonly used */
5019 ErrorHandling: 
5020    __attribute__((cold, unused)); /* Semi-colon is required here */
5021    printf("error\n");
5022    return 0;
5024 NoError:
5025    printf("no error\n");
5026    return 1;
5027 @end smallexample
5029 @table @code
5030 @item unused
5031 @cindex @code{unused} label attribute
5032 This feature is intended for program-generated code that may contain 
5033 unused labels, but which is compiled with @option{-Wall}.  It is
5034 not normally appropriate to use in it human-written code, though it
5035 could be useful in cases where the code that jumps to the label is
5036 contained within an @code{#ifdef} conditional.
5038 @item hot
5039 @cindex @code{hot} label attribute
5040 The @code{hot} attribute on a label is used to inform the compiler that
5041 the path following the label is more likely than paths that are not so
5042 annotated.  This attribute is used in cases where @code{__builtin_expect}
5043 cannot be used, for instance with computed goto or @code{asm goto}.
5045 @item cold
5046 @cindex @code{cold} label attribute
5047 The @code{cold} attribute on labels is used to inform the compiler that
5048 the path following the label is unlikely to be executed.  This attribute
5049 is used in cases where @code{__builtin_expect} cannot be used, for instance
5050 with computed goto or @code{asm goto}.
5052 @end table
5054 @node Attribute Syntax
5055 @section Attribute Syntax
5056 @cindex attribute syntax
5058 This section describes the syntax with which @code{__attribute__} may be
5059 used, and the constructs to which attribute specifiers bind, for the C
5060 language.  Some details may vary for C++ and Objective-C@.  Because of
5061 infelicities in the grammar for attributes, some forms described here
5062 may not be successfully parsed in all cases.
5064 There are some problems with the semantics of attributes in C++.  For
5065 example, there are no manglings for attributes, although they may affect
5066 code generation, so problems may arise when attributed types are used in
5067 conjunction with templates or overloading.  Similarly, @code{typeid}
5068 does not distinguish between types with different attributes.  Support
5069 for attributes in C++ may be restricted in future to attributes on
5070 declarations only, but not on nested declarators.
5072 @xref{Function Attributes}, for details of the semantics of attributes
5073 applying to functions.  @xref{Variable Attributes}, for details of the
5074 semantics of attributes applying to variables.  @xref{Type Attributes},
5075 for details of the semantics of attributes applying to structure, union
5076 and enumerated types.
5077 @xref{Label Attributes}, for details of the semantics of attributes 
5078 applying to labels.
5080 An @dfn{attribute specifier} is of the form
5081 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
5082 is a possibly empty comma-separated sequence of @dfn{attributes}, where
5083 each attribute is one of the following:
5085 @itemize @bullet
5086 @item
5087 Empty.  Empty attributes are ignored.
5089 @item
5090 An attribute name
5091 (which may be an identifier such as @code{unused}, or a reserved
5092 word such as @code{const}).
5094 @item
5095 An attribute name followed by a parenthesized list of
5096 parameters for the attribute.
5097 These parameters take one of the following forms:
5099 @itemize @bullet
5100 @item
5101 An identifier.  For example, @code{mode} attributes use this form.
5103 @item
5104 An identifier followed by a comma and a non-empty comma-separated list
5105 of expressions.  For example, @code{format} attributes use this form.
5107 @item
5108 A possibly empty comma-separated list of expressions.  For example,
5109 @code{format_arg} attributes use this form with the list being a single
5110 integer constant expression, and @code{alias} attributes use this form
5111 with the list being a single string constant.
5112 @end itemize
5113 @end itemize
5115 An @dfn{attribute specifier list} is a sequence of one or more attribute
5116 specifiers, not separated by any other tokens.
5118 You may optionally specify attribute names with @samp{__}
5119 preceding and following the name.
5120 This allows you to use them in header files without
5121 being concerned about a possible macro of the same name.  For example,
5122 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
5125 @subsubheading Label Attributes
5127 In GNU C, an attribute specifier list may appear after the colon following a
5128 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
5129 attributes on labels if the attribute specifier is immediately
5130 followed by a semicolon (i.e., the label applies to an empty
5131 statement).  If the semicolon is missing, C++ label attributes are
5132 ambiguous, as it is permissible for a declaration, which could begin
5133 with an attribute list, to be labelled in C++.  Declarations cannot be
5134 labelled in C90 or C99, so the ambiguity does not arise there.
5136 @subsubheading Type Attributes
5138 An attribute specifier list may appear as part of a @code{struct},
5139 @code{union} or @code{enum} specifier.  It may go either immediately
5140 after the @code{struct}, @code{union} or @code{enum} keyword, or after
5141 the closing brace.  The former syntax is preferred.
5142 Where attribute specifiers follow the closing brace, they are considered
5143 to relate to the structure, union or enumerated type defined, not to any
5144 enclosing declaration the type specifier appears in, and the type
5145 defined is not complete until after the attribute specifiers.
5146 @c Otherwise, there would be the following problems: a shift/reduce
5147 @c conflict between attributes binding the struct/union/enum and
5148 @c binding to the list of specifiers/qualifiers; and "aligned"
5149 @c attributes could use sizeof for the structure, but the size could be
5150 @c changed later by "packed" attributes.
5153 @subsubheading All other attributes
5155 Otherwise, an attribute specifier appears as part of a declaration,
5156 counting declarations of unnamed parameters and type names, and relates
5157 to that declaration (which may be nested in another declaration, for
5158 example in the case of a parameter declaration), or to a particular declarator
5159 within a declaration.  Where an
5160 attribute specifier is applied to a parameter declared as a function or
5161 an array, it should apply to the function or array rather than the
5162 pointer to which the parameter is implicitly converted, but this is not
5163 yet correctly implemented.
5165 Any list of specifiers and qualifiers at the start of a declaration may
5166 contain attribute specifiers, whether or not such a list may in that
5167 context contain storage class specifiers.  (Some attributes, however,
5168 are essentially in the nature of storage class specifiers, and only make
5169 sense where storage class specifiers may be used; for example,
5170 @code{section}.)  There is one necessary limitation to this syntax: the
5171 first old-style parameter declaration in a function definition cannot
5172 begin with an attribute specifier, because such an attribute applies to
5173 the function instead by syntax described below (which, however, is not
5174 yet implemented in this case).  In some other cases, attribute
5175 specifiers are permitted by this grammar but not yet supported by the
5176 compiler.  All attribute specifiers in this place relate to the
5177 declaration as a whole.  In the obsolescent usage where a type of
5178 @code{int} is implied by the absence of type specifiers, such a list of
5179 specifiers and qualifiers may be an attribute specifier list with no
5180 other specifiers or qualifiers.
5182 At present, the first parameter in a function prototype must have some
5183 type specifier that is not an attribute specifier; this resolves an
5184 ambiguity in the interpretation of @code{void f(int
5185 (__attribute__((foo)) x))}, but is subject to change.  At present, if
5186 the parentheses of a function declarator contain only attributes then
5187 those attributes are ignored, rather than yielding an error or warning
5188 or implying a single parameter of type int, but this is subject to
5189 change.
5191 An attribute specifier list may appear immediately before a declarator
5192 (other than the first) in a comma-separated list of declarators in a
5193 declaration of more than one identifier using a single list of
5194 specifiers and qualifiers.  Such attribute specifiers apply
5195 only to the identifier before whose declarator they appear.  For
5196 example, in
5198 @smallexample
5199 __attribute__((noreturn)) void d0 (void),
5200     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
5201      d2 (void);
5202 @end smallexample
5204 @noindent
5205 the @code{noreturn} attribute applies to all the functions
5206 declared; the @code{format} attribute only applies to @code{d1}.
5208 An attribute specifier list may appear immediately before the comma,
5209 @code{=} or semicolon terminating the declaration of an identifier other
5210 than a function definition.  Such attribute specifiers apply
5211 to the declared object or function.  Where an
5212 assembler name for an object or function is specified (@pxref{Asm
5213 Labels}), the attribute must follow the @code{asm}
5214 specification.
5216 An attribute specifier list may, in future, be permitted to appear after
5217 the declarator in a function definition (before any old-style parameter
5218 declarations or the function body).
5220 Attribute specifiers may be mixed with type qualifiers appearing inside
5221 the @code{[]} of a parameter array declarator, in the C99 construct by
5222 which such qualifiers are applied to the pointer to which the array is
5223 implicitly converted.  Such attribute specifiers apply to the pointer,
5224 not to the array, but at present this is not implemented and they are
5225 ignored.
5227 An attribute specifier list may appear at the start of a nested
5228 declarator.  At present, there are some limitations in this usage: the
5229 attributes correctly apply to the declarator, but for most individual
5230 attributes the semantics this implies are not implemented.
5231 When attribute specifiers follow the @code{*} of a pointer
5232 declarator, they may be mixed with any type qualifiers present.
5233 The following describes the formal semantics of this syntax.  It makes the
5234 most sense if you are familiar with the formal specification of
5235 declarators in the ISO C standard.
5237 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
5238 D1}, where @code{T} contains declaration specifiers that specify a type
5239 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
5240 contains an identifier @var{ident}.  The type specified for @var{ident}
5241 for derived declarators whose type does not include an attribute
5242 specifier is as in the ISO C standard.
5244 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
5245 and the declaration @code{T D} specifies the type
5246 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
5247 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
5248 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
5250 If @code{D1} has the form @code{*
5251 @var{type-qualifier-and-attribute-specifier-list} D}, and the
5252 declaration @code{T D} specifies the type
5253 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
5254 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
5255 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
5256 @var{ident}.
5258 For example,
5260 @smallexample
5261 void (__attribute__((noreturn)) ****f) (void);
5262 @end smallexample
5264 @noindent
5265 specifies the type ``pointer to pointer to pointer to pointer to
5266 non-returning function returning @code{void}''.  As another example,
5268 @smallexample
5269 char *__attribute__((aligned(8))) *f;
5270 @end smallexample
5272 @noindent
5273 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
5274 Note again that this does not work with most attributes; for example,
5275 the usage of @samp{aligned} and @samp{noreturn} attributes given above
5276 is not yet supported.
5278 For compatibility with existing code written for compiler versions that
5279 did not implement attributes on nested declarators, some laxity is
5280 allowed in the placing of attributes.  If an attribute that only applies
5281 to types is applied to a declaration, it is treated as applying to
5282 the type of that declaration.  If an attribute that only applies to
5283 declarations is applied to the type of a declaration, it is treated
5284 as applying to that declaration; and, for compatibility with code
5285 placing the attributes immediately before the identifier declared, such
5286 an attribute applied to a function return type is treated as
5287 applying to the function type, and such an attribute applied to an array
5288 element type is treated as applying to the array type.  If an
5289 attribute that only applies to function types is applied to a
5290 pointer-to-function type, it is treated as applying to the pointer
5291 target type; if such an attribute is applied to a function return type
5292 that is not a pointer-to-function type, it is treated as applying
5293 to the function type.
5295 @node Function Prototypes
5296 @section Prototypes and Old-Style Function Definitions
5297 @cindex function prototype declarations
5298 @cindex old-style function definitions
5299 @cindex promotion of formal parameters
5301 GNU C extends ISO C to allow a function prototype to override a later
5302 old-style non-prototype definition.  Consider the following example:
5304 @smallexample
5305 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
5306 #ifdef __STDC__
5307 #define P(x) x
5308 #else
5309 #define P(x) ()
5310 #endif
5312 /* @r{Prototype function declaration.}  */
5313 int isroot P((uid_t));
5315 /* @r{Old-style function definition.}  */
5317 isroot (x)   /* @r{??? lossage here ???} */
5318      uid_t x;
5320   return x == 0;
5322 @end smallexample
5324 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
5325 not allow this example, because subword arguments in old-style
5326 non-prototype definitions are promoted.  Therefore in this example the
5327 function definition's argument is really an @code{int}, which does not
5328 match the prototype argument type of @code{short}.
5330 This restriction of ISO C makes it hard to write code that is portable
5331 to traditional C compilers, because the programmer does not know
5332 whether the @code{uid_t} type is @code{short}, @code{int}, or
5333 @code{long}.  Therefore, in cases like these GNU C allows a prototype
5334 to override a later old-style definition.  More precisely, in GNU C, a
5335 function prototype argument type overrides the argument type specified
5336 by a later old-style definition if the former type is the same as the
5337 latter type before promotion.  Thus in GNU C the above example is
5338 equivalent to the following:
5340 @smallexample
5341 int isroot (uid_t);
5344 isroot (uid_t x)
5346   return x == 0;
5348 @end smallexample
5350 @noindent
5351 GNU C++ does not support old-style function definitions, so this
5352 extension is irrelevant.
5354 @node C++ Comments
5355 @section C++ Style Comments
5356 @cindex @code{//}
5357 @cindex C++ comments
5358 @cindex comments, C++ style
5360 In GNU C, you may use C++ style comments, which start with @samp{//} and
5361 continue until the end of the line.  Many other C implementations allow
5362 such comments, and they are included in the 1999 C standard.  However,
5363 C++ style comments are not recognized if you specify an @option{-std}
5364 option specifying a version of ISO C before C99, or @option{-ansi}
5365 (equivalent to @option{-std=c90}).
5367 @node Dollar Signs
5368 @section Dollar Signs in Identifier Names
5369 @cindex $
5370 @cindex dollar signs in identifier names
5371 @cindex identifier names, dollar signs in
5373 In GNU C, you may normally use dollar signs in identifier names.
5374 This is because many traditional C implementations allow such identifiers.
5375 However, dollar signs in identifiers are not supported on a few target
5376 machines, typically because the target assembler does not allow them.
5378 @node Character Escapes
5379 @section The Character @key{ESC} in Constants
5381 You can use the sequence @samp{\e} in a string or character constant to
5382 stand for the ASCII character @key{ESC}.
5384 @node Variable Attributes
5385 @section Specifying Attributes of Variables
5386 @cindex attribute of variables
5387 @cindex variable attributes
5389 The keyword @code{__attribute__} allows you to specify special
5390 attributes of variables or structure fields.  This keyword is followed
5391 by an attribute specification inside double parentheses.  Some
5392 attributes are currently defined generically for variables.
5393 Other attributes are defined for variables on particular target
5394 systems.  Other attributes are available for functions
5395 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
5396 types (@pxref{Type Attributes}).
5397 Other front ends might define more attributes
5398 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5400 @xref{Attribute Syntax}, for details of the exact syntax for using
5401 attributes.
5403 @menu
5404 * Common Variable Attributes::
5405 * AVR Variable Attributes::
5406 * Blackfin Variable Attributes::
5407 * H8/300 Variable Attributes::
5408 * IA-64 Variable Attributes::
5409 * M32R/D Variable Attributes::
5410 * MeP Variable Attributes::
5411 * Microsoft Windows Variable Attributes::
5412 * PowerPC Variable Attributes::
5413 * SPU Variable Attributes::
5414 * x86 Variable Attributes::
5415 * Xstormy16 Variable Attributes::
5416 @end menu
5418 @node Common Variable Attributes
5419 @subsection Common Variable Attributes
5421 The following attributes are supported on most targets.
5423 @table @code
5424 @cindex @code{aligned} variable attribute
5425 @item aligned (@var{alignment})
5426 This attribute specifies a minimum alignment for the variable or
5427 structure field, measured in bytes.  For example, the declaration:
5429 @smallexample
5430 int x __attribute__ ((aligned (16))) = 0;
5431 @end smallexample
5433 @noindent
5434 causes the compiler to allocate the global variable @code{x} on a
5435 16-byte boundary.  On a 68040, this could be used in conjunction with
5436 an @code{asm} expression to access the @code{move16} instruction which
5437 requires 16-byte aligned operands.
5439 You can also specify the alignment of structure fields.  For example, to
5440 create a double-word aligned @code{int} pair, you could write:
5442 @smallexample
5443 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5444 @end smallexample
5446 @noindent
5447 This is an alternative to creating a union with a @code{double} member,
5448 which forces the union to be double-word aligned.
5450 As in the preceding examples, you can explicitly specify the alignment
5451 (in bytes) that you wish the compiler to use for a given variable or
5452 structure field.  Alternatively, you can leave out the alignment factor
5453 and just ask the compiler to align a variable or field to the
5454 default alignment for the target architecture you are compiling for.
5455 The default alignment is sufficient for all scalar types, but may not be
5456 enough for all vector types on a target that supports vector operations.
5457 The default alignment is fixed for a particular target ABI.
5459 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5460 which is the largest alignment ever used for any data type on the
5461 target machine you are compiling for.  For example, you could write:
5463 @smallexample
5464 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5465 @end smallexample
5467 The compiler automatically sets the alignment for the declared
5468 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5469 often make copy operations more efficient, because the compiler can
5470 use whatever instructions copy the biggest chunks of memory when
5471 performing copies to or from the variables or fields that you have
5472 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5473 may change depending on command-line options.
5475 When used on a struct, or struct member, the @code{aligned} attribute can
5476 only increase the alignment; in order to decrease it, the @code{packed}
5477 attribute must be specified as well.  When used as part of a typedef, the
5478 @code{aligned} attribute can both increase and decrease alignment, and
5479 specifying the @code{packed} attribute generates a warning.
5481 Note that the effectiveness of @code{aligned} attributes may be limited
5482 by inherent limitations in your linker.  On many systems, the linker is
5483 only able to arrange for variables to be aligned up to a certain maximum
5484 alignment.  (For some linkers, the maximum supported alignment may
5485 be very very small.)  If your linker is only able to align variables
5486 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5487 in an @code{__attribute__} still only provides you with 8-byte
5488 alignment.  See your linker documentation for further information.
5490 The @code{aligned} attribute can also be used for functions
5491 (@pxref{Common Function Attributes}.)
5493 @item cleanup (@var{cleanup_function})
5494 @cindex @code{cleanup} variable attribute
5495 The @code{cleanup} attribute runs a function when the variable goes
5496 out of scope.  This attribute can only be applied to auto function
5497 scope variables; it may not be applied to parameters or variables
5498 with static storage duration.  The function must take one parameter,
5499 a pointer to a type compatible with the variable.  The return value
5500 of the function (if any) is ignored.
5502 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5503 is run during the stack unwinding that happens during the
5504 processing of the exception.  Note that the @code{cleanup} attribute
5505 does not allow the exception to be caught, only to perform an action.
5506 It is undefined what happens if @var{cleanup_function} does not
5507 return normally.
5509 @item common
5510 @itemx nocommon
5511 @cindex @code{common} variable attribute
5512 @cindex @code{nocommon} variable attribute
5513 @opindex fcommon
5514 @opindex fno-common
5515 The @code{common} attribute requests GCC to place a variable in
5516 ``common'' storage.  The @code{nocommon} attribute requests the
5517 opposite---to allocate space for it directly.
5519 These attributes override the default chosen by the
5520 @option{-fno-common} and @option{-fcommon} flags respectively.
5522 @item deprecated
5523 @itemx deprecated (@var{msg})
5524 @cindex @code{deprecated} variable attribute
5525 The @code{deprecated} attribute results in a warning if the variable
5526 is used anywhere in the source file.  This is useful when identifying
5527 variables that are expected to be removed in a future version of a
5528 program.  The warning also includes the location of the declaration
5529 of the deprecated variable, to enable users to easily find further
5530 information about why the variable is deprecated, or what they should
5531 do instead.  Note that the warning only occurs for uses:
5533 @smallexample
5534 extern int old_var __attribute__ ((deprecated));
5535 extern int old_var;
5536 int new_fn () @{ return old_var; @}
5537 @end smallexample
5539 @noindent
5540 results in a warning on line 3 but not line 2.  The optional @var{msg}
5541 argument, which must be a string, is printed in the warning if
5542 present.
5544 The @code{deprecated} attribute can also be used for functions and
5545 types (@pxref{Common Function Attributes},
5546 @pxref{Common Type Attributes}).
5548 @item mode (@var{mode})
5549 @cindex @code{mode} variable attribute
5550 This attribute specifies the data type for the declaration---whichever
5551 type corresponds to the mode @var{mode}.  This in effect lets you
5552 request an integer or floating-point type according to its width.
5554 You may also specify a mode of @code{byte} or @code{__byte__} to
5555 indicate the mode corresponding to a one-byte integer, @code{word} or
5556 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5557 or @code{__pointer__} for the mode used to represent pointers.
5559 @item packed
5560 @cindex @code{packed} variable attribute
5561 The @code{packed} attribute specifies that a variable or structure field
5562 should have the smallest possible alignment---one byte for a variable,
5563 and one bit for a field, unless you specify a larger value with the
5564 @code{aligned} attribute.
5566 Here is a structure in which the field @code{x} is packed, so that it
5567 immediately follows @code{a}:
5569 @smallexample
5570 struct foo
5572   char a;
5573   int x[2] __attribute__ ((packed));
5575 @end smallexample
5577 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5578 @code{packed} attribute on bit-fields of type @code{char}.  This has
5579 been fixed in GCC 4.4 but the change can lead to differences in the
5580 structure layout.  See the documentation of
5581 @option{-Wpacked-bitfield-compat} for more information.
5583 @item section ("@var{section-name}")
5584 @cindex @code{section} variable attribute
5585 Normally, the compiler places the objects it generates in sections like
5586 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5587 or you need certain particular variables to appear in special sections,
5588 for example to map to special hardware.  The @code{section}
5589 attribute specifies that a variable (or function) lives in a particular
5590 section.  For example, this small program uses several specific section names:
5592 @smallexample
5593 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5594 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5595 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5596 int init_data __attribute__ ((section ("INITDATA")));
5598 main()
5600   /* @r{Initialize stack pointer} */
5601   init_sp (stack + sizeof (stack));
5603   /* @r{Initialize initialized data} */
5604   memcpy (&init_data, &data, &edata - &data);
5606   /* @r{Turn on the serial ports} */
5607   init_duart (&a);
5608   init_duart (&b);
5610 @end smallexample
5612 @noindent
5613 Use the @code{section} attribute with
5614 @emph{global} variables and not @emph{local} variables,
5615 as shown in the example.
5617 You may use the @code{section} attribute with initialized or
5618 uninitialized global variables but the linker requires
5619 each object be defined once, with the exception that uninitialized
5620 variables tentatively go in the @code{common} (or @code{bss}) section
5621 and can be multiply ``defined''.  Using the @code{section} attribute
5622 changes what section the variable goes into and may cause the
5623 linker to issue an error if an uninitialized variable has multiple
5624 definitions.  You can force a variable to be initialized with the
5625 @option{-fno-common} flag or the @code{nocommon} attribute.
5627 Some file formats do not support arbitrary sections so the @code{section}
5628 attribute is not available on all platforms.
5629 If you need to map the entire contents of a module to a particular
5630 section, consider using the facilities of the linker instead.
5632 @item tls_model ("@var{tls_model}")
5633 @cindex @code{tls_model} variable attribute
5634 The @code{tls_model} attribute sets thread-local storage model
5635 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5636 overriding @option{-ftls-model=} command-line switch on a per-variable
5637 basis.
5638 The @var{tls_model} argument should be one of @code{global-dynamic},
5639 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5641 Not all targets support this attribute.
5643 @item unused
5644 @cindex @code{unused} variable attribute
5645 This attribute, attached to a variable, means that the variable is meant
5646 to be possibly unused.  GCC does not produce a warning for this
5647 variable.
5649 @item used
5650 @cindex @code{used} variable attribute
5651 This attribute, attached to a variable with static storage, means that
5652 the variable must be emitted even if it appears that the variable is not
5653 referenced.
5655 When applied to a static data member of a C++ class template, the
5656 attribute also means that the member is instantiated if the
5657 class itself is instantiated.
5659 @item vector_size (@var{bytes})
5660 @cindex @code{vector_size} variable attribute
5661 This attribute specifies the vector size for the variable, measured in
5662 bytes.  For example, the declaration:
5664 @smallexample
5665 int foo __attribute__ ((vector_size (16)));
5666 @end smallexample
5668 @noindent
5669 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5670 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5671 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5673 This attribute is only applicable to integral and float scalars,
5674 although arrays, pointers, and function return values are allowed in
5675 conjunction with this construct.
5677 Aggregates with this attribute are invalid, even if they are of the same
5678 size as a corresponding scalar.  For example, the declaration:
5680 @smallexample
5681 struct S @{ int a; @};
5682 struct S  __attribute__ ((vector_size (16))) foo;
5683 @end smallexample
5685 @noindent
5686 is invalid even if the size of the structure is the same as the size of
5687 the @code{int}.
5689 @item weak
5690 @cindex @code{weak} variable attribute
5691 The @code{weak} attribute is described in
5692 @ref{Common Function Attributes}.
5694 @end table
5696 @node AVR Variable Attributes
5697 @subsection AVR Variable Attributes
5699 @table @code
5700 @item progmem
5701 @cindex @code{progmem} variable attribute, AVR
5702 The @code{progmem} attribute is used on the AVR to place read-only
5703 data in the non-volatile program memory (flash). The @code{progmem}
5704 attribute accomplishes this by putting respective variables into a
5705 section whose name starts with @code{.progmem}.
5707 This attribute works similar to the @code{section} attribute
5708 but adds additional checking. Notice that just like the
5709 @code{section} attribute, @code{progmem} affects the location
5710 of the data but not how this data is accessed.
5712 In order to read data located with the @code{progmem} attribute
5713 (inline) assembler must be used.
5714 @smallexample
5715 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5716 #include <avr/pgmspace.h> 
5718 /* Locate var in flash memory */
5719 const int var[2] PROGMEM = @{ 1, 2 @};
5721 int read_var (int i)
5723     /* Access var[] by accessor macro from avr/pgmspace.h */
5724     return (int) pgm_read_word (& var[i]);
5726 @end smallexample
5728 AVR is a Harvard architecture processor and data and read-only data
5729 normally resides in the data memory (RAM).
5731 See also the @ref{AVR Named Address Spaces} section for
5732 an alternate way to locate and access data in flash memory.
5734 @item io
5735 @itemx io (@var{addr})
5736 @cindex @code{io} variable attribute, AVR
5737 Variables with the @code{io} attribute are used to address
5738 memory-mapped peripherals in the io address range.
5739 If an address is specified, the variable
5740 is assigned that address, and the value is interpreted as an
5741 address in the data address space.
5742 Example:
5744 @smallexample
5745 volatile int porta __attribute__((io (0x22)));
5746 @end smallexample
5748 The address specified in the address in the data address range.
5750 Otherwise, the variable it is not assigned an address, but the
5751 compiler will still use in/out instructions where applicable,
5752 assuming some other module assigns an address in the io address range.
5753 Example:
5755 @smallexample
5756 extern volatile int porta __attribute__((io));
5757 @end smallexample
5759 @item io_low
5760 @itemx io_low (@var{addr})
5761 @cindex @code{io_low} variable attribute, AVR
5762 This is like the @code{io} attribute, but additionally it informs the
5763 compiler that the object lies in the lower half of the I/O area,
5764 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5765 instructions.
5767 @item address
5768 @itemx address (@var{addr})
5769 @cindex @code{address} variable attribute, AVR
5770 Variables with the @code{address} attribute are used to address
5771 memory-mapped peripherals that may lie outside the io address range.
5773 @smallexample
5774 volatile int porta __attribute__((address (0x600)));
5775 @end smallexample
5777 @end table
5779 @node Blackfin Variable Attributes
5780 @subsection Blackfin Variable Attributes
5782 Three attributes are currently defined for the Blackfin.
5784 @table @code
5785 @item l1_data
5786 @itemx l1_data_A
5787 @itemx l1_data_B
5788 @cindex @code{l1_data} variable attribute, Blackfin
5789 @cindex @code{l1_data_A} variable attribute, Blackfin
5790 @cindex @code{l1_data_B} variable attribute, Blackfin
5791 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5792 Variables with @code{l1_data} attribute are put into the specific section
5793 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5794 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5795 attribute are put into the specific section named @code{.l1.data.B}.
5797 @item l2
5798 @cindex @code{l2} variable attribute, Blackfin
5799 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5800 Variables with @code{l2} attribute are put into the specific section
5801 named @code{.l2.data}.
5802 @end table
5804 @node H8/300 Variable Attributes
5805 @subsection H8/300 Variable Attributes
5807 These variable attributes are available for H8/300 targets:
5809 @table @code
5810 @item eightbit_data
5811 @cindex @code{eightbit_data} variable attribute, H8/300
5812 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5813 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5814 variable should be placed into the eight-bit data section.
5815 The compiler generates more efficient code for certain operations
5816 on data in the eight-bit data area.  Note the eight-bit data area is limited to
5817 256 bytes of data.
5819 You must use GAS and GLD from GNU binutils version 2.7 or later for
5820 this attribute to work correctly.
5822 @item tiny_data
5823 @cindex @code{tiny_data} variable attribute, H8/300
5824 @cindex tiny data section on the H8/300H and H8S
5825 Use this attribute on the H8/300H and H8S to indicate that the specified
5826 variable should be placed into the tiny data section.
5827 The compiler generates more efficient code for loads and stores
5828 on data in the tiny data section.  Note the tiny data area is limited to
5829 slightly under 32KB of data.
5831 @end table
5833 @node IA-64 Variable Attributes
5834 @subsection IA-64 Variable Attributes
5836 The IA-64 back end supports the following variable attribute:
5838 @table @code
5839 @item model (@var{model-name})
5840 @cindex @code{model} variable attribute, IA-64
5842 On IA-64, use this attribute to set the addressability of an object.
5843 At present, the only supported identifier for @var{model-name} is
5844 @code{small}, indicating addressability via ``small'' (22-bit)
5845 addresses (so that their addresses can be loaded with the @code{addl}
5846 instruction).  Caveat: such addressing is by definition not position
5847 independent and hence this attribute must not be used for objects
5848 defined by shared libraries.
5850 @end table
5852 @node M32R/D Variable Attributes
5853 @subsection M32R/D Variable Attributes
5855 One attribute is currently defined for the M32R/D@.
5857 @table @code
5858 @item model (@var{model-name})
5859 @cindex @code{model-name} variable attribute, M32R/D
5860 @cindex variable addressability on the M32R/D
5861 Use this attribute on the M32R/D to set the addressability of an object.
5862 The identifier @var{model-name} is one of @code{small}, @code{medium},
5863 or @code{large}, representing each of the code models.
5865 Small model objects live in the lower 16MB of memory (so that their
5866 addresses can be loaded with the @code{ld24} instruction).
5868 Medium and large model objects may live anywhere in the 32-bit address space
5869 (the compiler generates @code{seth/add3} instructions to load their
5870 addresses).
5871 @end table
5873 @node MeP Variable Attributes
5874 @subsection MeP Variable Attributes
5876 The MeP target has a number of addressing modes and busses.  The
5877 @code{near} space spans the standard memory space's first 16 megabytes
5878 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5879 The @code{based} space is a 128-byte region in the memory space that
5880 is addressed relative to the @code{$tp} register.  The @code{tiny}
5881 space is a 65536-byte region relative to the @code{$gp} register.  In
5882 addition to these memory regions, the MeP target has a separate 16-bit
5883 control bus which is specified with @code{cb} attributes.
5885 @table @code
5887 @item based
5888 @cindex @code{based} variable attribute, MeP
5889 Any variable with the @code{based} attribute is assigned to the
5890 @code{.based} section, and is accessed with relative to the
5891 @code{$tp} register.
5893 @item tiny
5894 @cindex @code{tiny} variable attribute, MeP
5895 Likewise, the @code{tiny} attribute assigned variables to the
5896 @code{.tiny} section, relative to the @code{$gp} register.
5898 @item near
5899 @cindex @code{near} variable attribute, MeP
5900 Variables with the @code{near} attribute are assumed to have addresses
5901 that fit in a 24-bit addressing mode.  This is the default for large
5902 variables (@code{-mtiny=4} is the default) but this attribute can
5903 override @code{-mtiny=} for small variables, or override @code{-ml}.
5905 @item far
5906 @cindex @code{far} variable attribute, MeP
5907 Variables with the @code{far} attribute are addressed using a full
5908 32-bit address.  Since this covers the entire memory space, this
5909 allows modules to make no assumptions about where variables might be
5910 stored.
5912 @item io
5913 @cindex @code{io} variable attribute, MeP
5914 @itemx io (@var{addr})
5915 Variables with the @code{io} attribute are used to address
5916 memory-mapped peripherals.  If an address is specified, the variable
5917 is assigned that address, else it is not assigned an address (it is
5918 assumed some other module assigns an address).  Example:
5920 @smallexample
5921 int timer_count __attribute__((io(0x123)));
5922 @end smallexample
5924 @item cb
5925 @itemx cb (@var{addr})
5926 @cindex @code{cb} variable attribute, MeP
5927 Variables with the @code{cb} attribute are used to access the control
5928 bus, using special instructions.  @code{addr} indicates the control bus
5929 address.  Example:
5931 @smallexample
5932 int cpu_clock __attribute__((cb(0x123)));
5933 @end smallexample
5935 @end table
5937 @node Microsoft Windows Variable Attributes
5938 @subsection Microsoft Windows Variable Attributes
5940 You can use these attributes on Microsoft Windows targets.
5941 @ref{x86 Variable Attributes} for additional Windows compatibility
5942 attributes available on all x86 targets.
5944 @table @code
5945 @item dllimport
5946 @itemx dllexport
5947 @cindex @code{dllimport} variable attribute
5948 @cindex @code{dllexport} variable attribute
5949 The @code{dllimport} and @code{dllexport} attributes are described in
5950 @ref{Microsoft Windows Function Attributes}.
5952 @item selectany
5953 @cindex @code{selectany} variable attribute
5954 The @code{selectany} attribute causes an initialized global variable to
5955 have link-once semantics.  When multiple definitions of the variable are
5956 encountered by the linker, the first is selected and the remainder are
5957 discarded.  Following usage by the Microsoft compiler, the linker is told
5958 @emph{not} to warn about size or content differences of the multiple
5959 definitions.
5961 Although the primary usage of this attribute is for POD types, the
5962 attribute can also be applied to global C++ objects that are initialized
5963 by a constructor.  In this case, the static initialization and destruction
5964 code for the object is emitted in each translation defining the object,
5965 but the calls to the constructor and destructor are protected by a
5966 link-once guard variable.
5968 The @code{selectany} attribute is only available on Microsoft Windows
5969 targets.  You can use @code{__declspec (selectany)} as a synonym for
5970 @code{__attribute__ ((selectany))} for compatibility with other
5971 compilers.
5973 @item shared
5974 @cindex @code{shared} variable attribute
5975 On Microsoft Windows, in addition to putting variable definitions in a named
5976 section, the section can also be shared among all running copies of an
5977 executable or DLL@.  For example, this small program defines shared data
5978 by putting it in a named section @code{shared} and marking the section
5979 shareable:
5981 @smallexample
5982 int foo __attribute__((section ("shared"), shared)) = 0;
5985 main()
5987   /* @r{Read and write foo.  All running
5988      copies see the same value.}  */
5989   return 0;
5991 @end smallexample
5993 @noindent
5994 You may only use the @code{shared} attribute along with @code{section}
5995 attribute with a fully-initialized global definition because of the way
5996 linkers work.  See @code{section} attribute for more information.
5998 The @code{shared} attribute is only available on Microsoft Windows@.
6000 @end table
6002 @node PowerPC Variable Attributes
6003 @subsection PowerPC Variable Attributes
6005 Three attributes currently are defined for PowerPC configurations:
6006 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6008 @cindex @code{ms_struct} variable attribute, PowerPC
6009 @cindex @code{gcc_struct} variable attribute, PowerPC
6010 For full documentation of the struct attributes please see the
6011 documentation in @ref{x86 Variable Attributes}.
6013 @cindex @code{altivec} variable attribute, PowerPC
6014 For documentation of @code{altivec} attribute please see the
6015 documentation in @ref{PowerPC Type Attributes}.
6017 @node SPU Variable Attributes
6018 @subsection SPU Variable Attributes
6020 @cindex @code{spu_vector} variable attribute, SPU
6021 The SPU supports the @code{spu_vector} attribute for variables.  For
6022 documentation of this attribute please see the documentation in
6023 @ref{SPU Type Attributes}.
6025 @node x86 Variable Attributes
6026 @subsection x86 Variable Attributes
6028 Two attributes are currently defined for x86 configurations:
6029 @code{ms_struct} and @code{gcc_struct}.
6031 @table @code
6032 @item ms_struct
6033 @itemx gcc_struct
6034 @cindex @code{ms_struct} variable attribute, x86
6035 @cindex @code{gcc_struct} variable attribute, x86
6037 If @code{packed} is used on a structure, or if bit-fields are used,
6038 it may be that the Microsoft ABI lays out the structure differently
6039 than the way GCC normally does.  Particularly when moving packed
6040 data between functions compiled with GCC and the native Microsoft compiler
6041 (either via function call or as data in a file), it may be necessary to access
6042 either format.
6044 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6045 compilers to match the native Microsoft compiler.
6047 The Microsoft structure layout algorithm is fairly simple with the exception
6048 of the bit-field packing.  
6049 The padding and alignment of members of structures and whether a bit-field 
6050 can straddle a storage-unit boundary are determine by these rules:
6052 @enumerate
6053 @item Structure members are stored sequentially in the order in which they are
6054 declared: the first member has the lowest memory address and the last member
6055 the highest.
6057 @item Every data object has an alignment requirement.  The alignment requirement
6058 for all data except structures, unions, and arrays is either the size of the
6059 object or the current packing size (specified with either the
6060 @code{aligned} attribute or the @code{pack} pragma),
6061 whichever is less.  For structures, unions, and arrays,
6062 the alignment requirement is the largest alignment requirement of its members.
6063 Every object is allocated an offset so that:
6065 @smallexample
6066 offset % alignment_requirement == 0
6067 @end smallexample
6069 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
6070 unit if the integral types are the same size and if the next bit-field fits
6071 into the current allocation unit without crossing the boundary imposed by the
6072 common alignment requirements of the bit-fields.
6073 @end enumerate
6075 MSVC interprets zero-length bit-fields in the following ways:
6077 @enumerate
6078 @item If a zero-length bit-field is inserted between two bit-fields that
6079 are normally coalesced, the bit-fields are not coalesced.
6081 For example:
6083 @smallexample
6084 struct
6085  @{
6086    unsigned long bf_1 : 12;
6087    unsigned long : 0;
6088    unsigned long bf_2 : 12;
6089  @} t1;
6090 @end smallexample
6092 @noindent
6093 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
6094 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
6096 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
6097 alignment of the zero-length bit-field is greater than the member that follows it,
6098 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
6100 For example:
6102 @smallexample
6103 struct
6104  @{
6105    char foo : 4;
6106    short : 0;
6107    char bar;
6108  @} t2;
6110 struct
6111  @{
6112    char foo : 4;
6113    short : 0;
6114    double bar;
6115  @} t3;
6116 @end smallexample
6118 @noindent
6119 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
6120 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
6121 bit-field does not affect the alignment of @code{bar} or, as a result, the size
6122 of the structure.
6124 Taking this into account, it is important to note the following:
6126 @enumerate
6127 @item If a zero-length bit-field follows a normal bit-field, the type of the
6128 zero-length bit-field may affect the alignment of the structure as whole. For
6129 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
6130 normal bit-field, and is of type short.
6132 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
6133 still affect the alignment of the structure:
6135 @smallexample
6136 struct
6137  @{
6138    char foo : 6;
6139    long : 0;
6140  @} t4;
6141 @end smallexample
6143 @noindent
6144 Here, @code{t4} takes up 4 bytes.
6145 @end enumerate
6147 @item Zero-length bit-fields following non-bit-field members are ignored:
6149 @smallexample
6150 struct
6151  @{
6152    char foo;
6153    long : 0;
6154    char bar;
6155  @} t5;
6156 @end smallexample
6158 @noindent
6159 Here, @code{t5} takes up 2 bytes.
6160 @end enumerate
6161 @end table
6163 @node Xstormy16 Variable Attributes
6164 @subsection Xstormy16 Variable Attributes
6166 One attribute is currently defined for xstormy16 configurations:
6167 @code{below100}.
6169 @table @code
6170 @item below100
6171 @cindex @code{below100} variable attribute, Xstormy16
6173 If a variable has the @code{below100} attribute (@code{BELOW100} is
6174 allowed also), GCC places the variable in the first 0x100 bytes of
6175 memory and use special opcodes to access it.  Such variables are
6176 placed in either the @code{.bss_below100} section or the
6177 @code{.data_below100} section.
6179 @end table
6181 @node Type Attributes
6182 @section Specifying Attributes of Types
6183 @cindex attribute of types
6184 @cindex type attributes
6186 The keyword @code{__attribute__} allows you to specify special
6187 attributes of types.  Some type attributes apply only to @code{struct}
6188 and @code{union} types, while others can apply to any type defined
6189 via a @code{typedef} declaration.  Other attributes are defined for
6190 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6191 Attributes}) and for variables (@pxref{Variable Attributes}).
6193 The @code{__attribute__} keyword is followed by an attribute specification
6194 inside double parentheses.  
6196 You may specify type attributes in an enum, struct or union type
6197 declaration or definition by placing them immediately after the
6198 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6199 syntax is to place them just past the closing curly brace of the
6200 definition.
6202 You can also include type attributes in a @code{typedef} declaration.
6203 @xref{Attribute Syntax}, for details of the exact syntax for using
6204 attributes.
6206 @menu
6207 * Common Type Attributes::
6208 * ARM Type Attributes::
6209 * MeP Type Attributes::
6210 * PowerPC Type Attributes::
6211 * SPU Type Attributes::
6212 * x86 Type Attributes::
6213 @end menu
6215 @node Common Type Attributes
6216 @subsection Common Type Attributes
6218 The following type attributes are supported on most targets.
6220 @table @code
6221 @cindex @code{aligned} type attribute
6222 @item aligned (@var{alignment})
6223 This attribute specifies a minimum alignment (in bytes) for variables
6224 of the specified type.  For example, the declarations:
6226 @smallexample
6227 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6228 typedef int more_aligned_int __attribute__ ((aligned (8)));
6229 @end smallexample
6231 @noindent
6232 force the compiler to ensure (as far as it can) that each variable whose
6233 type is @code{struct S} or @code{more_aligned_int} is allocated and
6234 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6235 variables of type @code{struct S} aligned to 8-byte boundaries allows
6236 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6237 store) instructions when copying one variable of type @code{struct S} to
6238 another, thus improving run-time efficiency.
6240 Note that the alignment of any given @code{struct} or @code{union} type
6241 is required by the ISO C standard to be at least a perfect multiple of
6242 the lowest common multiple of the alignments of all of the members of
6243 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6244 effectively adjust the alignment of a @code{struct} or @code{union}
6245 type by attaching an @code{aligned} attribute to any one of the members
6246 of such a type, but the notation illustrated in the example above is a
6247 more obvious, intuitive, and readable way to request the compiler to
6248 adjust the alignment of an entire @code{struct} or @code{union} type.
6250 As in the preceding example, you can explicitly specify the alignment
6251 (in bytes) that you wish the compiler to use for a given @code{struct}
6252 or @code{union} type.  Alternatively, you can leave out the alignment factor
6253 and just ask the compiler to align a type to the maximum
6254 useful alignment for the target machine you are compiling for.  For
6255 example, you could write:
6257 @smallexample
6258 struct S @{ short f[3]; @} __attribute__ ((aligned));
6259 @end smallexample
6261 Whenever you leave out the alignment factor in an @code{aligned}
6262 attribute specification, the compiler automatically sets the alignment
6263 for the type to the largest alignment that is ever used for any data
6264 type on the target machine you are compiling for.  Doing this can often
6265 make copy operations more efficient, because the compiler can use
6266 whatever instructions copy the biggest chunks of memory when performing
6267 copies to or from the variables that have types that you have aligned
6268 this way.
6270 In the example above, if the size of each @code{short} is 2 bytes, then
6271 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6272 power of two that is greater than or equal to that is 8, so the
6273 compiler sets the alignment for the entire @code{struct S} type to 8
6274 bytes.
6276 Note that although you can ask the compiler to select a time-efficient
6277 alignment for a given type and then declare only individual stand-alone
6278 objects of that type, the compiler's ability to select a time-efficient
6279 alignment is primarily useful only when you plan to create arrays of
6280 variables having the relevant (efficiently aligned) type.  If you
6281 declare or use arrays of variables of an efficiently-aligned type, then
6282 it is likely that your program also does pointer arithmetic (or
6283 subscripting, which amounts to the same thing) on pointers to the
6284 relevant type, and the code that the compiler generates for these
6285 pointer arithmetic operations is often more efficient for
6286 efficiently-aligned types than for other types.
6288 The @code{aligned} attribute can only increase the alignment; but you
6289 can decrease it by specifying @code{packed} as well.  See below.
6291 Note that the effectiveness of @code{aligned} attributes may be limited
6292 by inherent limitations in your linker.  On many systems, the linker is
6293 only able to arrange for variables to be aligned up to a certain maximum
6294 alignment.  (For some linkers, the maximum supported alignment may
6295 be very very small.)  If your linker is only able to align variables
6296 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6297 in an @code{__attribute__} still only provides you with 8-byte
6298 alignment.  See your linker documentation for further information.
6300 @opindex fshort-enums
6301 Specifying this attribute for @code{struct} and @code{union} types is
6302 equivalent to specifying the @code{packed} attribute on each of the
6303 structure or union members.  Specifying the @option{-fshort-enums}
6304 flag on the line is equivalent to specifying the @code{packed}
6305 attribute on all @code{enum} definitions.
6307 In the following example @code{struct my_packed_struct}'s members are
6308 packed closely together, but the internal layout of its @code{s} member
6309 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6310 be packed too.
6312 @smallexample
6313 struct my_unpacked_struct
6314  @{
6315     char c;
6316     int i;
6317  @};
6319 struct __attribute__ ((__packed__)) my_packed_struct
6320   @{
6321      char c;
6322      int  i;
6323      struct my_unpacked_struct s;
6324   @};
6325 @end smallexample
6327 You may only specify this attribute on the definition of an @code{enum},
6328 @code{struct} or @code{union}, not on a @code{typedef} that does not
6329 also define the enumerated type, structure or union.
6331 @item bnd_variable_size
6332 @cindex @code{bnd_variable_size} type attribute
6333 @cindex Pointer Bounds Checker attributes
6334 When applied to a structure field, this attribute tells Pointer
6335 Bounds Checker that the size of this field should not be computed
6336 using static type information.  It may be used to mark variably-sized
6337 static array fields placed at the end of a structure.
6339 @smallexample
6340 struct S
6342   int size;
6343   char data[1];
6345 S *p = (S *)malloc (sizeof(S) + 100);
6346 p->data[10] = 0; //Bounds violation
6347 @end smallexample
6349 @noindent
6350 By using an attribute for the field we may avoid unwanted bound
6351 violation checks:
6353 @smallexample
6354 struct S
6356   int size;
6357   char data[1] __attribute__((bnd_variable_size));
6359 S *p = (S *)malloc (sizeof(S) + 100);
6360 p->data[10] = 0; //OK
6361 @end smallexample
6363 @item deprecated
6364 @itemx deprecated (@var{msg})
6365 @cindex @code{deprecated} type attribute
6366 The @code{deprecated} attribute results in a warning if the type
6367 is used anywhere in the source file.  This is useful when identifying
6368 types that are expected to be removed in a future version of a program.
6369 If possible, the warning also includes the location of the declaration
6370 of the deprecated type, to enable users to easily find further
6371 information about why the type is deprecated, or what they should do
6372 instead.  Note that the warnings only occur for uses and then only
6373 if the type is being applied to an identifier that itself is not being
6374 declared as deprecated.
6376 @smallexample
6377 typedef int T1 __attribute__ ((deprecated));
6378 T1 x;
6379 typedef T1 T2;
6380 T2 y;
6381 typedef T1 T3 __attribute__ ((deprecated));
6382 T3 z __attribute__ ((deprecated));
6383 @end smallexample
6385 @noindent
6386 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
6387 warning is issued for line 4 because T2 is not explicitly
6388 deprecated.  Line 5 has no warning because T3 is explicitly
6389 deprecated.  Similarly for line 6.  The optional @var{msg}
6390 argument, which must be a string, is printed in the warning if
6391 present.
6393 The @code{deprecated} attribute can also be used for functions and
6394 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6396 @item designated_init
6397 @cindex @code{designated_init} type attribute
6398 This attribute may only be applied to structure types.  It indicates
6399 that any initialization of an object of this type must use designated
6400 initializers rather than positional initializers.  The intent of this
6401 attribute is to allow the programmer to indicate that a structure's
6402 layout may change, and that therefore relying on positional
6403 initialization will result in future breakage.
6405 GCC emits warnings based on this attribute by default; use
6406 @option{-Wno-designated-init} to suppress them.
6408 @item may_alias
6409 @cindex @code{may_alias} type attribute
6410 Accesses through pointers to types with this attribute are not subject
6411 to type-based alias analysis, but are instead assumed to be able to alias
6412 any other type of objects.
6413 In the context of section 6.5 paragraph 7 of the C99 standard,
6414 an lvalue expression
6415 dereferencing such a pointer is treated like having a character type.
6416 See @option{-fstrict-aliasing} for more information on aliasing issues.
6417 This extension exists to support some vector APIs, in which pointers to
6418 one vector type are permitted to alias pointers to a different vector type.
6420 Note that an object of a type with this attribute does not have any
6421 special semantics.
6423 Example of use:
6425 @smallexample
6426 typedef short __attribute__((__may_alias__)) short_a;
6429 main (void)
6431   int a = 0x12345678;
6432   short_a *b = (short_a *) &a;
6434   b[1] = 0;
6436   if (a == 0x12345678)
6437     abort();
6439   exit(0);
6441 @end smallexample
6443 @noindent
6444 If you replaced @code{short_a} with @code{short} in the variable
6445 declaration, the above program would abort when compiled with
6446 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6447 above.
6449 @item packed
6450 @cindex @code{packed} type attribute
6451 This attribute, attached to @code{struct} or @code{union} type
6452 definition, specifies that each member (other than zero-width bit-fields)
6453 of the structure or union is placed to minimize the memory required.  When
6454 attached to an @code{enum} definition, it indicates that the smallest
6455 integral type should be used.
6457 @item transparent_union
6458 @cindex @code{transparent_union} type attribute
6460 This attribute, attached to a @code{union} type definition, indicates
6461 that any function parameter having that union type causes calls to that
6462 function to be treated in a special way.
6464 First, the argument corresponding to a transparent union type can be of
6465 any type in the union; no cast is required.  Also, if the union contains
6466 a pointer type, the corresponding argument can be a null pointer
6467 constant or a void pointer expression; and if the union contains a void
6468 pointer type, the corresponding argument can be any pointer expression.
6469 If the union member type is a pointer, qualifiers like @code{const} on
6470 the referenced type must be respected, just as with normal pointer
6471 conversions.
6473 Second, the argument is passed to the function using the calling
6474 conventions of the first member of the transparent union, not the calling
6475 conventions of the union itself.  All members of the union must have the
6476 same machine representation; this is necessary for this argument passing
6477 to work properly.
6479 Transparent unions are designed for library functions that have multiple
6480 interfaces for compatibility reasons.  For example, suppose the
6481 @code{wait} function must accept either a value of type @code{int *} to
6482 comply with POSIX, or a value of type @code{union wait *} to comply with
6483 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
6484 @code{wait} would accept both kinds of arguments, but it would also
6485 accept any other pointer type and this would make argument type checking
6486 less useful.  Instead, @code{<sys/wait.h>} might define the interface
6487 as follows:
6489 @smallexample
6490 typedef union __attribute__ ((__transparent_union__))
6491   @{
6492     int *__ip;
6493     union wait *__up;
6494   @} wait_status_ptr_t;
6496 pid_t wait (wait_status_ptr_t);
6497 @end smallexample
6499 @noindent
6500 This interface allows either @code{int *} or @code{union wait *}
6501 arguments to be passed, using the @code{int *} calling convention.
6502 The program can call @code{wait} with arguments of either type:
6504 @smallexample
6505 int w1 () @{ int w; return wait (&w); @}
6506 int w2 () @{ union wait w; return wait (&w); @}
6507 @end smallexample
6509 @noindent
6510 With this interface, @code{wait}'s implementation might look like this:
6512 @smallexample
6513 pid_t wait (wait_status_ptr_t p)
6515   return waitpid (-1, p.__ip, 0);
6517 @end smallexample
6519 @item unused
6520 @cindex @code{unused} type attribute
6521 When attached to a type (including a @code{union} or a @code{struct}),
6522 this attribute means that variables of that type are meant to appear
6523 possibly unused.  GCC does not produce a warning for any variables of
6524 that type, even if the variable appears to do nothing.  This is often
6525 the case with lock or thread classes, which are usually defined and then
6526 not referenced, but contain constructors and destructors that have
6527 nontrivial bookkeeping functions.
6529 @item visibility
6530 @cindex @code{visibility} type attribute
6531 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6532 applied to class, struct, union and enum types.  Unlike other type
6533 attributes, the attribute must appear between the initial keyword and
6534 the name of the type; it cannot appear after the body of the type.
6536 Note that the type visibility is applied to vague linkage entities
6537 associated with the class (vtable, typeinfo node, etc.).  In
6538 particular, if a class is thrown as an exception in one shared object
6539 and caught in another, the class must have default visibility.
6540 Otherwise the two shared objects are unable to use the same
6541 typeinfo node and exception handling will break.
6543 @end table
6545 To specify multiple attributes, separate them by commas within the
6546 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6547 packed))}.
6549 @node ARM Type Attributes
6550 @subsection ARM Type Attributes
6552 @cindex @code{notshared} type attribute, ARM
6553 On those ARM targets that support @code{dllimport} (such as Symbian
6554 OS), you can use the @code{notshared} attribute to indicate that the
6555 virtual table and other similar data for a class should not be
6556 exported from a DLL@.  For example:
6558 @smallexample
6559 class __declspec(notshared) C @{
6560 public:
6561   __declspec(dllimport) C();
6562   virtual void f();
6565 __declspec(dllexport)
6566 C::C() @{@}
6567 @end smallexample
6569 @noindent
6570 In this code, @code{C::C} is exported from the current DLL, but the
6571 virtual table for @code{C} is not exported.  (You can use
6572 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6573 most Symbian OS code uses @code{__declspec}.)
6575 @node MeP Type Attributes
6576 @subsection MeP Type Attributes
6578 @cindex @code{based} type attribute, MeP
6579 @cindex @code{tiny} type attribute, MeP
6580 @cindex @code{near} type attribute, MeP
6581 @cindex @code{far} type attribute, MeP
6582 Many of the MeP variable attributes may be applied to types as well.
6583 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6584 @code{far} attributes may be applied to either.  The @code{io} and
6585 @code{cb} attributes may not be applied to types.
6587 @node PowerPC Type Attributes
6588 @subsection PowerPC Type Attributes
6590 Three attributes currently are defined for PowerPC configurations:
6591 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6593 @cindex @code{ms_struct} type attribute, PowerPC
6594 @cindex @code{gcc_struct} type attribute, PowerPC
6595 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6596 attributes please see the documentation in @ref{x86 Type Attributes}.
6598 @cindex @code{altivec} type attribute, PowerPC
6599 The @code{altivec} attribute allows one to declare AltiVec vector data
6600 types supported by the AltiVec Programming Interface Manual.  The
6601 attribute requires an argument to specify one of three vector types:
6602 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6603 and @code{bool__} (always followed by unsigned).
6605 @smallexample
6606 __attribute__((altivec(vector__)))
6607 __attribute__((altivec(pixel__))) unsigned short
6608 __attribute__((altivec(bool__))) unsigned
6609 @end smallexample
6611 These attributes mainly are intended to support the @code{__vector},
6612 @code{__pixel}, and @code{__bool} AltiVec keywords.
6614 @node SPU Type Attributes
6615 @subsection SPU Type Attributes
6617 @cindex @code{spu_vector} type attribute, SPU
6618 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6619 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6620 Language Extensions Specification.  It is intended to support the
6621 @code{__vector} keyword.
6623 @node x86 Type Attributes
6624 @subsection x86 Type Attributes
6626 Two attributes are currently defined for x86 configurations:
6627 @code{ms_struct} and @code{gcc_struct}.
6629 @table @code
6631 @item ms_struct
6632 @itemx gcc_struct
6633 @cindex @code{ms_struct} type attribute, x86
6634 @cindex @code{gcc_struct} type attribute, x86
6636 If @code{packed} is used on a structure, or if bit-fields are used
6637 it may be that the Microsoft ABI packs them differently
6638 than GCC normally packs them.  Particularly when moving packed
6639 data between functions compiled with GCC and the native Microsoft compiler
6640 (either via function call or as data in a file), it may be necessary to access
6641 either format.
6643 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6644 compilers to match the native Microsoft compiler.
6645 @end table
6647 @node Alignment
6648 @section Inquiring on Alignment of Types or Variables
6649 @cindex alignment
6650 @cindex type alignment
6651 @cindex variable alignment
6653 The keyword @code{__alignof__} allows you to inquire about how an object
6654 is aligned, or the minimum alignment usually required by a type.  Its
6655 syntax is just like @code{sizeof}.
6657 For example, if the target machine requires a @code{double} value to be
6658 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6659 This is true on many RISC machines.  On more traditional machine
6660 designs, @code{__alignof__ (double)} is 4 or even 2.
6662 Some machines never actually require alignment; they allow reference to any
6663 data type even at an odd address.  For these machines, @code{__alignof__}
6664 reports the smallest alignment that GCC gives the data type, usually as
6665 mandated by the target ABI.
6667 If the operand of @code{__alignof__} is an lvalue rather than a type,
6668 its value is the required alignment for its type, taking into account
6669 any minimum alignment specified with GCC's @code{__attribute__}
6670 extension (@pxref{Variable Attributes}).  For example, after this
6671 declaration:
6673 @smallexample
6674 struct foo @{ int x; char y; @} foo1;
6675 @end smallexample
6677 @noindent
6678 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6679 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6681 It is an error to ask for the alignment of an incomplete type.
6684 @node Inline
6685 @section An Inline Function is As Fast As a Macro
6686 @cindex inline functions
6687 @cindex integrating function code
6688 @cindex open coding
6689 @cindex macros, inline alternative
6691 By declaring a function inline, you can direct GCC to make
6692 calls to that function faster.  One way GCC can achieve this is to
6693 integrate that function's code into the code for its callers.  This
6694 makes execution faster by eliminating the function-call overhead; in
6695 addition, if any of the actual argument values are constant, their
6696 known values may permit simplifications at compile time so that not
6697 all of the inline function's code needs to be included.  The effect on
6698 code size is less predictable; object code may be larger or smaller
6699 with function inlining, depending on the particular case.  You can
6700 also direct GCC to try to integrate all ``simple enough'' functions
6701 into their callers with the option @option{-finline-functions}.
6703 GCC implements three different semantics of declaring a function
6704 inline.  One is available with @option{-std=gnu89} or
6705 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6706 on all inline declarations, another when
6707 @option{-std=c99}, @option{-std=c11},
6708 @option{-std=gnu99} or @option{-std=gnu11}
6709 (without @option{-fgnu89-inline}), and the third
6710 is used when compiling C++.
6712 To declare a function inline, use the @code{inline} keyword in its
6713 declaration, like this:
6715 @smallexample
6716 static inline int
6717 inc (int *a)
6719   return (*a)++;
6721 @end smallexample
6723 If you are writing a header file to be included in ISO C90 programs, write
6724 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6726 The three types of inlining behave similarly in two important cases:
6727 when the @code{inline} keyword is used on a @code{static} function,
6728 like the example above, and when a function is first declared without
6729 using the @code{inline} keyword and then is defined with
6730 @code{inline}, like this:
6732 @smallexample
6733 extern int inc (int *a);
6734 inline int
6735 inc (int *a)
6737   return (*a)++;
6739 @end smallexample
6741 In both of these common cases, the program behaves the same as if you
6742 had not used the @code{inline} keyword, except for its speed.
6744 @cindex inline functions, omission of
6745 @opindex fkeep-inline-functions
6746 When a function is both inline and @code{static}, if all calls to the
6747 function are integrated into the caller, and the function's address is
6748 never used, then the function's own assembler code is never referenced.
6749 In this case, GCC does not actually output assembler code for the
6750 function, unless you specify the option @option{-fkeep-inline-functions}.
6751 Some calls cannot be integrated for various reasons (in particular,
6752 calls that precede the function's definition cannot be integrated, and
6753 neither can recursive calls within the definition).  If there is a
6754 nonintegrated call, then the function is compiled to assembler code as
6755 usual.  The function must also be compiled as usual if the program
6756 refers to its address, because that can't be inlined.
6758 @opindex Winline
6759 Note that certain usages in a function definition can make it unsuitable
6760 for inline substitution.  Among these usages are: variadic functions, use of
6761 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6762 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6763 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6764 warns when a function marked @code{inline} could not be substituted,
6765 and gives the reason for the failure.
6767 @cindex automatic @code{inline} for C++ member fns
6768 @cindex @code{inline} automatic for C++ member fns
6769 @cindex member fns, automatically @code{inline}
6770 @cindex C++ member fns, automatically @code{inline}
6771 @opindex fno-default-inline
6772 As required by ISO C++, GCC considers member functions defined within
6773 the body of a class to be marked inline even if they are
6774 not explicitly declared with the @code{inline} keyword.  You can
6775 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6776 Options,,Options Controlling C++ Dialect}.
6778 GCC does not inline any functions when not optimizing unless you specify
6779 the @samp{always_inline} attribute for the function, like this:
6781 @smallexample
6782 /* @r{Prototype.}  */
6783 inline void foo (const char) __attribute__((always_inline));
6784 @end smallexample
6786 The remainder of this section is specific to GNU C90 inlining.
6788 @cindex non-static inline function
6789 When an inline function is not @code{static}, then the compiler must assume
6790 that there may be calls from other source files; since a global symbol can
6791 be defined only once in any program, the function must not be defined in
6792 the other source files, so the calls therein cannot be integrated.
6793 Therefore, a non-@code{static} inline function is always compiled on its
6794 own in the usual fashion.
6796 If you specify both @code{inline} and @code{extern} in the function
6797 definition, then the definition is used only for inlining.  In no case
6798 is the function compiled on its own, not even if you refer to its
6799 address explicitly.  Such an address becomes an external reference, as
6800 if you had only declared the function, and had not defined it.
6802 This combination of @code{inline} and @code{extern} has almost the
6803 effect of a macro.  The way to use it is to put a function definition in
6804 a header file with these keywords, and put another copy of the
6805 definition (lacking @code{inline} and @code{extern}) in a library file.
6806 The definition in the header file causes most calls to the function
6807 to be inlined.  If any uses of the function remain, they refer to
6808 the single copy in the library.
6810 @node Volatiles
6811 @section When is a Volatile Object Accessed?
6812 @cindex accessing volatiles
6813 @cindex volatile read
6814 @cindex volatile write
6815 @cindex volatile access
6817 C has the concept of volatile objects.  These are normally accessed by
6818 pointers and used for accessing hardware or inter-thread
6819 communication.  The standard encourages compilers to refrain from
6820 optimizations concerning accesses to volatile objects, but leaves it
6821 implementation defined as to what constitutes a volatile access.  The
6822 minimum requirement is that at a sequence point all previous accesses
6823 to volatile objects have stabilized and no subsequent accesses have
6824 occurred.  Thus an implementation is free to reorder and combine
6825 volatile accesses that occur between sequence points, but cannot do
6826 so for accesses across a sequence point.  The use of volatile does
6827 not allow you to violate the restriction on updating objects multiple
6828 times between two sequence points.
6830 Accesses to non-volatile objects are not ordered with respect to
6831 volatile accesses.  You cannot use a volatile object as a memory
6832 barrier to order a sequence of writes to non-volatile memory.  For
6833 instance:
6835 @smallexample
6836 int *ptr = @var{something};
6837 volatile int vobj;
6838 *ptr = @var{something};
6839 vobj = 1;
6840 @end smallexample
6842 @noindent
6843 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6844 that the write to @var{*ptr} occurs by the time the update
6845 of @var{vobj} happens.  If you need this guarantee, you must use
6846 a stronger memory barrier such as:
6848 @smallexample
6849 int *ptr = @var{something};
6850 volatile int vobj;
6851 *ptr = @var{something};
6852 asm volatile ("" : : : "memory");
6853 vobj = 1;
6854 @end smallexample
6856 A scalar volatile object is read when it is accessed in a void context:
6858 @smallexample
6859 volatile int *src = @var{somevalue};
6860 *src;
6861 @end smallexample
6863 Such expressions are rvalues, and GCC implements this as a
6864 read of the volatile object being pointed to.
6866 Assignments are also expressions and have an rvalue.  However when
6867 assigning to a scalar volatile, the volatile object is not reread,
6868 regardless of whether the assignment expression's rvalue is used or
6869 not.  If the assignment's rvalue is used, the value is that assigned
6870 to the volatile object.  For instance, there is no read of @var{vobj}
6871 in all the following cases:
6873 @smallexample
6874 int obj;
6875 volatile int vobj;
6876 vobj = @var{something};
6877 obj = vobj = @var{something};
6878 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6879 obj = (@var{something}, vobj = @var{anotherthing});
6880 @end smallexample
6882 If you need to read the volatile object after an assignment has
6883 occurred, you must use a separate expression with an intervening
6884 sequence point.
6886 As bit-fields are not individually addressable, volatile bit-fields may
6887 be implicitly read when written to, or when adjacent bit-fields are
6888 accessed.  Bit-field operations may be optimized such that adjacent
6889 bit-fields are only partially accessed, if they straddle a storage unit
6890 boundary.  For these reasons it is unwise to use volatile bit-fields to
6891 access hardware.
6893 @node Using Assembly Language with C
6894 @section How to Use Inline Assembly Language in C Code
6895 @cindex @code{asm} keyword
6896 @cindex assembly language in C
6897 @cindex inline assembly language
6898 @cindex mixing assembly language and C
6900 The @code{asm} keyword allows you to embed assembler instructions
6901 within C code.  GCC provides two forms of inline @code{asm}
6902 statements.  A @dfn{basic @code{asm}} statement is one with no
6903 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
6904 statement (@pxref{Extended Asm}) includes one or more operands.  
6905 The extended form is preferred for mixing C and assembly language
6906 within a function, but to include assembly language at
6907 top level you must use basic @code{asm}.
6909 You can also use the @code{asm} keyword to override the assembler name
6910 for a C symbol, or to place a C variable in a specific register.
6912 @menu
6913 * Basic Asm::          Inline assembler without operands.
6914 * Extended Asm::       Inline assembler with operands.
6915 * Constraints::        Constraints for @code{asm} operands
6916 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6917 * Explicit Reg Vars::  Defining variables residing in specified registers.
6918 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6919 @end menu
6921 @node Basic Asm
6922 @subsection Basic Asm --- Assembler Instructions Without Operands
6923 @cindex basic @code{asm}
6924 @cindex assembly language in C, basic
6926 A basic @code{asm} statement has the following syntax:
6928 @example
6929 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
6930 @end example
6932 The @code{asm} keyword is a GNU extension.
6933 When writing code that can be compiled with @option{-ansi} and the
6934 various @option{-std} options, use @code{__asm__} instead of 
6935 @code{asm} (@pxref{Alternate Keywords}).
6937 @subsubheading Qualifiers
6938 @table @code
6939 @item volatile
6940 The optional @code{volatile} qualifier has no effect. 
6941 All basic @code{asm} blocks are implicitly volatile.
6942 @end table
6944 @subsubheading Parameters
6945 @table @var
6947 @item AssemblerInstructions
6948 This is a literal string that specifies the assembler code. The string can 
6949 contain any instructions recognized by the assembler, including directives. 
6950 GCC does not parse the assembler instructions themselves and 
6951 does not know what they mean or even whether they are valid assembler input. 
6953 You may place multiple assembler instructions together in a single @code{asm} 
6954 string, separated by the characters normally used in assembly code for the 
6955 system. A combination that works in most places is a newline to break the 
6956 line, plus a tab character (written as @samp{\n\t}).
6957 Some assemblers allow semicolons as a line separator. However, 
6958 note that some assembler dialects use semicolons to start a comment. 
6959 @end table
6961 @subsubheading Remarks
6962 Using extended @code{asm} typically produces smaller, safer, and more
6963 efficient code, and in most cases it is a better solution than basic
6964 @code{asm}.  However, there are two situations where only basic @code{asm}
6965 can be used:
6967 @itemize @bullet
6968 @item
6969 Extended @code{asm} statements have to be inside a C
6970 function, so to write inline assembly language at file scope (``top-level''),
6971 outside of C functions, you must use basic @code{asm}.
6972 You can use this technique to emit assembler directives,
6973 define assembly language macros that can be invoked elsewhere in the file,
6974 or write entire functions in assembly language.
6976 @item
6977 Functions declared
6978 with the @code{naked} attribute also require basic @code{asm}
6979 (@pxref{Function Attributes}).
6980 @end itemize
6982 Safely accessing C data and calling functions from basic @code{asm} is more 
6983 complex than it may appear. To access C data, it is better to use extended 
6984 @code{asm}.
6986 Do not expect a sequence of @code{asm} statements to remain perfectly 
6987 consecutive after compilation. If certain instructions need to remain 
6988 consecutive in the output, put them in a single multi-instruction @code{asm}
6989 statement. Note that GCC's optimizers can move @code{asm} statements 
6990 relative to other code, including across jumps.
6992 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6993 GCC does not know about these jumps, and therefore cannot take 
6994 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6995 labels are only supported in extended @code{asm}.
6997 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6998 assembly code when optimizing. This can lead to unexpected duplicate 
6999 symbol errors during compilation if your assembly code defines symbols or 
7000 labels.
7002 Since GCC does not parse the @var{AssemblerInstructions}, it has no 
7003 visibility of any symbols it references. This may result in GCC discarding 
7004 those symbols as unreferenced.
7006 The compiler copies the assembler instructions in a basic @code{asm} 
7007 verbatim to the assembly language output file, without 
7008 processing dialects or any of the @samp{%} operators that are available with
7009 extended @code{asm}. This results in minor differences between basic 
7010 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
7011 registers you might use @samp{%eax} in basic @code{asm} and
7012 @samp{%%eax} in extended @code{asm}.
7014 On targets such as x86 that support multiple assembler dialects,
7015 all basic @code{asm} blocks use the assembler dialect specified by the 
7016 @option{-masm} command-line option (@pxref{x86 Options}).  
7017 Basic @code{asm} provides no
7018 mechanism to provide different assembler strings for different dialects.
7020 Here is an example of basic @code{asm} for i386:
7022 @example
7023 /* Note that this code will not compile with -masm=intel */
7024 #define DebugBreak() asm("int $3")
7025 @end example
7027 @node Extended Asm
7028 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7029 @cindex extended @code{asm}
7030 @cindex assembly language in C, extended
7032 With extended @code{asm} you can read and write C variables from 
7033 assembler and perform jumps from assembler code to C labels.  
7034 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7035 the operand parameters after the assembler template:
7037 @example
7038 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
7039                  : @var{OutputOperands} 
7040                  @r{[} : @var{InputOperands}
7041                  @r{[} : @var{Clobbers} @r{]} @r{]})
7043 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
7044                       : 
7045                       : @var{InputOperands}
7046                       : @var{Clobbers}
7047                       : @var{GotoLabels})
7048 @end example
7050 The @code{asm} keyword is a GNU extension.
7051 When writing code that can be compiled with @option{-ansi} and the
7052 various @option{-std} options, use @code{__asm__} instead of 
7053 @code{asm} (@pxref{Alternate Keywords}).
7055 @subsubheading Qualifiers
7056 @table @code
7058 @item volatile
7059 The typical use of extended @code{asm} statements is to manipulate input 
7060 values to produce output values. However, your @code{asm} statements may 
7061 also produce side effects. If so, you may need to use the @code{volatile} 
7062 qualifier to disable certain optimizations. @xref{Volatile}.
7064 @item goto
7065 This qualifier informs the compiler that the @code{asm} statement may 
7066 perform a jump to one of the labels listed in the @var{GotoLabels}.
7067 @xref{GotoLabels}.
7068 @end table
7070 @subsubheading Parameters
7071 @table @var
7072 @item AssemblerTemplate
7073 This is a literal string that is the template for the assembler code. It is a 
7074 combination of fixed text and tokens that refer to the input, output, 
7075 and goto parameters. @xref{AssemblerTemplate}.
7077 @item OutputOperands
7078 A comma-separated list of the C variables modified by the instructions in the 
7079 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
7081 @item InputOperands
7082 A comma-separated list of C expressions read by the instructions in the 
7083 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
7085 @item Clobbers
7086 A comma-separated list of registers or other values changed by the 
7087 @var{AssemblerTemplate}, beyond those listed as outputs.
7088 An empty list is permitted.  @xref{Clobbers}.
7090 @item GotoLabels
7091 When you are using the @code{goto} form of @code{asm}, this section contains 
7092 the list of all C labels to which the code in the 
7093 @var{AssemblerTemplate} may jump. 
7094 @xref{GotoLabels}.
7096 @code{asm} statements may not perform jumps into other @code{asm} statements,
7097 only to the listed @var{GotoLabels}.
7098 GCC's optimizers do not know about other jumps; therefore they cannot take 
7099 account of them when deciding how to optimize.
7100 @end table
7102 The total number of input + output + goto operands is limited to 30.
7104 @subsubheading Remarks
7105 The @code{asm} statement allows you to include assembly instructions directly 
7106 within C code. This may help you to maximize performance in time-sensitive 
7107 code or to access assembly instructions that are not readily available to C 
7108 programs.
7110 Note that extended @code{asm} statements must be inside a function. Only 
7111 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7112 Functions declared with the @code{naked} attribute also require basic 
7113 @code{asm} (@pxref{Function Attributes}).
7115 While the uses of @code{asm} are many and varied, it may help to think of an 
7116 @code{asm} statement as a series of low-level instructions that convert input 
7117 parameters to output parameters. So a simple (if not particularly useful) 
7118 example for i386 using @code{asm} might look like this:
7120 @example
7121 int src = 1;
7122 int dst;   
7124 asm ("mov %1, %0\n\t"
7125     "add $1, %0"
7126     : "=r" (dst) 
7127     : "r" (src));
7129 printf("%d\n", dst);
7130 @end example
7132 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7134 @anchor{Volatile}
7135 @subsubsection Volatile
7136 @cindex volatile @code{asm}
7137 @cindex @code{asm} volatile
7139 GCC's optimizers sometimes discard @code{asm} statements if they determine 
7140 there is no need for the output variables. Also, the optimizers may move 
7141 code out of loops if they believe that the code will always return the same 
7142 result (i.e. none of its input values change between calls). Using the 
7143 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
7144 that have no output operands, including @code{asm goto} statements, 
7145 are implicitly volatile.
7147 This i386 code demonstrates a case that does not use (or require) the 
7148 @code{volatile} qualifier. If it is performing assertion checking, this code 
7149 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
7150 unreferenced by any code. As a result, the optimizers can discard the 
7151 @code{asm} statement, which in turn removes the need for the entire 
7152 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
7153 isn't needed you allow the optimizers to produce the most efficient code 
7154 possible.
7156 @example
7157 void DoCheck(uint32_t dwSomeValue)
7159    uint32_t dwRes;
7161    // Assumes dwSomeValue is not zero.
7162    asm ("bsfl %1,%0"
7163      : "=r" (dwRes)
7164      : "r" (dwSomeValue)
7165      : "cc");
7167    assert(dwRes > 3);
7169 @end example
7171 The next example shows a case where the optimizers can recognize that the input 
7172 (@code{dwSomeValue}) never changes during the execution of the function and can 
7173 therefore move the @code{asm} outside the loop to produce more efficient code. 
7174 Again, using @code{volatile} disables this type of optimization.
7176 @example
7177 void do_print(uint32_t dwSomeValue)
7179    uint32_t dwRes;
7181    for (uint32_t x=0; x < 5; x++)
7182    @{
7183       // Assumes dwSomeValue is not zero.
7184       asm ("bsfl %1,%0"
7185         : "=r" (dwRes)
7186         : "r" (dwSomeValue)
7187         : "cc");
7189       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7190    @}
7192 @end example
7194 The following example demonstrates a case where you need to use the 
7195 @code{volatile} qualifier. 
7196 It uses the x86 @code{rdtsc} instruction, which reads 
7197 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
7198 the optimizers might assume that the @code{asm} block will always return the 
7199 same value and therefore optimize away the second call.
7201 @example
7202 uint64_t msr;
7204 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7205         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7206         "or %%rdx, %0"        // 'Or' in the lower bits.
7207         : "=a" (msr)
7208         : 
7209         : "rdx");
7211 printf("msr: %llx\n", msr);
7213 // Do other work...
7215 // Reprint the timestamp
7216 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7217         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7218         "or %%rdx, %0"        // 'Or' in the lower bits.
7219         : "=a" (msr)
7220         : 
7221         : "rdx");
7223 printf("msr: %llx\n", msr);
7224 @end example
7226 GCC's optimizers do not treat this code like the non-volatile code in the 
7227 earlier examples. They do not move it out of loops or omit it on the 
7228 assumption that the result from a previous call is still valid.
7230 Note that the compiler can move even volatile @code{asm} instructions relative 
7231 to other code, including across jump instructions. For example, on many 
7232 targets there is a system register that controls the rounding mode of 
7233 floating-point operations. Setting it with a volatile @code{asm}, as in the 
7234 following PowerPC example, does not work reliably.
7236 @example
7237 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7238 sum = x + y;
7239 @end example
7241 The compiler may move the addition back before the volatile @code{asm}. To 
7242 make it work as expected, add an artificial dependency to the @code{asm} by 
7243 referencing a variable in the subsequent code, for example: 
7245 @example
7246 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7247 sum = x + y;
7248 @end example
7250 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7251 assembly code when optimizing. This can lead to unexpected duplicate symbol 
7252 errors during compilation if your asm code defines symbols or labels. 
7253 Using @samp{%=} 
7254 (@pxref{AssemblerTemplate}) may help resolve this problem.
7256 @anchor{AssemblerTemplate}
7257 @subsubsection Assembler Template
7258 @cindex @code{asm} assembler template
7260 An assembler template is a literal string containing assembler instructions.
7261 The compiler replaces tokens in the template that refer 
7262 to inputs, outputs, and goto labels,
7263 and then outputs the resulting string to the assembler. The 
7264 string can contain any instructions recognized by the assembler, including 
7265 directives. GCC does not parse the assembler instructions 
7266 themselves and does not know what they mean or even whether they are valid 
7267 assembler input. However, it does count the statements 
7268 (@pxref{Size of an asm}).
7270 You may place multiple assembler instructions together in a single @code{asm} 
7271 string, separated by the characters normally used in assembly code for the 
7272 system. A combination that works in most places is a newline to break the 
7273 line, plus a tab character to move to the instruction field (written as 
7274 @samp{\n\t}). 
7275 Some assemblers allow semicolons as a line separator. However, note 
7276 that some assembler dialects use semicolons to start a comment. 
7278 Do not expect a sequence of @code{asm} statements to remain perfectly 
7279 consecutive after compilation, even when you are using the @code{volatile} 
7280 qualifier. If certain instructions need to remain consecutive in the output, 
7281 put them in a single multi-instruction asm statement.
7283 Accessing data from C programs without using input/output operands (such as 
7284 by using global symbols directly from the assembler template) may not work as 
7285 expected. Similarly, calling functions directly from an assembler template 
7286 requires a detailed understanding of the target assembler and ABI.
7288 Since GCC does not parse the assembler template,
7289 it has no visibility of any 
7290 symbols it references. This may result in GCC discarding those symbols as 
7291 unreferenced unless they are also listed as input, output, or goto operands.
7293 @subsubheading Special format strings
7295 In addition to the tokens described by the input, output, and goto operands, 
7296 these tokens have special meanings in the assembler template:
7298 @table @samp
7299 @item %% 
7300 Outputs a single @samp{%} into the assembler code.
7302 @item %= 
7303 Outputs a number that is unique to each instance of the @code{asm} 
7304 statement in the entire compilation. This option is useful when creating local 
7305 labels and referring to them multiple times in a single template that 
7306 generates multiple assembler instructions. 
7308 @item %@{
7309 @itemx %|
7310 @itemx %@}
7311 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7312 into the assembler code.  When unescaped, these characters have special
7313 meaning to indicate multiple assembler dialects, as described below.
7314 @end table
7316 @subsubheading Multiple assembler dialects in @code{asm} templates
7318 On targets such as x86, GCC supports multiple assembler dialects.
7319 The @option{-masm} option controls which dialect GCC uses as its 
7320 default for inline assembler. The target-specific documentation for the 
7321 @option{-masm} option contains the list of supported dialects, as well as the 
7322 default dialect if the option is not specified. This information may be 
7323 important to understand, since assembler code that works correctly when 
7324 compiled using one dialect will likely fail if compiled using another.
7325 @xref{x86 Options}.
7327 If your code needs to support multiple assembler dialects (for example, if 
7328 you are writing public headers that need to support a variety of compilation 
7329 options), use constructs of this form:
7331 @example
7332 @{ dialect0 | dialect1 | dialect2... @}
7333 @end example
7335 This construct outputs @code{dialect0} 
7336 when using dialect #0 to compile the code, 
7337 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
7338 braces than the number of dialects the compiler supports, the construct 
7339 outputs nothing.
7341 For example, if an x86 compiler supports two dialects
7342 (@samp{att}, @samp{intel}), an 
7343 assembler template such as this:
7345 @example
7346 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7347 @end example
7349 @noindent
7350 is equivalent to one of
7352 @example
7353 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
7354 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
7355 @end example
7357 Using that same compiler, this code:
7359 @example
7360 "xchg@{l@}\t@{%%@}ebx, %1"
7361 @end example
7363 @noindent
7364 corresponds to either
7366 @example
7367 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
7368 "xchg\tebx, %1"                    @r{/* intel dialect */}
7369 @end example
7371 There is no support for nesting dialect alternatives.
7373 @anchor{OutputOperands}
7374 @subsubsection Output Operands
7375 @cindex @code{asm} output operands
7377 An @code{asm} statement has zero or more output operands indicating the names
7378 of C variables modified by the assembler code.
7380 In this i386 example, @code{old} (referred to in the template string as 
7381 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
7382 (@code{%2}) is an input:
7384 @example
7385 bool old;
7387 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7388          "sbb %0,%0"      // Use the CF to calculate old.
7389    : "=r" (old), "+rm" (*Base)
7390    : "Ir" (Offset)
7391    : "cc");
7393 return old;
7394 @end example
7396 Operands are separated by commas.  Each operand has this format:
7398 @example
7399 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7400 @end example
7402 @table @var
7403 @item asmSymbolicName
7404 Specifies a symbolic name for the operand.
7405 Reference the name in the assembler template 
7406 by enclosing it in square brackets 
7407 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
7408 that contains the definition. Any valid C variable name is acceptable, 
7409 including names already defined in the surrounding code. No two operands 
7410 within the same @code{asm} statement can use the same symbolic name.
7412 When not using an @var{asmSymbolicName}, use the (zero-based) position
7413 of the operand 
7414 in the list of operands in the assembler template. For example if there are 
7415 three output operands, use @samp{%0} in the template to refer to the first, 
7416 @samp{%1} for the second, and @samp{%2} for the third. 
7418 @item constraint
7419 A string constant specifying constraints on the placement of the operand; 
7420 @xref{Constraints}, for details.
7422 Output constraints must begin with either @samp{=} (a variable overwriting an 
7423 existing value) or @samp{+} (when reading and writing). When using 
7424 @samp{=}, do not assume the location contains the existing value
7425 on entry to the @code{asm}, except 
7426 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7428 After the prefix, there must be one or more additional constraints 
7429 (@pxref{Constraints}) that describe where the value resides. Common 
7430 constraints include @samp{r} for register and @samp{m} for memory. 
7431 When you list more than one possible location (for example, @code{"=rm"}),
7432 the compiler chooses the most efficient one based on the current context. 
7433 If you list as many alternates as the @code{asm} statement allows, you permit 
7434 the optimizers to produce the best possible code. 
7435 If you must use a specific register, but your Machine Constraints do not
7436 provide sufficient control to select the specific register you want, 
7437 local register variables may provide a solution (@pxref{Local Reg Vars}).
7439 @item cvariablename
7440 Specifies a C lvalue expression to hold the output, typically a variable name.
7441 The enclosing parentheses are a required part of the syntax.
7443 @end table
7445 When the compiler selects the registers to use to 
7446 represent the output operands, it does not use any of the clobbered registers 
7447 (@pxref{Clobbers}).
7449 Output operand expressions must be lvalues. The compiler cannot check whether 
7450 the operands have data types that are reasonable for the instruction being 
7451 executed. For output expressions that are not directly addressable (for 
7452 example a bit-field), the constraint must allow a register. In that case, GCC 
7453 uses the register as the output of the @code{asm}, and then stores that 
7454 register into the output. 
7456 Operands using the @samp{+} constraint modifier count as two operands 
7457 (that is, both as input and output) towards the total maximum of 30 operands
7458 per @code{asm} statement.
7460 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7461 operands that must not overlap an input.  Otherwise, 
7462 GCC may allocate the output operand in the same register as an unrelated 
7463 input operand, on the assumption that the assembler code consumes its 
7464 inputs before producing outputs. This assumption may be false if the assembler 
7465 code actually consists of more than one instruction.
7467 The same problem can occur if one output parameter (@var{a}) allows a register 
7468 constraint and another output parameter (@var{b}) allows a memory constraint.
7469 The code generated by GCC to access the memory address in @var{b} can contain
7470 registers which @emph{might} be shared by @var{a}, and GCC considers those 
7471 registers to be inputs to the asm. As above, GCC assumes that such input
7472 registers are consumed before any outputs are written. This assumption may 
7473 result in incorrect behavior if the asm writes to @var{a} before using 
7474 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7475 ensures that modifying @var{a} does not affect the address referenced by 
7476 @var{b}. Otherwise, the location of @var{b} 
7477 is undefined if @var{a} is modified before using @var{b}.
7479 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7480 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7481 dependent. The list of supported modifiers for x86 is found at 
7482 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7484 If the C code that follows the @code{asm} makes no use of any of the output 
7485 operands, use @code{volatile} for the @code{asm} statement to prevent the 
7486 optimizers from discarding the @code{asm} statement as unneeded 
7487 (see @ref{Volatile}).
7489 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
7490 references the first output operand as @code{%0} (were there a second, it 
7491 would be @code{%1}, etc). The number of the first input operand is one greater 
7492 than that of the last output operand. In this i386 example, that makes 
7493 @code{Mask} referenced as @code{%1}:
7495 @example
7496 uint32_t Mask = 1234;
7497 uint32_t Index;
7499   asm ("bsfl %1, %0"
7500      : "=r" (Index)
7501      : "r" (Mask)
7502      : "cc");
7503 @end example
7505 That code overwrites the variable @code{Index} (@samp{=}),
7506 placing the value in a register (@samp{r}).
7507 Using the generic @samp{r} constraint instead of a constraint for a specific 
7508 register allows the compiler to pick the register to use, which can result 
7509 in more efficient code. This may not be possible if an assembler instruction 
7510 requires a specific register.
7512 The following i386 example uses the @var{asmSymbolicName} syntax.
7513 It produces the 
7514 same result as the code above, but some may consider it more readable or more 
7515 maintainable since reordering index numbers is not necessary when adding or 
7516 removing operands. The names @code{aIndex} and @code{aMask}
7517 are only used in this example to emphasize which 
7518 names get used where.
7519 It is acceptable to reuse the names @code{Index} and @code{Mask}.
7521 @example
7522 uint32_t Mask = 1234;
7523 uint32_t Index;
7525   asm ("bsfl %[aMask], %[aIndex]"
7526      : [aIndex] "=r" (Index)
7527      : [aMask] "r" (Mask)
7528      : "cc");
7529 @end example
7531 Here are some more examples of output operands.
7533 @example
7534 uint32_t c = 1;
7535 uint32_t d;
7536 uint32_t *e = &c;
7538 asm ("mov %[e], %[d]"
7539    : [d] "=rm" (d)
7540    : [e] "rm" (*e));
7541 @end example
7543 Here, @code{d} may either be in a register or in memory. Since the compiler 
7544 might already have the current value of the @code{uint32_t} location
7545 pointed to by @code{e}
7546 in a register, you can enable it to choose the best location
7547 for @code{d} by specifying both constraints.
7549 @anchor{InputOperands}
7550 @subsubsection Input Operands
7551 @cindex @code{asm} input operands
7552 @cindex @code{asm} expressions
7554 Input operands make values from C variables and expressions available to the 
7555 assembly code.
7557 Operands are separated by commas.  Each operand has this format:
7559 @example
7560 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
7561 @end example
7563 @table @var
7564 @item asmSymbolicName
7565 Specifies a symbolic name for the operand.
7566 Reference the name in the assembler template 
7567 by enclosing it in square brackets 
7568 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
7569 that contains the definition. Any valid C variable name is acceptable, 
7570 including names already defined in the surrounding code. No two operands 
7571 within the same @code{asm} statement can use the same symbolic name.
7573 When not using an @var{asmSymbolicName}, use the (zero-based) position
7574 of the operand 
7575 in the list of operands in the assembler template. For example if there are
7576 two output operands and three inputs,
7577 use @samp{%2} in the template to refer to the first input operand,
7578 @samp{%3} for the second, and @samp{%4} for the third. 
7580 @item constraint
7581 A string constant specifying constraints on the placement of the operand; 
7582 @xref{Constraints}, for details.
7584 Input constraint strings may not begin with either @samp{=} or @samp{+}.
7585 When you list more than one possible location (for example, @samp{"irm"}), 
7586 the compiler chooses the most efficient one based on the current context.
7587 If you must use a specific register, but your Machine Constraints do not
7588 provide sufficient control to select the specific register you want, 
7589 local register variables may provide a solution (@pxref{Local Reg Vars}).
7591 Input constraints can also be digits (for example, @code{"0"}). This indicates 
7592 that the specified input must be in the same place as the output constraint 
7593 at the (zero-based) index in the output constraint list. 
7594 When using @var{asmSymbolicName} syntax for the output operands,
7595 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
7597 @item cexpression
7598 This is the C variable or expression being passed to the @code{asm} statement 
7599 as input.  The enclosing parentheses are a required part of the syntax.
7601 @end table
7603 When the compiler selects the registers to use to represent the input 
7604 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
7606 If there are no output operands but there are input operands, place two 
7607 consecutive colons where the output operands would go:
7609 @example
7610 __asm__ ("some instructions"
7611    : /* No outputs. */
7612    : "r" (Offset / 8));
7613 @end example
7615 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7616 (except for inputs tied to outputs). The compiler assumes that on exit from 
7617 the @code{asm} statement these operands contain the same values as they 
7618 had before executing the statement. 
7619 It is @emph{not} possible to use clobbers
7620 to inform the compiler that the values in these inputs are changing. One 
7621 common work-around is to tie the changing input variable to an output variable 
7622 that never gets used. Note, however, that if the code that follows the 
7623 @code{asm} statement makes no use of any of the output operands, the GCC 
7624 optimizers may discard the @code{asm} statement as unneeded 
7625 (see @ref{Volatile}).
7627 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7628 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7629 dependent. The list of supported modifiers for x86 is found at 
7630 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7632 In this example using the fictitious @code{combine} instruction, the 
7633 constraint @code{"0"} for input operand 1 says that it must occupy the same 
7634 location as output operand 0. Only input operands may use numbers in 
7635 constraints, and they must each refer to an output operand. Only a number (or 
7636 the symbolic assembler name) in the constraint can guarantee that one operand 
7637 is in the same place as another. The mere fact that @code{foo} is the value of 
7638 both operands is not enough to guarantee that they are in the same place in 
7639 the generated assembler code.
7641 @example
7642 asm ("combine %2, %0" 
7643    : "=r" (foo) 
7644    : "0" (foo), "g" (bar));
7645 @end example
7647 Here is an example using symbolic names.
7649 @example
7650 asm ("cmoveq %1, %2, %[result]" 
7651    : [result] "=r"(result) 
7652    : "r" (test), "r" (new), "[result]" (old));
7653 @end example
7655 @anchor{Clobbers}
7656 @subsubsection Clobbers
7657 @cindex @code{asm} clobbers
7659 While the compiler is aware of changes to entries listed in the output 
7660 operands, the inline @code{asm} code may modify more than just the outputs. For 
7661 example, calculations may require additional registers, or the processor may 
7662 overwrite a register as a side effect of a particular assembler instruction. 
7663 In order to inform the compiler of these changes, list them in the clobber 
7664 list. Clobber list items are either register names or the special clobbers 
7665 (listed below). Each clobber list item is a string constant 
7666 enclosed in double quotes and separated by commas.
7668 Clobber descriptions may not in any way overlap with an input or output 
7669 operand. For example, you may not have an operand describing a register class 
7670 with one member when listing that register in the clobber list. Variables 
7671 declared to live in specific registers (@pxref{Explicit Reg Vars}) and used 
7672 as @code{asm} input or output operands must have no part mentioned in the 
7673 clobber description. In particular, there is no way to specify that input 
7674 operands get modified without also specifying them as output operands.
7676 When the compiler selects which registers to use to represent input and output 
7677 operands, it does not use any of the clobbered registers. As a result, 
7678 clobbered registers are available for any use in the assembler code.
7680 Here is a realistic example for the VAX showing the use of clobbered 
7681 registers: 
7683 @example
7684 asm volatile ("movc3 %0, %1, %2"
7685                    : /* No outputs. */
7686                    : "g" (from), "g" (to), "g" (count)
7687                    : "r0", "r1", "r2", "r3", "r4", "r5");
7688 @end example
7690 Also, there are two special clobber arguments:
7692 @table @code
7693 @item "cc"
7694 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7695 register. On some machines, GCC represents the condition codes as a specific 
7696 hardware register; @code{"cc"} serves to name this register.
7697 On other machines, condition code handling is different, 
7698 and specifying @code{"cc"} has no effect. But 
7699 it is valid no matter what the target.
7701 @item "memory"
7702 The @code{"memory"} clobber tells the compiler that the assembly code
7703 performs memory 
7704 reads or writes to items other than those listed in the input and output 
7705 operands (for example, accessing the memory pointed to by one of the input 
7706 parameters). To ensure memory contains correct values, GCC may need to flush 
7707 specific register values to memory before executing the @code{asm}. Further, 
7708 the compiler does not assume that any values read from memory before an 
7709 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
7710 needed.  
7711 Using the @code{"memory"} clobber effectively forms a read/write
7712 memory barrier for the compiler.
7714 Note that this clobber does not prevent the @emph{processor} from doing 
7715 speculative reads past the @code{asm} statement. To prevent that, you need 
7716 processor-specific fence instructions.
7718 Flushing registers to memory has performance implications and may be an issue 
7719 for time-sensitive code.  You can use a trick to avoid this if the size of 
7720 the memory being accessed is known at compile time. For example, if accessing 
7721 ten bytes of a string, use a memory input like: 
7723 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7725 @end table
7727 @anchor{GotoLabels}
7728 @subsubsection Goto Labels
7729 @cindex @code{asm} goto labels
7731 @code{asm goto} allows assembly code to jump to one or more C labels.  The
7732 @var{GotoLabels} section in an @code{asm goto} statement contains 
7733 a comma-separated 
7734 list of all C labels to which the assembler code may jump. GCC assumes that 
7735 @code{asm} execution falls through to the next statement (if this is not the 
7736 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7737 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7738 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7739 Attributes}).
7741 An @code{asm goto} statement cannot have outputs.
7742 This is due to an internal restriction of 
7743 the compiler: control transfer instructions cannot have outputs. 
7744 If the assembler code does modify anything, use the @code{"memory"} clobber 
7745 to force the 
7746 optimizers to flush all register values to memory and reload them if 
7747 necessary after the @code{asm} statement.
7749 Also note that an @code{asm goto} statement is always implicitly
7750 considered volatile.
7752 To reference a label in the assembler template,
7753 prefix it with @samp{%l} (lowercase @samp{L}) followed 
7754 by its (zero-based) position in @var{GotoLabels} plus the number of input 
7755 operands.  For example, if the @code{asm} has three inputs and references two 
7756 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
7758 Alternately, you can reference labels using the actual C label name enclosed
7759 in brackets.  For example, to reference a label named @code{carry}, you can
7760 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
7761 section when using this approach.
7763 Here is an example of @code{asm goto} for i386:
7765 @example
7766 asm goto (
7767     "btl %1, %0\n\t"
7768     "jc %l2"
7769     : /* No outputs. */
7770     : "r" (p1), "r" (p2) 
7771     : "cc" 
7772     : carry);
7774 return 0;
7776 carry:
7777 return 1;
7778 @end example
7780 The following example shows an @code{asm goto} that uses a memory clobber.
7782 @example
7783 int frob(int x)
7785   int y;
7786   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7787             : /* No outputs. */
7788             : "r"(x), "r"(&y)
7789             : "r5", "memory" 
7790             : error);
7791   return y;
7792 error:
7793   return -1;
7795 @end example
7797 @anchor{x86Operandmodifiers}
7798 @subsubsection x86 Operand Modifiers
7800 References to input, output, and goto operands in the assembler template
7801 of extended @code{asm} statements can use 
7802 modifiers to affect the way the operands are formatted in 
7803 the code output to the assembler. For example, the 
7804 following code uses the @samp{h} and @samp{b} modifiers for x86:
7806 @example
7807 uint16_t  num;
7808 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7809 @end example
7811 @noindent
7812 These modifiers generate this assembler code:
7814 @example
7815 xchg %ah, %al
7816 @end example
7818 The rest of this discussion uses the following code for illustrative purposes.
7820 @example
7821 int main()
7823    int iInt = 1;
7825 top:
7827    asm volatile goto ("some assembler instructions here"
7828    : /* No outputs. */
7829    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7830    : /* No clobbers. */
7831    : top);
7833 @end example
7835 With no modifiers, this is what the output from the operands would be for the 
7836 @samp{att} and @samp{intel} dialects of assembler:
7838 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7839 @headitem Operand @tab masm=att @tab masm=intel
7840 @item @code{%0}
7841 @tab @code{%eax}
7842 @tab @code{eax}
7843 @item @code{%1}
7844 @tab @code{$2}
7845 @tab @code{2}
7846 @item @code{%2}
7847 @tab @code{$.L2}
7848 @tab @code{OFFSET FLAT:.L2}
7849 @end multitable
7851 The table below shows the list of supported modifiers and their effects.
7853 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7854 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7855 @item @code{z}
7856 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7857 @tab @code{%z0}
7858 @tab @code{l}
7859 @tab 
7860 @item @code{b}
7861 @tab Print the QImode name of the register.
7862 @tab @code{%b0}
7863 @tab @code{%al}
7864 @tab @code{al}
7865 @item @code{h}
7866 @tab Print the QImode name for a ``high'' register.
7867 @tab @code{%h0}
7868 @tab @code{%ah}
7869 @tab @code{ah}
7870 @item @code{w}
7871 @tab Print the HImode name of the register.
7872 @tab @code{%w0}
7873 @tab @code{%ax}
7874 @tab @code{ax}
7875 @item @code{k}
7876 @tab Print the SImode name of the register.
7877 @tab @code{%k0}
7878 @tab @code{%eax}
7879 @tab @code{eax}
7880 @item @code{q}
7881 @tab Print the DImode name of the register.
7882 @tab @code{%q0}
7883 @tab @code{%rax}
7884 @tab @code{rax}
7885 @item @code{l}
7886 @tab Print the label name with no punctuation.
7887 @tab @code{%l2}
7888 @tab @code{.L2}
7889 @tab @code{.L2}
7890 @item @code{c}
7891 @tab Require a constant operand and print the constant expression with no punctuation.
7892 @tab @code{%c1}
7893 @tab @code{2}
7894 @tab @code{2}
7895 @end multitable
7897 @anchor{x86floatingpointasmoperands}
7898 @subsubsection x86 Floating-Point @code{asm} Operands
7900 On x86 targets, there are several rules on the usage of stack-like registers
7901 in the operands of an @code{asm}.  These rules apply only to the operands
7902 that are stack-like registers:
7904 @enumerate
7905 @item
7906 Given a set of input registers that die in an @code{asm}, it is
7907 necessary to know which are implicitly popped by the @code{asm}, and
7908 which must be explicitly popped by GCC@.
7910 An input register that is implicitly popped by the @code{asm} must be
7911 explicitly clobbered, unless it is constrained to match an
7912 output operand.
7914 @item
7915 For any input register that is implicitly popped by an @code{asm}, it is
7916 necessary to know how to adjust the stack to compensate for the pop.
7917 If any non-popped input is closer to the top of the reg-stack than
7918 the implicitly popped register, it would not be possible to know what the
7919 stack looked like---it's not clear how the rest of the stack ``slides
7920 up''.
7922 All implicitly popped input registers must be closer to the top of
7923 the reg-stack than any input that is not implicitly popped.
7925 It is possible that if an input dies in an @code{asm}, the compiler might
7926 use the input register for an output reload.  Consider this example:
7928 @smallexample
7929 asm ("foo" : "=t" (a) : "f" (b));
7930 @end smallexample
7932 @noindent
7933 This code says that input @code{b} is not popped by the @code{asm}, and that
7934 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7935 deeper after the @code{asm} than it was before.  But, it is possible that
7936 reload may think that it can use the same register for both the input and
7937 the output.
7939 To prevent this from happening,
7940 if any input operand uses the @samp{f} constraint, all output register
7941 constraints must use the @samp{&} early-clobber modifier.
7943 The example above is correctly written as:
7945 @smallexample
7946 asm ("foo" : "=&t" (a) : "f" (b));
7947 @end smallexample
7949 @item
7950 Some operands need to be in particular places on the stack.  All
7951 output operands fall in this category---GCC has no other way to
7952 know which registers the outputs appear in unless you indicate
7953 this in the constraints.
7955 Output operands must specifically indicate which register an output
7956 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
7957 constraints must select a class with a single register.
7959 @item
7960 Output operands may not be ``inserted'' between existing stack registers.
7961 Since no 387 opcode uses a read/write operand, all output operands
7962 are dead before the @code{asm}, and are pushed by the @code{asm}.
7963 It makes no sense to push anywhere but the top of the reg-stack.
7965 Output operands must start at the top of the reg-stack: output
7966 operands may not ``skip'' a register.
7968 @item
7969 Some @code{asm} statements may need extra stack space for internal
7970 calculations.  This can be guaranteed by clobbering stack registers
7971 unrelated to the inputs and outputs.
7973 @end enumerate
7975 This @code{asm}
7976 takes one input, which is internally popped, and produces two outputs.
7978 @smallexample
7979 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7980 @end smallexample
7982 @noindent
7983 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7984 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7985 for the compiler to know that @code{fyl2xp1} pops both inputs.
7987 @smallexample
7988 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7989 @end smallexample
7991 @lowersections
7992 @include md.texi
7993 @raisesections
7995 @node Asm Labels
7996 @subsection Controlling Names Used in Assembler Code
7997 @cindex assembler names for identifiers
7998 @cindex names used in assembler code
7999 @cindex identifiers, names in assembler code
8001 You can specify the name to be used in the assembler code for a C
8002 function or variable by writing the @code{asm} (or @code{__asm__})
8003 keyword after the declarator as follows:
8005 @smallexample
8006 int foo asm ("myfoo") = 2;
8007 @end smallexample
8009 @noindent
8010 This specifies that the name to be used for the variable @code{foo} in
8011 the assembler code should be @samp{myfoo} rather than the usual
8012 @samp{_foo}.
8014 On systems where an underscore is normally prepended to the name of a C
8015 function or variable, this feature allows you to define names for the
8016 linker that do not start with an underscore.
8018 It does not make sense to use this feature with a non-static local
8019 variable since such variables do not have assembler names.  If you are
8020 trying to put the variable in a particular register, see @ref{Explicit
8021 Reg Vars}.  GCC presently accepts such code with a warning, but will
8022 probably be changed to issue an error, rather than a warning, in the
8023 future.
8025 You cannot use @code{asm} in this way in a function @emph{definition}; but
8026 you can get the same effect by writing a declaration for the function
8027 before its definition and putting @code{asm} there, like this:
8029 @smallexample
8030 extern func () asm ("FUNC");
8032 func (x, y)
8033      int x, y;
8034 /* @r{@dots{}} */
8035 @end smallexample
8037 It is up to you to make sure that the assembler names you choose do not
8038 conflict with any other assembler symbols.  Also, you must not use a
8039 register name; that would produce completely invalid assembler code.  GCC
8040 does not as yet have the ability to store static variables in registers.
8041 Perhaps that will be added.
8043 @node Explicit Reg Vars
8044 @subsection Variables in Specified Registers
8045 @cindex explicit register variables
8046 @cindex variables in specified registers
8047 @cindex specified registers
8048 @cindex registers, global allocation
8050 GNU C allows you to put a few global variables into specified hardware
8051 registers.  You can also specify the register in which an ordinary
8052 register variable should be allocated.
8054 @itemize @bullet
8055 @item
8056 Global register variables reserve registers throughout the program.
8057 This may be useful in programs such as programming language
8058 interpreters that have a couple of global variables that are accessed
8059 very often.
8061 @item
8062 Local register variables in specific registers do not reserve the
8063 registers, except at the point where they are used as input or output
8064 operands in an @code{asm} statement and the @code{asm} statement itself is
8065 not deleted.  The compiler's data flow analysis is capable of determining
8066 where the specified registers contain live values, and where they are
8067 available for other uses.  Stores into local register variables may be deleted
8068 when they appear to be dead according to dataflow analysis.  References
8069 to local register variables may be deleted or moved or simplified.
8071 These local variables are sometimes convenient for use with the extended
8072 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
8073 output of the assembler instruction directly into a particular register.
8074 (This works provided the register you specify fits the constraints
8075 specified for that operand in the @code{asm}.)
8076 @end itemize
8078 @menu
8079 * Global Reg Vars::
8080 * Local Reg Vars::
8081 @end menu
8083 @node Global Reg Vars
8084 @subsubsection Defining Global Register Variables
8085 @cindex global register variables
8086 @cindex registers, global variables in
8088 You can define a global register variable in GNU C like this:
8090 @smallexample
8091 register int *foo asm ("a5");
8092 @end smallexample
8094 @noindent
8095 Here @code{a5} is the name of the register that should be used.  Choose a
8096 register that is normally saved and restored by function calls on your
8097 machine, so that library routines will not clobber it.
8099 Naturally the register name is CPU-dependent, so you need to
8100 conditionalize your program according to CPU type.  The register
8101 @code{a5} is a good choice on a 68000 for a variable of pointer
8102 type.  On machines with register windows, be sure to choose a ``global''
8103 register that is not affected magically by the function call mechanism.
8105 In addition, different operating systems on the same CPU may differ in how they
8106 name the registers; then you need additional conditionals.  For
8107 example, some 68000 operating systems call this register @code{%a5}.
8109 Eventually there may be a way of asking the compiler to choose a register
8110 automatically, but first we need to figure out how it should choose and
8111 how to enable you to guide the choice.  No solution is evident.
8113 Defining a global register variable in a certain register reserves that
8114 register entirely for this use, at least within the current compilation.
8115 The register is not allocated for any other purpose in the functions
8116 in the current compilation, and is not saved and restored by
8117 these functions.  Stores into this register are never deleted even if they
8118 appear to be dead, but references may be deleted or moved or
8119 simplified.
8121 It is not safe to access the global register variables from signal
8122 handlers, or from more than one thread of control, because the system
8123 library routines may temporarily use the register for other things (unless
8124 you recompile them specially for the task at hand).
8126 @cindex @code{qsort}, and global register variables
8127 It is not safe for one function that uses a global register variable to
8128 call another such function @code{foo} by way of a third function
8129 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
8130 different source file in which the variable isn't declared).  This is
8131 because @code{lose} might save the register and put some other value there.
8132 For example, you can't expect a global register variable to be available in
8133 the comparison-function that you pass to @code{qsort}, since @code{qsort}
8134 might have put something else in that register.  (If you are prepared to
8135 recompile @code{qsort} with the same global register variable, you can
8136 solve this problem.)
8138 If you want to recompile @code{qsort} or other source files that do not
8139 actually use your global register variable, so that they do not use that
8140 register for any other purpose, then it suffices to specify the compiler
8141 option @option{-ffixed-@var{reg}}.  You need not actually add a global
8142 register declaration to their source code.
8144 A function that can alter the value of a global register variable cannot
8145 safely be called from a function compiled without this variable, because it
8146 could clobber the value the caller expects to find there on return.
8147 Therefore, the function that is the entry point into the part of the
8148 program that uses the global register variable must explicitly save and
8149 restore the value that belongs to its caller.
8151 @cindex register variable after @code{longjmp}
8152 @cindex global register after @code{longjmp}
8153 @cindex value after @code{longjmp}
8154 @findex longjmp
8155 @findex setjmp
8156 On most machines, @code{longjmp} restores to each global register
8157 variable the value it had at the time of the @code{setjmp}.  On some
8158 machines, however, @code{longjmp} does not change the value of global
8159 register variables.  To be portable, the function that called @code{setjmp}
8160 should make other arrangements to save the values of the global register
8161 variables, and to restore them in a @code{longjmp}.  This way, the same
8162 thing happens regardless of what @code{longjmp} does.
8164 All global register variable declarations must precede all function
8165 definitions.  If such a declaration could appear after function
8166 definitions, the declaration would be too late to prevent the register from
8167 being used for other purposes in the preceding functions.
8169 Global register variables may not have initial values, because an
8170 executable file has no means to supply initial contents for a register.
8172 On the SPARC, there are reports that g3 @dots{} g7 are suitable
8173 registers, but certain library functions, such as @code{getwd}, as well
8174 as the subroutines for division and remainder, modify g3 and g4.  g1 and
8175 g2 are local temporaries.
8177 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
8178 Of course, it does not do to use more than a few of those.
8180 @node Local Reg Vars
8181 @subsubsection Specifying Registers for Local Variables
8182 @cindex local variables, specifying registers
8183 @cindex specifying registers for local variables
8184 @cindex registers for local variables
8186 You can define a local register variable with a specified register
8187 like this:
8189 @smallexample
8190 register int *foo asm ("a5");
8191 @end smallexample
8193 @noindent
8194 Here @code{a5} is the name of the register that should be used.  Note
8195 that this is the same syntax used for defining global register
8196 variables, but for a local variable it appears within a function.
8198 Naturally the register name is CPU-dependent, but this is not a
8199 problem, since specific registers are most often useful with explicit
8200 assembler instructions (@pxref{Extended Asm}).  Both of these things
8201 generally require that you conditionalize your program according to
8202 CPU type.
8204 In addition, operating systems on one type of CPU may differ in how they
8205 name the registers; then you need additional conditionals.  For
8206 example, some 68000 operating systems call this register @code{%a5}.
8208 Defining such a register variable does not reserve the register; it
8209 remains available for other uses in places where flow control determines
8210 the variable's value is not live.
8212 This option does not guarantee that GCC generates code that has
8213 this variable in the register you specify at all times.  You may not
8214 code an explicit reference to this register in the assembler
8215 instruction template part of an @code{asm} statement and assume it
8216 always refers to this variable.
8217 However, using the variable as an input or output operand to the @code{asm}
8218 guarantees that the specified register is used for that operand.  
8219 @xref{Extended Asm}, for more information.
8221 Stores into local register variables may be deleted when they appear to be dead
8222 according to dataflow analysis.  References to local register variables may
8223 be deleted or moved or simplified.
8225 As with global register variables, it is recommended that you choose a
8226 register that is normally saved and restored by function calls on
8227 your machine, so that library routines will not clobber it.  
8229 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
8230 specific register, but there's no matching constraint letter for that 
8231 register. To force the operand into that register, create a local variable 
8232 and specify the register in the variable's declaration. Then use the local 
8233 variable for the asm operand and specify any constraint letter that matches 
8234 the register:
8236 @smallexample
8237 register int *p1 asm ("r0") = @dots{};
8238 register int *p2 asm ("r1") = @dots{};
8239 register int *result asm ("r0");
8240 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8241 @end smallexample
8243 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
8244 call-clobbered by subsequent code, including function calls and library calls 
8245 for arithmetic operators on other variables (for example the initialization 
8246 of p2). In this case, use temporary variables for expressions between the 
8247 register assignments:
8249 @smallexample
8250 int t1 = @dots{};
8251 register int *p1 asm ("r0") = @dots{};
8252 register int *p2 asm ("r1") = t1;
8253 register int *result asm ("r0");
8254 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8255 @end smallexample
8257 @node Size of an asm
8258 @subsection Size of an @code{asm}
8260 Some targets require that GCC track the size of each instruction used
8261 in order to generate correct code.  Because the final length of the
8262 code produced by an @code{asm} statement is only known by the
8263 assembler, GCC must make an estimate as to how big it will be.  It
8264 does this by counting the number of instructions in the pattern of the
8265 @code{asm} and multiplying that by the length of the longest
8266 instruction supported by that processor.  (When working out the number
8267 of instructions, it assumes that any occurrence of a newline or of
8268 whatever statement separator character is supported by the assembler --
8269 typically @samp{;} --- indicates the end of an instruction.)
8271 Normally, GCC's estimate is adequate to ensure that correct
8272 code is generated, but it is possible to confuse the compiler if you use
8273 pseudo instructions or assembler macros that expand into multiple real
8274 instructions, or if you use assembler directives that expand to more
8275 space in the object file than is needed for a single instruction.
8276 If this happens then the assembler may produce a diagnostic saying that
8277 a label is unreachable.
8279 @node Alternate Keywords
8280 @section Alternate Keywords
8281 @cindex alternate keywords
8282 @cindex keywords, alternate
8284 @option{-ansi} and the various @option{-std} options disable certain
8285 keywords.  This causes trouble when you want to use GNU C extensions, or
8286 a general-purpose header file that should be usable by all programs,
8287 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
8288 @code{inline} are not available in programs compiled with
8289 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8290 program compiled with @option{-std=c99} or @option{-std=c11}).  The
8291 ISO C99 keyword
8292 @code{restrict} is only available when @option{-std=gnu99} (which will
8293 eventually be the default) or @option{-std=c99} (or the equivalent
8294 @option{-std=iso9899:1999}), or an option for a later standard
8295 version, is used.
8297 The way to solve these problems is to put @samp{__} at the beginning and
8298 end of each problematical keyword.  For example, use @code{__asm__}
8299 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8301 Other C compilers won't accept these alternative keywords; if you want to
8302 compile with another compiler, you can define the alternate keywords as
8303 macros to replace them with the customary keywords.  It looks like this:
8305 @smallexample
8306 #ifndef __GNUC__
8307 #define __asm__ asm
8308 #endif
8309 @end smallexample
8311 @findex __extension__
8312 @opindex pedantic
8313 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8314 You can
8315 prevent such warnings within one expression by writing
8316 @code{__extension__} before the expression.  @code{__extension__} has no
8317 effect aside from this.
8319 @node Incomplete Enums
8320 @section Incomplete @code{enum} Types
8322 You can define an @code{enum} tag without specifying its possible values.
8323 This results in an incomplete type, much like what you get if you write
8324 @code{struct foo} without describing the elements.  A later declaration
8325 that does specify the possible values completes the type.
8327 You can't allocate variables or storage using the type while it is
8328 incomplete.  However, you can work with pointers to that type.
8330 This extension may not be very useful, but it makes the handling of
8331 @code{enum} more consistent with the way @code{struct} and @code{union}
8332 are handled.
8334 This extension is not supported by GNU C++.
8336 @node Function Names
8337 @section Function Names as Strings
8338 @cindex @code{__func__} identifier
8339 @cindex @code{__FUNCTION__} identifier
8340 @cindex @code{__PRETTY_FUNCTION__} identifier
8342 GCC provides three magic variables that hold the name of the current
8343 function, as a string.  The first of these is @code{__func__}, which
8344 is part of the C99 standard:
8346 The identifier @code{__func__} is implicitly declared by the translator
8347 as if, immediately following the opening brace of each function
8348 definition, the declaration
8350 @smallexample
8351 static const char __func__[] = "function-name";
8352 @end smallexample
8354 @noindent
8355 appeared, where function-name is the name of the lexically-enclosing
8356 function.  This name is the unadorned name of the function.
8358 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8359 backward compatibility with old versions of GCC.
8361 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8362 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
8363 the type signature of the function as well as its bare name.  For
8364 example, this program:
8366 @smallexample
8367 extern "C" @{
8368 extern int printf (char *, ...);
8371 class a @{
8372  public:
8373   void sub (int i)
8374     @{
8375       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8376       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8377     @}
8381 main (void)
8383   a ax;
8384   ax.sub (0);
8385   return 0;
8387 @end smallexample
8389 @noindent
8390 gives this output:
8392 @smallexample
8393 __FUNCTION__ = sub
8394 __PRETTY_FUNCTION__ = void a::sub(int)
8395 @end smallexample
8397 These identifiers are variables, not preprocessor macros, and may not
8398 be used to initialize @code{char} arrays or be concatenated with other string
8399 literals.
8401 @node Return Address
8402 @section Getting the Return or Frame Address of a Function
8404 These functions may be used to get information about the callers of a
8405 function.
8407 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8408 This function returns the return address of the current function, or of
8409 one of its callers.  The @var{level} argument is number of frames to
8410 scan up the call stack.  A value of @code{0} yields the return address
8411 of the current function, a value of @code{1} yields the return address
8412 of the caller of the current function, and so forth.  When inlining
8413 the expected behavior is that the function returns the address of
8414 the function that is returned to.  To work around this behavior use
8415 the @code{noinline} function attribute.
8417 The @var{level} argument must be a constant integer.
8419 On some machines it may be impossible to determine the return address of
8420 any function other than the current one; in such cases, or when the top
8421 of the stack has been reached, this function returns @code{0} or a
8422 random value.  In addition, @code{__builtin_frame_address} may be used
8423 to determine if the top of the stack has been reached.
8425 Additional post-processing of the returned value may be needed, see
8426 @code{__builtin_extract_return_addr}.
8428 This function should only be used with a nonzero argument for debugging
8429 purposes.
8430 @end deftypefn
8432 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
8433 The address as returned by @code{__builtin_return_address} may have to be fed
8434 through this function to get the actual encoded address.  For example, on the
8435 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
8436 platforms an offset has to be added for the true next instruction to be
8437 executed.
8439 If no fixup is needed, this function simply passes through @var{addr}.
8440 @end deftypefn
8442 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
8443 This function does the reverse of @code{__builtin_extract_return_addr}.
8444 @end deftypefn
8446 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
8447 This function is similar to @code{__builtin_return_address}, but it
8448 returns the address of the function frame rather than the return address
8449 of the function.  Calling @code{__builtin_frame_address} with a value of
8450 @code{0} yields the frame address of the current function, a value of
8451 @code{1} yields the frame address of the caller of the current function,
8452 and so forth.
8454 The frame is the area on the stack that holds local variables and saved
8455 registers.  The frame address is normally the address of the first word
8456 pushed on to the stack by the function.  However, the exact definition
8457 depends upon the processor and the calling convention.  If the processor
8458 has a dedicated frame pointer register, and the function has a frame,
8459 then @code{__builtin_frame_address} returns the value of the frame
8460 pointer register.
8462 On some machines it may be impossible to determine the frame address of
8463 any function other than the current one; in such cases, or when the top
8464 of the stack has been reached, this function returns @code{0} if
8465 the first frame pointer is properly initialized by the startup code.
8467 This function should only be used with a nonzero argument for debugging
8468 purposes.
8469 @end deftypefn
8471 @node Vector Extensions
8472 @section Using Vector Instructions through Built-in Functions
8474 On some targets, the instruction set contains SIMD vector instructions which
8475 operate on multiple values contained in one large register at the same time.
8476 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
8477 this way.
8479 The first step in using these extensions is to provide the necessary data
8480 types.  This should be done using an appropriate @code{typedef}:
8482 @smallexample
8483 typedef int v4si __attribute__ ((vector_size (16)));
8484 @end smallexample
8486 @noindent
8487 The @code{int} type specifies the base type, while the attribute specifies
8488 the vector size for the variable, measured in bytes.  For example, the
8489 declaration above causes the compiler to set the mode for the @code{v4si}
8490 type to be 16 bytes wide and divided into @code{int} sized units.  For
8491 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
8492 corresponding mode of @code{foo} is @acronym{V4SI}.
8494 The @code{vector_size} attribute is only applicable to integral and
8495 float scalars, although arrays, pointers, and function return values
8496 are allowed in conjunction with this construct. Only sizes that are
8497 a power of two are currently allowed.
8499 All the basic integer types can be used as base types, both as signed
8500 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
8501 @code{long long}.  In addition, @code{float} and @code{double} can be
8502 used to build floating-point vector types.
8504 Specifying a combination that is not valid for the current architecture
8505 causes GCC to synthesize the instructions using a narrower mode.
8506 For example, if you specify a variable of type @code{V4SI} and your
8507 architecture does not allow for this specific SIMD type, GCC
8508 produces code that uses 4 @code{SIs}.
8510 The types defined in this manner can be used with a subset of normal C
8511 operations.  Currently, GCC allows using the following operators
8512 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
8514 The operations behave like C++ @code{valarrays}.  Addition is defined as
8515 the addition of the corresponding elements of the operands.  For
8516 example, in the code below, each of the 4 elements in @var{a} is
8517 added to the corresponding 4 elements in @var{b} and the resulting
8518 vector is stored in @var{c}.
8520 @smallexample
8521 typedef int v4si __attribute__ ((vector_size (16)));
8523 v4si a, b, c;
8525 c = a + b;
8526 @end smallexample
8528 Subtraction, multiplication, division, and the logical operations
8529 operate in a similar manner.  Likewise, the result of using the unary
8530 minus or complement operators on a vector type is a vector whose
8531 elements are the negative or complemented values of the corresponding
8532 elements in the operand.
8534 It is possible to use shifting operators @code{<<}, @code{>>} on
8535 integer-type vectors. The operation is defined as following: @code{@{a0,
8536 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
8537 @dots{}, an >> bn@}}@. Vector operands must have the same number of
8538 elements. 
8540 For convenience, it is allowed to use a binary vector operation
8541 where one operand is a scalar. In that case the compiler transforms
8542 the scalar operand into a vector where each element is the scalar from
8543 the operation. The transformation happens only if the scalar could be
8544 safely converted to the vector-element type.
8545 Consider the following code.
8547 @smallexample
8548 typedef int v4si __attribute__ ((vector_size (16)));
8550 v4si a, b, c;
8551 long l;
8553 a = b + 1;    /* a = b + @{1,1,1,1@}; */
8554 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
8556 a = l + a;    /* Error, cannot convert long to int. */
8557 @end smallexample
8559 Vectors can be subscripted as if the vector were an array with
8560 the same number of elements and base type.  Out of bound accesses
8561 invoke undefined behavior at run time.  Warnings for out of bound
8562 accesses for vector subscription can be enabled with
8563 @option{-Warray-bounds}.
8565 Vector comparison is supported with standard comparison
8566 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
8567 vector expressions of integer-type or real-type. Comparison between
8568 integer-type vectors and real-type vectors are not supported.  The
8569 result of the comparison is a vector of the same width and number of
8570 elements as the comparison operands with a signed integral element
8571 type.
8573 Vectors are compared element-wise producing 0 when comparison is false
8574 and -1 (constant of the appropriate type where all bits are set)
8575 otherwise. Consider the following example.
8577 @smallexample
8578 typedef int v4si __attribute__ ((vector_size (16)));
8580 v4si a = @{1,2,3,4@};
8581 v4si b = @{3,2,1,4@};
8582 v4si c;
8584 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
8585 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
8586 @end smallexample
8588 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8589 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8590 integer vector with the same number of elements of the same size as @code{b}
8591 and @code{c}, computes all three arguments and creates a vector
8592 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
8593 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8594 As in the case of binary operations, this syntax is also accepted when
8595 one of @code{b} or @code{c} is a scalar that is then transformed into a
8596 vector. If both @code{b} and @code{c} are scalars and the type of
8597 @code{true?b:c} has the same size as the element type of @code{a}, then
8598 @code{b} and @code{c} are converted to a vector type whose elements have
8599 this type and with the same number of elements as @code{a}.
8601 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8602 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8603 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8604 For mixed operations between a scalar @code{s} and a vector @code{v},
8605 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8606 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8608 Vector shuffling is available using functions
8609 @code{__builtin_shuffle (vec, mask)} and
8610 @code{__builtin_shuffle (vec0, vec1, mask)}.
8611 Both functions construct a permutation of elements from one or two
8612 vectors and return a vector of the same type as the input vector(s).
8613 The @var{mask} is an integral vector with the same width (@var{W})
8614 and element count (@var{N}) as the output vector.
8616 The elements of the input vectors are numbered in memory ordering of
8617 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8618 elements of @var{mask} are considered modulo @var{N} in the single-operand
8619 case and modulo @math{2*@var{N}} in the two-operand case.
8621 Consider the following example,
8623 @smallexample
8624 typedef int v4si __attribute__ ((vector_size (16)));
8626 v4si a = @{1,2,3,4@};
8627 v4si b = @{5,6,7,8@};
8628 v4si mask1 = @{0,1,1,3@};
8629 v4si mask2 = @{0,4,2,5@};
8630 v4si res;
8632 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
8633 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
8634 @end smallexample
8636 Note that @code{__builtin_shuffle} is intentionally semantically
8637 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8639 You can declare variables and use them in function calls and returns, as
8640 well as in assignments and some casts.  You can specify a vector type as
8641 a return type for a function.  Vector types can also be used as function
8642 arguments.  It is possible to cast from one vector type to another,
8643 provided they are of the same size (in fact, you can also cast vectors
8644 to and from other datatypes of the same size).
8646 You cannot operate between vectors of different lengths or different
8647 signedness without a cast.
8649 @node Offsetof
8650 @section Support for @code{offsetof}
8651 @findex __builtin_offsetof
8653 GCC implements for both C and C++ a syntactic extension to implement
8654 the @code{offsetof} macro.
8656 @smallexample
8657 primary:
8658         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8660 offsetof_member_designator:
8661           @code{identifier}
8662         | offsetof_member_designator "." @code{identifier}
8663         | offsetof_member_designator "[" @code{expr} "]"
8664 @end smallexample
8666 This extension is sufficient such that
8668 @smallexample
8669 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8670 @end smallexample
8672 @noindent
8673 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8674 may be dependent.  In either case, @var{member} may consist of a single
8675 identifier, or a sequence of member accesses and array references.
8677 @node __sync Builtins
8678 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
8680 The following built-in functions
8681 are intended to be compatible with those described
8682 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8683 section 7.4.  As such, they depart from normal GCC practice by not using
8684 the @samp{__builtin_} prefix and also by being overloaded so that they
8685 work on multiple types.
8687 The definition given in the Intel documentation allows only for the use of
8688 the types @code{int}, @code{long}, @code{long long} or their unsigned
8689 counterparts.  GCC allows any integral scalar or pointer type that is
8690 1, 2, 4 or 8 bytes in length.
8692 These functions are implemented in terms of the @samp{__atomic}
8693 builtins (@pxref{__atomic Builtins}).  They should not be used for new
8694 code which should use the @samp{__atomic} builtins instead.
8696 Not all operations are supported by all target processors.  If a particular
8697 operation cannot be implemented on the target processor, a warning is
8698 generated and a call to an external function is generated.  The external
8699 function carries the same name as the built-in version,
8700 with an additional suffix
8701 @samp{_@var{n}} where @var{n} is the size of the data type.
8703 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8704 @c useful for implementing the operation under the control of an external
8705 @c mutex.
8707 In most cases, these built-in functions are considered a @dfn{full barrier}.
8708 That is,
8709 no memory operand is moved across the operation, either forward or
8710 backward.  Further, instructions are issued as necessary to prevent the
8711 processor from speculating loads across the operation and from queuing stores
8712 after the operation.
8714 All of the routines are described in the Intel documentation to take
8715 ``an optional list of variables protected by the memory barrier''.  It's
8716 not clear what is meant by that; it could mean that @emph{only} the
8717 listed variables are protected, or it could mean a list of additional
8718 variables to be protected.  The list is ignored by GCC which treats it as
8719 empty.  GCC interprets an empty list as meaning that all globally
8720 accessible variables should be protected.
8722 @table @code
8723 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8724 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8725 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8726 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8727 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8728 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8729 @findex __sync_fetch_and_add
8730 @findex __sync_fetch_and_sub
8731 @findex __sync_fetch_and_or
8732 @findex __sync_fetch_and_and
8733 @findex __sync_fetch_and_xor
8734 @findex __sync_fetch_and_nand
8735 These built-in functions perform the operation suggested by the name, and
8736 returns the value that had previously been in memory.  That is,
8738 @smallexample
8739 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8740 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8741 @end smallexample
8743 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8744 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8746 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8747 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8748 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8749 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8750 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8751 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8752 @findex __sync_add_and_fetch
8753 @findex __sync_sub_and_fetch
8754 @findex __sync_or_and_fetch
8755 @findex __sync_and_and_fetch
8756 @findex __sync_xor_and_fetch
8757 @findex __sync_nand_and_fetch
8758 These built-in functions perform the operation suggested by the name, and
8759 return the new value.  That is,
8761 @smallexample
8762 @{ *ptr @var{op}= value; return *ptr; @}
8763 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8764 @end smallexample
8766 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8767 as @code{*ptr = ~(*ptr & value)} instead of
8768 @code{*ptr = ~*ptr & value}.
8770 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8771 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8772 @findex __sync_bool_compare_and_swap
8773 @findex __sync_val_compare_and_swap
8774 These built-in functions perform an atomic compare and swap.
8775 That is, if the current
8776 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8777 @code{*@var{ptr}}.
8779 The ``bool'' version returns true if the comparison is successful and
8780 @var{newval} is written.  The ``val'' version returns the contents
8781 of @code{*@var{ptr}} before the operation.
8783 @item __sync_synchronize (...)
8784 @findex __sync_synchronize
8785 This built-in function issues a full memory barrier.
8787 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8788 @findex __sync_lock_test_and_set
8789 This built-in function, as described by Intel, is not a traditional test-and-set
8790 operation, but rather an atomic exchange operation.  It writes @var{value}
8791 into @code{*@var{ptr}}, and returns the previous contents of
8792 @code{*@var{ptr}}.
8794 Many targets have only minimal support for such locks, and do not support
8795 a full exchange operation.  In this case, a target may support reduced
8796 functionality here by which the @emph{only} valid value to store is the
8797 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8798 is implementation defined.
8800 This built-in function is not a full barrier,
8801 but rather an @dfn{acquire barrier}.
8802 This means that references after the operation cannot move to (or be
8803 speculated to) before the operation, but previous memory stores may not
8804 be globally visible yet, and previous memory loads may not yet be
8805 satisfied.
8807 @item void __sync_lock_release (@var{type} *ptr, ...)
8808 @findex __sync_lock_release
8809 This built-in function releases the lock acquired by
8810 @code{__sync_lock_test_and_set}.
8811 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8813 This built-in function is not a full barrier,
8814 but rather a @dfn{release barrier}.
8815 This means that all previous memory stores are globally visible, and all
8816 previous memory loads have been satisfied, but following memory reads
8817 are not prevented from being speculated to before the barrier.
8818 @end table
8820 @node __atomic Builtins
8821 @section Built-in Functions for Memory Model Aware Atomic Operations
8823 The following built-in functions approximately match the requirements for
8824 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8825 functions, but all also have a memory model parameter.  These are all
8826 identified by being prefixed with @samp{__atomic}, and most are overloaded
8827 such that they work with multiple types.
8829 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8830 bytes in length. 16-byte integral types are also allowed if
8831 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8833 Target architectures are encouraged to provide their own patterns for
8834 each of these built-in functions.  If no target is provided, the original 
8835 non-memory model set of @samp{__sync} atomic built-in functions are
8836 utilized, along with any required synchronization fences surrounding it in
8837 order to achieve the proper behavior.  Execution in this case is subject
8838 to the same restrictions as those built-in functions.
8840 If there is no pattern or mechanism to provide a lock free instruction
8841 sequence, a call is made to an external routine with the same parameters
8842 to be resolved at run time.
8844 The four non-arithmetic functions (load, store, exchange, and 
8845 compare_exchange) all have a generic version as well.  This generic
8846 version works on any data type.  If the data type size maps to one
8847 of the integral sizes that may have lock free support, the generic
8848 version utilizes the lock free built-in function.  Otherwise an
8849 external call is left to be resolved at run time.  This external call is
8850 the same format with the addition of a @samp{size_t} parameter inserted
8851 as the first parameter indicating the size of the object being pointed to.
8852 All objects must be the same size.
8854 There are 6 different memory models that can be specified.  These map
8855 to the same names in the C++11 standard.  Refer there or to the
8856 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8857 atomic synchronization} for more detailed definitions.  These memory
8858 models integrate both barriers to code motion as well as synchronization
8859 requirements with other threads. These are listed in approximately
8860 ascending order of strength. It is also possible to use target specific
8861 flags for memory model flags, like Hardware Lock Elision.
8863 @table  @code
8864 @item __ATOMIC_RELAXED
8865 No barriers or synchronization.
8866 @item __ATOMIC_CONSUME
8867 Data dependency only for both barrier and synchronization with another
8868 thread.
8869 @item __ATOMIC_ACQUIRE
8870 Barrier to hoisting of code and synchronizes with release (or stronger)
8871 semantic stores from another thread.
8872 @item __ATOMIC_RELEASE
8873 Barrier to sinking of code and synchronizes with acquire (or stronger)
8874 semantic loads from another thread.
8875 @item __ATOMIC_ACQ_REL
8876 Full barrier in both directions and synchronizes with acquire loads and
8877 release stores in another thread.
8878 @item __ATOMIC_SEQ_CST
8879 Full barrier in both directions and synchronizes with acquire loads and
8880 release stores in all threads.
8881 @end table
8883 When implementing patterns for these built-in functions, the memory model
8884 parameter can be ignored as long as the pattern implements the most
8885 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8886 execute correctly with this memory model but they may not execute as
8887 efficiently as they could with a more appropriate implementation of the
8888 relaxed requirements.
8890 Note that the C++11 standard allows for the memory model parameter to be
8891 determined at run time rather than at compile time.  These built-in
8892 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8893 than invoke a runtime library call or inline a switch statement.  This is
8894 standard compliant, safe, and the simplest approach for now.
8896 The memory model parameter is a signed int, but only the lower 8 bits are
8897 reserved for the memory model.  The remainder of the signed int is reserved
8898 for future use and should be 0.  Use of the predefined atomic values
8899 ensures proper usage.
8901 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8902 This built-in function implements an atomic load operation.  It returns the
8903 contents of @code{*@var{ptr}}.
8905 The valid memory model variants are
8906 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8907 and @code{__ATOMIC_CONSUME}.
8909 @end deftypefn
8911 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8912 This is the generic version of an atomic load.  It returns the
8913 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8915 @end deftypefn
8917 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8918 This built-in function implements an atomic store operation.  It writes 
8919 @code{@var{val}} into @code{*@var{ptr}}.  
8921 The valid memory model variants are
8922 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8924 @end deftypefn
8926 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8927 This is the generic version of an atomic store.  It stores the value
8928 of @code{*@var{val}} into @code{*@var{ptr}}.
8930 @end deftypefn
8932 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8933 This built-in function implements an atomic exchange operation.  It writes
8934 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8935 @code{*@var{ptr}}.
8937 The valid memory model variants are
8938 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8939 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8941 @end deftypefn
8943 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8944 This is the generic version of an atomic exchange.  It stores the
8945 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8946 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8948 @end deftypefn
8950 @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)
8951 This built-in function implements an atomic compare and exchange operation.
8952 This compares the contents of @code{*@var{ptr}} with the contents of
8953 @code{*@var{expected}} and if equal, writes @var{desired} into
8954 @code{*@var{ptr}}.  If they are not equal, the current contents of
8955 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8956 for weak compare_exchange, and false for the strong variation.  Many targets 
8957 only offer the strong variation and ignore the parameter.  When in doubt, use
8958 the strong variation.
8960 True is returned if @var{desired} is written into
8961 @code{*@var{ptr}} and the execution is considered to conform to the
8962 memory model specified by @var{success_memmodel}.  There are no
8963 restrictions on what memory model can be used here.
8965 False is returned otherwise, and the execution is considered to conform
8966 to @var{failure_memmodel}. This memory model cannot be
8967 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8968 stronger model than that specified by @var{success_memmodel}.
8970 @end deftypefn
8972 @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)
8973 This built-in function implements the generic version of
8974 @code{__atomic_compare_exchange}.  The function is virtually identical to
8975 @code{__atomic_compare_exchange_n}, except the desired value is also a
8976 pointer.
8978 @end deftypefn
8980 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8981 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8982 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8983 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8984 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8985 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8986 These built-in functions perform the operation suggested by the name, and
8987 return the result of the operation. That is,
8989 @smallexample
8990 @{ *ptr @var{op}= val; return *ptr; @}
8991 @end smallexample
8993 All memory models are valid.
8995 @end deftypefn
8997 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8998 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8999 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
9000 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
9001 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
9002 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
9003 These built-in functions perform the operation suggested by the name, and
9004 return the value that had previously been in @code{*@var{ptr}}.  That is,
9006 @smallexample
9007 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9008 @end smallexample
9010 All memory models are valid.
9012 @end deftypefn
9014 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
9016 This built-in function performs an atomic test-and-set operation on
9017 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
9018 defined nonzero ``set'' value and the return value is @code{true} if and only
9019 if the previous contents were ``set''.
9020 It should be only used for operands of type @code{bool} or @code{char}. For 
9021 other types only part of the value may be set.
9023 All memory models are valid.
9025 @end deftypefn
9027 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
9029 This built-in function performs an atomic clear operation on
9030 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
9031 It should be only used for operands of type @code{bool} or @code{char} and 
9032 in conjunction with @code{__atomic_test_and_set}.
9033 For other types it may only clear partially. If the type is not @code{bool}
9034 prefer using @code{__atomic_store}.
9036 The valid memory model variants are
9037 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9038 @code{__ATOMIC_RELEASE}.
9040 @end deftypefn
9042 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
9044 This built-in function acts as a synchronization fence between threads
9045 based on the specified memory model.
9047 All memory orders are valid.
9049 @end deftypefn
9051 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
9053 This built-in function acts as a synchronization fence between a thread
9054 and signal handlers based in the same thread.
9056 All memory orders are valid.
9058 @end deftypefn
9060 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
9062 This built-in function returns true if objects of @var{size} bytes always
9063 generate lock free atomic instructions for the target architecture.  
9064 @var{size} must resolve to a compile-time constant and the result also
9065 resolves to a compile-time constant.
9067 @var{ptr} is an optional pointer to the object that may be used to determine
9068 alignment.  A value of 0 indicates typical alignment should be used.  The 
9069 compiler may also ignore this parameter.
9071 @smallexample
9072 if (_atomic_always_lock_free (sizeof (long long), 0))
9073 @end smallexample
9075 @end deftypefn
9077 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9079 This built-in function returns true if objects of @var{size} bytes always
9080 generate lock free atomic instructions for the target architecture.  If
9081 it is not known to be lock free a call is made to a runtime routine named
9082 @code{__atomic_is_lock_free}.
9084 @var{ptr} is an optional pointer to the object that may be used to determine
9085 alignment.  A value of 0 indicates typical alignment should be used.  The 
9086 compiler may also ignore this parameter.
9087 @end deftypefn
9089 @node Integer Overflow Builtins
9090 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9092 The following built-in functions allow performing simple arithmetic operations
9093 together with checking whether the operations overflowed.
9095 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9096 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9097 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9098 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9099 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9100 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9101 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9103 These built-in functions promote the first two operands into infinite precision signed
9104 type and perform addition on those promoted operands.  The result is then
9105 cast to the type the third pointer argument points to and stored there.
9106 If the stored result is equal to the infinite precision result, the built-in
9107 functions return false, otherwise they return true.  As the addition is
9108 performed in infinite signed precision, these built-in functions have fully defined
9109 behavior for all argument values.
9111 The first built-in function allows arbitrary integral types for operands and
9112 the result type must be pointer to some integer type, the rest of the built-in
9113 functions have explicit integer types.
9115 The compiler will attempt to use hardware instructions to implement
9116 these built-in functions where possible, like conditional jump on overflow
9117 after addition, conditional jump on carry etc.
9119 @end deftypefn
9121 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9122 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9123 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9124 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9125 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9126 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9127 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9129 These built-in functions are similar to the add overflow checking built-in
9130 functions above, except they perform subtraction, subtract the second argument
9131 from the first one, instead of addition.
9133 @end deftypefn
9135 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9136 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9137 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9138 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9139 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9140 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9141 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9143 These built-in functions are similar to the add overflow checking built-in
9144 functions above, except they perform multiplication, instead of addition.
9146 @end deftypefn
9148 @node x86 specific memory model extensions for transactional memory
9149 @section x86-Specific Memory Model Extensions for Transactional Memory
9151 The x86 architecture supports additional memory ordering flags
9152 to mark lock critical sections for hardware lock elision. 
9153 These must be specified in addition to an existing memory model to 
9154 atomic intrinsics.
9156 @table @code
9157 @item __ATOMIC_HLE_ACQUIRE
9158 Start lock elision on a lock variable.
9159 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
9160 @item __ATOMIC_HLE_RELEASE
9161 End lock elision on a lock variable.
9162 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
9163 @end table
9165 When a lock acquire fails it is required for good performance to abort
9166 the transaction quickly. This can be done with a @code{_mm_pause}
9168 @smallexample
9169 #include <immintrin.h> // For _mm_pause
9171 int lockvar;
9173 /* Acquire lock with lock elision */
9174 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9175     _mm_pause(); /* Abort failed transaction */
9177 /* Free lock with lock elision */
9178 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9179 @end smallexample
9181 @node Object Size Checking
9182 @section Object Size Checking Built-in Functions
9183 @findex __builtin_object_size
9184 @findex __builtin___memcpy_chk
9185 @findex __builtin___mempcpy_chk
9186 @findex __builtin___memmove_chk
9187 @findex __builtin___memset_chk
9188 @findex __builtin___strcpy_chk
9189 @findex __builtin___stpcpy_chk
9190 @findex __builtin___strncpy_chk
9191 @findex __builtin___strcat_chk
9192 @findex __builtin___strncat_chk
9193 @findex __builtin___sprintf_chk
9194 @findex __builtin___snprintf_chk
9195 @findex __builtin___vsprintf_chk
9196 @findex __builtin___vsnprintf_chk
9197 @findex __builtin___printf_chk
9198 @findex __builtin___vprintf_chk
9199 @findex __builtin___fprintf_chk
9200 @findex __builtin___vfprintf_chk
9202 GCC implements a limited buffer overflow protection mechanism
9203 that can prevent some buffer overflow attacks.
9205 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9206 is a built-in construct that returns a constant number of bytes from
9207 @var{ptr} to the end of the object @var{ptr} pointer points to
9208 (if known at compile time).  @code{__builtin_object_size} never evaluates
9209 its arguments for side-effects.  If there are any side-effects in them, it
9210 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9211 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
9212 point to and all of them are known at compile time, the returned number
9213 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9214 0 and minimum if nonzero.  If it is not possible to determine which objects
9215 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9216 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9217 for @var{type} 2 or 3.
9219 @var{type} is an integer constant from 0 to 3.  If the least significant
9220 bit is clear, objects are whole variables, if it is set, a closest
9221 surrounding subobject is considered the object a pointer points to.
9222 The second bit determines if maximum or minimum of remaining bytes
9223 is computed.
9225 @smallexample
9226 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9227 char *p = &var.buf1[1], *q = &var.b;
9229 /* Here the object p points to is var.  */
9230 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9231 /* The subobject p points to is var.buf1.  */
9232 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9233 /* The object q points to is var.  */
9234 assert (__builtin_object_size (q, 0)
9235         == (char *) (&var + 1) - (char *) &var.b);
9236 /* The subobject q points to is var.b.  */
9237 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9238 @end smallexample
9239 @end deftypefn
9241 There are built-in functions added for many common string operation
9242 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9243 built-in is provided.  This built-in has an additional last argument,
9244 which is the number of bytes remaining in object the @var{dest}
9245 argument points to or @code{(size_t) -1} if the size is not known.
9247 The built-in functions are optimized into the normal string functions
9248 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9249 it is known at compile time that the destination object will not
9250 be overflown.  If the compiler can determine at compile time the
9251 object will be always overflown, it issues a warning.
9253 The intended use can be e.g.@:
9255 @smallexample
9256 #undef memcpy
9257 #define bos0(dest) __builtin_object_size (dest, 0)
9258 #define memcpy(dest, src, n) \
9259   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9261 char *volatile p;
9262 char buf[10];
9263 /* It is unknown what object p points to, so this is optimized
9264    into plain memcpy - no checking is possible.  */
9265 memcpy (p, "abcde", n);
9266 /* Destination is known and length too.  It is known at compile
9267    time there will be no overflow.  */
9268 memcpy (&buf[5], "abcde", 5);
9269 /* Destination is known, but the length is not known at compile time.
9270    This will result in __memcpy_chk call that can check for overflow
9271    at run time.  */
9272 memcpy (&buf[5], "abcde", n);
9273 /* Destination is known and it is known at compile time there will
9274    be overflow.  There will be a warning and __memcpy_chk call that
9275    will abort the program at run time.  */
9276 memcpy (&buf[6], "abcde", 5);
9277 @end smallexample
9279 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9280 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9281 @code{strcat} and @code{strncat}.
9283 There are also checking built-in functions for formatted output functions.
9284 @smallexample
9285 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9286 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9287                               const char *fmt, ...);
9288 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9289                               va_list ap);
9290 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9291                                const char *fmt, va_list ap);
9292 @end smallexample
9294 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9295 etc.@: functions and can contain implementation specific flags on what
9296 additional security measures the checking function might take, such as
9297 handling @code{%n} differently.
9299 The @var{os} argument is the object size @var{s} points to, like in the
9300 other built-in functions.  There is a small difference in the behavior
9301 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9302 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9303 the checking function is called with @var{os} argument set to
9304 @code{(size_t) -1}.
9306 In addition to this, there are checking built-in functions
9307 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9308 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9309 These have just one additional argument, @var{flag}, right before
9310 format string @var{fmt}.  If the compiler is able to optimize them to
9311 @code{fputc} etc.@: functions, it does, otherwise the checking function
9312 is called and the @var{flag} argument passed to it.
9314 @node Pointer Bounds Checker builtins
9315 @section Pointer Bounds Checker Built-in Functions
9316 @cindex Pointer Bounds Checker builtins
9317 @findex __builtin___bnd_set_ptr_bounds
9318 @findex __builtin___bnd_narrow_ptr_bounds
9319 @findex __builtin___bnd_copy_ptr_bounds
9320 @findex __builtin___bnd_init_ptr_bounds
9321 @findex __builtin___bnd_null_ptr_bounds
9322 @findex __builtin___bnd_store_ptr_bounds
9323 @findex __builtin___bnd_chk_ptr_lbounds
9324 @findex __builtin___bnd_chk_ptr_ubounds
9325 @findex __builtin___bnd_chk_ptr_bounds
9326 @findex __builtin___bnd_get_ptr_lbound
9327 @findex __builtin___bnd_get_ptr_ubound
9329 GCC provides a set of built-in functions to control Pointer Bounds Checker
9330 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
9331 even if you compile with Pointer Bounds Checker off
9332 (@option{-fno-check-pointer-bounds}).
9333 The behavior may differ in such case as documented below.
9335 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9337 This built-in function returns a new pointer with the value of @var{q}, and
9338 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
9339 Bounds Checker off, the built-in function just returns the first argument.
9341 @smallexample
9342 extern void *__wrap_malloc (size_t n)
9344   void *p = (void *)__real_malloc (n);
9345   if (!p) return __builtin___bnd_null_ptr_bounds (p);
9346   return __builtin___bnd_set_ptr_bounds (p, n);
9348 @end smallexample
9350 @end deftypefn
9352 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
9354 This built-in function returns a new pointer with the value of @var{p}
9355 and associates it with the narrowed bounds formed by the intersection
9356 of bounds associated with @var{q} and the bounds
9357 [@var{p}, @var{p} + @var{size} - 1].
9358 With Pointer Bounds Checker off, the built-in function just returns the first
9359 argument.
9361 @smallexample
9362 void init_objects (object *objs, size_t size)
9364   size_t i;
9365   /* Initialize objects one-by-one passing pointers with bounds of 
9366      an object, not the full array of objects.  */
9367   for (i = 0; i < size; i++)
9368     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
9369                                                     sizeof(object)));
9371 @end smallexample
9373 @end deftypefn
9375 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
9377 This built-in function returns a new pointer with the value of @var{q},
9378 and associates it with the bounds already associated with pointer @var{r}.
9379 With Pointer Bounds Checker off, the built-in function just returns the first
9380 argument.
9382 @smallexample
9383 /* Here is a way to get pointer to object's field but
9384    still with the full object's bounds.  */
9385 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
9386                                                   objptr);
9387 @end smallexample
9389 @end deftypefn
9391 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
9393 This built-in function returns a new pointer with the value of @var{q}, and
9394 associates it with INIT (allowing full memory access) bounds. With Pointer
9395 Bounds Checker off, the built-in function just returns the first argument.
9397 @end deftypefn
9399 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
9401 This built-in function returns a new pointer with the value of @var{q}, and
9402 associates it with NULL (allowing no memory access) bounds. With Pointer
9403 Bounds Checker off, the built-in function just returns the first argument.
9405 @end deftypefn
9407 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
9409 This built-in function stores the bounds associated with pointer @var{ptr_val}
9410 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
9411 bounds from legacy code without touching the associated pointer's memory when
9412 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
9413 function call is ignored.
9415 @end deftypefn
9417 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
9419 This built-in function checks if the pointer @var{q} is within the lower
9420 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
9421 function call is ignored.
9423 @smallexample
9424 extern void *__wrap_memset (void *dst, int c, size_t len)
9426   if (len > 0)
9427     @{
9428       __builtin___bnd_chk_ptr_lbounds (dst);
9429       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
9430       __real_memset (dst, c, len);
9431     @}
9432   return dst;
9434 @end smallexample
9436 @end deftypefn
9438 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
9440 This built-in function checks if the pointer @var{q} is within the upper
9441 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
9442 function call is ignored.
9444 @end deftypefn
9446 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
9448 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
9449 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
9450 off, the built-in function call is ignored.
9452 @smallexample
9453 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
9455   if (n > 0)
9456     @{
9457       __bnd_chk_ptr_bounds (dst, n);
9458       __bnd_chk_ptr_bounds (src, n);
9459       __real_memcpy (dst, src, n);
9460     @}
9461   return dst;
9463 @end smallexample
9465 @end deftypefn
9467 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
9469 This built-in function returns the lower bound associated
9470 with the pointer @var{q}, as a pointer value.  
9471 This is useful for debugging using @code{printf}.
9472 With Pointer Bounds Checker off, the built-in function returns 0.
9474 @smallexample
9475 void *lb = __builtin___bnd_get_ptr_lbound (q);
9476 void *ub = __builtin___bnd_get_ptr_ubound (q);
9477 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
9478 @end smallexample
9480 @end deftypefn
9482 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
9484 This built-in function returns the upper bound (which is a pointer) associated
9485 with the pointer @var{q}.  With Pointer Bounds Checker off,
9486 the built-in function returns -1.
9488 @end deftypefn
9490 @node Cilk Plus Builtins
9491 @section Cilk Plus C/C++ Language Extension Built-in Functions
9493 GCC provides support for the following built-in reduction functions if Cilk Plus
9494 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
9496 @itemize @bullet
9497 @item @code{__sec_implicit_index}
9498 @item @code{__sec_reduce}
9499 @item @code{__sec_reduce_add}
9500 @item @code{__sec_reduce_all_nonzero}
9501 @item @code{__sec_reduce_all_zero}
9502 @item @code{__sec_reduce_any_nonzero}
9503 @item @code{__sec_reduce_any_zero}
9504 @item @code{__sec_reduce_max}
9505 @item @code{__sec_reduce_min}
9506 @item @code{__sec_reduce_max_ind}
9507 @item @code{__sec_reduce_min_ind}
9508 @item @code{__sec_reduce_mul}
9509 @item @code{__sec_reduce_mutating}
9510 @end itemize
9512 Further details and examples about these built-in functions are described 
9513 in the Cilk Plus language manual which can be found at 
9514 @uref{http://www.cilkplus.org}.
9516 @node Other Builtins
9517 @section Other Built-in Functions Provided by GCC
9518 @cindex built-in functions
9519 @findex __builtin_call_with_static_chain
9520 @findex __builtin_fpclassify
9521 @findex __builtin_isfinite
9522 @findex __builtin_isnormal
9523 @findex __builtin_isgreater
9524 @findex __builtin_isgreaterequal
9525 @findex __builtin_isinf_sign
9526 @findex __builtin_isless
9527 @findex __builtin_islessequal
9528 @findex __builtin_islessgreater
9529 @findex __builtin_isunordered
9530 @findex __builtin_powi
9531 @findex __builtin_powif
9532 @findex __builtin_powil
9533 @findex _Exit
9534 @findex _exit
9535 @findex abort
9536 @findex abs
9537 @findex acos
9538 @findex acosf
9539 @findex acosh
9540 @findex acoshf
9541 @findex acoshl
9542 @findex acosl
9543 @findex alloca
9544 @findex asin
9545 @findex asinf
9546 @findex asinh
9547 @findex asinhf
9548 @findex asinhl
9549 @findex asinl
9550 @findex atan
9551 @findex atan2
9552 @findex atan2f
9553 @findex atan2l
9554 @findex atanf
9555 @findex atanh
9556 @findex atanhf
9557 @findex atanhl
9558 @findex atanl
9559 @findex bcmp
9560 @findex bzero
9561 @findex cabs
9562 @findex cabsf
9563 @findex cabsl
9564 @findex cacos
9565 @findex cacosf
9566 @findex cacosh
9567 @findex cacoshf
9568 @findex cacoshl
9569 @findex cacosl
9570 @findex calloc
9571 @findex carg
9572 @findex cargf
9573 @findex cargl
9574 @findex casin
9575 @findex casinf
9576 @findex casinh
9577 @findex casinhf
9578 @findex casinhl
9579 @findex casinl
9580 @findex catan
9581 @findex catanf
9582 @findex catanh
9583 @findex catanhf
9584 @findex catanhl
9585 @findex catanl
9586 @findex cbrt
9587 @findex cbrtf
9588 @findex cbrtl
9589 @findex ccos
9590 @findex ccosf
9591 @findex ccosh
9592 @findex ccoshf
9593 @findex ccoshl
9594 @findex ccosl
9595 @findex ceil
9596 @findex ceilf
9597 @findex ceill
9598 @findex cexp
9599 @findex cexpf
9600 @findex cexpl
9601 @findex cimag
9602 @findex cimagf
9603 @findex cimagl
9604 @findex clog
9605 @findex clogf
9606 @findex clogl
9607 @findex conj
9608 @findex conjf
9609 @findex conjl
9610 @findex copysign
9611 @findex copysignf
9612 @findex copysignl
9613 @findex cos
9614 @findex cosf
9615 @findex cosh
9616 @findex coshf
9617 @findex coshl
9618 @findex cosl
9619 @findex cpow
9620 @findex cpowf
9621 @findex cpowl
9622 @findex cproj
9623 @findex cprojf
9624 @findex cprojl
9625 @findex creal
9626 @findex crealf
9627 @findex creall
9628 @findex csin
9629 @findex csinf
9630 @findex csinh
9631 @findex csinhf
9632 @findex csinhl
9633 @findex csinl
9634 @findex csqrt
9635 @findex csqrtf
9636 @findex csqrtl
9637 @findex ctan
9638 @findex ctanf
9639 @findex ctanh
9640 @findex ctanhf
9641 @findex ctanhl
9642 @findex ctanl
9643 @findex dcgettext
9644 @findex dgettext
9645 @findex drem
9646 @findex dremf
9647 @findex dreml
9648 @findex erf
9649 @findex erfc
9650 @findex erfcf
9651 @findex erfcl
9652 @findex erff
9653 @findex erfl
9654 @findex exit
9655 @findex exp
9656 @findex exp10
9657 @findex exp10f
9658 @findex exp10l
9659 @findex exp2
9660 @findex exp2f
9661 @findex exp2l
9662 @findex expf
9663 @findex expl
9664 @findex expm1
9665 @findex expm1f
9666 @findex expm1l
9667 @findex fabs
9668 @findex fabsf
9669 @findex fabsl
9670 @findex fdim
9671 @findex fdimf
9672 @findex fdiml
9673 @findex ffs
9674 @findex floor
9675 @findex floorf
9676 @findex floorl
9677 @findex fma
9678 @findex fmaf
9679 @findex fmal
9680 @findex fmax
9681 @findex fmaxf
9682 @findex fmaxl
9683 @findex fmin
9684 @findex fminf
9685 @findex fminl
9686 @findex fmod
9687 @findex fmodf
9688 @findex fmodl
9689 @findex fprintf
9690 @findex fprintf_unlocked
9691 @findex fputs
9692 @findex fputs_unlocked
9693 @findex frexp
9694 @findex frexpf
9695 @findex frexpl
9696 @findex fscanf
9697 @findex gamma
9698 @findex gammaf
9699 @findex gammal
9700 @findex gamma_r
9701 @findex gammaf_r
9702 @findex gammal_r
9703 @findex gettext
9704 @findex hypot
9705 @findex hypotf
9706 @findex hypotl
9707 @findex ilogb
9708 @findex ilogbf
9709 @findex ilogbl
9710 @findex imaxabs
9711 @findex index
9712 @findex isalnum
9713 @findex isalpha
9714 @findex isascii
9715 @findex isblank
9716 @findex iscntrl
9717 @findex isdigit
9718 @findex isgraph
9719 @findex islower
9720 @findex isprint
9721 @findex ispunct
9722 @findex isspace
9723 @findex isupper
9724 @findex iswalnum
9725 @findex iswalpha
9726 @findex iswblank
9727 @findex iswcntrl
9728 @findex iswdigit
9729 @findex iswgraph
9730 @findex iswlower
9731 @findex iswprint
9732 @findex iswpunct
9733 @findex iswspace
9734 @findex iswupper
9735 @findex iswxdigit
9736 @findex isxdigit
9737 @findex j0
9738 @findex j0f
9739 @findex j0l
9740 @findex j1
9741 @findex j1f
9742 @findex j1l
9743 @findex jn
9744 @findex jnf
9745 @findex jnl
9746 @findex labs
9747 @findex ldexp
9748 @findex ldexpf
9749 @findex ldexpl
9750 @findex lgamma
9751 @findex lgammaf
9752 @findex lgammal
9753 @findex lgamma_r
9754 @findex lgammaf_r
9755 @findex lgammal_r
9756 @findex llabs
9757 @findex llrint
9758 @findex llrintf
9759 @findex llrintl
9760 @findex llround
9761 @findex llroundf
9762 @findex llroundl
9763 @findex log
9764 @findex log10
9765 @findex log10f
9766 @findex log10l
9767 @findex log1p
9768 @findex log1pf
9769 @findex log1pl
9770 @findex log2
9771 @findex log2f
9772 @findex log2l
9773 @findex logb
9774 @findex logbf
9775 @findex logbl
9776 @findex logf
9777 @findex logl
9778 @findex lrint
9779 @findex lrintf
9780 @findex lrintl
9781 @findex lround
9782 @findex lroundf
9783 @findex lroundl
9784 @findex malloc
9785 @findex memchr
9786 @findex memcmp
9787 @findex memcpy
9788 @findex mempcpy
9789 @findex memset
9790 @findex modf
9791 @findex modff
9792 @findex modfl
9793 @findex nearbyint
9794 @findex nearbyintf
9795 @findex nearbyintl
9796 @findex nextafter
9797 @findex nextafterf
9798 @findex nextafterl
9799 @findex nexttoward
9800 @findex nexttowardf
9801 @findex nexttowardl
9802 @findex pow
9803 @findex pow10
9804 @findex pow10f
9805 @findex pow10l
9806 @findex powf
9807 @findex powl
9808 @findex printf
9809 @findex printf_unlocked
9810 @findex putchar
9811 @findex puts
9812 @findex remainder
9813 @findex remainderf
9814 @findex remainderl
9815 @findex remquo
9816 @findex remquof
9817 @findex remquol
9818 @findex rindex
9819 @findex rint
9820 @findex rintf
9821 @findex rintl
9822 @findex round
9823 @findex roundf
9824 @findex roundl
9825 @findex scalb
9826 @findex scalbf
9827 @findex scalbl
9828 @findex scalbln
9829 @findex scalblnf
9830 @findex scalblnf
9831 @findex scalbn
9832 @findex scalbnf
9833 @findex scanfnl
9834 @findex signbit
9835 @findex signbitf
9836 @findex signbitl
9837 @findex signbitd32
9838 @findex signbitd64
9839 @findex signbitd128
9840 @findex significand
9841 @findex significandf
9842 @findex significandl
9843 @findex sin
9844 @findex sincos
9845 @findex sincosf
9846 @findex sincosl
9847 @findex sinf
9848 @findex sinh
9849 @findex sinhf
9850 @findex sinhl
9851 @findex sinl
9852 @findex snprintf
9853 @findex sprintf
9854 @findex sqrt
9855 @findex sqrtf
9856 @findex sqrtl
9857 @findex sscanf
9858 @findex stpcpy
9859 @findex stpncpy
9860 @findex strcasecmp
9861 @findex strcat
9862 @findex strchr
9863 @findex strcmp
9864 @findex strcpy
9865 @findex strcspn
9866 @findex strdup
9867 @findex strfmon
9868 @findex strftime
9869 @findex strlen
9870 @findex strncasecmp
9871 @findex strncat
9872 @findex strncmp
9873 @findex strncpy
9874 @findex strndup
9875 @findex strpbrk
9876 @findex strrchr
9877 @findex strspn
9878 @findex strstr
9879 @findex tan
9880 @findex tanf
9881 @findex tanh
9882 @findex tanhf
9883 @findex tanhl
9884 @findex tanl
9885 @findex tgamma
9886 @findex tgammaf
9887 @findex tgammal
9888 @findex toascii
9889 @findex tolower
9890 @findex toupper
9891 @findex towlower
9892 @findex towupper
9893 @findex trunc
9894 @findex truncf
9895 @findex truncl
9896 @findex vfprintf
9897 @findex vfscanf
9898 @findex vprintf
9899 @findex vscanf
9900 @findex vsnprintf
9901 @findex vsprintf
9902 @findex vsscanf
9903 @findex y0
9904 @findex y0f
9905 @findex y0l
9906 @findex y1
9907 @findex y1f
9908 @findex y1l
9909 @findex yn
9910 @findex ynf
9911 @findex ynl
9913 GCC provides a large number of built-in functions other than the ones
9914 mentioned above.  Some of these are for internal use in the processing
9915 of exceptions or variable-length argument lists and are not
9916 documented here because they may change from time to time; we do not
9917 recommend general use of these functions.
9919 The remaining functions are provided for optimization purposes.
9921 @opindex fno-builtin
9922 GCC includes built-in versions of many of the functions in the standard
9923 C library.  The versions prefixed with @code{__builtin_} are always
9924 treated as having the same meaning as the C library function even if you
9925 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
9926 Many of these functions are only optimized in certain cases; if they are
9927 not optimized in a particular case, a call to the library function is
9928 emitted.
9930 @opindex ansi
9931 @opindex std
9932 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9933 @option{-std=c99} or @option{-std=c11}), the functions
9934 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9935 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9936 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9937 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9938 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9939 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9940 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9941 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9942 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9943 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9944 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9945 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9946 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9947 @code{significandl}, @code{significand}, @code{sincosf},
9948 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9949 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9950 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9951 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9952 @code{yn}
9953 may be handled as built-in functions.
9954 All these functions have corresponding versions
9955 prefixed with @code{__builtin_}, which may be used even in strict C90
9956 mode.
9958 The ISO C99 functions
9959 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9960 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9961 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9962 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9963 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9964 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9965 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9966 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9967 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9968 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9969 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9970 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9971 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9972 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9973 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9974 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9975 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9976 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9977 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9978 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9979 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9980 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9981 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9982 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9983 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9984 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9985 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9986 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9987 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9988 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9989 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9990 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9991 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9992 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9993 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9994 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9995 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9996 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9997 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9998 are handled as built-in functions
9999 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10001 There are also built-in versions of the ISO C99 functions
10002 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10003 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10004 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10005 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10006 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10007 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10008 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10009 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10010 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10011 that are recognized in any mode since ISO C90 reserves these names for
10012 the purpose to which ISO C99 puts them.  All these functions have
10013 corresponding versions prefixed with @code{__builtin_}.
10015 The ISO C94 functions
10016 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10017 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10018 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10019 @code{towupper}
10020 are handled as built-in functions
10021 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10023 The ISO C90 functions
10024 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10025 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10026 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10027 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10028 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10029 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10030 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10031 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10032 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10033 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10034 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10035 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10036 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10037 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10038 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10039 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10040 are all recognized as built-in functions unless
10041 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10042 is specified for an individual function).  All of these functions have
10043 corresponding versions prefixed with @code{__builtin_}.
10045 GCC provides built-in versions of the ISO C99 floating-point comparison
10046 macros that avoid raising exceptions for unordered operands.  They have
10047 the same names as the standard macros ( @code{isgreater},
10048 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10049 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10050 prefixed.  We intend for a library implementor to be able to simply
10051 @code{#define} each standard macro to its built-in equivalent.
10052 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10053 @code{isinf_sign} and @code{isnormal} built-ins used with
10054 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
10055 built-in functions appear both with and without the @code{__builtin_} prefix.
10057 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10059 You can use the built-in function @code{__builtin_types_compatible_p} to
10060 determine whether two types are the same.
10062 This built-in function returns 1 if the unqualified versions of the
10063 types @var{type1} and @var{type2} (which are types, not expressions) are
10064 compatible, 0 otherwise.  The result of this built-in function can be
10065 used in integer constant expressions.
10067 This built-in function ignores top level qualifiers (e.g., @code{const},
10068 @code{volatile}).  For example, @code{int} is equivalent to @code{const
10069 int}.
10071 The type @code{int[]} and @code{int[5]} are compatible.  On the other
10072 hand, @code{int} and @code{char *} are not compatible, even if the size
10073 of their types, on the particular architecture are the same.  Also, the
10074 amount of pointer indirection is taken into account when determining
10075 similarity.  Consequently, @code{short *} is not similar to
10076 @code{short **}.  Furthermore, two types that are typedefed are
10077 considered compatible if their underlying types are compatible.
10079 An @code{enum} type is not considered to be compatible with another
10080 @code{enum} type even if both are compatible with the same integer
10081 type; this is what the C standard specifies.
10082 For example, @code{enum @{foo, bar@}} is not similar to
10083 @code{enum @{hot, dog@}}.
10085 You typically use this function in code whose execution varies
10086 depending on the arguments' types.  For example:
10088 @smallexample
10089 #define foo(x)                                                  \
10090   (@{                                                           \
10091     typeof (x) tmp = (x);                                       \
10092     if (__builtin_types_compatible_p (typeof (x), long double)) \
10093       tmp = foo_long_double (tmp);                              \
10094     else if (__builtin_types_compatible_p (typeof (x), double)) \
10095       tmp = foo_double (tmp);                                   \
10096     else if (__builtin_types_compatible_p (typeof (x), float))  \
10097       tmp = foo_float (tmp);                                    \
10098     else                                                        \
10099       abort ();                                                 \
10100     tmp;                                                        \
10101   @})
10102 @end smallexample
10104 @emph{Note:} This construct is only available for C@.
10106 @end deftypefn
10108 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10110 The @var{call_exp} expression must be a function call, and the
10111 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
10112 is passed to the function call in the target's static chain location.
10113 The result of builtin is the result of the function call.
10115 @emph{Note:} This builtin is only available for C@.
10116 This builtin can be used to call Go closures from C.
10118 @end deftypefn
10120 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10122 You can use the built-in function @code{__builtin_choose_expr} to
10123 evaluate code depending on the value of a constant expression.  This
10124 built-in function returns @var{exp1} if @var{const_exp}, which is an
10125 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
10127 This built-in function is analogous to the @samp{? :} operator in C,
10128 except that the expression returned has its type unaltered by promotion
10129 rules.  Also, the built-in function does not evaluate the expression
10130 that is not chosen.  For example, if @var{const_exp} evaluates to true,
10131 @var{exp2} is not evaluated even if it has side-effects.
10133 This built-in function can return an lvalue if the chosen argument is an
10134 lvalue.
10136 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10137 type.  Similarly, if @var{exp2} is returned, its return type is the same
10138 as @var{exp2}.
10140 Example:
10142 @smallexample
10143 #define foo(x)                                                    \
10144   __builtin_choose_expr (                                         \
10145     __builtin_types_compatible_p (typeof (x), double),            \
10146     foo_double (x),                                               \
10147     __builtin_choose_expr (                                       \
10148       __builtin_types_compatible_p (typeof (x), float),           \
10149       foo_float (x),                                              \
10150       /* @r{The void expression results in a compile-time error}  \
10151          @r{when assigning the result to something.}  */          \
10152       (void)0))
10153 @end smallexample
10155 @emph{Note:} This construct is only available for C@.  Furthermore, the
10156 unused expression (@var{exp1} or @var{exp2} depending on the value of
10157 @var{const_exp}) may still generate syntax errors.  This may change in
10158 future revisions.
10160 @end deftypefn
10162 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10164 The built-in function @code{__builtin_complex} is provided for use in
10165 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10166 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
10167 real binary floating-point type, and the result has the corresponding
10168 complex type with real and imaginary parts @var{real} and @var{imag}.
10169 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10170 infinities, NaNs and negative zeros are involved.
10172 @end deftypefn
10174 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10175 You can use the built-in function @code{__builtin_constant_p} to
10176 determine if a value is known to be constant at compile time and hence
10177 that GCC can perform constant-folding on expressions involving that
10178 value.  The argument of the function is the value to test.  The function
10179 returns the integer 1 if the argument is known to be a compile-time
10180 constant and 0 if it is not known to be a compile-time constant.  A
10181 return of 0 does not indicate that the value is @emph{not} a constant,
10182 but merely that GCC cannot prove it is a constant with the specified
10183 value of the @option{-O} option.
10185 You typically use this function in an embedded application where
10186 memory is a critical resource.  If you have some complex calculation,
10187 you may want it to be folded if it involves constants, but need to call
10188 a function if it does not.  For example:
10190 @smallexample
10191 #define Scale_Value(X)      \
10192   (__builtin_constant_p (X) \
10193   ? ((X) * SCALE + OFFSET) : Scale (X))
10194 @end smallexample
10196 You may use this built-in function in either a macro or an inline
10197 function.  However, if you use it in an inlined function and pass an
10198 argument of the function as the argument to the built-in, GCC 
10199 never returns 1 when you call the inline function with a string constant
10200 or compound literal (@pxref{Compound Literals}) and does not return 1
10201 when you pass a constant numeric value to the inline function unless you
10202 specify the @option{-O} option.
10204 You may also use @code{__builtin_constant_p} in initializers for static
10205 data.  For instance, you can write
10207 @smallexample
10208 static const int table[] = @{
10209    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10210    /* @r{@dots{}} */
10212 @end smallexample
10214 @noindent
10215 This is an acceptable initializer even if @var{EXPRESSION} is not a
10216 constant expression, including the case where
10217 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10218 folded to a constant but @var{EXPRESSION} contains operands that are
10219 not otherwise permitted in a static initializer (for example,
10220 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
10221 built-in in this case, because it has no opportunity to perform
10222 optimization.
10223 @end deftypefn
10225 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10226 @opindex fprofile-arcs
10227 You may use @code{__builtin_expect} to provide the compiler with
10228 branch prediction information.  In general, you should prefer to
10229 use actual profile feedback for this (@option{-fprofile-arcs}), as
10230 programmers are notoriously bad at predicting how their programs
10231 actually perform.  However, there are applications in which this
10232 data is hard to collect.
10234 The return value is the value of @var{exp}, which should be an integral
10235 expression.  The semantics of the built-in are that it is expected that
10236 @var{exp} == @var{c}.  For example:
10238 @smallexample
10239 if (__builtin_expect (x, 0))
10240   foo ();
10241 @end smallexample
10243 @noindent
10244 indicates that we do not expect to call @code{foo}, since
10245 we expect @code{x} to be zero.  Since you are limited to integral
10246 expressions for @var{exp}, you should use constructions such as
10248 @smallexample
10249 if (__builtin_expect (ptr != NULL, 1))
10250   foo (*ptr);
10251 @end smallexample
10253 @noindent
10254 when testing pointer or floating-point values.
10255 @end deftypefn
10257 @deftypefn {Built-in Function} void __builtin_trap (void)
10258 This function causes the program to exit abnormally.  GCC implements
10259 this function by using a target-dependent mechanism (such as
10260 intentionally executing an illegal instruction) or by calling
10261 @code{abort}.  The mechanism used may vary from release to release so
10262 you should not rely on any particular implementation.
10263 @end deftypefn
10265 @deftypefn {Built-in Function} void __builtin_unreachable (void)
10266 If control flow reaches the point of the @code{__builtin_unreachable},
10267 the program is undefined.  It is useful in situations where the
10268 compiler cannot deduce the unreachability of the code.
10270 One such case is immediately following an @code{asm} statement that
10271 either never terminates, or one that transfers control elsewhere
10272 and never returns.  In this example, without the
10273 @code{__builtin_unreachable}, GCC issues a warning that control
10274 reaches the end of a non-void function.  It also generates code
10275 to return after the @code{asm}.
10277 @smallexample
10278 int f (int c, int v)
10280   if (c)
10281     @{
10282       return v;
10283     @}
10284   else
10285     @{
10286       asm("jmp error_handler");
10287       __builtin_unreachable ();
10288     @}
10290 @end smallexample
10292 @noindent
10293 Because the @code{asm} statement unconditionally transfers control out
10294 of the function, control never reaches the end of the function
10295 body.  The @code{__builtin_unreachable} is in fact unreachable and
10296 communicates this fact to the compiler.
10298 Another use for @code{__builtin_unreachable} is following a call a
10299 function that never returns but that is not declared
10300 @code{__attribute__((noreturn))}, as in this example:
10302 @smallexample
10303 void function_that_never_returns (void);
10305 int g (int c)
10307   if (c)
10308     @{
10309       return 1;
10310     @}
10311   else
10312     @{
10313       function_that_never_returns ();
10314       __builtin_unreachable ();
10315     @}
10317 @end smallexample
10319 @end deftypefn
10321 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
10322 This function returns its first argument, and allows the compiler
10323 to assume that the returned pointer is at least @var{align} bytes
10324 aligned.  This built-in can have either two or three arguments,
10325 if it has three, the third argument should have integer type, and
10326 if it is nonzero means misalignment offset.  For example:
10328 @smallexample
10329 void *x = __builtin_assume_aligned (arg, 16);
10330 @end smallexample
10332 @noindent
10333 means that the compiler can assume @code{x}, set to @code{arg}, is at least
10334 16-byte aligned, while:
10336 @smallexample
10337 void *x = __builtin_assume_aligned (arg, 32, 8);
10338 @end smallexample
10340 @noindent
10341 means that the compiler can assume for @code{x}, set to @code{arg}, that
10342 @code{(char *) x - 8} is 32-byte aligned.
10343 @end deftypefn
10345 @deftypefn {Built-in Function} int __builtin_LINE ()
10346 This function is the equivalent to the preprocessor @code{__LINE__}
10347 macro and returns the line number of the invocation of the built-in.
10348 In a C++ default argument for a function @var{F}, it gets the line number of
10349 the call to @var{F}.
10350 @end deftypefn
10352 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
10353 This function is the equivalent to the preprocessor @code{__FUNCTION__}
10354 macro and returns the function name the invocation of the built-in is in.
10355 @end deftypefn
10357 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
10358 This function is the equivalent to the preprocessor @code{__FILE__}
10359 macro and returns the file name the invocation of the built-in is in.
10360 In a C++ default argument for a function @var{F}, it gets the file name of
10361 the call to @var{F}.
10362 @end deftypefn
10364 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
10365 This function is used to flush the processor's instruction cache for
10366 the region of memory between @var{begin} inclusive and @var{end}
10367 exclusive.  Some targets require that the instruction cache be
10368 flushed, after modifying memory containing code, in order to obtain
10369 deterministic behavior.
10371 If the target does not require instruction cache flushes,
10372 @code{__builtin___clear_cache} has no effect.  Otherwise either
10373 instructions are emitted in-line to clear the instruction cache or a
10374 call to the @code{__clear_cache} function in libgcc is made.
10375 @end deftypefn
10377 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
10378 This function is used to minimize cache-miss latency by moving data into
10379 a cache before it is accessed.
10380 You can insert calls to @code{__builtin_prefetch} into code for which
10381 you know addresses of data in memory that is likely to be accessed soon.
10382 If the target supports them, data prefetch instructions are generated.
10383 If the prefetch is done early enough before the access then the data will
10384 be in the cache by the time it is accessed.
10386 The value of @var{addr} is the address of the memory to prefetch.
10387 There are two optional arguments, @var{rw} and @var{locality}.
10388 The value of @var{rw} is a compile-time constant one or zero; one
10389 means that the prefetch is preparing for a write to the memory address
10390 and zero, the default, means that the prefetch is preparing for a read.
10391 The value @var{locality} must be a compile-time constant integer between
10392 zero and three.  A value of zero means that the data has no temporal
10393 locality, so it need not be left in the cache after the access.  A value
10394 of three means that the data has a high degree of temporal locality and
10395 should be left in all levels of cache possible.  Values of one and two
10396 mean, respectively, a low or moderate degree of temporal locality.  The
10397 default is three.
10399 @smallexample
10400 for (i = 0; i < n; i++)
10401   @{
10402     a[i] = a[i] + b[i];
10403     __builtin_prefetch (&a[i+j], 1, 1);
10404     __builtin_prefetch (&b[i+j], 0, 1);
10405     /* @r{@dots{}} */
10406   @}
10407 @end smallexample
10409 Data prefetch does not generate faults if @var{addr} is invalid, but
10410 the address expression itself must be valid.  For example, a prefetch
10411 of @code{p->next} does not fault if @code{p->next} is not a valid
10412 address, but evaluation faults if @code{p} is not a valid address.
10414 If the target does not support data prefetch, the address expression
10415 is evaluated if it includes side effects but no other code is generated
10416 and GCC does not issue a warning.
10417 @end deftypefn
10419 @deftypefn {Built-in Function} double __builtin_huge_val (void)
10420 Returns a positive infinity, if supported by the floating-point format,
10421 else @code{DBL_MAX}.  This function is suitable for implementing the
10422 ISO C macro @code{HUGE_VAL}.
10423 @end deftypefn
10425 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
10426 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
10427 @end deftypefn
10429 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
10430 Similar to @code{__builtin_huge_val}, except the return
10431 type is @code{long double}.
10432 @end deftypefn
10434 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
10435 This built-in implements the C99 fpclassify functionality.  The first
10436 five int arguments should be the target library's notion of the
10437 possible FP classes and are used for return values.  They must be
10438 constant values and they must appear in this order: @code{FP_NAN},
10439 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
10440 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
10441 to classify.  GCC treats the last argument as type-generic, which
10442 means it does not do default promotion from float to double.
10443 @end deftypefn
10445 @deftypefn {Built-in Function} double __builtin_inf (void)
10446 Similar to @code{__builtin_huge_val}, except a warning is generated
10447 if the target floating-point format does not support infinities.
10448 @end deftypefn
10450 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
10451 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
10452 @end deftypefn
10454 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
10455 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
10456 @end deftypefn
10458 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
10459 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
10460 @end deftypefn
10462 @deftypefn {Built-in Function} float __builtin_inff (void)
10463 Similar to @code{__builtin_inf}, except the return type is @code{float}.
10464 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
10465 @end deftypefn
10467 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
10468 Similar to @code{__builtin_inf}, except the return
10469 type is @code{long double}.
10470 @end deftypefn
10472 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
10473 Similar to @code{isinf}, except the return value is -1 for
10474 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
10475 Note while the parameter list is an
10476 ellipsis, this function only accepts exactly one floating-point
10477 argument.  GCC treats this parameter as type-generic, which means it
10478 does not do default promotion from float to double.
10479 @end deftypefn
10481 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
10482 This is an implementation of the ISO C99 function @code{nan}.
10484 Since ISO C99 defines this function in terms of @code{strtod}, which we
10485 do not implement, a description of the parsing is in order.  The string
10486 is parsed as by @code{strtol}; that is, the base is recognized by
10487 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
10488 in the significand such that the least significant bit of the number
10489 is at the least significant bit of the significand.  The number is
10490 truncated to fit the significand field provided.  The significand is
10491 forced to be a quiet NaN@.
10493 This function, if given a string literal all of which would have been
10494 consumed by @code{strtol}, is evaluated early enough that it is considered a
10495 compile-time constant.
10496 @end deftypefn
10498 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
10499 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
10500 @end deftypefn
10502 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
10503 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
10504 @end deftypefn
10506 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
10507 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
10508 @end deftypefn
10510 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
10511 Similar to @code{__builtin_nan}, except the return type is @code{float}.
10512 @end deftypefn
10514 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
10515 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
10516 @end deftypefn
10518 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
10519 Similar to @code{__builtin_nan}, except the significand is forced
10520 to be a signaling NaN@.  The @code{nans} function is proposed by
10521 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
10522 @end deftypefn
10524 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
10525 Similar to @code{__builtin_nans}, except the return type is @code{float}.
10526 @end deftypefn
10528 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
10529 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
10530 @end deftypefn
10532 @deftypefn {Built-in Function} int __builtin_ffs (int x)
10533 Returns one plus the index of the least significant 1-bit of @var{x}, or
10534 if @var{x} is zero, returns zero.
10535 @end deftypefn
10537 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
10538 Returns the number of leading 0-bits in @var{x}, starting at the most
10539 significant bit position.  If @var{x} is 0, the result is undefined.
10540 @end deftypefn
10542 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
10543 Returns the number of trailing 0-bits in @var{x}, starting at the least
10544 significant bit position.  If @var{x} is 0, the result is undefined.
10545 @end deftypefn
10547 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
10548 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
10549 number of bits following the most significant bit that are identical
10550 to it.  There are no special cases for 0 or other values. 
10551 @end deftypefn
10553 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
10554 Returns the number of 1-bits in @var{x}.
10555 @end deftypefn
10557 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
10558 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
10559 modulo 2.
10560 @end deftypefn
10562 @deftypefn {Built-in Function} int __builtin_ffsl (long)
10563 Similar to @code{__builtin_ffs}, except the argument type is
10564 @code{long}.
10565 @end deftypefn
10567 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
10568 Similar to @code{__builtin_clz}, except the argument type is
10569 @code{unsigned long}.
10570 @end deftypefn
10572 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
10573 Similar to @code{__builtin_ctz}, except the argument type is
10574 @code{unsigned long}.
10575 @end deftypefn
10577 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
10578 Similar to @code{__builtin_clrsb}, except the argument type is
10579 @code{long}.
10580 @end deftypefn
10582 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
10583 Similar to @code{__builtin_popcount}, except the argument type is
10584 @code{unsigned long}.
10585 @end deftypefn
10587 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
10588 Similar to @code{__builtin_parity}, except the argument type is
10589 @code{unsigned long}.
10590 @end deftypefn
10592 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
10593 Similar to @code{__builtin_ffs}, except the argument type is
10594 @code{long long}.
10595 @end deftypefn
10597 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
10598 Similar to @code{__builtin_clz}, except the argument type is
10599 @code{unsigned long long}.
10600 @end deftypefn
10602 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
10603 Similar to @code{__builtin_ctz}, except the argument type is
10604 @code{unsigned long long}.
10605 @end deftypefn
10607 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
10608 Similar to @code{__builtin_clrsb}, except the argument type is
10609 @code{long long}.
10610 @end deftypefn
10612 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10613 Similar to @code{__builtin_popcount}, except the argument type is
10614 @code{unsigned long long}.
10615 @end deftypefn
10617 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10618 Similar to @code{__builtin_parity}, except the argument type is
10619 @code{unsigned long long}.
10620 @end deftypefn
10622 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10623 Returns the first argument raised to the power of the second.  Unlike the
10624 @code{pow} function no guarantees about precision and rounding are made.
10625 @end deftypefn
10627 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10628 Similar to @code{__builtin_powi}, except the argument and return types
10629 are @code{float}.
10630 @end deftypefn
10632 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10633 Similar to @code{__builtin_powi}, except the argument and return types
10634 are @code{long double}.
10635 @end deftypefn
10637 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10638 Returns @var{x} with the order of the bytes reversed; for example,
10639 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
10640 exactly 8 bits.
10641 @end deftypefn
10643 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10644 Similar to @code{__builtin_bswap16}, except the argument and return types
10645 are 32 bit.
10646 @end deftypefn
10648 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10649 Similar to @code{__builtin_bswap32}, except the argument and return types
10650 are 64 bit.
10651 @end deftypefn
10653 @node Target Builtins
10654 @section Built-in Functions Specific to Particular Target Machines
10656 On some target machines, GCC supports many built-in functions specific
10657 to those machines.  Generally these generate calls to specific machine
10658 instructions, but allow the compiler to schedule those calls.
10660 @menu
10661 * AArch64 Built-in Functions::
10662 * Alpha Built-in Functions::
10663 * Altera Nios II Built-in Functions::
10664 * ARC Built-in Functions::
10665 * ARC SIMD Built-in Functions::
10666 * ARM iWMMXt Built-in Functions::
10667 * ARM C Language Extensions (ACLE)::
10668 * ARM Floating Point Status and Control Intrinsics::
10669 * AVR Built-in Functions::
10670 * Blackfin Built-in Functions::
10671 * FR-V Built-in Functions::
10672 * MIPS DSP Built-in Functions::
10673 * MIPS Paired-Single Support::
10674 * MIPS Loongson Built-in Functions::
10675 * Other MIPS Built-in Functions::
10676 * MSP430 Built-in Functions::
10677 * NDS32 Built-in Functions::
10678 * picoChip Built-in Functions::
10679 * PowerPC Built-in Functions::
10680 * PowerPC AltiVec/VSX Built-in Functions::
10681 * PowerPC Hardware Transactional Memory Built-in Functions::
10682 * RX Built-in Functions::
10683 * S/390 System z Built-in Functions::
10684 * SH Built-in Functions::
10685 * SPARC VIS Built-in Functions::
10686 * SPU Built-in Functions::
10687 * TI C6X Built-in Functions::
10688 * TILE-Gx Built-in Functions::
10689 * TILEPro Built-in Functions::
10690 * x86 Built-in Functions::
10691 * x86 transactional memory intrinsics::
10692 @end menu
10694 @node AArch64 Built-in Functions
10695 @subsection AArch64 Built-in Functions
10697 These built-in functions are available for the AArch64 family of
10698 processors.
10699 @smallexample
10700 unsigned int __builtin_aarch64_get_fpcr ()
10701 void __builtin_aarch64_set_fpcr (unsigned int)
10702 unsigned int __builtin_aarch64_get_fpsr ()
10703 void __builtin_aarch64_set_fpsr (unsigned int)
10704 @end smallexample
10706 @node Alpha Built-in Functions
10707 @subsection Alpha Built-in Functions
10709 These built-in functions are available for the Alpha family of
10710 processors, depending on the command-line switches used.
10712 The following built-in functions are always available.  They
10713 all generate the machine instruction that is part of the name.
10715 @smallexample
10716 long __builtin_alpha_implver (void)
10717 long __builtin_alpha_rpcc (void)
10718 long __builtin_alpha_amask (long)
10719 long __builtin_alpha_cmpbge (long, long)
10720 long __builtin_alpha_extbl (long, long)
10721 long __builtin_alpha_extwl (long, long)
10722 long __builtin_alpha_extll (long, long)
10723 long __builtin_alpha_extql (long, long)
10724 long __builtin_alpha_extwh (long, long)
10725 long __builtin_alpha_extlh (long, long)
10726 long __builtin_alpha_extqh (long, long)
10727 long __builtin_alpha_insbl (long, long)
10728 long __builtin_alpha_inswl (long, long)
10729 long __builtin_alpha_insll (long, long)
10730 long __builtin_alpha_insql (long, long)
10731 long __builtin_alpha_inswh (long, long)
10732 long __builtin_alpha_inslh (long, long)
10733 long __builtin_alpha_insqh (long, long)
10734 long __builtin_alpha_mskbl (long, long)
10735 long __builtin_alpha_mskwl (long, long)
10736 long __builtin_alpha_mskll (long, long)
10737 long __builtin_alpha_mskql (long, long)
10738 long __builtin_alpha_mskwh (long, long)
10739 long __builtin_alpha_msklh (long, long)
10740 long __builtin_alpha_mskqh (long, long)
10741 long __builtin_alpha_umulh (long, long)
10742 long __builtin_alpha_zap (long, long)
10743 long __builtin_alpha_zapnot (long, long)
10744 @end smallexample
10746 The following built-in functions are always with @option{-mmax}
10747 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10748 later.  They all generate the machine instruction that is part
10749 of the name.
10751 @smallexample
10752 long __builtin_alpha_pklb (long)
10753 long __builtin_alpha_pkwb (long)
10754 long __builtin_alpha_unpkbl (long)
10755 long __builtin_alpha_unpkbw (long)
10756 long __builtin_alpha_minub8 (long, long)
10757 long __builtin_alpha_minsb8 (long, long)
10758 long __builtin_alpha_minuw4 (long, long)
10759 long __builtin_alpha_minsw4 (long, long)
10760 long __builtin_alpha_maxub8 (long, long)
10761 long __builtin_alpha_maxsb8 (long, long)
10762 long __builtin_alpha_maxuw4 (long, long)
10763 long __builtin_alpha_maxsw4 (long, long)
10764 long __builtin_alpha_perr (long, long)
10765 @end smallexample
10767 The following built-in functions are always with @option{-mcix}
10768 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10769 later.  They all generate the machine instruction that is part
10770 of the name.
10772 @smallexample
10773 long __builtin_alpha_cttz (long)
10774 long __builtin_alpha_ctlz (long)
10775 long __builtin_alpha_ctpop (long)
10776 @end smallexample
10778 The following built-in functions are available on systems that use the OSF/1
10779 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
10780 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10781 @code{rdval} and @code{wrval}.
10783 @smallexample
10784 void *__builtin_thread_pointer (void)
10785 void __builtin_set_thread_pointer (void *)
10786 @end smallexample
10788 @node Altera Nios II Built-in Functions
10789 @subsection Altera Nios II Built-in Functions
10791 These built-in functions are available for the Altera Nios II
10792 family of processors.
10794 The following built-in functions are always available.  They
10795 all generate the machine instruction that is part of the name.
10797 @example
10798 int __builtin_ldbio (volatile const void *)
10799 int __builtin_ldbuio (volatile const void *)
10800 int __builtin_ldhio (volatile const void *)
10801 int __builtin_ldhuio (volatile const void *)
10802 int __builtin_ldwio (volatile const void *)
10803 void __builtin_stbio (volatile void *, int)
10804 void __builtin_sthio (volatile void *, int)
10805 void __builtin_stwio (volatile void *, int)
10806 void __builtin_sync (void)
10807 int __builtin_rdctl (int) 
10808 void __builtin_wrctl (int, int)
10809 @end example
10811 The following built-in functions are always available.  They
10812 all generate a Nios II Custom Instruction. The name of the
10813 function represents the types that the function takes and
10814 returns. The letter before the @code{n} is the return type
10815 or void if absent. The @code{n} represents the first parameter
10816 to all the custom instructions, the custom instruction number.
10817 The two letters after the @code{n} represent the up to two
10818 parameters to the function.
10820 The letters represent the following data types:
10821 @table @code
10822 @item <no letter>
10823 @code{void} for return type and no parameter for parameter types.
10825 @item i
10826 @code{int} for return type and parameter type
10828 @item f
10829 @code{float} for return type and parameter type
10831 @item p
10832 @code{void *} for return type and parameter type
10834 @end table
10836 And the function names are:
10837 @example
10838 void __builtin_custom_n (void)
10839 void __builtin_custom_ni (int)
10840 void __builtin_custom_nf (float)
10841 void __builtin_custom_np (void *)
10842 void __builtin_custom_nii (int, int)
10843 void __builtin_custom_nif (int, float)
10844 void __builtin_custom_nip (int, void *)
10845 void __builtin_custom_nfi (float, int)
10846 void __builtin_custom_nff (float, float)
10847 void __builtin_custom_nfp (float, void *)
10848 void __builtin_custom_npi (void *, int)
10849 void __builtin_custom_npf (void *, float)
10850 void __builtin_custom_npp (void *, void *)
10851 int __builtin_custom_in (void)
10852 int __builtin_custom_ini (int)
10853 int __builtin_custom_inf (float)
10854 int __builtin_custom_inp (void *)
10855 int __builtin_custom_inii (int, int)
10856 int __builtin_custom_inif (int, float)
10857 int __builtin_custom_inip (int, void *)
10858 int __builtin_custom_infi (float, int)
10859 int __builtin_custom_inff (float, float)
10860 int __builtin_custom_infp (float, void *)
10861 int __builtin_custom_inpi (void *, int)
10862 int __builtin_custom_inpf (void *, float)
10863 int __builtin_custom_inpp (void *, void *)
10864 float __builtin_custom_fn (void)
10865 float __builtin_custom_fni (int)
10866 float __builtin_custom_fnf (float)
10867 float __builtin_custom_fnp (void *)
10868 float __builtin_custom_fnii (int, int)
10869 float __builtin_custom_fnif (int, float)
10870 float __builtin_custom_fnip (int, void *)
10871 float __builtin_custom_fnfi (float, int)
10872 float __builtin_custom_fnff (float, float)
10873 float __builtin_custom_fnfp (float, void *)
10874 float __builtin_custom_fnpi (void *, int)
10875 float __builtin_custom_fnpf (void *, float)
10876 float __builtin_custom_fnpp (void *, void *)
10877 void * __builtin_custom_pn (void)
10878 void * __builtin_custom_pni (int)
10879 void * __builtin_custom_pnf (float)
10880 void * __builtin_custom_pnp (void *)
10881 void * __builtin_custom_pnii (int, int)
10882 void * __builtin_custom_pnif (int, float)
10883 void * __builtin_custom_pnip (int, void *)
10884 void * __builtin_custom_pnfi (float, int)
10885 void * __builtin_custom_pnff (float, float)
10886 void * __builtin_custom_pnfp (float, void *)
10887 void * __builtin_custom_pnpi (void *, int)
10888 void * __builtin_custom_pnpf (void *, float)
10889 void * __builtin_custom_pnpp (void *, void *)
10890 @end example
10892 @node ARC Built-in Functions
10893 @subsection ARC Built-in Functions
10895 The following built-in functions are provided for ARC targets.  The
10896 built-ins generate the corresponding assembly instructions.  In the
10897 examples given below, the generated code often requires an operand or
10898 result to be in a register.  Where necessary further code will be
10899 generated to ensure this is true, but for brevity this is not
10900 described in each case.
10902 @emph{Note:} Using a built-in to generate an instruction not supported
10903 by a target may cause problems. At present the compiler is not
10904 guaranteed to detect such misuse, and as a result an internal compiler
10905 error may be generated.
10907 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10908 Return 1 if @var{val} is known to have the byte alignment given
10909 by @var{alignval}, otherwise return 0.
10910 Note that this is different from
10911 @smallexample
10912 __alignof__(*(char *)@var{val}) >= alignval
10913 @end smallexample
10914 because __alignof__ sees only the type of the dereference, whereas
10915 __builtin_arc_align uses alignment information from the pointer
10916 as well as from the pointed-to type.
10917 The information available will depend on optimization level.
10918 @end deftypefn
10920 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10921 Generates
10922 @example
10924 @end example
10925 @end deftypefn
10927 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10928 The operand is the number of a register to be read.  Generates:
10929 @example
10930 mov  @var{dest}, r@var{regno}
10931 @end example
10932 where the value in @var{dest} will be the result returned from the
10933 built-in.
10934 @end deftypefn
10936 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10937 The first operand is the number of a register to be written, the
10938 second operand is a compile time constant to write into that
10939 register.  Generates:
10940 @example
10941 mov  r@var{regno}, @var{val}
10942 @end example
10943 @end deftypefn
10945 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10946 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10947 Generates:
10948 @example
10949 divaw  @var{dest}, @var{a}, @var{b}
10950 @end example
10951 where the value in @var{dest} will be the result returned from the
10952 built-in.
10953 @end deftypefn
10955 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10956 Generates
10957 @example
10958 flag  @var{a}
10959 @end example
10960 @end deftypefn
10962 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10963 The operand, @var{auxv}, is the address of an auxiliary register and
10964 must be a compile time constant.  Generates:
10965 @example
10966 lr  @var{dest}, [@var{auxr}]
10967 @end example
10968 Where the value in @var{dest} will be the result returned from the
10969 built-in.
10970 @end deftypefn
10972 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10973 Only available with @option{-mmul64}.  Generates:
10974 @example
10975 mul64  @var{a}, @var{b}
10976 @end example
10977 @end deftypefn
10979 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10980 Only available with @option{-mmul64}.  Generates:
10981 @example
10982 mulu64  @var{a}, @var{b}
10983 @end example
10984 @end deftypefn
10986 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10987 Generates:
10988 @example
10990 @end example
10991 @end deftypefn
10993 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10994 Only valid if the @samp{norm} instruction is available through the
10995 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10996 Generates:
10997 @example
10998 norm  @var{dest}, @var{src}
10999 @end example
11000 Where the value in @var{dest} will be the result returned from the
11001 built-in.
11002 @end deftypefn
11004 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
11005 Only valid if the @samp{normw} instruction is available through the
11006 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11007 Generates:
11008 @example
11009 normw  @var{dest}, @var{src}
11010 @end example
11011 Where the value in @var{dest} will be the result returned from the
11012 built-in.
11013 @end deftypefn
11015 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
11016 Generates:
11017 @example
11018 rtie
11019 @end example
11020 @end deftypefn
11022 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
11023 Generates:
11024 @example
11025 sleep  @var{a}
11026 @end example
11027 @end deftypefn
11029 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11030 The first argument, @var{auxv}, is the address of an auxiliary
11031 register, the second argument, @var{val}, is a compile time constant
11032 to be written to the register.  Generates:
11033 @example
11034 sr  @var{auxr}, [@var{val}]
11035 @end example
11036 @end deftypefn
11038 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
11039 Only valid with @option{-mswap}.  Generates:
11040 @example
11041 swap  @var{dest}, @var{src}
11042 @end example
11043 Where the value in @var{dest} will be the result returned from the
11044 built-in.
11045 @end deftypefn
11047 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
11048 Generates:
11049 @example
11051 @end example
11052 @end deftypefn
11054 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
11055 Only available with @option{-mcpu=ARC700}.  Generates:
11056 @example
11057 sync
11058 @end example
11059 @end deftypefn
11061 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
11062 Only available with @option{-mcpu=ARC700}.  Generates:
11063 @example
11064 trap_s  @var{c}
11065 @end example
11066 @end deftypefn
11068 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
11069 Only available with @option{-mcpu=ARC700}.  Generates:
11070 @example
11071 unimp_s
11072 @end example
11073 @end deftypefn
11075 The instructions generated by the following builtins are not
11076 considered as candidates for scheduling.  They are not moved around by
11077 the compiler during scheduling, and thus can be expected to appear
11078 where they are put in the C code:
11079 @example
11080 __builtin_arc_brk()
11081 __builtin_arc_core_read()
11082 __builtin_arc_core_write()
11083 __builtin_arc_flag()
11084 __builtin_arc_lr()
11085 __builtin_arc_sleep()
11086 __builtin_arc_sr()
11087 __builtin_arc_swi()
11088 @end example
11090 @node ARC SIMD Built-in Functions
11091 @subsection ARC SIMD Built-in Functions
11093 SIMD builtins provided by the compiler can be used to generate the
11094 vector instructions.  This section describes the available builtins
11095 and their usage in programs.  With the @option{-msimd} option, the
11096 compiler provides 128-bit vector types, which can be specified using
11097 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
11098 can be included to use the following predefined types:
11099 @example
11100 typedef int __v4si   __attribute__((vector_size(16)));
11101 typedef short __v8hi __attribute__((vector_size(16)));
11102 @end example
11104 These types can be used to define 128-bit variables.  The built-in
11105 functions listed in the following section can be used on these
11106 variables to generate the vector operations.
11108 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11109 @file{arc-simd.h} also provides equivalent macros called
11110 @code{_@var{someinsn}} that can be used for programming ease and
11111 improved readability.  The following macros for DMA control are also
11112 provided:
11113 @example
11114 #define _setup_dma_in_channel_reg _vdiwr
11115 #define _setup_dma_out_channel_reg _vdowr
11116 @end example
11118 The following is a complete list of all the SIMD built-ins provided
11119 for ARC, grouped by calling signature.
11121 The following take two @code{__v8hi} arguments and return a
11122 @code{__v8hi} result:
11123 @example
11124 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11125 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11126 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11127 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11128 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11129 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11130 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11131 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11132 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11133 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11134 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11135 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11136 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11137 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11138 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11139 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11140 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11141 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11142 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11143 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11144 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11145 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11146 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11147 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11148 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11149 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11150 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11151 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11152 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11153 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11154 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11155 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11156 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11157 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11158 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11159 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11160 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11161 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11162 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11163 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11164 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11165 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11166 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11167 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11168 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11169 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11170 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11171 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11172 @end example
11174 The following take one @code{__v8hi} and one @code{int} argument and return a
11175 @code{__v8hi} result:
11177 @example
11178 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11179 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11180 __v8hi __builtin_arc_vbminw (__v8hi, int)
11181 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11182 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11183 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11184 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11185 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11186 @end example
11188 The following take one @code{__v8hi} argument and one @code{int} argument which
11189 must be a 3-bit compile time constant indicating a register number
11190 I0-I7.  They return a @code{__v8hi} result.
11191 @example
11192 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11193 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11194 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11195 @end example
11197 The following take one @code{__v8hi} argument and one @code{int}
11198 argument which must be a 6-bit compile time constant.  They return a
11199 @code{__v8hi} result.
11200 @example
11201 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11202 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11203 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11204 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11205 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11206 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11207 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11208 @end example
11210 The following take one @code{__v8hi} argument and one @code{int} argument which
11211 must be a 8-bit compile time constant.  They return a @code{__v8hi}
11212 result.
11213 @example
11214 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11215 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11216 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11217 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11218 @end example
11220 The following take two @code{int} arguments, the second of which which
11221 must be a 8-bit compile time constant.  They return a @code{__v8hi}
11222 result:
11223 @example
11224 __v8hi __builtin_arc_vmovaw (int, const int)
11225 __v8hi __builtin_arc_vmovw (int, const int)
11226 __v8hi __builtin_arc_vmovzw (int, const int)
11227 @end example
11229 The following take a single @code{__v8hi} argument and return a
11230 @code{__v8hi} result:
11231 @example
11232 __v8hi __builtin_arc_vabsaw (__v8hi)
11233 __v8hi __builtin_arc_vabsw (__v8hi)
11234 __v8hi __builtin_arc_vaddsuw (__v8hi)
11235 __v8hi __builtin_arc_vexch1 (__v8hi)
11236 __v8hi __builtin_arc_vexch2 (__v8hi)
11237 __v8hi __builtin_arc_vexch4 (__v8hi)
11238 __v8hi __builtin_arc_vsignw (__v8hi)
11239 __v8hi __builtin_arc_vupbaw (__v8hi)
11240 __v8hi __builtin_arc_vupbw (__v8hi)
11241 __v8hi __builtin_arc_vupsbaw (__v8hi)
11242 __v8hi __builtin_arc_vupsbw (__v8hi)
11243 @end example
11245 The following take two @code{int} arguments and return no result:
11246 @example
11247 void __builtin_arc_vdirun (int, int)
11248 void __builtin_arc_vdorun (int, int)
11249 @end example
11251 The following take two @code{int} arguments and return no result.  The
11252 first argument must a 3-bit compile time constant indicating one of
11253 the DR0-DR7 DMA setup channels:
11254 @example
11255 void __builtin_arc_vdiwr (const int, int)
11256 void __builtin_arc_vdowr (const int, int)
11257 @end example
11259 The following take an @code{int} argument and return no result:
11260 @example
11261 void __builtin_arc_vendrec (int)
11262 void __builtin_arc_vrec (int)
11263 void __builtin_arc_vrecrun (int)
11264 void __builtin_arc_vrun (int)
11265 @end example
11267 The following take a @code{__v8hi} argument and two @code{int}
11268 arguments and return a @code{__v8hi} result.  The second argument must
11269 be a 3-bit compile time constants, indicating one the registers I0-I7,
11270 and the third argument must be an 8-bit compile time constant.
11272 @emph{Note:} Although the equivalent hardware instructions do not take
11273 an SIMD register as an operand, these builtins overwrite the relevant
11274 bits of the @code{__v8hi} register provided as the first argument with
11275 the value loaded from the @code{[Ib, u8]} location in the SDM.
11277 @example
11278 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
11279 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
11280 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
11281 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
11282 @end example
11284 The following take two @code{int} arguments and return a @code{__v8hi}
11285 result.  The first argument must be a 3-bit compile time constants,
11286 indicating one the registers I0-I7, and the second argument must be an
11287 8-bit compile time constant.
11289 @example
11290 __v8hi __builtin_arc_vld128 (const int, const int)
11291 __v8hi __builtin_arc_vld64w (const int, const int)
11292 @end example
11294 The following take a @code{__v8hi} argument and two @code{int}
11295 arguments and return no result.  The second argument must be a 3-bit
11296 compile time constants, indicating one the registers I0-I7, and the
11297 third argument must be an 8-bit compile time constant.
11299 @example
11300 void __builtin_arc_vst128 (__v8hi, const int, const int)
11301 void __builtin_arc_vst64 (__v8hi, const int, const int)
11302 @end example
11304 The following take a @code{__v8hi} argument and three @code{int}
11305 arguments and return no result.  The second argument must be a 3-bit
11306 compile-time constant, identifying the 16-bit sub-register to be
11307 stored, the third argument must be a 3-bit compile time constants,
11308 indicating one the registers I0-I7, and the fourth argument must be an
11309 8-bit compile time constant.
11311 @example
11312 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
11313 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
11314 @end example
11316 @node ARM iWMMXt Built-in Functions
11317 @subsection ARM iWMMXt Built-in Functions
11319 These built-in functions are available for the ARM family of
11320 processors when the @option{-mcpu=iwmmxt} switch is used:
11322 @smallexample
11323 typedef int v2si __attribute__ ((vector_size (8)));
11324 typedef short v4hi __attribute__ ((vector_size (8)));
11325 typedef char v8qi __attribute__ ((vector_size (8)));
11327 int __builtin_arm_getwcgr0 (void)
11328 void __builtin_arm_setwcgr0 (int)
11329 int __builtin_arm_getwcgr1 (void)
11330 void __builtin_arm_setwcgr1 (int)
11331 int __builtin_arm_getwcgr2 (void)
11332 void __builtin_arm_setwcgr2 (int)
11333 int __builtin_arm_getwcgr3 (void)
11334 void __builtin_arm_setwcgr3 (int)
11335 int __builtin_arm_textrmsb (v8qi, int)
11336 int __builtin_arm_textrmsh (v4hi, int)
11337 int __builtin_arm_textrmsw (v2si, int)
11338 int __builtin_arm_textrmub (v8qi, int)
11339 int __builtin_arm_textrmuh (v4hi, int)
11340 int __builtin_arm_textrmuw (v2si, int)
11341 v8qi __builtin_arm_tinsrb (v8qi, int, int)
11342 v4hi __builtin_arm_tinsrh (v4hi, int, int)
11343 v2si __builtin_arm_tinsrw (v2si, int, int)
11344 long long __builtin_arm_tmia (long long, int, int)
11345 long long __builtin_arm_tmiabb (long long, int, int)
11346 long long __builtin_arm_tmiabt (long long, int, int)
11347 long long __builtin_arm_tmiaph (long long, int, int)
11348 long long __builtin_arm_tmiatb (long long, int, int)
11349 long long __builtin_arm_tmiatt (long long, int, int)
11350 int __builtin_arm_tmovmskb (v8qi)
11351 int __builtin_arm_tmovmskh (v4hi)
11352 int __builtin_arm_tmovmskw (v2si)
11353 long long __builtin_arm_waccb (v8qi)
11354 long long __builtin_arm_wacch (v4hi)
11355 long long __builtin_arm_waccw (v2si)
11356 v8qi __builtin_arm_waddb (v8qi, v8qi)
11357 v8qi __builtin_arm_waddbss (v8qi, v8qi)
11358 v8qi __builtin_arm_waddbus (v8qi, v8qi)
11359 v4hi __builtin_arm_waddh (v4hi, v4hi)
11360 v4hi __builtin_arm_waddhss (v4hi, v4hi)
11361 v4hi __builtin_arm_waddhus (v4hi, v4hi)
11362 v2si __builtin_arm_waddw (v2si, v2si)
11363 v2si __builtin_arm_waddwss (v2si, v2si)
11364 v2si __builtin_arm_waddwus (v2si, v2si)
11365 v8qi __builtin_arm_walign (v8qi, v8qi, int)
11366 long long __builtin_arm_wand(long long, long long)
11367 long long __builtin_arm_wandn (long long, long long)
11368 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
11369 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
11370 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
11371 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
11372 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
11373 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
11374 v2si __builtin_arm_wcmpeqw (v2si, v2si)
11375 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
11376 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
11377 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
11378 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
11379 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
11380 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
11381 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
11382 long long __builtin_arm_wmacsz (v4hi, v4hi)
11383 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
11384 long long __builtin_arm_wmacuz (v4hi, v4hi)
11385 v4hi __builtin_arm_wmadds (v4hi, v4hi)
11386 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
11387 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
11388 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
11389 v2si __builtin_arm_wmaxsw (v2si, v2si)
11390 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
11391 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
11392 v2si __builtin_arm_wmaxuw (v2si, v2si)
11393 v8qi __builtin_arm_wminsb (v8qi, v8qi)
11394 v4hi __builtin_arm_wminsh (v4hi, v4hi)
11395 v2si __builtin_arm_wminsw (v2si, v2si)
11396 v8qi __builtin_arm_wminub (v8qi, v8qi)
11397 v4hi __builtin_arm_wminuh (v4hi, v4hi)
11398 v2si __builtin_arm_wminuw (v2si, v2si)
11399 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
11400 v4hi __builtin_arm_wmulul (v4hi, v4hi)
11401 v4hi __builtin_arm_wmulum (v4hi, v4hi)
11402 long long __builtin_arm_wor (long long, long long)
11403 v2si __builtin_arm_wpackdss (long long, long long)
11404 v2si __builtin_arm_wpackdus (long long, long long)
11405 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
11406 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
11407 v4hi __builtin_arm_wpackwss (v2si, v2si)
11408 v4hi __builtin_arm_wpackwus (v2si, v2si)
11409 long long __builtin_arm_wrord (long long, long long)
11410 long long __builtin_arm_wrordi (long long, int)
11411 v4hi __builtin_arm_wrorh (v4hi, long long)
11412 v4hi __builtin_arm_wrorhi (v4hi, int)
11413 v2si __builtin_arm_wrorw (v2si, long long)
11414 v2si __builtin_arm_wrorwi (v2si, int)
11415 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
11416 v2si __builtin_arm_wsadbz (v8qi, v8qi)
11417 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
11418 v2si __builtin_arm_wsadhz (v4hi, v4hi)
11419 v4hi __builtin_arm_wshufh (v4hi, int)
11420 long long __builtin_arm_wslld (long long, long long)
11421 long long __builtin_arm_wslldi (long long, int)
11422 v4hi __builtin_arm_wsllh (v4hi, long long)
11423 v4hi __builtin_arm_wsllhi (v4hi, int)
11424 v2si __builtin_arm_wsllw (v2si, long long)
11425 v2si __builtin_arm_wsllwi (v2si, int)
11426 long long __builtin_arm_wsrad (long long, long long)
11427 long long __builtin_arm_wsradi (long long, int)
11428 v4hi __builtin_arm_wsrah (v4hi, long long)
11429 v4hi __builtin_arm_wsrahi (v4hi, int)
11430 v2si __builtin_arm_wsraw (v2si, long long)
11431 v2si __builtin_arm_wsrawi (v2si, int)
11432 long long __builtin_arm_wsrld (long long, long long)
11433 long long __builtin_arm_wsrldi (long long, int)
11434 v4hi __builtin_arm_wsrlh (v4hi, long long)
11435 v4hi __builtin_arm_wsrlhi (v4hi, int)
11436 v2si __builtin_arm_wsrlw (v2si, long long)
11437 v2si __builtin_arm_wsrlwi (v2si, int)
11438 v8qi __builtin_arm_wsubb (v8qi, v8qi)
11439 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
11440 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
11441 v4hi __builtin_arm_wsubh (v4hi, v4hi)
11442 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
11443 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
11444 v2si __builtin_arm_wsubw (v2si, v2si)
11445 v2si __builtin_arm_wsubwss (v2si, v2si)
11446 v2si __builtin_arm_wsubwus (v2si, v2si)
11447 v4hi __builtin_arm_wunpckehsb (v8qi)
11448 v2si __builtin_arm_wunpckehsh (v4hi)
11449 long long __builtin_arm_wunpckehsw (v2si)
11450 v4hi __builtin_arm_wunpckehub (v8qi)
11451 v2si __builtin_arm_wunpckehuh (v4hi)
11452 long long __builtin_arm_wunpckehuw (v2si)
11453 v4hi __builtin_arm_wunpckelsb (v8qi)
11454 v2si __builtin_arm_wunpckelsh (v4hi)
11455 long long __builtin_arm_wunpckelsw (v2si)
11456 v4hi __builtin_arm_wunpckelub (v8qi)
11457 v2si __builtin_arm_wunpckeluh (v4hi)
11458 long long __builtin_arm_wunpckeluw (v2si)
11459 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
11460 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
11461 v2si __builtin_arm_wunpckihw (v2si, v2si)
11462 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
11463 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
11464 v2si __builtin_arm_wunpckilw (v2si, v2si)
11465 long long __builtin_arm_wxor (long long, long long)
11466 long long __builtin_arm_wzero ()
11467 @end smallexample
11470 @node ARM C Language Extensions (ACLE)
11471 @subsection ARM C Language Extensions (ACLE)
11473 GCC implements extensions for C as described in the ARM C Language
11474 Extensions (ACLE) specification, which can be found at
11475 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
11477 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
11478 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
11479 intrinsics can be found at
11480 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
11481 The built-in intrinsics for the Advanced SIMD extension are available when
11482 NEON is enabled.
11484 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
11485 back ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM back end's
11486 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
11487 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
11488 intrinsics yet.
11490 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
11491 availability of extensions.
11493 @node ARM Floating Point Status and Control Intrinsics
11494 @subsection ARM Floating Point Status and Control Intrinsics
11496 These built-in functions are available for the ARM family of
11497 processors with floating-point unit.
11499 @smallexample
11500 unsigned int __builtin_arm_get_fpscr ()
11501 void __builtin_arm_set_fpscr (unsigned int)
11502 @end smallexample
11504 @node AVR Built-in Functions
11505 @subsection AVR Built-in Functions
11507 For each built-in function for AVR, there is an equally named,
11508 uppercase built-in macro defined. That way users can easily query if
11509 or if not a specific built-in is implemented or not. For example, if
11510 @code{__builtin_avr_nop} is available the macro
11511 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
11513 The following built-in functions map to the respective machine
11514 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
11515 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
11516 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
11517 as library call if no hardware multiplier is available.
11519 @smallexample
11520 void __builtin_avr_nop (void)
11521 void __builtin_avr_sei (void)
11522 void __builtin_avr_cli (void)
11523 void __builtin_avr_sleep (void)
11524 void __builtin_avr_wdr (void)
11525 unsigned char __builtin_avr_swap (unsigned char)
11526 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
11527 int __builtin_avr_fmuls (char, char)
11528 int __builtin_avr_fmulsu (char, unsigned char)
11529 @end smallexample
11531 In order to delay execution for a specific number of cycles, GCC
11532 implements
11533 @smallexample
11534 void __builtin_avr_delay_cycles (unsigned long ticks)
11535 @end smallexample
11537 @noindent
11538 @code{ticks} is the number of ticks to delay execution. Note that this
11539 built-in does not take into account the effect of interrupts that
11540 might increase delay time. @code{ticks} must be a compile-time
11541 integer constant; delays with a variable number of cycles are not supported.
11543 @smallexample
11544 char __builtin_avr_flash_segment (const __memx void*)
11545 @end smallexample
11547 @noindent
11548 This built-in takes a byte address to the 24-bit
11549 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
11550 the number of the flash segment (the 64 KiB chunk) where the address
11551 points to.  Counting starts at @code{0}.
11552 If the address does not point to flash memory, return @code{-1}.
11554 @smallexample
11555 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
11556 @end smallexample
11558 @noindent
11559 Insert bits from @var{bits} into @var{val} and return the resulting
11560 value. The nibbles of @var{map} determine how the insertion is
11561 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
11562 @enumerate
11563 @item If @var{X} is @code{0xf},
11564 then the @var{n}-th bit of @var{val} is returned unaltered.
11566 @item If X is in the range 0@dots{}7,
11567 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
11569 @item If X is in the range 8@dots{}@code{0xe},
11570 then the @var{n}-th result bit is undefined.
11571 @end enumerate
11573 @noindent
11574 One typical use case for this built-in is adjusting input and
11575 output values to non-contiguous port layouts. Some examples:
11577 @smallexample
11578 // same as val, bits is unused
11579 __builtin_avr_insert_bits (0xffffffff, bits, val)
11580 @end smallexample
11582 @smallexample
11583 // same as bits, val is unused
11584 __builtin_avr_insert_bits (0x76543210, bits, val)
11585 @end smallexample
11587 @smallexample
11588 // same as rotating bits by 4
11589 __builtin_avr_insert_bits (0x32107654, bits, 0)
11590 @end smallexample
11592 @smallexample
11593 // high nibble of result is the high nibble of val
11594 // low nibble of result is the low nibble of bits
11595 __builtin_avr_insert_bits (0xffff3210, bits, val)
11596 @end smallexample
11598 @smallexample
11599 // reverse the bit order of bits
11600 __builtin_avr_insert_bits (0x01234567, bits, 0)
11601 @end smallexample
11603 @node Blackfin Built-in Functions
11604 @subsection Blackfin Built-in Functions
11606 Currently, there are two Blackfin-specific built-in functions.  These are
11607 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
11608 using inline assembly; by using these built-in functions the compiler can
11609 automatically add workarounds for hardware errata involving these
11610 instructions.  These functions are named as follows:
11612 @smallexample
11613 void __builtin_bfin_csync (void)
11614 void __builtin_bfin_ssync (void)
11615 @end smallexample
11617 @node FR-V Built-in Functions
11618 @subsection FR-V Built-in Functions
11620 GCC provides many FR-V-specific built-in functions.  In general,
11621 these functions are intended to be compatible with those described
11622 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11623 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
11624 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11625 pointer rather than by value.
11627 Most of the functions are named after specific FR-V instructions.
11628 Such functions are said to be ``directly mapped'' and are summarized
11629 here in tabular form.
11631 @menu
11632 * Argument Types::
11633 * Directly-mapped Integer Functions::
11634 * Directly-mapped Media Functions::
11635 * Raw read/write Functions::
11636 * Other Built-in Functions::
11637 @end menu
11639 @node Argument Types
11640 @subsubsection Argument Types
11642 The arguments to the built-in functions can be divided into three groups:
11643 register numbers, compile-time constants and run-time values.  In order
11644 to make this classification clear at a glance, the arguments and return
11645 values are given the following pseudo types:
11647 @multitable @columnfractions .20 .30 .15 .35
11648 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11649 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11650 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11651 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11652 @item @code{uw2} @tab @code{unsigned long long} @tab No
11653 @tab an unsigned doubleword
11654 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11655 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11656 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11657 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11658 @end multitable
11660 These pseudo types are not defined by GCC, they are simply a notational
11661 convenience used in this manual.
11663 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11664 and @code{sw2} are evaluated at run time.  They correspond to
11665 register operands in the underlying FR-V instructions.
11667 @code{const} arguments represent immediate operands in the underlying
11668 FR-V instructions.  They must be compile-time constants.
11670 @code{acc} arguments are evaluated at compile time and specify the number
11671 of an accumulator register.  For example, an @code{acc} argument of 2
11672 selects the ACC2 register.
11674 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11675 number of an IACC register.  See @pxref{Other Built-in Functions}
11676 for more details.
11678 @node Directly-mapped Integer Functions
11679 @subsubsection Directly-Mapped Integer Functions
11681 The functions listed below map directly to FR-V I-type instructions.
11683 @multitable @columnfractions .45 .32 .23
11684 @item Function prototype @tab Example usage @tab Assembly output
11685 @item @code{sw1 __ADDSS (sw1, sw1)}
11686 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11687 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11688 @item @code{sw1 __SCAN (sw1, sw1)}
11689 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11690 @tab @code{SCAN @var{a},@var{b},@var{c}}
11691 @item @code{sw1 __SCUTSS (sw1)}
11692 @tab @code{@var{b} = __SCUTSS (@var{a})}
11693 @tab @code{SCUTSS @var{a},@var{b}}
11694 @item @code{sw1 __SLASS (sw1, sw1)}
11695 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11696 @tab @code{SLASS @var{a},@var{b},@var{c}}
11697 @item @code{void __SMASS (sw1, sw1)}
11698 @tab @code{__SMASS (@var{a}, @var{b})}
11699 @tab @code{SMASS @var{a},@var{b}}
11700 @item @code{void __SMSSS (sw1, sw1)}
11701 @tab @code{__SMSSS (@var{a}, @var{b})}
11702 @tab @code{SMSSS @var{a},@var{b}}
11703 @item @code{void __SMU (sw1, sw1)}
11704 @tab @code{__SMU (@var{a}, @var{b})}
11705 @tab @code{SMU @var{a},@var{b}}
11706 @item @code{sw2 __SMUL (sw1, sw1)}
11707 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11708 @tab @code{SMUL @var{a},@var{b},@var{c}}
11709 @item @code{sw1 __SUBSS (sw1, sw1)}
11710 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11711 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11712 @item @code{uw2 __UMUL (uw1, uw1)}
11713 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11714 @tab @code{UMUL @var{a},@var{b},@var{c}}
11715 @end multitable
11717 @node Directly-mapped Media Functions
11718 @subsubsection Directly-Mapped Media Functions
11720 The functions listed below map directly to FR-V M-type instructions.
11722 @multitable @columnfractions .45 .32 .23
11723 @item Function prototype @tab Example usage @tab Assembly output
11724 @item @code{uw1 __MABSHS (sw1)}
11725 @tab @code{@var{b} = __MABSHS (@var{a})}
11726 @tab @code{MABSHS @var{a},@var{b}}
11727 @item @code{void __MADDACCS (acc, acc)}
11728 @tab @code{__MADDACCS (@var{b}, @var{a})}
11729 @tab @code{MADDACCS @var{a},@var{b}}
11730 @item @code{sw1 __MADDHSS (sw1, sw1)}
11731 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11732 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11733 @item @code{uw1 __MADDHUS (uw1, uw1)}
11734 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11735 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11736 @item @code{uw1 __MAND (uw1, uw1)}
11737 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11738 @tab @code{MAND @var{a},@var{b},@var{c}}
11739 @item @code{void __MASACCS (acc, acc)}
11740 @tab @code{__MASACCS (@var{b}, @var{a})}
11741 @tab @code{MASACCS @var{a},@var{b}}
11742 @item @code{uw1 __MAVEH (uw1, uw1)}
11743 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11744 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11745 @item @code{uw2 __MBTOH (uw1)}
11746 @tab @code{@var{b} = __MBTOH (@var{a})}
11747 @tab @code{MBTOH @var{a},@var{b}}
11748 @item @code{void __MBTOHE (uw1 *, uw1)}
11749 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11750 @tab @code{MBTOHE @var{a},@var{b}}
11751 @item @code{void __MCLRACC (acc)}
11752 @tab @code{__MCLRACC (@var{a})}
11753 @tab @code{MCLRACC @var{a}}
11754 @item @code{void __MCLRACCA (void)}
11755 @tab @code{__MCLRACCA ()}
11756 @tab @code{MCLRACCA}
11757 @item @code{uw1 __Mcop1 (uw1, uw1)}
11758 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11759 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11760 @item @code{uw1 __Mcop2 (uw1, uw1)}
11761 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11762 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11763 @item @code{uw1 __MCPLHI (uw2, const)}
11764 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11765 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11766 @item @code{uw1 __MCPLI (uw2, const)}
11767 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11768 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11769 @item @code{void __MCPXIS (acc, sw1, sw1)}
11770 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11771 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11772 @item @code{void __MCPXIU (acc, uw1, uw1)}
11773 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11774 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11775 @item @code{void __MCPXRS (acc, sw1, sw1)}
11776 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11777 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11778 @item @code{void __MCPXRU (acc, uw1, uw1)}
11779 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11780 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11781 @item @code{uw1 __MCUT (acc, uw1)}
11782 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11783 @tab @code{MCUT @var{a},@var{b},@var{c}}
11784 @item @code{uw1 __MCUTSS (acc, sw1)}
11785 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11786 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11787 @item @code{void __MDADDACCS (acc, acc)}
11788 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11789 @tab @code{MDADDACCS @var{a},@var{b}}
11790 @item @code{void __MDASACCS (acc, acc)}
11791 @tab @code{__MDASACCS (@var{b}, @var{a})}
11792 @tab @code{MDASACCS @var{a},@var{b}}
11793 @item @code{uw2 __MDCUTSSI (acc, const)}
11794 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11795 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11796 @item @code{uw2 __MDPACKH (uw2, uw2)}
11797 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11798 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11799 @item @code{uw2 __MDROTLI (uw2, const)}
11800 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11801 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11802 @item @code{void __MDSUBACCS (acc, acc)}
11803 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11804 @tab @code{MDSUBACCS @var{a},@var{b}}
11805 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11806 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11807 @tab @code{MDUNPACKH @var{a},@var{b}}
11808 @item @code{uw2 __MEXPDHD (uw1, const)}
11809 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11810 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11811 @item @code{uw1 __MEXPDHW (uw1, const)}
11812 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11813 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11814 @item @code{uw1 __MHDSETH (uw1, const)}
11815 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11816 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11817 @item @code{sw1 __MHDSETS (const)}
11818 @tab @code{@var{b} = __MHDSETS (@var{a})}
11819 @tab @code{MHDSETS #@var{a},@var{b}}
11820 @item @code{uw1 __MHSETHIH (uw1, const)}
11821 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11822 @tab @code{MHSETHIH #@var{a},@var{b}}
11823 @item @code{sw1 __MHSETHIS (sw1, const)}
11824 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11825 @tab @code{MHSETHIS #@var{a},@var{b}}
11826 @item @code{uw1 __MHSETLOH (uw1, const)}
11827 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11828 @tab @code{MHSETLOH #@var{a},@var{b}}
11829 @item @code{sw1 __MHSETLOS (sw1, const)}
11830 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11831 @tab @code{MHSETLOS #@var{a},@var{b}}
11832 @item @code{uw1 __MHTOB (uw2)}
11833 @tab @code{@var{b} = __MHTOB (@var{a})}
11834 @tab @code{MHTOB @var{a},@var{b}}
11835 @item @code{void __MMACHS (acc, sw1, sw1)}
11836 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11837 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11838 @item @code{void __MMACHU (acc, uw1, uw1)}
11839 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11840 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11841 @item @code{void __MMRDHS (acc, sw1, sw1)}
11842 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11843 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11844 @item @code{void __MMRDHU (acc, uw1, uw1)}
11845 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11846 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11847 @item @code{void __MMULHS (acc, sw1, sw1)}
11848 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11849 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11850 @item @code{void __MMULHU (acc, uw1, uw1)}
11851 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11852 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11853 @item @code{void __MMULXHS (acc, sw1, sw1)}
11854 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11855 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11856 @item @code{void __MMULXHU (acc, uw1, uw1)}
11857 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11858 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11859 @item @code{uw1 __MNOT (uw1)}
11860 @tab @code{@var{b} = __MNOT (@var{a})}
11861 @tab @code{MNOT @var{a},@var{b}}
11862 @item @code{uw1 __MOR (uw1, uw1)}
11863 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11864 @tab @code{MOR @var{a},@var{b},@var{c}}
11865 @item @code{uw1 __MPACKH (uh, uh)}
11866 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11867 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11868 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11869 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11870 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11871 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11872 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11873 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11874 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11875 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11876 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11877 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11878 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11879 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11880 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11881 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11882 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11883 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11884 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11885 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11886 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11887 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11888 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11889 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11890 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11891 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11892 @item @code{void __MQMACHS (acc, sw2, sw2)}
11893 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11894 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11895 @item @code{void __MQMACHU (acc, uw2, uw2)}
11896 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11897 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11898 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11899 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11900 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11901 @item @code{void __MQMULHS (acc, sw2, sw2)}
11902 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11903 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11904 @item @code{void __MQMULHU (acc, uw2, uw2)}
11905 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11906 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11907 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11908 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11909 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11910 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11911 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11912 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11913 @item @code{sw2 __MQSATHS (sw2, sw2)}
11914 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11915 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11916 @item @code{uw2 __MQSLLHI (uw2, int)}
11917 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11918 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11919 @item @code{sw2 __MQSRAHI (sw2, int)}
11920 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11921 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11922 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11923 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11924 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11925 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11926 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11927 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11928 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11929 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11930 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11931 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11932 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11933 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11934 @item @code{uw1 __MRDACC (acc)}
11935 @tab @code{@var{b} = __MRDACC (@var{a})}
11936 @tab @code{MRDACC @var{a},@var{b}}
11937 @item @code{uw1 __MRDACCG (acc)}
11938 @tab @code{@var{b} = __MRDACCG (@var{a})}
11939 @tab @code{MRDACCG @var{a},@var{b}}
11940 @item @code{uw1 __MROTLI (uw1, const)}
11941 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11942 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11943 @item @code{uw1 __MROTRI (uw1, const)}
11944 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11945 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11946 @item @code{sw1 __MSATHS (sw1, sw1)}
11947 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11948 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11949 @item @code{uw1 __MSATHU (uw1, uw1)}
11950 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11951 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11952 @item @code{uw1 __MSLLHI (uw1, const)}
11953 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11954 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11955 @item @code{sw1 __MSRAHI (sw1, const)}
11956 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11957 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11958 @item @code{uw1 __MSRLHI (uw1, const)}
11959 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11960 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11961 @item @code{void __MSUBACCS (acc, acc)}
11962 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11963 @tab @code{MSUBACCS @var{a},@var{b}}
11964 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11965 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11966 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11967 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11968 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11969 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11970 @item @code{void __MTRAP (void)}
11971 @tab @code{__MTRAP ()}
11972 @tab @code{MTRAP}
11973 @item @code{uw2 __MUNPACKH (uw1)}
11974 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11975 @tab @code{MUNPACKH @var{a},@var{b}}
11976 @item @code{uw1 __MWCUT (uw2, uw1)}
11977 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11978 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11979 @item @code{void __MWTACC (acc, uw1)}
11980 @tab @code{__MWTACC (@var{b}, @var{a})}
11981 @tab @code{MWTACC @var{a},@var{b}}
11982 @item @code{void __MWTACCG (acc, uw1)}
11983 @tab @code{__MWTACCG (@var{b}, @var{a})}
11984 @tab @code{MWTACCG @var{a},@var{b}}
11985 @item @code{uw1 __MXOR (uw1, uw1)}
11986 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11987 @tab @code{MXOR @var{a},@var{b},@var{c}}
11988 @end multitable
11990 @node Raw read/write Functions
11991 @subsubsection Raw Read/Write Functions
11993 This sections describes built-in functions related to read and write
11994 instructions to access memory.  These functions generate
11995 @code{membar} instructions to flush the I/O load and stores where
11996 appropriate, as described in Fujitsu's manual described above.
11998 @table @code
12000 @item unsigned char __builtin_read8 (void *@var{data})
12001 @item unsigned short __builtin_read16 (void *@var{data})
12002 @item unsigned long __builtin_read32 (void *@var{data})
12003 @item unsigned long long __builtin_read64 (void *@var{data})
12005 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12006 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12007 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12008 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12009 @end table
12011 @node Other Built-in Functions
12012 @subsubsection Other Built-in Functions
12014 This section describes built-in functions that are not named after
12015 a specific FR-V instruction.
12017 @table @code
12018 @item sw2 __IACCreadll (iacc @var{reg})
12019 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
12020 for future expansion and must be 0.
12022 @item sw1 __IACCreadl (iacc @var{reg})
12023 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12024 Other values of @var{reg} are rejected as invalid.
12026 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12027 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
12028 is reserved for future expansion and must be 0.
12030 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12031 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12032 is 1.  Other values of @var{reg} are rejected as invalid.
12034 @item void __data_prefetch0 (const void *@var{x})
12035 Use the @code{dcpl} instruction to load the contents of address @var{x}
12036 into the data cache.
12038 @item void __data_prefetch (const void *@var{x})
12039 Use the @code{nldub} instruction to load the contents of address @var{x}
12040 into the data cache.  The instruction is issued in slot I1@.
12041 @end table
12043 @node MIPS DSP Built-in Functions
12044 @subsection MIPS DSP Built-in Functions
12046 The MIPS DSP Application-Specific Extension (ASE) includes new
12047 instructions that are designed to improve the performance of DSP and
12048 media applications.  It provides instructions that operate on packed
12049 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12051 GCC supports MIPS DSP operations using both the generic
12052 vector extensions (@pxref{Vector Extensions}) and a collection of
12053 MIPS-specific built-in functions.  Both kinds of support are
12054 enabled by the @option{-mdsp} command-line option.
12056 Revision 2 of the ASE was introduced in the second half of 2006.
12057 This revision adds extra instructions to the original ASE, but is
12058 otherwise backwards-compatible with it.  You can select revision 2
12059 using the command-line option @option{-mdspr2}; this option implies
12060 @option{-mdsp}.
12062 The SCOUNT and POS bits of the DSP control register are global.  The
12063 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12064 POS bits.  During optimization, the compiler does not delete these
12065 instructions and it does not delete calls to functions containing
12066 these instructions.
12068 At present, GCC only provides support for operations on 32-bit
12069 vectors.  The vector type associated with 8-bit integer data is
12070 usually called @code{v4i8}, the vector type associated with Q7
12071 is usually called @code{v4q7}, the vector type associated with 16-bit
12072 integer data is usually called @code{v2i16}, and the vector type
12073 associated with Q15 is usually called @code{v2q15}.  They can be
12074 defined in C as follows:
12076 @smallexample
12077 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12078 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12079 typedef short v2i16 __attribute__ ((vector_size(4)));
12080 typedef short v2q15 __attribute__ ((vector_size(4)));
12081 @end smallexample
12083 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12084 initialized in the same way as aggregates.  For example:
12086 @smallexample
12087 v4i8 a = @{1, 2, 3, 4@};
12088 v4i8 b;
12089 b = (v4i8) @{5, 6, 7, 8@};
12091 v2q15 c = @{0x0fcb, 0x3a75@};
12092 v2q15 d;
12093 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12094 @end smallexample
12096 @emph{Note:} The CPU's endianness determines the order in which values
12097 are packed.  On little-endian targets, the first value is the least
12098 significant and the last value is the most significant.  The opposite
12099 order applies to big-endian targets.  For example, the code above
12100 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12101 and @code{4} on big-endian targets.
12103 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12104 representation.  As shown in this example, the integer representation
12105 of a Q7 value can be obtained by multiplying the fractional value by
12106 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
12107 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
12108 @code{0x1.0p31}.
12110 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12111 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
12112 and @code{c} and @code{d} are @code{v2q15} values.
12114 @multitable @columnfractions .50 .50
12115 @item C code @tab MIPS instruction
12116 @item @code{a + b} @tab @code{addu.qb}
12117 @item @code{c + d} @tab @code{addq.ph}
12118 @item @code{a - b} @tab @code{subu.qb}
12119 @item @code{c - d} @tab @code{subq.ph}
12120 @end multitable
12122 The table below lists the @code{v2i16} operation for which
12123 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
12124 @code{v2i16} values.
12126 @multitable @columnfractions .50 .50
12127 @item C code @tab MIPS instruction
12128 @item @code{e * f} @tab @code{mul.ph}
12129 @end multitable
12131 It is easier to describe the DSP built-in functions if we first define
12132 the following types:
12134 @smallexample
12135 typedef int q31;
12136 typedef int i32;
12137 typedef unsigned int ui32;
12138 typedef long long a64;
12139 @end smallexample
12141 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12142 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12143 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
12144 @code{long long}, but we use @code{a64} to indicate values that are
12145 placed in one of the four DSP accumulators (@code{$ac0},
12146 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12148 Also, some built-in functions prefer or require immediate numbers as
12149 parameters, because the corresponding DSP instructions accept both immediate
12150 numbers and register operands, or accept immediate numbers only.  The
12151 immediate parameters are listed as follows.
12153 @smallexample
12154 imm0_3: 0 to 3.
12155 imm0_7: 0 to 7.
12156 imm0_15: 0 to 15.
12157 imm0_31: 0 to 31.
12158 imm0_63: 0 to 63.
12159 imm0_255: 0 to 255.
12160 imm_n32_31: -32 to 31.
12161 imm_n512_511: -512 to 511.
12162 @end smallexample
12164 The following built-in functions map directly to a particular MIPS DSP
12165 instruction.  Please refer to the architecture specification
12166 for details on what each instruction does.
12168 @smallexample
12169 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12170 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12171 q31 __builtin_mips_addq_s_w (q31, q31)
12172 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12173 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12174 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12175 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12176 q31 __builtin_mips_subq_s_w (q31, q31)
12177 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12178 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12179 i32 __builtin_mips_addsc (i32, i32)
12180 i32 __builtin_mips_addwc (i32, i32)
12181 i32 __builtin_mips_modsub (i32, i32)
12182 i32 __builtin_mips_raddu_w_qb (v4i8)
12183 v2q15 __builtin_mips_absq_s_ph (v2q15)
12184 q31 __builtin_mips_absq_s_w (q31)
12185 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12186 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12187 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12188 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12189 q31 __builtin_mips_preceq_w_phl (v2q15)
12190 q31 __builtin_mips_preceq_w_phr (v2q15)
12191 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12192 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12193 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12194 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12195 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12196 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12197 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12198 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12199 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12200 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12201 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12202 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12203 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12204 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12205 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12206 q31 __builtin_mips_shll_s_w (q31, i32)
12207 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12208 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12209 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12210 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12211 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12212 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12213 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12214 q31 __builtin_mips_shra_r_w (q31, i32)
12215 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12216 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12217 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12218 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12219 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12220 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12221 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12222 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12223 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12224 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12225 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12226 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12227 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12228 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12229 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12230 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12231 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12232 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12233 i32 __builtin_mips_bitrev (i32)
12234 i32 __builtin_mips_insv (i32, i32)
12235 v4i8 __builtin_mips_repl_qb (imm0_255)
12236 v4i8 __builtin_mips_repl_qb (i32)
12237 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12238 v2q15 __builtin_mips_repl_ph (i32)
12239 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12240 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12241 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12242 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12243 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12244 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12245 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12246 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12247 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12248 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12249 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12250 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12251 i32 __builtin_mips_extr_w (a64, imm0_31)
12252 i32 __builtin_mips_extr_w (a64, i32)
12253 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12254 i32 __builtin_mips_extr_s_h (a64, i32)
12255 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12256 i32 __builtin_mips_extr_rs_w (a64, i32)
12257 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12258 i32 __builtin_mips_extr_r_w (a64, i32)
12259 i32 __builtin_mips_extp (a64, imm0_31)
12260 i32 __builtin_mips_extp (a64, i32)
12261 i32 __builtin_mips_extpdp (a64, imm0_31)
12262 i32 __builtin_mips_extpdp (a64, i32)
12263 a64 __builtin_mips_shilo (a64, imm_n32_31)
12264 a64 __builtin_mips_shilo (a64, i32)
12265 a64 __builtin_mips_mthlip (a64, i32)
12266 void __builtin_mips_wrdsp (i32, imm0_63)
12267 i32 __builtin_mips_rddsp (imm0_63)
12268 i32 __builtin_mips_lbux (void *, i32)
12269 i32 __builtin_mips_lhx (void *, i32)
12270 i32 __builtin_mips_lwx (void *, i32)
12271 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12272 i32 __builtin_mips_bposge32 (void)
12273 a64 __builtin_mips_madd (a64, i32, i32);
12274 a64 __builtin_mips_maddu (a64, ui32, ui32);
12275 a64 __builtin_mips_msub (a64, i32, i32);
12276 a64 __builtin_mips_msubu (a64, ui32, ui32);
12277 a64 __builtin_mips_mult (i32, i32);
12278 a64 __builtin_mips_multu (ui32, ui32);
12279 @end smallexample
12281 The following built-in functions map directly to a particular MIPS DSP REV 2
12282 instruction.  Please refer to the architecture specification
12283 for details on what each instruction does.
12285 @smallexample
12286 v4q7 __builtin_mips_absq_s_qb (v4q7);
12287 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12288 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12289 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12290 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12291 i32 __builtin_mips_append (i32, i32, imm0_31);
12292 i32 __builtin_mips_balign (i32, i32, imm0_3);
12293 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12294 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12295 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12296 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12297 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12298 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12299 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12300 q31 __builtin_mips_mulq_rs_w (q31, q31);
12301 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12302 q31 __builtin_mips_mulq_s_w (q31, q31);
12303 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12304 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12305 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12306 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12307 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12308 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12309 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12310 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12311 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12312 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12313 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12314 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12315 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12316 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12317 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12318 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12319 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12320 q31 __builtin_mips_addqh_w (q31, q31);
12321 q31 __builtin_mips_addqh_r_w (q31, q31);
12322 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12323 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12324 q31 __builtin_mips_subqh_w (q31, q31);
12325 q31 __builtin_mips_subqh_r_w (q31, q31);
12326 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12327 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12328 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12329 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12330 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12331 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12332 @end smallexample
12335 @node MIPS Paired-Single Support
12336 @subsection MIPS Paired-Single Support
12338 The MIPS64 architecture includes a number of instructions that
12339 operate on pairs of single-precision floating-point values.
12340 Each pair is packed into a 64-bit floating-point register,
12341 with one element being designated the ``upper half'' and
12342 the other being designated the ``lower half''.
12344 GCC supports paired-single operations using both the generic
12345 vector extensions (@pxref{Vector Extensions}) and a collection of
12346 MIPS-specific built-in functions.  Both kinds of support are
12347 enabled by the @option{-mpaired-single} command-line option.
12349 The vector type associated with paired-single values is usually
12350 called @code{v2sf}.  It can be defined in C as follows:
12352 @smallexample
12353 typedef float v2sf __attribute__ ((vector_size (8)));
12354 @end smallexample
12356 @code{v2sf} values are initialized in the same way as aggregates.
12357 For example:
12359 @smallexample
12360 v2sf a = @{1.5, 9.1@};
12361 v2sf b;
12362 float e, f;
12363 b = (v2sf) @{e, f@};
12364 @end smallexample
12366 @emph{Note:} The CPU's endianness determines which value is stored in
12367 the upper half of a register and which value is stored in the lower half.
12368 On little-endian targets, the first value is the lower one and the second
12369 value is the upper one.  The opposite order applies to big-endian targets.
12370 For example, the code above sets the lower half of @code{a} to
12371 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12373 @node MIPS Loongson Built-in Functions
12374 @subsection MIPS Loongson Built-in Functions
12376 GCC provides intrinsics to access the SIMD instructions provided by the
12377 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
12378 available after inclusion of the @code{loongson.h} header file,
12379 operate on the following 64-bit vector types:
12381 @itemize
12382 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12383 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12384 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12385 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12386 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12387 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12388 @end itemize
12390 The intrinsics provided are listed below; each is named after the
12391 machine instruction to which it corresponds, with suffixes added as
12392 appropriate to distinguish intrinsics that expand to the same machine
12393 instruction yet have different argument types.  Refer to the architecture
12394 documentation for a description of the functionality of each
12395 instruction.
12397 @smallexample
12398 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12399 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12400 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12401 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12402 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12403 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12404 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12405 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12406 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12407 uint64_t paddd_u (uint64_t s, uint64_t t);
12408 int64_t paddd_s (int64_t s, int64_t t);
12409 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12410 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12411 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12412 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12413 uint64_t pandn_ud (uint64_t s, uint64_t t);
12414 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12415 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12416 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12417 int64_t pandn_sd (int64_t s, int64_t t);
12418 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12419 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12420 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12421 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12422 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12423 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12424 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12425 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12426 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12427 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12428 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12429 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12430 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12431 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12432 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12433 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12434 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12435 uint16x4_t pextrh_u (uint16x4_t s, int field);
12436 int16x4_t pextrh_s (int16x4_t s, int field);
12437 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12438 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12439 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12440 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12441 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12442 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12443 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12444 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12445 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12446 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12447 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12448 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12449 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12450 uint8x8_t pmovmskb_u (uint8x8_t s);
12451 int8x8_t pmovmskb_s (int8x8_t s);
12452 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12453 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12454 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12455 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12456 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12457 uint16x4_t biadd (uint8x8_t s);
12458 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12459 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12460 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12461 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12462 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12463 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12464 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12465 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12466 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12467 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12468 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12469 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12470 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12471 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12472 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12473 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12474 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12475 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12476 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12477 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12478 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12479 uint64_t psubd_u (uint64_t s, uint64_t t);
12480 int64_t psubd_s (int64_t s, int64_t t);
12481 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12482 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12483 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12484 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12485 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12486 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12487 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12488 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12489 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12490 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12491 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12492 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12493 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12494 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12495 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12496 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12497 @end smallexample
12499 @menu
12500 * Paired-Single Arithmetic::
12501 * Paired-Single Built-in Functions::
12502 * MIPS-3D Built-in Functions::
12503 @end menu
12505 @node Paired-Single Arithmetic
12506 @subsubsection Paired-Single Arithmetic
12508 The table below lists the @code{v2sf} operations for which hardware
12509 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
12510 values and @code{x} is an integral value.
12512 @multitable @columnfractions .50 .50
12513 @item C code @tab MIPS instruction
12514 @item @code{a + b} @tab @code{add.ps}
12515 @item @code{a - b} @tab @code{sub.ps}
12516 @item @code{-a} @tab @code{neg.ps}
12517 @item @code{a * b} @tab @code{mul.ps}
12518 @item @code{a * b + c} @tab @code{madd.ps}
12519 @item @code{a * b - c} @tab @code{msub.ps}
12520 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
12521 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
12522 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
12523 @end multitable
12525 Note that the multiply-accumulate instructions can be disabled
12526 using the command-line option @code{-mno-fused-madd}.
12528 @node Paired-Single Built-in Functions
12529 @subsubsection Paired-Single Built-in Functions
12531 The following paired-single functions map directly to a particular
12532 MIPS instruction.  Please refer to the architecture specification
12533 for details on what each instruction does.
12535 @table @code
12536 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
12537 Pair lower lower (@code{pll.ps}).
12539 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
12540 Pair upper lower (@code{pul.ps}).
12542 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
12543 Pair lower upper (@code{plu.ps}).
12545 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
12546 Pair upper upper (@code{puu.ps}).
12548 @item v2sf __builtin_mips_cvt_ps_s (float, float)
12549 Convert pair to paired single (@code{cvt.ps.s}).
12551 @item float __builtin_mips_cvt_s_pl (v2sf)
12552 Convert pair lower to single (@code{cvt.s.pl}).
12554 @item float __builtin_mips_cvt_s_pu (v2sf)
12555 Convert pair upper to single (@code{cvt.s.pu}).
12557 @item v2sf __builtin_mips_abs_ps (v2sf)
12558 Absolute value (@code{abs.ps}).
12560 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12561 Align variable (@code{alnv.ps}).
12563 @emph{Note:} The value of the third parameter must be 0 or 4
12564 modulo 8, otherwise the result is unpredictable.  Please read the
12565 instruction description for details.
12566 @end table
12568 The following multi-instruction functions are also available.
12569 In each case, @var{cond} can be any of the 16 floating-point conditions:
12570 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12571 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12572 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12574 @table @code
12575 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12576 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12577 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12578 @code{movt.ps}/@code{movf.ps}).
12580 The @code{movt} functions return the value @var{x} computed by:
12582 @smallexample
12583 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12584 mov.ps @var{x},@var{c}
12585 movt.ps @var{x},@var{d},@var{cc}
12586 @end smallexample
12588 The @code{movf} functions are similar but use @code{movf.ps} instead
12589 of @code{movt.ps}.
12591 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12592 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12593 Comparison of two paired-single values (@code{c.@var{cond}.ps},
12594 @code{bc1t}/@code{bc1f}).
12596 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12597 and return either the upper or lower half of the result.  For example:
12599 @smallexample
12600 v2sf a, b;
12601 if (__builtin_mips_upper_c_eq_ps (a, b))
12602   upper_halves_are_equal ();
12603 else
12604   upper_halves_are_unequal ();
12606 if (__builtin_mips_lower_c_eq_ps (a, b))
12607   lower_halves_are_equal ();
12608 else
12609   lower_halves_are_unequal ();
12610 @end smallexample
12611 @end table
12613 @node MIPS-3D Built-in Functions
12614 @subsubsection MIPS-3D Built-in Functions
12616 The MIPS-3D Application-Specific Extension (ASE) includes additional
12617 paired-single instructions that are designed to improve the performance
12618 of 3D graphics operations.  Support for these instructions is controlled
12619 by the @option{-mips3d} command-line option.
12621 The functions listed below map directly to a particular MIPS-3D
12622 instruction.  Please refer to the architecture specification for
12623 more details on what each instruction does.
12625 @table @code
12626 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
12627 Reduction add (@code{addr.ps}).
12629 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
12630 Reduction multiply (@code{mulr.ps}).
12632 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
12633 Convert paired single to paired word (@code{cvt.pw.ps}).
12635 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
12636 Convert paired word to paired single (@code{cvt.ps.pw}).
12638 @item float __builtin_mips_recip1_s (float)
12639 @itemx double __builtin_mips_recip1_d (double)
12640 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
12641 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
12643 @item float __builtin_mips_recip2_s (float, float)
12644 @itemx double __builtin_mips_recip2_d (double, double)
12645 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
12646 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
12648 @item float __builtin_mips_rsqrt1_s (float)
12649 @itemx double __builtin_mips_rsqrt1_d (double)
12650 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
12651 Reduced-precision reciprocal square root (sequence step 1)
12652 (@code{rsqrt1.@var{fmt}}).
12654 @item float __builtin_mips_rsqrt2_s (float, float)
12655 @itemx double __builtin_mips_rsqrt2_d (double, double)
12656 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
12657 Reduced-precision reciprocal square root (sequence step 2)
12658 (@code{rsqrt2.@var{fmt}}).
12659 @end table
12661 The following multi-instruction functions are also available.
12662 In each case, @var{cond} can be any of the 16 floating-point conditions:
12663 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12664 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
12665 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12667 @table @code
12668 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
12669 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
12670 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
12671 @code{bc1t}/@code{bc1f}).
12673 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
12674 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
12675 For example:
12677 @smallexample
12678 float a, b;
12679 if (__builtin_mips_cabs_eq_s (a, b))
12680   true ();
12681 else
12682   false ();
12683 @end smallexample
12685 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12686 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12687 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
12688 @code{bc1t}/@code{bc1f}).
12690 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
12691 and return either the upper or lower half of the result.  For example:
12693 @smallexample
12694 v2sf a, b;
12695 if (__builtin_mips_upper_cabs_eq_ps (a, b))
12696   upper_halves_are_equal ();
12697 else
12698   upper_halves_are_unequal ();
12700 if (__builtin_mips_lower_cabs_eq_ps (a, b))
12701   lower_halves_are_equal ();
12702 else
12703   lower_halves_are_unequal ();
12704 @end smallexample
12706 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12707 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12708 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
12709 @code{movt.ps}/@code{movf.ps}).
12711 The @code{movt} functions return the value @var{x} computed by:
12713 @smallexample
12714 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
12715 mov.ps @var{x},@var{c}
12716 movt.ps @var{x},@var{d},@var{cc}
12717 @end smallexample
12719 The @code{movf} functions are similar but use @code{movf.ps} instead
12720 of @code{movt.ps}.
12722 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12723 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12724 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12725 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12726 Comparison of two paired-single values
12727 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12728 @code{bc1any2t}/@code{bc1any2f}).
12730 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12731 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
12732 result is true and the @code{all} forms return true if both results are true.
12733 For example:
12735 @smallexample
12736 v2sf a, b;
12737 if (__builtin_mips_any_c_eq_ps (a, b))
12738   one_is_true ();
12739 else
12740   both_are_false ();
12742 if (__builtin_mips_all_c_eq_ps (a, b))
12743   both_are_true ();
12744 else
12745   one_is_false ();
12746 @end smallexample
12748 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12749 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12750 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12751 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12752 Comparison of four paired-single values
12753 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12754 @code{bc1any4t}/@code{bc1any4f}).
12756 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
12757 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
12758 The @code{any} forms return true if any of the four results are true
12759 and the @code{all} forms return true if all four results are true.
12760 For example:
12762 @smallexample
12763 v2sf a, b, c, d;
12764 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
12765   some_are_true ();
12766 else
12767   all_are_false ();
12769 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
12770   all_are_true ();
12771 else
12772   some_are_false ();
12773 @end smallexample
12774 @end table
12776 @node Other MIPS Built-in Functions
12777 @subsection Other MIPS Built-in Functions
12779 GCC provides other MIPS-specific built-in functions:
12781 @table @code
12782 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
12783 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
12784 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
12785 when this function is available.
12787 @item unsigned int __builtin_mips_get_fcsr (void)
12788 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
12789 Get and set the contents of the floating-point control and status register
12790 (FPU control register 31).  These functions are only available in hard-float
12791 code but can be called in both MIPS16 and non-MIPS16 contexts.
12793 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
12794 register except the condition codes, which GCC assumes are preserved.
12795 @end table
12797 @node MSP430 Built-in Functions
12798 @subsection MSP430 Built-in Functions
12800 GCC provides a couple of special builtin functions to aid in the
12801 writing of interrupt handlers in C.
12803 @table @code
12804 @item __bic_SR_register_on_exit (int @var{mask})
12805 This clears the indicated bits in the saved copy of the status register
12806 currently residing on the stack.  This only works inside interrupt
12807 handlers and the changes to the status register will only take affect
12808 once the handler returns.
12810 @item __bis_SR_register_on_exit (int @var{mask})
12811 This sets the indicated bits in the saved copy of the status register
12812 currently residing on the stack.  This only works inside interrupt
12813 handlers and the changes to the status register will only take affect
12814 once the handler returns.
12816 @item __delay_cycles (long long @var{cycles})
12817 This inserts an instruction sequence that takes exactly @var{cycles}
12818 cycles (between 0 and about 17E9) to complete.  The inserted sequence
12819 may use jumps, loops, or no-ops, and does not interfere with any other
12820 instructions.  Note that @var{cycles} must be a compile-time constant
12821 integer - that is, you must pass a number, not a variable that may be
12822 optimized to a constant later.  The number of cycles delayed by this
12823 builtin is exact.
12824 @end table
12826 @node NDS32 Built-in Functions
12827 @subsection NDS32 Built-in Functions
12829 These built-in functions are available for the NDS32 target:
12831 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
12832 Insert an ISYNC instruction into the instruction stream where
12833 @var{addr} is an instruction address for serialization.
12834 @end deftypefn
12836 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
12837 Insert an ISB instruction into the instruction stream.
12838 @end deftypefn
12840 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
12841 Return the content of a system register which is mapped by @var{sr}.
12842 @end deftypefn
12844 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
12845 Return the content of a user space register which is mapped by @var{usr}.
12846 @end deftypefn
12848 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
12849 Move the @var{value} to a system register which is mapped by @var{sr}.
12850 @end deftypefn
12852 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
12853 Move the @var{value} to a user space register which is mapped by @var{usr}.
12854 @end deftypefn
12856 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
12857 Enable global interrupt.
12858 @end deftypefn
12860 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
12861 Disable global interrupt.
12862 @end deftypefn
12864 @node picoChip Built-in Functions
12865 @subsection picoChip Built-in Functions
12867 GCC provides an interface to selected machine instructions from the
12868 picoChip instruction set.
12870 @table @code
12871 @item int __builtin_sbc (int @var{value})
12872 Sign bit count.  Return the number of consecutive bits in @var{value}
12873 that have the same value as the sign bit.  The result is the number of
12874 leading sign bits minus one, giving the number of redundant sign bits in
12875 @var{value}.
12877 @item int __builtin_byteswap (int @var{value})
12878 Byte swap.  Return the result of swapping the upper and lower bytes of
12879 @var{value}.
12881 @item int __builtin_brev (int @var{value})
12882 Bit reversal.  Return the result of reversing the bits in
12883 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
12884 and so on.
12886 @item int __builtin_adds (int @var{x}, int @var{y})
12887 Saturating addition.  Return the result of adding @var{x} and @var{y},
12888 storing the value 32767 if the result overflows.
12890 @item int __builtin_subs (int @var{x}, int @var{y})
12891 Saturating subtraction.  Return the result of subtracting @var{y} from
12892 @var{x}, storing the value @minus{}32768 if the result overflows.
12894 @item void __builtin_halt (void)
12895 Halt.  The processor stops execution.  This built-in is useful for
12896 implementing assertions.
12898 @end table
12900 @node PowerPC Built-in Functions
12901 @subsection PowerPC Built-in Functions
12903 These built-in functions are available for the PowerPC family of
12904 processors:
12905 @smallexample
12906 float __builtin_recipdivf (float, float);
12907 float __builtin_rsqrtf (float);
12908 double __builtin_recipdiv (double, double);
12909 double __builtin_rsqrt (double);
12910 uint64_t __builtin_ppc_get_timebase ();
12911 unsigned long __builtin_ppc_mftb ();
12912 double __builtin_unpack_longdouble (long double, int);
12913 long double __builtin_pack_longdouble (double, double);
12914 @end smallexample
12916 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
12917 @code{__builtin_rsqrtf} functions generate multiple instructions to
12918 implement the reciprocal sqrt functionality using reciprocal sqrt
12919 estimate instructions.
12921 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
12922 functions generate multiple instructions to implement division using
12923 the reciprocal estimate instructions.
12925 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
12926 functions generate instructions to read the Time Base Register.  The
12927 @code{__builtin_ppc_get_timebase} function may generate multiple
12928 instructions and always returns the 64 bits of the Time Base Register.
12929 The @code{__builtin_ppc_mftb} function always generates one instruction and
12930 returns the Time Base Register value as an unsigned long, throwing away
12931 the most significant word on 32-bit environments.
12933 The following built-in functions are available for the PowerPC family
12934 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
12935 or @option{-mpopcntd}):
12936 @smallexample
12937 long __builtin_bpermd (long, long);
12938 int __builtin_divwe (int, int);
12939 int __builtin_divweo (int, int);
12940 unsigned int __builtin_divweu (unsigned int, unsigned int);
12941 unsigned int __builtin_divweuo (unsigned int, unsigned int);
12942 long __builtin_divde (long, long);
12943 long __builtin_divdeo (long, long);
12944 unsigned long __builtin_divdeu (unsigned long, unsigned long);
12945 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
12946 unsigned int cdtbcd (unsigned int);
12947 unsigned int cbcdtd (unsigned int);
12948 unsigned int addg6s (unsigned int, unsigned int);
12949 @end smallexample
12951 The @code{__builtin_divde}, @code{__builtin_divdeo},
12952 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
12953 64-bit environment support ISA 2.06 or later.
12955 The following built-in functions are available for the PowerPC family
12956 of processors when hardware decimal floating point
12957 (@option{-mhard-dfp}) is available:
12958 @smallexample
12959 _Decimal64 __builtin_dxex (_Decimal64);
12960 _Decimal128 __builtin_dxexq (_Decimal128);
12961 _Decimal64 __builtin_ddedpd (int, _Decimal64);
12962 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
12963 _Decimal64 __builtin_denbcd (int, _Decimal64);
12964 _Decimal128 __builtin_denbcdq (int, _Decimal128);
12965 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
12966 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
12967 _Decimal64 __builtin_dscli (_Decimal64, int);
12968 _Decimal128 __builtin_dscliq (_Decimal128, int);
12969 _Decimal64 __builtin_dscri (_Decimal64, int);
12970 _Decimal128 __builtin_dscriq (_Decimal128, int);
12971 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
12972 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
12973 @end smallexample
12975 The following built-in functions are available for the PowerPC family
12976 of processors when the Vector Scalar (vsx) instruction set is
12977 available:
12978 @smallexample
12979 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
12980 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
12981                                                 unsigned long long);
12982 @end smallexample
12984 @node PowerPC AltiVec/VSX Built-in Functions
12985 @subsection PowerPC AltiVec Built-in Functions
12987 GCC provides an interface for the PowerPC family of processors to access
12988 the AltiVec operations described in Motorola's AltiVec Programming
12989 Interface Manual.  The interface is made available by including
12990 @code{<altivec.h>} and using @option{-maltivec} and
12991 @option{-mabi=altivec}.  The interface supports the following vector
12992 types.
12994 @smallexample
12995 vector unsigned char
12996 vector signed char
12997 vector bool char
12999 vector unsigned short
13000 vector signed short
13001 vector bool short
13002 vector pixel
13004 vector unsigned int
13005 vector signed int
13006 vector bool int
13007 vector float
13008 @end smallexample
13010 If @option{-mvsx} is used the following additional vector types are
13011 implemented.
13013 @smallexample
13014 vector unsigned long
13015 vector signed long
13016 vector double
13017 @end smallexample
13019 The long types are only implemented for 64-bit code generation, and
13020 the long type is only used in the floating point/integer conversion
13021 instructions.
13023 GCC's implementation of the high-level language interface available from
13024 C and C++ code differs from Motorola's documentation in several ways.
13026 @itemize @bullet
13028 @item
13029 A vector constant is a list of constant expressions within curly braces.
13031 @item
13032 A vector initializer requires no cast if the vector constant is of the
13033 same type as the variable it is initializing.
13035 @item
13036 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13037 vector type is the default signedness of the base type.  The default
13038 varies depending on the operating system, so a portable program should
13039 always specify the signedness.
13041 @item
13042 Compiling with @option{-maltivec} adds keywords @code{__vector},
13043 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13044 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13045 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13046 disabled.  To use them, you must include @code{<altivec.h>} instead.
13048 @item
13049 GCC allows using a @code{typedef} name as the type specifier for a
13050 vector type.
13052 @item
13053 For C, overloaded functions are implemented with macros so the following
13054 does not work:
13056 @smallexample
13057   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13058 @end smallexample
13060 @noindent
13061 Since @code{vec_add} is a macro, the vector constant in the example
13062 is treated as four separate arguments.  Wrap the entire argument in
13063 parentheses for this to work.
13064 @end itemize
13066 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13067 Internally, GCC uses built-in functions to achieve the functionality in
13068 the aforementioned header file, but they are not supported and are
13069 subject to change without notice.
13071 The following interfaces are supported for the generic and specific
13072 AltiVec operations and the AltiVec predicates.  In cases where there
13073 is a direct mapping between generic and specific operations, only the
13074 generic names are shown here, although the specific operations can also
13075 be used.
13077 Arguments that are documented as @code{const int} require literal
13078 integral values within the range required for that operation.
13080 @smallexample
13081 vector signed char vec_abs (vector signed char);
13082 vector signed short vec_abs (vector signed short);
13083 vector signed int vec_abs (vector signed int);
13084 vector float vec_abs (vector float);
13086 vector signed char vec_abss (vector signed char);
13087 vector signed short vec_abss (vector signed short);
13088 vector signed int vec_abss (vector signed int);
13090 vector signed char vec_add (vector bool char, vector signed char);
13091 vector signed char vec_add (vector signed char, vector bool char);
13092 vector signed char vec_add (vector signed char, vector signed char);
13093 vector unsigned char vec_add (vector bool char, vector unsigned char);
13094 vector unsigned char vec_add (vector unsigned char, vector bool char);
13095 vector unsigned char vec_add (vector unsigned char,
13096                               vector unsigned char);
13097 vector signed short vec_add (vector bool short, vector signed short);
13098 vector signed short vec_add (vector signed short, vector bool short);
13099 vector signed short vec_add (vector signed short, vector signed short);
13100 vector unsigned short vec_add (vector bool short,
13101                                vector unsigned short);
13102 vector unsigned short vec_add (vector unsigned short,
13103                                vector bool short);
13104 vector unsigned short vec_add (vector unsigned short,
13105                                vector unsigned short);
13106 vector signed int vec_add (vector bool int, vector signed int);
13107 vector signed int vec_add (vector signed int, vector bool int);
13108 vector signed int vec_add (vector signed int, vector signed int);
13109 vector unsigned int vec_add (vector bool int, vector unsigned int);
13110 vector unsigned int vec_add (vector unsigned int, vector bool int);
13111 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13112 vector float vec_add (vector float, vector float);
13114 vector float vec_vaddfp (vector float, vector float);
13116 vector signed int vec_vadduwm (vector bool int, vector signed int);
13117 vector signed int vec_vadduwm (vector signed int, vector bool int);
13118 vector signed int vec_vadduwm (vector signed int, vector signed int);
13119 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13120 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13121 vector unsigned int vec_vadduwm (vector unsigned int,
13122                                  vector unsigned int);
13124 vector signed short vec_vadduhm (vector bool short,
13125                                  vector signed short);
13126 vector signed short vec_vadduhm (vector signed short,
13127                                  vector bool short);
13128 vector signed short vec_vadduhm (vector signed short,
13129                                  vector signed short);
13130 vector unsigned short vec_vadduhm (vector bool short,
13131                                    vector unsigned short);
13132 vector unsigned short vec_vadduhm (vector unsigned short,
13133                                    vector bool short);
13134 vector unsigned short vec_vadduhm (vector unsigned short,
13135                                    vector unsigned short);
13137 vector signed char vec_vaddubm (vector bool char, vector signed char);
13138 vector signed char vec_vaddubm (vector signed char, vector bool char);
13139 vector signed char vec_vaddubm (vector signed char, vector signed char);
13140 vector unsigned char vec_vaddubm (vector bool char,
13141                                   vector unsigned char);
13142 vector unsigned char vec_vaddubm (vector unsigned char,
13143                                   vector bool char);
13144 vector unsigned char vec_vaddubm (vector unsigned char,
13145                                   vector unsigned char);
13147 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13149 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13150 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13151 vector unsigned char vec_adds (vector unsigned char,
13152                                vector unsigned char);
13153 vector signed char vec_adds (vector bool char, vector signed char);
13154 vector signed char vec_adds (vector signed char, vector bool char);
13155 vector signed char vec_adds (vector signed char, vector signed char);
13156 vector unsigned short vec_adds (vector bool short,
13157                                 vector unsigned short);
13158 vector unsigned short vec_adds (vector unsigned short,
13159                                 vector bool short);
13160 vector unsigned short vec_adds (vector unsigned short,
13161                                 vector unsigned short);
13162 vector signed short vec_adds (vector bool short, vector signed short);
13163 vector signed short vec_adds (vector signed short, vector bool short);
13164 vector signed short vec_adds (vector signed short, vector signed short);
13165 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13166 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13167 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13168 vector signed int vec_adds (vector bool int, vector signed int);
13169 vector signed int vec_adds (vector signed int, vector bool int);
13170 vector signed int vec_adds (vector signed int, vector signed int);
13172 vector signed int vec_vaddsws (vector bool int, vector signed int);
13173 vector signed int vec_vaddsws (vector signed int, vector bool int);
13174 vector signed int vec_vaddsws (vector signed int, vector signed int);
13176 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13177 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13178 vector unsigned int vec_vadduws (vector unsigned int,
13179                                  vector unsigned int);
13181 vector signed short vec_vaddshs (vector bool short,
13182                                  vector signed short);
13183 vector signed short vec_vaddshs (vector signed short,
13184                                  vector bool short);
13185 vector signed short vec_vaddshs (vector signed short,
13186                                  vector signed short);
13188 vector unsigned short vec_vadduhs (vector bool short,
13189                                    vector unsigned short);
13190 vector unsigned short vec_vadduhs (vector unsigned short,
13191                                    vector bool short);
13192 vector unsigned short vec_vadduhs (vector unsigned short,
13193                                    vector unsigned short);
13195 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13196 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13197 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13199 vector unsigned char vec_vaddubs (vector bool char,
13200                                   vector unsigned char);
13201 vector unsigned char vec_vaddubs (vector unsigned char,
13202                                   vector bool char);
13203 vector unsigned char vec_vaddubs (vector unsigned char,
13204                                   vector unsigned char);
13206 vector float vec_and (vector float, vector float);
13207 vector float vec_and (vector float, vector bool int);
13208 vector float vec_and (vector bool int, vector float);
13209 vector bool int vec_and (vector bool int, vector bool int);
13210 vector signed int vec_and (vector bool int, vector signed int);
13211 vector signed int vec_and (vector signed int, vector bool int);
13212 vector signed int vec_and (vector signed int, vector signed int);
13213 vector unsigned int vec_and (vector bool int, vector unsigned int);
13214 vector unsigned int vec_and (vector unsigned int, vector bool int);
13215 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13216 vector bool short vec_and (vector bool short, vector bool short);
13217 vector signed short vec_and (vector bool short, vector signed short);
13218 vector signed short vec_and (vector signed short, vector bool short);
13219 vector signed short vec_and (vector signed short, vector signed short);
13220 vector unsigned short vec_and (vector bool short,
13221                                vector unsigned short);
13222 vector unsigned short vec_and (vector unsigned short,
13223                                vector bool short);
13224 vector unsigned short vec_and (vector unsigned short,
13225                                vector unsigned short);
13226 vector signed char vec_and (vector bool char, vector signed char);
13227 vector bool char vec_and (vector bool char, vector bool char);
13228 vector signed char vec_and (vector signed char, vector bool char);
13229 vector signed char vec_and (vector signed char, vector signed char);
13230 vector unsigned char vec_and (vector bool char, vector unsigned char);
13231 vector unsigned char vec_and (vector unsigned char, vector bool char);
13232 vector unsigned char vec_and (vector unsigned char,
13233                               vector unsigned char);
13235 vector float vec_andc (vector float, vector float);
13236 vector float vec_andc (vector float, vector bool int);
13237 vector float vec_andc (vector bool int, vector float);
13238 vector bool int vec_andc (vector bool int, vector bool int);
13239 vector signed int vec_andc (vector bool int, vector signed int);
13240 vector signed int vec_andc (vector signed int, vector bool int);
13241 vector signed int vec_andc (vector signed int, vector signed int);
13242 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13243 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13244 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13245 vector bool short vec_andc (vector bool short, vector bool short);
13246 vector signed short vec_andc (vector bool short, vector signed short);
13247 vector signed short vec_andc (vector signed short, vector bool short);
13248 vector signed short vec_andc (vector signed short, vector signed short);
13249 vector unsigned short vec_andc (vector bool short,
13250                                 vector unsigned short);
13251 vector unsigned short vec_andc (vector unsigned short,
13252                                 vector bool short);
13253 vector unsigned short vec_andc (vector unsigned short,
13254                                 vector unsigned short);
13255 vector signed char vec_andc (vector bool char, vector signed char);
13256 vector bool char vec_andc (vector bool char, vector bool char);
13257 vector signed char vec_andc (vector signed char, vector bool char);
13258 vector signed char vec_andc (vector signed char, vector signed char);
13259 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13260 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13261 vector unsigned char vec_andc (vector unsigned char,
13262                                vector unsigned char);
13264 vector unsigned char vec_avg (vector unsigned char,
13265                               vector unsigned char);
13266 vector signed char vec_avg (vector signed char, vector signed char);
13267 vector unsigned short vec_avg (vector unsigned short,
13268                                vector unsigned short);
13269 vector signed short vec_avg (vector signed short, vector signed short);
13270 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13271 vector signed int vec_avg (vector signed int, vector signed int);
13273 vector signed int vec_vavgsw (vector signed int, vector signed int);
13275 vector unsigned int vec_vavguw (vector unsigned int,
13276                                 vector unsigned int);
13278 vector signed short vec_vavgsh (vector signed short,
13279                                 vector signed short);
13281 vector unsigned short vec_vavguh (vector unsigned short,
13282                                   vector unsigned short);
13284 vector signed char vec_vavgsb (vector signed char, vector signed char);
13286 vector unsigned char vec_vavgub (vector unsigned char,
13287                                  vector unsigned char);
13289 vector float vec_copysign (vector float);
13291 vector float vec_ceil (vector float);
13293 vector signed int vec_cmpb (vector float, vector float);
13295 vector bool char vec_cmpeq (vector signed char, vector signed char);
13296 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13297 vector bool short vec_cmpeq (vector signed short, vector signed short);
13298 vector bool short vec_cmpeq (vector unsigned short,
13299                              vector unsigned short);
13300 vector bool int vec_cmpeq (vector signed int, vector signed int);
13301 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13302 vector bool int vec_cmpeq (vector float, vector float);
13304 vector bool int vec_vcmpeqfp (vector float, vector float);
13306 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13307 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13309 vector bool short vec_vcmpequh (vector signed short,
13310                                 vector signed short);
13311 vector bool short vec_vcmpequh (vector unsigned short,
13312                                 vector unsigned short);
13314 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13315 vector bool char vec_vcmpequb (vector unsigned char,
13316                                vector unsigned char);
13318 vector bool int vec_cmpge (vector float, vector float);
13320 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13321 vector bool char vec_cmpgt (vector signed char, vector signed char);
13322 vector bool short vec_cmpgt (vector unsigned short,
13323                              vector unsigned short);
13324 vector bool short vec_cmpgt (vector signed short, vector signed short);
13325 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13326 vector bool int vec_cmpgt (vector signed int, vector signed int);
13327 vector bool int vec_cmpgt (vector float, vector float);
13329 vector bool int vec_vcmpgtfp (vector float, vector float);
13331 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13333 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13335 vector bool short vec_vcmpgtsh (vector signed short,
13336                                 vector signed short);
13338 vector bool short vec_vcmpgtuh (vector unsigned short,
13339                                 vector unsigned short);
13341 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13343 vector bool char vec_vcmpgtub (vector unsigned char,
13344                                vector unsigned char);
13346 vector bool int vec_cmple (vector float, vector float);
13348 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13349 vector bool char vec_cmplt (vector signed char, vector signed char);
13350 vector bool short vec_cmplt (vector unsigned short,
13351                              vector unsigned short);
13352 vector bool short vec_cmplt (vector signed short, vector signed short);
13353 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13354 vector bool int vec_cmplt (vector signed int, vector signed int);
13355 vector bool int vec_cmplt (vector float, vector float);
13357 vector float vec_cpsgn (vector float, vector float);
13359 vector float vec_ctf (vector unsigned int, const int);
13360 vector float vec_ctf (vector signed int, const int);
13361 vector double vec_ctf (vector unsigned long, const int);
13362 vector double vec_ctf (vector signed long, const int);
13364 vector float vec_vcfsx (vector signed int, const int);
13366 vector float vec_vcfux (vector unsigned int, const int);
13368 vector signed int vec_cts (vector float, const int);
13369 vector signed long vec_cts (vector double, const int);
13371 vector unsigned int vec_ctu (vector float, const int);
13372 vector unsigned long vec_ctu (vector double, const int);
13374 void vec_dss (const int);
13376 void vec_dssall (void);
13378 void vec_dst (const vector unsigned char *, int, const int);
13379 void vec_dst (const vector signed char *, int, const int);
13380 void vec_dst (const vector bool char *, int, const int);
13381 void vec_dst (const vector unsigned short *, int, const int);
13382 void vec_dst (const vector signed short *, int, const int);
13383 void vec_dst (const vector bool short *, int, const int);
13384 void vec_dst (const vector pixel *, int, const int);
13385 void vec_dst (const vector unsigned int *, int, const int);
13386 void vec_dst (const vector signed int *, int, const int);
13387 void vec_dst (const vector bool int *, int, const int);
13388 void vec_dst (const vector float *, int, const int);
13389 void vec_dst (const unsigned char *, int, const int);
13390 void vec_dst (const signed char *, int, const int);
13391 void vec_dst (const unsigned short *, int, const int);
13392 void vec_dst (const short *, int, const int);
13393 void vec_dst (const unsigned int *, int, const int);
13394 void vec_dst (const int *, int, const int);
13395 void vec_dst (const unsigned long *, int, const int);
13396 void vec_dst (const long *, int, const int);
13397 void vec_dst (const float *, int, const int);
13399 void vec_dstst (const vector unsigned char *, int, const int);
13400 void vec_dstst (const vector signed char *, int, const int);
13401 void vec_dstst (const vector bool char *, int, const int);
13402 void vec_dstst (const vector unsigned short *, int, const int);
13403 void vec_dstst (const vector signed short *, int, const int);
13404 void vec_dstst (const vector bool short *, int, const int);
13405 void vec_dstst (const vector pixel *, int, const int);
13406 void vec_dstst (const vector unsigned int *, int, const int);
13407 void vec_dstst (const vector signed int *, int, const int);
13408 void vec_dstst (const vector bool int *, int, const int);
13409 void vec_dstst (const vector float *, int, const int);
13410 void vec_dstst (const unsigned char *, int, const int);
13411 void vec_dstst (const signed char *, int, const int);
13412 void vec_dstst (const unsigned short *, int, const int);
13413 void vec_dstst (const short *, int, const int);
13414 void vec_dstst (const unsigned int *, int, const int);
13415 void vec_dstst (const int *, int, const int);
13416 void vec_dstst (const unsigned long *, int, const int);
13417 void vec_dstst (const long *, int, const int);
13418 void vec_dstst (const float *, int, const int);
13420 void vec_dststt (const vector unsigned char *, int, const int);
13421 void vec_dststt (const vector signed char *, int, const int);
13422 void vec_dststt (const vector bool char *, int, const int);
13423 void vec_dststt (const vector unsigned short *, int, const int);
13424 void vec_dststt (const vector signed short *, int, const int);
13425 void vec_dststt (const vector bool short *, int, const int);
13426 void vec_dststt (const vector pixel *, int, const int);
13427 void vec_dststt (const vector unsigned int *, int, const int);
13428 void vec_dststt (const vector signed int *, int, const int);
13429 void vec_dststt (const vector bool int *, int, const int);
13430 void vec_dststt (const vector float *, int, const int);
13431 void vec_dststt (const unsigned char *, int, const int);
13432 void vec_dststt (const signed char *, int, const int);
13433 void vec_dststt (const unsigned short *, int, const int);
13434 void vec_dststt (const short *, int, const int);
13435 void vec_dststt (const unsigned int *, int, const int);
13436 void vec_dststt (const int *, int, const int);
13437 void vec_dststt (const unsigned long *, int, const int);
13438 void vec_dststt (const long *, int, const int);
13439 void vec_dststt (const float *, int, const int);
13441 void vec_dstt (const vector unsigned char *, int, const int);
13442 void vec_dstt (const vector signed char *, int, const int);
13443 void vec_dstt (const vector bool char *, int, const int);
13444 void vec_dstt (const vector unsigned short *, int, const int);
13445 void vec_dstt (const vector signed short *, int, const int);
13446 void vec_dstt (const vector bool short *, int, const int);
13447 void vec_dstt (const vector pixel *, int, const int);
13448 void vec_dstt (const vector unsigned int *, int, const int);
13449 void vec_dstt (const vector signed int *, int, const int);
13450 void vec_dstt (const vector bool int *, int, const int);
13451 void vec_dstt (const vector float *, int, const int);
13452 void vec_dstt (const unsigned char *, int, const int);
13453 void vec_dstt (const signed char *, int, const int);
13454 void vec_dstt (const unsigned short *, int, const int);
13455 void vec_dstt (const short *, int, const int);
13456 void vec_dstt (const unsigned int *, int, const int);
13457 void vec_dstt (const int *, int, const int);
13458 void vec_dstt (const unsigned long *, int, const int);
13459 void vec_dstt (const long *, int, const int);
13460 void vec_dstt (const float *, int, const int);
13462 vector float vec_expte (vector float);
13464 vector float vec_floor (vector float);
13466 vector float vec_ld (int, const vector float *);
13467 vector float vec_ld (int, const float *);
13468 vector bool int vec_ld (int, const vector bool int *);
13469 vector signed int vec_ld (int, const vector signed int *);
13470 vector signed int vec_ld (int, const int *);
13471 vector signed int vec_ld (int, const long *);
13472 vector unsigned int vec_ld (int, const vector unsigned int *);
13473 vector unsigned int vec_ld (int, const unsigned int *);
13474 vector unsigned int vec_ld (int, const unsigned long *);
13475 vector bool short vec_ld (int, const vector bool short *);
13476 vector pixel vec_ld (int, const vector pixel *);
13477 vector signed short vec_ld (int, const vector signed short *);
13478 vector signed short vec_ld (int, const short *);
13479 vector unsigned short vec_ld (int, const vector unsigned short *);
13480 vector unsigned short vec_ld (int, const unsigned short *);
13481 vector bool char vec_ld (int, const vector bool char *);
13482 vector signed char vec_ld (int, const vector signed char *);
13483 vector signed char vec_ld (int, const signed char *);
13484 vector unsigned char vec_ld (int, const vector unsigned char *);
13485 vector unsigned char vec_ld (int, const unsigned char *);
13487 vector signed char vec_lde (int, const signed char *);
13488 vector unsigned char vec_lde (int, const unsigned char *);
13489 vector signed short vec_lde (int, const short *);
13490 vector unsigned short vec_lde (int, const unsigned short *);
13491 vector float vec_lde (int, const float *);
13492 vector signed int vec_lde (int, const int *);
13493 vector unsigned int vec_lde (int, const unsigned int *);
13494 vector signed int vec_lde (int, const long *);
13495 vector unsigned int vec_lde (int, const unsigned long *);
13497 vector float vec_lvewx (int, float *);
13498 vector signed int vec_lvewx (int, int *);
13499 vector unsigned int vec_lvewx (int, unsigned int *);
13500 vector signed int vec_lvewx (int, long *);
13501 vector unsigned int vec_lvewx (int, unsigned long *);
13503 vector signed short vec_lvehx (int, short *);
13504 vector unsigned short vec_lvehx (int, unsigned short *);
13506 vector signed char vec_lvebx (int, char *);
13507 vector unsigned char vec_lvebx (int, unsigned char *);
13509 vector float vec_ldl (int, const vector float *);
13510 vector float vec_ldl (int, const float *);
13511 vector bool int vec_ldl (int, const vector bool int *);
13512 vector signed int vec_ldl (int, const vector signed int *);
13513 vector signed int vec_ldl (int, const int *);
13514 vector signed int vec_ldl (int, const long *);
13515 vector unsigned int vec_ldl (int, const vector unsigned int *);
13516 vector unsigned int vec_ldl (int, const unsigned int *);
13517 vector unsigned int vec_ldl (int, const unsigned long *);
13518 vector bool short vec_ldl (int, const vector bool short *);
13519 vector pixel vec_ldl (int, const vector pixel *);
13520 vector signed short vec_ldl (int, const vector signed short *);
13521 vector signed short vec_ldl (int, const short *);
13522 vector unsigned short vec_ldl (int, const vector unsigned short *);
13523 vector unsigned short vec_ldl (int, const unsigned short *);
13524 vector bool char vec_ldl (int, const vector bool char *);
13525 vector signed char vec_ldl (int, const vector signed char *);
13526 vector signed char vec_ldl (int, const signed char *);
13527 vector unsigned char vec_ldl (int, const vector unsigned char *);
13528 vector unsigned char vec_ldl (int, const unsigned char *);
13530 vector float vec_loge (vector float);
13532 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
13533 vector unsigned char vec_lvsl (int, const volatile signed char *);
13534 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
13535 vector unsigned char vec_lvsl (int, const volatile short *);
13536 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
13537 vector unsigned char vec_lvsl (int, const volatile int *);
13538 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
13539 vector unsigned char vec_lvsl (int, const volatile long *);
13540 vector unsigned char vec_lvsl (int, const volatile float *);
13542 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
13543 vector unsigned char vec_lvsr (int, const volatile signed char *);
13544 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
13545 vector unsigned char vec_lvsr (int, const volatile short *);
13546 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
13547 vector unsigned char vec_lvsr (int, const volatile int *);
13548 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
13549 vector unsigned char vec_lvsr (int, const volatile long *);
13550 vector unsigned char vec_lvsr (int, const volatile float *);
13552 vector float vec_madd (vector float, vector float, vector float);
13554 vector signed short vec_madds (vector signed short,
13555                                vector signed short,
13556                                vector signed short);
13558 vector unsigned char vec_max (vector bool char, vector unsigned char);
13559 vector unsigned char vec_max (vector unsigned char, vector bool char);
13560 vector unsigned char vec_max (vector unsigned char,
13561                               vector unsigned char);
13562 vector signed char vec_max (vector bool char, vector signed char);
13563 vector signed char vec_max (vector signed char, vector bool char);
13564 vector signed char vec_max (vector signed char, vector signed char);
13565 vector unsigned short vec_max (vector bool short,
13566                                vector unsigned short);
13567 vector unsigned short vec_max (vector unsigned short,
13568                                vector bool short);
13569 vector unsigned short vec_max (vector unsigned short,
13570                                vector unsigned short);
13571 vector signed short vec_max (vector bool short, vector signed short);
13572 vector signed short vec_max (vector signed short, vector bool short);
13573 vector signed short vec_max (vector signed short, vector signed short);
13574 vector unsigned int vec_max (vector bool int, vector unsigned int);
13575 vector unsigned int vec_max (vector unsigned int, vector bool int);
13576 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13577 vector signed int vec_max (vector bool int, vector signed int);
13578 vector signed int vec_max (vector signed int, vector bool int);
13579 vector signed int vec_max (vector signed int, vector signed int);
13580 vector float vec_max (vector float, vector float);
13582 vector float vec_vmaxfp (vector float, vector float);
13584 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13585 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13586 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13588 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13589 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13590 vector unsigned int vec_vmaxuw (vector unsigned int,
13591                                 vector unsigned int);
13593 vector signed short vec_vmaxsh (vector bool short, vector signed short);
13594 vector signed short vec_vmaxsh (vector signed short, vector bool short);
13595 vector signed short vec_vmaxsh (vector signed short,
13596                                 vector signed short);
13598 vector unsigned short vec_vmaxuh (vector bool short,
13599                                   vector unsigned short);
13600 vector unsigned short vec_vmaxuh (vector unsigned short,
13601                                   vector bool short);
13602 vector unsigned short vec_vmaxuh (vector unsigned short,
13603                                   vector unsigned short);
13605 vector signed char vec_vmaxsb (vector bool char, vector signed char);
13606 vector signed char vec_vmaxsb (vector signed char, vector bool char);
13607 vector signed char vec_vmaxsb (vector signed char, vector signed char);
13609 vector unsigned char vec_vmaxub (vector bool char,
13610                                  vector unsigned char);
13611 vector unsigned char vec_vmaxub (vector unsigned char,
13612                                  vector bool char);
13613 vector unsigned char vec_vmaxub (vector unsigned char,
13614                                  vector unsigned char);
13616 vector bool char vec_mergeh (vector bool char, vector bool char);
13617 vector signed char vec_mergeh (vector signed char, vector signed char);
13618 vector unsigned char vec_mergeh (vector unsigned char,
13619                                  vector unsigned char);
13620 vector bool short vec_mergeh (vector bool short, vector bool short);
13621 vector pixel vec_mergeh (vector pixel, vector pixel);
13622 vector signed short vec_mergeh (vector signed short,
13623                                 vector signed short);
13624 vector unsigned short vec_mergeh (vector unsigned short,
13625                                   vector unsigned short);
13626 vector float vec_mergeh (vector float, vector float);
13627 vector bool int vec_mergeh (vector bool int, vector bool int);
13628 vector signed int vec_mergeh (vector signed int, vector signed int);
13629 vector unsigned int vec_mergeh (vector unsigned int,
13630                                 vector unsigned int);
13632 vector float vec_vmrghw (vector float, vector float);
13633 vector bool int vec_vmrghw (vector bool int, vector bool int);
13634 vector signed int vec_vmrghw (vector signed int, vector signed int);
13635 vector unsigned int vec_vmrghw (vector unsigned int,
13636                                 vector unsigned int);
13638 vector bool short vec_vmrghh (vector bool short, vector bool short);
13639 vector signed short vec_vmrghh (vector signed short,
13640                                 vector signed short);
13641 vector unsigned short vec_vmrghh (vector unsigned short,
13642                                   vector unsigned short);
13643 vector pixel vec_vmrghh (vector pixel, vector pixel);
13645 vector bool char vec_vmrghb (vector bool char, vector bool char);
13646 vector signed char vec_vmrghb (vector signed char, vector signed char);
13647 vector unsigned char vec_vmrghb (vector unsigned char,
13648                                  vector unsigned char);
13650 vector bool char vec_mergel (vector bool char, vector bool char);
13651 vector signed char vec_mergel (vector signed char, vector signed char);
13652 vector unsigned char vec_mergel (vector unsigned char,
13653                                  vector unsigned char);
13654 vector bool short vec_mergel (vector bool short, vector bool short);
13655 vector pixel vec_mergel (vector pixel, vector pixel);
13656 vector signed short vec_mergel (vector signed short,
13657                                 vector signed short);
13658 vector unsigned short vec_mergel (vector unsigned short,
13659                                   vector unsigned short);
13660 vector float vec_mergel (vector float, vector float);
13661 vector bool int vec_mergel (vector bool int, vector bool int);
13662 vector signed int vec_mergel (vector signed int, vector signed int);
13663 vector unsigned int vec_mergel (vector unsigned int,
13664                                 vector unsigned int);
13666 vector float vec_vmrglw (vector float, vector float);
13667 vector signed int vec_vmrglw (vector signed int, vector signed int);
13668 vector unsigned int vec_vmrglw (vector unsigned int,
13669                                 vector unsigned int);
13670 vector bool int vec_vmrglw (vector bool int, vector bool int);
13672 vector bool short vec_vmrglh (vector bool short, vector bool short);
13673 vector signed short vec_vmrglh (vector signed short,
13674                                 vector signed short);
13675 vector unsigned short vec_vmrglh (vector unsigned short,
13676                                   vector unsigned short);
13677 vector pixel vec_vmrglh (vector pixel, vector pixel);
13679 vector bool char vec_vmrglb (vector bool char, vector bool char);
13680 vector signed char vec_vmrglb (vector signed char, vector signed char);
13681 vector unsigned char vec_vmrglb (vector unsigned char,
13682                                  vector unsigned char);
13684 vector unsigned short vec_mfvscr (void);
13686 vector unsigned char vec_min (vector bool char, vector unsigned char);
13687 vector unsigned char vec_min (vector unsigned char, vector bool char);
13688 vector unsigned char vec_min (vector unsigned char,
13689                               vector unsigned char);
13690 vector signed char vec_min (vector bool char, vector signed char);
13691 vector signed char vec_min (vector signed char, vector bool char);
13692 vector signed char vec_min (vector signed char, vector signed char);
13693 vector unsigned short vec_min (vector bool short,
13694                                vector unsigned short);
13695 vector unsigned short vec_min (vector unsigned short,
13696                                vector bool short);
13697 vector unsigned short vec_min (vector unsigned short,
13698                                vector unsigned short);
13699 vector signed short vec_min (vector bool short, vector signed short);
13700 vector signed short vec_min (vector signed short, vector bool short);
13701 vector signed short vec_min (vector signed short, vector signed short);
13702 vector unsigned int vec_min (vector bool int, vector unsigned int);
13703 vector unsigned int vec_min (vector unsigned int, vector bool int);
13704 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
13705 vector signed int vec_min (vector bool int, vector signed int);
13706 vector signed int vec_min (vector signed int, vector bool int);
13707 vector signed int vec_min (vector signed int, vector signed int);
13708 vector float vec_min (vector float, vector float);
13710 vector float vec_vminfp (vector float, vector float);
13712 vector signed int vec_vminsw (vector bool int, vector signed int);
13713 vector signed int vec_vminsw (vector signed int, vector bool int);
13714 vector signed int vec_vminsw (vector signed int, vector signed int);
13716 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
13717 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
13718 vector unsigned int vec_vminuw (vector unsigned int,
13719                                 vector unsigned int);
13721 vector signed short vec_vminsh (vector bool short, vector signed short);
13722 vector signed short vec_vminsh (vector signed short, vector bool short);
13723 vector signed short vec_vminsh (vector signed short,
13724                                 vector signed short);
13726 vector unsigned short vec_vminuh (vector bool short,
13727                                   vector unsigned short);
13728 vector unsigned short vec_vminuh (vector unsigned short,
13729                                   vector bool short);
13730 vector unsigned short vec_vminuh (vector unsigned short,
13731                                   vector unsigned short);
13733 vector signed char vec_vminsb (vector bool char, vector signed char);
13734 vector signed char vec_vminsb (vector signed char, vector bool char);
13735 vector signed char vec_vminsb (vector signed char, vector signed char);
13737 vector unsigned char vec_vminub (vector bool char,
13738                                  vector unsigned char);
13739 vector unsigned char vec_vminub (vector unsigned char,
13740                                  vector bool char);
13741 vector unsigned char vec_vminub (vector unsigned char,
13742                                  vector unsigned char);
13744 vector signed short vec_mladd (vector signed short,
13745                                vector signed short,
13746                                vector signed short);
13747 vector signed short vec_mladd (vector signed short,
13748                                vector unsigned short,
13749                                vector unsigned short);
13750 vector signed short vec_mladd (vector unsigned short,
13751                                vector signed short,
13752                                vector signed short);
13753 vector unsigned short vec_mladd (vector unsigned short,
13754                                  vector unsigned short,
13755                                  vector unsigned short);
13757 vector signed short vec_mradds (vector signed short,
13758                                 vector signed short,
13759                                 vector signed short);
13761 vector unsigned int vec_msum (vector unsigned char,
13762                               vector unsigned char,
13763                               vector unsigned int);
13764 vector signed int vec_msum (vector signed char,
13765                             vector unsigned char,
13766                             vector signed int);
13767 vector unsigned int vec_msum (vector unsigned short,
13768                               vector unsigned short,
13769                               vector unsigned int);
13770 vector signed int vec_msum (vector signed short,
13771                             vector signed short,
13772                             vector signed int);
13774 vector signed int vec_vmsumshm (vector signed short,
13775                                 vector signed short,
13776                                 vector signed int);
13778 vector unsigned int vec_vmsumuhm (vector unsigned short,
13779                                   vector unsigned short,
13780                                   vector unsigned int);
13782 vector signed int vec_vmsummbm (vector signed char,
13783                                 vector unsigned char,
13784                                 vector signed int);
13786 vector unsigned int vec_vmsumubm (vector unsigned char,
13787                                   vector unsigned char,
13788                                   vector unsigned int);
13790 vector unsigned int vec_msums (vector unsigned short,
13791                                vector unsigned short,
13792                                vector unsigned int);
13793 vector signed int vec_msums (vector signed short,
13794                              vector signed short,
13795                              vector signed int);
13797 vector signed int vec_vmsumshs (vector signed short,
13798                                 vector signed short,
13799                                 vector signed int);
13801 vector unsigned int vec_vmsumuhs (vector unsigned short,
13802                                   vector unsigned short,
13803                                   vector unsigned int);
13805 void vec_mtvscr (vector signed int);
13806 void vec_mtvscr (vector unsigned int);
13807 void vec_mtvscr (vector bool int);
13808 void vec_mtvscr (vector signed short);
13809 void vec_mtvscr (vector unsigned short);
13810 void vec_mtvscr (vector bool short);
13811 void vec_mtvscr (vector pixel);
13812 void vec_mtvscr (vector signed char);
13813 void vec_mtvscr (vector unsigned char);
13814 void vec_mtvscr (vector bool char);
13816 vector unsigned short vec_mule (vector unsigned char,
13817                                 vector unsigned char);
13818 vector signed short vec_mule (vector signed char,
13819                               vector signed char);
13820 vector unsigned int vec_mule (vector unsigned short,
13821                               vector unsigned short);
13822 vector signed int vec_mule (vector signed short, vector signed short);
13824 vector signed int vec_vmulesh (vector signed short,
13825                                vector signed short);
13827 vector unsigned int vec_vmuleuh (vector unsigned short,
13828                                  vector unsigned short);
13830 vector signed short vec_vmulesb (vector signed char,
13831                                  vector signed char);
13833 vector unsigned short vec_vmuleub (vector unsigned char,
13834                                   vector unsigned char);
13836 vector unsigned short vec_mulo (vector unsigned char,
13837                                 vector unsigned char);
13838 vector signed short vec_mulo (vector signed char, vector signed char);
13839 vector unsigned int vec_mulo (vector unsigned short,
13840                               vector unsigned short);
13841 vector signed int vec_mulo (vector signed short, vector signed short);
13843 vector signed int vec_vmulosh (vector signed short,
13844                                vector signed short);
13846 vector unsigned int vec_vmulouh (vector unsigned short,
13847                                  vector unsigned short);
13849 vector signed short vec_vmulosb (vector signed char,
13850                                  vector signed char);
13852 vector unsigned short vec_vmuloub (vector unsigned char,
13853                                    vector unsigned char);
13855 vector float vec_nmsub (vector float, vector float, vector float);
13857 vector float vec_nor (vector float, vector float);
13858 vector signed int vec_nor (vector signed int, vector signed int);
13859 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
13860 vector bool int vec_nor (vector bool int, vector bool int);
13861 vector signed short vec_nor (vector signed short, vector signed short);
13862 vector unsigned short vec_nor (vector unsigned short,
13863                                vector unsigned short);
13864 vector bool short vec_nor (vector bool short, vector bool short);
13865 vector signed char vec_nor (vector signed char, vector signed char);
13866 vector unsigned char vec_nor (vector unsigned char,
13867                               vector unsigned char);
13868 vector bool char vec_nor (vector bool char, vector bool char);
13870 vector float vec_or (vector float, vector float);
13871 vector float vec_or (vector float, vector bool int);
13872 vector float vec_or (vector bool int, vector float);
13873 vector bool int vec_or (vector bool int, vector bool int);
13874 vector signed int vec_or (vector bool int, vector signed int);
13875 vector signed int vec_or (vector signed int, vector bool int);
13876 vector signed int vec_or (vector signed int, vector signed int);
13877 vector unsigned int vec_or (vector bool int, vector unsigned int);
13878 vector unsigned int vec_or (vector unsigned int, vector bool int);
13879 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
13880 vector bool short vec_or (vector bool short, vector bool short);
13881 vector signed short vec_or (vector bool short, vector signed short);
13882 vector signed short vec_or (vector signed short, vector bool short);
13883 vector signed short vec_or (vector signed short, vector signed short);
13884 vector unsigned short vec_or (vector bool short, vector unsigned short);
13885 vector unsigned short vec_or (vector unsigned short, vector bool short);
13886 vector unsigned short vec_or (vector unsigned short,
13887                               vector unsigned short);
13888 vector signed char vec_or (vector bool char, vector signed char);
13889 vector bool char vec_or (vector bool char, vector bool char);
13890 vector signed char vec_or (vector signed char, vector bool char);
13891 vector signed char vec_or (vector signed char, vector signed char);
13892 vector unsigned char vec_or (vector bool char, vector unsigned char);
13893 vector unsigned char vec_or (vector unsigned char, vector bool char);
13894 vector unsigned char vec_or (vector unsigned char,
13895                              vector unsigned char);
13897 vector signed char vec_pack (vector signed short, vector signed short);
13898 vector unsigned char vec_pack (vector unsigned short,
13899                                vector unsigned short);
13900 vector bool char vec_pack (vector bool short, vector bool short);
13901 vector signed short vec_pack (vector signed int, vector signed int);
13902 vector unsigned short vec_pack (vector unsigned int,
13903                                 vector unsigned int);
13904 vector bool short vec_pack (vector bool int, vector bool int);
13906 vector bool short vec_vpkuwum (vector bool int, vector bool int);
13907 vector signed short vec_vpkuwum (vector signed int, vector signed int);
13908 vector unsigned short vec_vpkuwum (vector unsigned int,
13909                                    vector unsigned int);
13911 vector bool char vec_vpkuhum (vector bool short, vector bool short);
13912 vector signed char vec_vpkuhum (vector signed short,
13913                                 vector signed short);
13914 vector unsigned char vec_vpkuhum (vector unsigned short,
13915                                   vector unsigned short);
13917 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
13919 vector unsigned char vec_packs (vector unsigned short,
13920                                 vector unsigned short);
13921 vector signed char vec_packs (vector signed short, vector signed short);
13922 vector unsigned short vec_packs (vector unsigned int,
13923                                  vector unsigned int);
13924 vector signed short vec_packs (vector signed int, vector signed int);
13926 vector signed short vec_vpkswss (vector signed int, vector signed int);
13928 vector unsigned short vec_vpkuwus (vector unsigned int,
13929                                    vector unsigned int);
13931 vector signed char vec_vpkshss (vector signed short,
13932                                 vector signed short);
13934 vector unsigned char vec_vpkuhus (vector unsigned short,
13935                                   vector unsigned short);
13937 vector unsigned char vec_packsu (vector unsigned short,
13938                                  vector unsigned short);
13939 vector unsigned char vec_packsu (vector signed short,
13940                                  vector signed short);
13941 vector unsigned short vec_packsu (vector unsigned int,
13942                                   vector unsigned int);
13943 vector unsigned short vec_packsu (vector signed int, vector signed int);
13945 vector unsigned short vec_vpkswus (vector signed int,
13946                                    vector signed int);
13948 vector unsigned char vec_vpkshus (vector signed short,
13949                                   vector signed short);
13951 vector float vec_perm (vector float,
13952                        vector float,
13953                        vector unsigned char);
13954 vector signed int vec_perm (vector signed int,
13955                             vector signed int,
13956                             vector unsigned char);
13957 vector unsigned int vec_perm (vector unsigned int,
13958                               vector unsigned int,
13959                               vector unsigned char);
13960 vector bool int vec_perm (vector bool int,
13961                           vector bool int,
13962                           vector unsigned char);
13963 vector signed short vec_perm (vector signed short,
13964                               vector signed short,
13965                               vector unsigned char);
13966 vector unsigned short vec_perm (vector unsigned short,
13967                                 vector unsigned short,
13968                                 vector unsigned char);
13969 vector bool short vec_perm (vector bool short,
13970                             vector bool short,
13971                             vector unsigned char);
13972 vector pixel vec_perm (vector pixel,
13973                        vector pixel,
13974                        vector unsigned char);
13975 vector signed char vec_perm (vector signed char,
13976                              vector signed char,
13977                              vector unsigned char);
13978 vector unsigned char vec_perm (vector unsigned char,
13979                                vector unsigned char,
13980                                vector unsigned char);
13981 vector bool char vec_perm (vector bool char,
13982                            vector bool char,
13983                            vector unsigned char);
13985 vector float vec_re (vector float);
13987 vector signed char vec_rl (vector signed char,
13988                            vector unsigned char);
13989 vector unsigned char vec_rl (vector unsigned char,
13990                              vector unsigned char);
13991 vector signed short vec_rl (vector signed short, vector unsigned short);
13992 vector unsigned short vec_rl (vector unsigned short,
13993                               vector unsigned short);
13994 vector signed int vec_rl (vector signed int, vector unsigned int);
13995 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
13997 vector signed int vec_vrlw (vector signed int, vector unsigned int);
13998 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14000 vector signed short vec_vrlh (vector signed short,
14001                               vector unsigned short);
14002 vector unsigned short vec_vrlh (vector unsigned short,
14003                                 vector unsigned short);
14005 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14006 vector unsigned char vec_vrlb (vector unsigned char,
14007                                vector unsigned char);
14009 vector float vec_round (vector float);
14011 vector float vec_recip (vector float, vector float);
14013 vector float vec_rsqrt (vector float);
14015 vector float vec_rsqrte (vector float);
14017 vector float vec_sel (vector float, vector float, vector bool int);
14018 vector float vec_sel (vector float, vector float, vector unsigned int);
14019 vector signed int vec_sel (vector signed int,
14020                            vector signed int,
14021                            vector bool int);
14022 vector signed int vec_sel (vector signed int,
14023                            vector signed int,
14024                            vector unsigned int);
14025 vector unsigned int vec_sel (vector unsigned int,
14026                              vector unsigned int,
14027                              vector bool int);
14028 vector unsigned int vec_sel (vector unsigned int,
14029                              vector unsigned int,
14030                              vector unsigned int);
14031 vector bool int vec_sel (vector bool int,
14032                          vector bool int,
14033                          vector bool int);
14034 vector bool int vec_sel (vector bool int,
14035                          vector bool int,
14036                          vector unsigned int);
14037 vector signed short vec_sel (vector signed short,
14038                              vector signed short,
14039                              vector bool short);
14040 vector signed short vec_sel (vector signed short,
14041                              vector signed short,
14042                              vector unsigned short);
14043 vector unsigned short vec_sel (vector unsigned short,
14044                                vector unsigned short,
14045                                vector bool short);
14046 vector unsigned short vec_sel (vector unsigned short,
14047                                vector unsigned short,
14048                                vector unsigned short);
14049 vector bool short vec_sel (vector bool short,
14050                            vector bool short,
14051                            vector bool short);
14052 vector bool short vec_sel (vector bool short,
14053                            vector bool short,
14054                            vector unsigned short);
14055 vector signed char vec_sel (vector signed char,
14056                             vector signed char,
14057                             vector bool char);
14058 vector signed char vec_sel (vector signed char,
14059                             vector signed char,
14060                             vector unsigned char);
14061 vector unsigned char vec_sel (vector unsigned char,
14062                               vector unsigned char,
14063                               vector bool char);
14064 vector unsigned char vec_sel (vector unsigned char,
14065                               vector unsigned char,
14066                               vector unsigned char);
14067 vector bool char vec_sel (vector bool char,
14068                           vector bool char,
14069                           vector bool char);
14070 vector bool char vec_sel (vector bool char,
14071                           vector bool char,
14072                           vector unsigned char);
14074 vector signed char vec_sl (vector signed char,
14075                            vector unsigned char);
14076 vector unsigned char vec_sl (vector unsigned char,
14077                              vector unsigned char);
14078 vector signed short vec_sl (vector signed short, vector unsigned short);
14079 vector unsigned short vec_sl (vector unsigned short,
14080                               vector unsigned short);
14081 vector signed int vec_sl (vector signed int, vector unsigned int);
14082 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14084 vector signed int vec_vslw (vector signed int, vector unsigned int);
14085 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14087 vector signed short vec_vslh (vector signed short,
14088                               vector unsigned short);
14089 vector unsigned short vec_vslh (vector unsigned short,
14090                                 vector unsigned short);
14092 vector signed char vec_vslb (vector signed char, vector unsigned char);
14093 vector unsigned char vec_vslb (vector unsigned char,
14094                                vector unsigned char);
14096 vector float vec_sld (vector float, vector float, const int);
14097 vector signed int vec_sld (vector signed int,
14098                            vector signed int,
14099                            const int);
14100 vector unsigned int vec_sld (vector unsigned int,
14101                              vector unsigned int,
14102                              const int);
14103 vector bool int vec_sld (vector bool int,
14104                          vector bool int,
14105                          const int);
14106 vector signed short vec_sld (vector signed short,
14107                              vector signed short,
14108                              const int);
14109 vector unsigned short vec_sld (vector unsigned short,
14110                                vector unsigned short,
14111                                const int);
14112 vector bool short vec_sld (vector bool short,
14113                            vector bool short,
14114                            const int);
14115 vector pixel vec_sld (vector pixel,
14116                       vector pixel,
14117                       const int);
14118 vector signed char vec_sld (vector signed char,
14119                             vector signed char,
14120                             const int);
14121 vector unsigned char vec_sld (vector unsigned char,
14122                               vector unsigned char,
14123                               const int);
14124 vector bool char vec_sld (vector bool char,
14125                           vector bool char,
14126                           const int);
14128 vector signed int vec_sll (vector signed int,
14129                            vector unsigned int);
14130 vector signed int vec_sll (vector signed int,
14131                            vector unsigned short);
14132 vector signed int vec_sll (vector signed int,
14133                            vector unsigned char);
14134 vector unsigned int vec_sll (vector unsigned int,
14135                              vector unsigned int);
14136 vector unsigned int vec_sll (vector unsigned int,
14137                              vector unsigned short);
14138 vector unsigned int vec_sll (vector unsigned int,
14139                              vector unsigned char);
14140 vector bool int vec_sll (vector bool int,
14141                          vector unsigned int);
14142 vector bool int vec_sll (vector bool int,
14143                          vector unsigned short);
14144 vector bool int vec_sll (vector bool int,
14145                          vector unsigned char);
14146 vector signed short vec_sll (vector signed short,
14147                              vector unsigned int);
14148 vector signed short vec_sll (vector signed short,
14149                              vector unsigned short);
14150 vector signed short vec_sll (vector signed short,
14151                              vector unsigned char);
14152 vector unsigned short vec_sll (vector unsigned short,
14153                                vector unsigned int);
14154 vector unsigned short vec_sll (vector unsigned short,
14155                                vector unsigned short);
14156 vector unsigned short vec_sll (vector unsigned short,
14157                                vector unsigned char);
14158 vector bool short vec_sll (vector bool short, vector unsigned int);
14159 vector bool short vec_sll (vector bool short, vector unsigned short);
14160 vector bool short vec_sll (vector bool short, vector unsigned char);
14161 vector pixel vec_sll (vector pixel, vector unsigned int);
14162 vector pixel vec_sll (vector pixel, vector unsigned short);
14163 vector pixel vec_sll (vector pixel, vector unsigned char);
14164 vector signed char vec_sll (vector signed char, vector unsigned int);
14165 vector signed char vec_sll (vector signed char, vector unsigned short);
14166 vector signed char vec_sll (vector signed char, vector unsigned char);
14167 vector unsigned char vec_sll (vector unsigned char,
14168                               vector unsigned int);
14169 vector unsigned char vec_sll (vector unsigned char,
14170                               vector unsigned short);
14171 vector unsigned char vec_sll (vector unsigned char,
14172                               vector unsigned char);
14173 vector bool char vec_sll (vector bool char, vector unsigned int);
14174 vector bool char vec_sll (vector bool char, vector unsigned short);
14175 vector bool char vec_sll (vector bool char, vector unsigned char);
14177 vector float vec_slo (vector float, vector signed char);
14178 vector float vec_slo (vector float, vector unsigned char);
14179 vector signed int vec_slo (vector signed int, vector signed char);
14180 vector signed int vec_slo (vector signed int, vector unsigned char);
14181 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14182 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14183 vector signed short vec_slo (vector signed short, vector signed char);
14184 vector signed short vec_slo (vector signed short, vector unsigned char);
14185 vector unsigned short vec_slo (vector unsigned short,
14186                                vector signed char);
14187 vector unsigned short vec_slo (vector unsigned short,
14188                                vector unsigned char);
14189 vector pixel vec_slo (vector pixel, vector signed char);
14190 vector pixel vec_slo (vector pixel, vector unsigned char);
14191 vector signed char vec_slo (vector signed char, vector signed char);
14192 vector signed char vec_slo (vector signed char, vector unsigned char);
14193 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14194 vector unsigned char vec_slo (vector unsigned char,
14195                               vector unsigned char);
14197 vector signed char vec_splat (vector signed char, const int);
14198 vector unsigned char vec_splat (vector unsigned char, const int);
14199 vector bool char vec_splat (vector bool char, const int);
14200 vector signed short vec_splat (vector signed short, const int);
14201 vector unsigned short vec_splat (vector unsigned short, const int);
14202 vector bool short vec_splat (vector bool short, const int);
14203 vector pixel vec_splat (vector pixel, const int);
14204 vector float vec_splat (vector float, const int);
14205 vector signed int vec_splat (vector signed int, const int);
14206 vector unsigned int vec_splat (vector unsigned int, const int);
14207 vector bool int vec_splat (vector bool int, const int);
14208 vector signed long vec_splat (vector signed long, const int);
14209 vector unsigned long vec_splat (vector unsigned long, const int);
14211 vector signed char vec_splats (signed char);
14212 vector unsigned char vec_splats (unsigned char);
14213 vector signed short vec_splats (signed short);
14214 vector unsigned short vec_splats (unsigned short);
14215 vector signed int vec_splats (signed int);
14216 vector unsigned int vec_splats (unsigned int);
14217 vector float vec_splats (float);
14219 vector float vec_vspltw (vector float, const int);
14220 vector signed int vec_vspltw (vector signed int, const int);
14221 vector unsigned int vec_vspltw (vector unsigned int, const int);
14222 vector bool int vec_vspltw (vector bool int, const int);
14224 vector bool short vec_vsplth (vector bool short, const int);
14225 vector signed short vec_vsplth (vector signed short, const int);
14226 vector unsigned short vec_vsplth (vector unsigned short, const int);
14227 vector pixel vec_vsplth (vector pixel, const int);
14229 vector signed char vec_vspltb (vector signed char, const int);
14230 vector unsigned char vec_vspltb (vector unsigned char, const int);
14231 vector bool char vec_vspltb (vector bool char, const int);
14233 vector signed char vec_splat_s8 (const int);
14235 vector signed short vec_splat_s16 (const int);
14237 vector signed int vec_splat_s32 (const int);
14239 vector unsigned char vec_splat_u8 (const int);
14241 vector unsigned short vec_splat_u16 (const int);
14243 vector unsigned int vec_splat_u32 (const int);
14245 vector signed char vec_sr (vector signed char, vector unsigned char);
14246 vector unsigned char vec_sr (vector unsigned char,
14247                              vector unsigned char);
14248 vector signed short vec_sr (vector signed short,
14249                             vector unsigned short);
14250 vector unsigned short vec_sr (vector unsigned short,
14251                               vector unsigned short);
14252 vector signed int vec_sr (vector signed int, vector unsigned int);
14253 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14255 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14256 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14258 vector signed short vec_vsrh (vector signed short,
14259                               vector unsigned short);
14260 vector unsigned short vec_vsrh (vector unsigned short,
14261                                 vector unsigned short);
14263 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14264 vector unsigned char vec_vsrb (vector unsigned char,
14265                                vector unsigned char);
14267 vector signed char vec_sra (vector signed char, vector unsigned char);
14268 vector unsigned char vec_sra (vector unsigned char,
14269                               vector unsigned char);
14270 vector signed short vec_sra (vector signed short,
14271                              vector unsigned short);
14272 vector unsigned short vec_sra (vector unsigned short,
14273                                vector unsigned short);
14274 vector signed int vec_sra (vector signed int, vector unsigned int);
14275 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14277 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14278 vector unsigned int vec_vsraw (vector unsigned int,
14279                                vector unsigned int);
14281 vector signed short vec_vsrah (vector signed short,
14282                                vector unsigned short);
14283 vector unsigned short vec_vsrah (vector unsigned short,
14284                                  vector unsigned short);
14286 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14287 vector unsigned char vec_vsrab (vector unsigned char,
14288                                 vector unsigned char);
14290 vector signed int vec_srl (vector signed int, vector unsigned int);
14291 vector signed int vec_srl (vector signed int, vector unsigned short);
14292 vector signed int vec_srl (vector signed int, vector unsigned char);
14293 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14294 vector unsigned int vec_srl (vector unsigned int,
14295                              vector unsigned short);
14296 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14297 vector bool int vec_srl (vector bool int, vector unsigned int);
14298 vector bool int vec_srl (vector bool int, vector unsigned short);
14299 vector bool int vec_srl (vector bool int, vector unsigned char);
14300 vector signed short vec_srl (vector signed short, vector unsigned int);
14301 vector signed short vec_srl (vector signed short,
14302                              vector unsigned short);
14303 vector signed short vec_srl (vector signed short, vector unsigned char);
14304 vector unsigned short vec_srl (vector unsigned short,
14305                                vector unsigned int);
14306 vector unsigned short vec_srl (vector unsigned short,
14307                                vector unsigned short);
14308 vector unsigned short vec_srl (vector unsigned short,
14309                                vector unsigned char);
14310 vector bool short vec_srl (vector bool short, vector unsigned int);
14311 vector bool short vec_srl (vector bool short, vector unsigned short);
14312 vector bool short vec_srl (vector bool short, vector unsigned char);
14313 vector pixel vec_srl (vector pixel, vector unsigned int);
14314 vector pixel vec_srl (vector pixel, vector unsigned short);
14315 vector pixel vec_srl (vector pixel, vector unsigned char);
14316 vector signed char vec_srl (vector signed char, vector unsigned int);
14317 vector signed char vec_srl (vector signed char, vector unsigned short);
14318 vector signed char vec_srl (vector signed char, vector unsigned char);
14319 vector unsigned char vec_srl (vector unsigned char,
14320                               vector unsigned int);
14321 vector unsigned char vec_srl (vector unsigned char,
14322                               vector unsigned short);
14323 vector unsigned char vec_srl (vector unsigned char,
14324                               vector unsigned char);
14325 vector bool char vec_srl (vector bool char, vector unsigned int);
14326 vector bool char vec_srl (vector bool char, vector unsigned short);
14327 vector bool char vec_srl (vector bool char, vector unsigned char);
14329 vector float vec_sro (vector float, vector signed char);
14330 vector float vec_sro (vector float, vector unsigned char);
14331 vector signed int vec_sro (vector signed int, vector signed char);
14332 vector signed int vec_sro (vector signed int, vector unsigned char);
14333 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14334 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14335 vector signed short vec_sro (vector signed short, vector signed char);
14336 vector signed short vec_sro (vector signed short, vector unsigned char);
14337 vector unsigned short vec_sro (vector unsigned short,
14338                                vector signed char);
14339 vector unsigned short vec_sro (vector unsigned short,
14340                                vector unsigned char);
14341 vector pixel vec_sro (vector pixel, vector signed char);
14342 vector pixel vec_sro (vector pixel, vector unsigned char);
14343 vector signed char vec_sro (vector signed char, vector signed char);
14344 vector signed char vec_sro (vector signed char, vector unsigned char);
14345 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14346 vector unsigned char vec_sro (vector unsigned char,
14347                               vector unsigned char);
14349 void vec_st (vector float, int, vector float *);
14350 void vec_st (vector float, int, float *);
14351 void vec_st (vector signed int, int, vector signed int *);
14352 void vec_st (vector signed int, int, int *);
14353 void vec_st (vector unsigned int, int, vector unsigned int *);
14354 void vec_st (vector unsigned int, int, unsigned int *);
14355 void vec_st (vector bool int, int, vector bool int *);
14356 void vec_st (vector bool int, int, unsigned int *);
14357 void vec_st (vector bool int, int, int *);
14358 void vec_st (vector signed short, int, vector signed short *);
14359 void vec_st (vector signed short, int, short *);
14360 void vec_st (vector unsigned short, int, vector unsigned short *);
14361 void vec_st (vector unsigned short, int, unsigned short *);
14362 void vec_st (vector bool short, int, vector bool short *);
14363 void vec_st (vector bool short, int, unsigned short *);
14364 void vec_st (vector pixel, int, vector pixel *);
14365 void vec_st (vector pixel, int, unsigned short *);
14366 void vec_st (vector pixel, int, short *);
14367 void vec_st (vector bool short, int, short *);
14368 void vec_st (vector signed char, int, vector signed char *);
14369 void vec_st (vector signed char, int, signed char *);
14370 void vec_st (vector unsigned char, int, vector unsigned char *);
14371 void vec_st (vector unsigned char, int, unsigned char *);
14372 void vec_st (vector bool char, int, vector bool char *);
14373 void vec_st (vector bool char, int, unsigned char *);
14374 void vec_st (vector bool char, int, signed char *);
14376 void vec_ste (vector signed char, int, signed char *);
14377 void vec_ste (vector unsigned char, int, unsigned char *);
14378 void vec_ste (vector bool char, int, signed char *);
14379 void vec_ste (vector bool char, int, unsigned char *);
14380 void vec_ste (vector signed short, int, short *);
14381 void vec_ste (vector unsigned short, int, unsigned short *);
14382 void vec_ste (vector bool short, int, short *);
14383 void vec_ste (vector bool short, int, unsigned short *);
14384 void vec_ste (vector pixel, int, short *);
14385 void vec_ste (vector pixel, int, unsigned short *);
14386 void vec_ste (vector float, int, float *);
14387 void vec_ste (vector signed int, int, int *);
14388 void vec_ste (vector unsigned int, int, unsigned int *);
14389 void vec_ste (vector bool int, int, int *);
14390 void vec_ste (vector bool int, int, unsigned int *);
14392 void vec_stvewx (vector float, int, float *);
14393 void vec_stvewx (vector signed int, int, int *);
14394 void vec_stvewx (vector unsigned int, int, unsigned int *);
14395 void vec_stvewx (vector bool int, int, int *);
14396 void vec_stvewx (vector bool int, int, unsigned int *);
14398 void vec_stvehx (vector signed short, int, short *);
14399 void vec_stvehx (vector unsigned short, int, unsigned short *);
14400 void vec_stvehx (vector bool short, int, short *);
14401 void vec_stvehx (vector bool short, int, unsigned short *);
14402 void vec_stvehx (vector pixel, int, short *);
14403 void vec_stvehx (vector pixel, int, unsigned short *);
14405 void vec_stvebx (vector signed char, int, signed char *);
14406 void vec_stvebx (vector unsigned char, int, unsigned char *);
14407 void vec_stvebx (vector bool char, int, signed char *);
14408 void vec_stvebx (vector bool char, int, unsigned char *);
14410 void vec_stl (vector float, int, vector float *);
14411 void vec_stl (vector float, int, float *);
14412 void vec_stl (vector signed int, int, vector signed int *);
14413 void vec_stl (vector signed int, int, int *);
14414 void vec_stl (vector unsigned int, int, vector unsigned int *);
14415 void vec_stl (vector unsigned int, int, unsigned int *);
14416 void vec_stl (vector bool int, int, vector bool int *);
14417 void vec_stl (vector bool int, int, unsigned int *);
14418 void vec_stl (vector bool int, int, int *);
14419 void vec_stl (vector signed short, int, vector signed short *);
14420 void vec_stl (vector signed short, int, short *);
14421 void vec_stl (vector unsigned short, int, vector unsigned short *);
14422 void vec_stl (vector unsigned short, int, unsigned short *);
14423 void vec_stl (vector bool short, int, vector bool short *);
14424 void vec_stl (vector bool short, int, unsigned short *);
14425 void vec_stl (vector bool short, int, short *);
14426 void vec_stl (vector pixel, int, vector pixel *);
14427 void vec_stl (vector pixel, int, unsigned short *);
14428 void vec_stl (vector pixel, int, short *);
14429 void vec_stl (vector signed char, int, vector signed char *);
14430 void vec_stl (vector signed char, int, signed char *);
14431 void vec_stl (vector unsigned char, int, vector unsigned char *);
14432 void vec_stl (vector unsigned char, int, unsigned char *);
14433 void vec_stl (vector bool char, int, vector bool char *);
14434 void vec_stl (vector bool char, int, unsigned char *);
14435 void vec_stl (vector bool char, int, signed char *);
14437 vector signed char vec_sub (vector bool char, vector signed char);
14438 vector signed char vec_sub (vector signed char, vector bool char);
14439 vector signed char vec_sub (vector signed char, vector signed char);
14440 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14441 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14442 vector unsigned char vec_sub (vector unsigned char,
14443                               vector unsigned char);
14444 vector signed short vec_sub (vector bool short, vector signed short);
14445 vector signed short vec_sub (vector signed short, vector bool short);
14446 vector signed short vec_sub (vector signed short, vector signed short);
14447 vector unsigned short vec_sub (vector bool short,
14448                                vector unsigned short);
14449 vector unsigned short vec_sub (vector unsigned short,
14450                                vector bool short);
14451 vector unsigned short vec_sub (vector unsigned short,
14452                                vector unsigned short);
14453 vector signed int vec_sub (vector bool int, vector signed int);
14454 vector signed int vec_sub (vector signed int, vector bool int);
14455 vector signed int vec_sub (vector signed int, vector signed int);
14456 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14457 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14458 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14459 vector float vec_sub (vector float, vector float);
14461 vector float vec_vsubfp (vector float, vector float);
14463 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14464 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14465 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14466 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14467 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14468 vector unsigned int vec_vsubuwm (vector unsigned int,
14469                                  vector unsigned int);
14471 vector signed short vec_vsubuhm (vector bool short,
14472                                  vector signed short);
14473 vector signed short vec_vsubuhm (vector signed short,
14474                                  vector bool short);
14475 vector signed short vec_vsubuhm (vector signed short,
14476                                  vector signed short);
14477 vector unsigned short vec_vsubuhm (vector bool short,
14478                                    vector unsigned short);
14479 vector unsigned short vec_vsubuhm (vector unsigned short,
14480                                    vector bool short);
14481 vector unsigned short vec_vsubuhm (vector unsigned short,
14482                                    vector unsigned short);
14484 vector signed char vec_vsububm (vector bool char, vector signed char);
14485 vector signed char vec_vsububm (vector signed char, vector bool char);
14486 vector signed char vec_vsububm (vector signed char, vector signed char);
14487 vector unsigned char vec_vsububm (vector bool char,
14488                                   vector unsigned char);
14489 vector unsigned char vec_vsububm (vector unsigned char,
14490                                   vector bool char);
14491 vector unsigned char vec_vsububm (vector unsigned char,
14492                                   vector unsigned char);
14494 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14496 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14497 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14498 vector unsigned char vec_subs (vector unsigned char,
14499                                vector unsigned char);
14500 vector signed char vec_subs (vector bool char, vector signed char);
14501 vector signed char vec_subs (vector signed char, vector bool char);
14502 vector signed char vec_subs (vector signed char, vector signed char);
14503 vector unsigned short vec_subs (vector bool short,
14504                                 vector unsigned short);
14505 vector unsigned short vec_subs (vector unsigned short,
14506                                 vector bool short);
14507 vector unsigned short vec_subs (vector unsigned short,
14508                                 vector unsigned short);
14509 vector signed short vec_subs (vector bool short, vector signed short);
14510 vector signed short vec_subs (vector signed short, vector bool short);
14511 vector signed short vec_subs (vector signed short, vector signed short);
14512 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14513 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14514 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14515 vector signed int vec_subs (vector bool int, vector signed int);
14516 vector signed int vec_subs (vector signed int, vector bool int);
14517 vector signed int vec_subs (vector signed int, vector signed int);
14519 vector signed int vec_vsubsws (vector bool int, vector signed int);
14520 vector signed int vec_vsubsws (vector signed int, vector bool int);
14521 vector signed int vec_vsubsws (vector signed int, vector signed int);
14523 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14524 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
14525 vector unsigned int vec_vsubuws (vector unsigned int,
14526                                  vector unsigned int);
14528 vector signed short vec_vsubshs (vector bool short,
14529                                  vector signed short);
14530 vector signed short vec_vsubshs (vector signed short,
14531                                  vector bool short);
14532 vector signed short vec_vsubshs (vector signed short,
14533                                  vector signed short);
14535 vector unsigned short vec_vsubuhs (vector bool short,
14536                                    vector unsigned short);
14537 vector unsigned short vec_vsubuhs (vector unsigned short,
14538                                    vector bool short);
14539 vector unsigned short vec_vsubuhs (vector unsigned short,
14540                                    vector unsigned short);
14542 vector signed char vec_vsubsbs (vector bool char, vector signed char);
14543 vector signed char vec_vsubsbs (vector signed char, vector bool char);
14544 vector signed char vec_vsubsbs (vector signed char, vector signed char);
14546 vector unsigned char vec_vsububs (vector bool char,
14547                                   vector unsigned char);
14548 vector unsigned char vec_vsububs (vector unsigned char,
14549                                   vector bool char);
14550 vector unsigned char vec_vsububs (vector unsigned char,
14551                                   vector unsigned char);
14553 vector unsigned int vec_sum4s (vector unsigned char,
14554                                vector unsigned int);
14555 vector signed int vec_sum4s (vector signed char, vector signed int);
14556 vector signed int vec_sum4s (vector signed short, vector signed int);
14558 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14560 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14562 vector unsigned int vec_vsum4ubs (vector unsigned char,
14563                                   vector unsigned int);
14565 vector signed int vec_sum2s (vector signed int, vector signed int);
14567 vector signed int vec_sums (vector signed int, vector signed int);
14569 vector float vec_trunc (vector float);
14571 vector signed short vec_unpackh (vector signed char);
14572 vector bool short vec_unpackh (vector bool char);
14573 vector signed int vec_unpackh (vector signed short);
14574 vector bool int vec_unpackh (vector bool short);
14575 vector unsigned int vec_unpackh (vector pixel);
14577 vector bool int vec_vupkhsh (vector bool short);
14578 vector signed int vec_vupkhsh (vector signed short);
14580 vector unsigned int vec_vupkhpx (vector pixel);
14582 vector bool short vec_vupkhsb (vector bool char);
14583 vector signed short vec_vupkhsb (vector signed char);
14585 vector signed short vec_unpackl (vector signed char);
14586 vector bool short vec_unpackl (vector bool char);
14587 vector unsigned int vec_unpackl (vector pixel);
14588 vector signed int vec_unpackl (vector signed short);
14589 vector bool int vec_unpackl (vector bool short);
14591 vector unsigned int vec_vupklpx (vector pixel);
14593 vector bool int vec_vupklsh (vector bool short);
14594 vector signed int vec_vupklsh (vector signed short);
14596 vector bool short vec_vupklsb (vector bool char);
14597 vector signed short vec_vupklsb (vector signed char);
14599 vector float vec_xor (vector float, vector float);
14600 vector float vec_xor (vector float, vector bool int);
14601 vector float vec_xor (vector bool int, vector float);
14602 vector bool int vec_xor (vector bool int, vector bool int);
14603 vector signed int vec_xor (vector bool int, vector signed int);
14604 vector signed int vec_xor (vector signed int, vector bool int);
14605 vector signed int vec_xor (vector signed int, vector signed int);
14606 vector unsigned int vec_xor (vector bool int, vector unsigned int);
14607 vector unsigned int vec_xor (vector unsigned int, vector bool int);
14608 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
14609 vector bool short vec_xor (vector bool short, vector bool short);
14610 vector signed short vec_xor (vector bool short, vector signed short);
14611 vector signed short vec_xor (vector signed short, vector bool short);
14612 vector signed short vec_xor (vector signed short, vector signed short);
14613 vector unsigned short vec_xor (vector bool short,
14614                                vector unsigned short);
14615 vector unsigned short vec_xor (vector unsigned short,
14616                                vector bool short);
14617 vector unsigned short vec_xor (vector unsigned short,
14618                                vector unsigned short);
14619 vector signed char vec_xor (vector bool char, vector signed char);
14620 vector bool char vec_xor (vector bool char, vector bool char);
14621 vector signed char vec_xor (vector signed char, vector bool char);
14622 vector signed char vec_xor (vector signed char, vector signed char);
14623 vector unsigned char vec_xor (vector bool char, vector unsigned char);
14624 vector unsigned char vec_xor (vector unsigned char, vector bool char);
14625 vector unsigned char vec_xor (vector unsigned char,
14626                               vector unsigned char);
14628 int vec_all_eq (vector signed char, vector bool char);
14629 int vec_all_eq (vector signed char, vector signed char);
14630 int vec_all_eq (vector unsigned char, vector bool char);
14631 int vec_all_eq (vector unsigned char, vector unsigned char);
14632 int vec_all_eq (vector bool char, vector bool char);
14633 int vec_all_eq (vector bool char, vector unsigned char);
14634 int vec_all_eq (vector bool char, vector signed char);
14635 int vec_all_eq (vector signed short, vector bool short);
14636 int vec_all_eq (vector signed short, vector signed short);
14637 int vec_all_eq (vector unsigned short, vector bool short);
14638 int vec_all_eq (vector unsigned short, vector unsigned short);
14639 int vec_all_eq (vector bool short, vector bool short);
14640 int vec_all_eq (vector bool short, vector unsigned short);
14641 int vec_all_eq (vector bool short, vector signed short);
14642 int vec_all_eq (vector pixel, vector pixel);
14643 int vec_all_eq (vector signed int, vector bool int);
14644 int vec_all_eq (vector signed int, vector signed int);
14645 int vec_all_eq (vector unsigned int, vector bool int);
14646 int vec_all_eq (vector unsigned int, vector unsigned int);
14647 int vec_all_eq (vector bool int, vector bool int);
14648 int vec_all_eq (vector bool int, vector unsigned int);
14649 int vec_all_eq (vector bool int, vector signed int);
14650 int vec_all_eq (vector float, vector float);
14652 int vec_all_ge (vector bool char, vector unsigned char);
14653 int vec_all_ge (vector unsigned char, vector bool char);
14654 int vec_all_ge (vector unsigned char, vector unsigned char);
14655 int vec_all_ge (vector bool char, vector signed char);
14656 int vec_all_ge (vector signed char, vector bool char);
14657 int vec_all_ge (vector signed char, vector signed char);
14658 int vec_all_ge (vector bool short, vector unsigned short);
14659 int vec_all_ge (vector unsigned short, vector bool short);
14660 int vec_all_ge (vector unsigned short, vector unsigned short);
14661 int vec_all_ge (vector signed short, vector signed short);
14662 int vec_all_ge (vector bool short, vector signed short);
14663 int vec_all_ge (vector signed short, vector bool short);
14664 int vec_all_ge (vector bool int, vector unsigned int);
14665 int vec_all_ge (vector unsigned int, vector bool int);
14666 int vec_all_ge (vector unsigned int, vector unsigned int);
14667 int vec_all_ge (vector bool int, vector signed int);
14668 int vec_all_ge (vector signed int, vector bool int);
14669 int vec_all_ge (vector signed int, vector signed int);
14670 int vec_all_ge (vector float, vector float);
14672 int vec_all_gt (vector bool char, vector unsigned char);
14673 int vec_all_gt (vector unsigned char, vector bool char);
14674 int vec_all_gt (vector unsigned char, vector unsigned char);
14675 int vec_all_gt (vector bool char, vector signed char);
14676 int vec_all_gt (vector signed char, vector bool char);
14677 int vec_all_gt (vector signed char, vector signed char);
14678 int vec_all_gt (vector bool short, vector unsigned short);
14679 int vec_all_gt (vector unsigned short, vector bool short);
14680 int vec_all_gt (vector unsigned short, vector unsigned short);
14681 int vec_all_gt (vector bool short, vector signed short);
14682 int vec_all_gt (vector signed short, vector bool short);
14683 int vec_all_gt (vector signed short, vector signed short);
14684 int vec_all_gt (vector bool int, vector unsigned int);
14685 int vec_all_gt (vector unsigned int, vector bool int);
14686 int vec_all_gt (vector unsigned int, vector unsigned int);
14687 int vec_all_gt (vector bool int, vector signed int);
14688 int vec_all_gt (vector signed int, vector bool int);
14689 int vec_all_gt (vector signed int, vector signed int);
14690 int vec_all_gt (vector float, vector float);
14692 int vec_all_in (vector float, vector float);
14694 int vec_all_le (vector bool char, vector unsigned char);
14695 int vec_all_le (vector unsigned char, vector bool char);
14696 int vec_all_le (vector unsigned char, vector unsigned char);
14697 int vec_all_le (vector bool char, vector signed char);
14698 int vec_all_le (vector signed char, vector bool char);
14699 int vec_all_le (vector signed char, vector signed char);
14700 int vec_all_le (vector bool short, vector unsigned short);
14701 int vec_all_le (vector unsigned short, vector bool short);
14702 int vec_all_le (vector unsigned short, vector unsigned short);
14703 int vec_all_le (vector bool short, vector signed short);
14704 int vec_all_le (vector signed short, vector bool short);
14705 int vec_all_le (vector signed short, vector signed short);
14706 int vec_all_le (vector bool int, vector unsigned int);
14707 int vec_all_le (vector unsigned int, vector bool int);
14708 int vec_all_le (vector unsigned int, vector unsigned int);
14709 int vec_all_le (vector bool int, vector signed int);
14710 int vec_all_le (vector signed int, vector bool int);
14711 int vec_all_le (vector signed int, vector signed int);
14712 int vec_all_le (vector float, vector float);
14714 int vec_all_lt (vector bool char, vector unsigned char);
14715 int vec_all_lt (vector unsigned char, vector bool char);
14716 int vec_all_lt (vector unsigned char, vector unsigned char);
14717 int vec_all_lt (vector bool char, vector signed char);
14718 int vec_all_lt (vector signed char, vector bool char);
14719 int vec_all_lt (vector signed char, vector signed char);
14720 int vec_all_lt (vector bool short, vector unsigned short);
14721 int vec_all_lt (vector unsigned short, vector bool short);
14722 int vec_all_lt (vector unsigned short, vector unsigned short);
14723 int vec_all_lt (vector bool short, vector signed short);
14724 int vec_all_lt (vector signed short, vector bool short);
14725 int vec_all_lt (vector signed short, vector signed short);
14726 int vec_all_lt (vector bool int, vector unsigned int);
14727 int vec_all_lt (vector unsigned int, vector bool int);
14728 int vec_all_lt (vector unsigned int, vector unsigned int);
14729 int vec_all_lt (vector bool int, vector signed int);
14730 int vec_all_lt (vector signed int, vector bool int);
14731 int vec_all_lt (vector signed int, vector signed int);
14732 int vec_all_lt (vector float, vector float);
14734 int vec_all_nan (vector float);
14736 int vec_all_ne (vector signed char, vector bool char);
14737 int vec_all_ne (vector signed char, vector signed char);
14738 int vec_all_ne (vector unsigned char, vector bool char);
14739 int vec_all_ne (vector unsigned char, vector unsigned char);
14740 int vec_all_ne (vector bool char, vector bool char);
14741 int vec_all_ne (vector bool char, vector unsigned char);
14742 int vec_all_ne (vector bool char, vector signed char);
14743 int vec_all_ne (vector signed short, vector bool short);
14744 int vec_all_ne (vector signed short, vector signed short);
14745 int vec_all_ne (vector unsigned short, vector bool short);
14746 int vec_all_ne (vector unsigned short, vector unsigned short);
14747 int vec_all_ne (vector bool short, vector bool short);
14748 int vec_all_ne (vector bool short, vector unsigned short);
14749 int vec_all_ne (vector bool short, vector signed short);
14750 int vec_all_ne (vector pixel, vector pixel);
14751 int vec_all_ne (vector signed int, vector bool int);
14752 int vec_all_ne (vector signed int, vector signed int);
14753 int vec_all_ne (vector unsigned int, vector bool int);
14754 int vec_all_ne (vector unsigned int, vector unsigned int);
14755 int vec_all_ne (vector bool int, vector bool int);
14756 int vec_all_ne (vector bool int, vector unsigned int);
14757 int vec_all_ne (vector bool int, vector signed int);
14758 int vec_all_ne (vector float, vector float);
14760 int vec_all_nge (vector float, vector float);
14762 int vec_all_ngt (vector float, vector float);
14764 int vec_all_nle (vector float, vector float);
14766 int vec_all_nlt (vector float, vector float);
14768 int vec_all_numeric (vector float);
14770 int vec_any_eq (vector signed char, vector bool char);
14771 int vec_any_eq (vector signed char, vector signed char);
14772 int vec_any_eq (vector unsigned char, vector bool char);
14773 int vec_any_eq (vector unsigned char, vector unsigned char);
14774 int vec_any_eq (vector bool char, vector bool char);
14775 int vec_any_eq (vector bool char, vector unsigned char);
14776 int vec_any_eq (vector bool char, vector signed char);
14777 int vec_any_eq (vector signed short, vector bool short);
14778 int vec_any_eq (vector signed short, vector signed short);
14779 int vec_any_eq (vector unsigned short, vector bool short);
14780 int vec_any_eq (vector unsigned short, vector unsigned short);
14781 int vec_any_eq (vector bool short, vector bool short);
14782 int vec_any_eq (vector bool short, vector unsigned short);
14783 int vec_any_eq (vector bool short, vector signed short);
14784 int vec_any_eq (vector pixel, vector pixel);
14785 int vec_any_eq (vector signed int, vector bool int);
14786 int vec_any_eq (vector signed int, vector signed int);
14787 int vec_any_eq (vector unsigned int, vector bool int);
14788 int vec_any_eq (vector unsigned int, vector unsigned int);
14789 int vec_any_eq (vector bool int, vector bool int);
14790 int vec_any_eq (vector bool int, vector unsigned int);
14791 int vec_any_eq (vector bool int, vector signed int);
14792 int vec_any_eq (vector float, vector float);
14794 int vec_any_ge (vector signed char, vector bool char);
14795 int vec_any_ge (vector unsigned char, vector bool char);
14796 int vec_any_ge (vector unsigned char, vector unsigned char);
14797 int vec_any_ge (vector signed char, vector signed char);
14798 int vec_any_ge (vector bool char, vector unsigned char);
14799 int vec_any_ge (vector bool char, vector signed char);
14800 int vec_any_ge (vector unsigned short, vector bool short);
14801 int vec_any_ge (vector unsigned short, vector unsigned short);
14802 int vec_any_ge (vector signed short, vector signed short);
14803 int vec_any_ge (vector signed short, vector bool short);
14804 int vec_any_ge (vector bool short, vector unsigned short);
14805 int vec_any_ge (vector bool short, vector signed short);
14806 int vec_any_ge (vector signed int, vector bool int);
14807 int vec_any_ge (vector unsigned int, vector bool int);
14808 int vec_any_ge (vector unsigned int, vector unsigned int);
14809 int vec_any_ge (vector signed int, vector signed int);
14810 int vec_any_ge (vector bool int, vector unsigned int);
14811 int vec_any_ge (vector bool int, vector signed int);
14812 int vec_any_ge (vector float, vector float);
14814 int vec_any_gt (vector bool char, vector unsigned char);
14815 int vec_any_gt (vector unsigned char, vector bool char);
14816 int vec_any_gt (vector unsigned char, vector unsigned char);
14817 int vec_any_gt (vector bool char, vector signed char);
14818 int vec_any_gt (vector signed char, vector bool char);
14819 int vec_any_gt (vector signed char, vector signed char);
14820 int vec_any_gt (vector bool short, vector unsigned short);
14821 int vec_any_gt (vector unsigned short, vector bool short);
14822 int vec_any_gt (vector unsigned short, vector unsigned short);
14823 int vec_any_gt (vector bool short, vector signed short);
14824 int vec_any_gt (vector signed short, vector bool short);
14825 int vec_any_gt (vector signed short, vector signed short);
14826 int vec_any_gt (vector bool int, vector unsigned int);
14827 int vec_any_gt (vector unsigned int, vector bool int);
14828 int vec_any_gt (vector unsigned int, vector unsigned int);
14829 int vec_any_gt (vector bool int, vector signed int);
14830 int vec_any_gt (vector signed int, vector bool int);
14831 int vec_any_gt (vector signed int, vector signed int);
14832 int vec_any_gt (vector float, vector float);
14834 int vec_any_le (vector bool char, vector unsigned char);
14835 int vec_any_le (vector unsigned char, vector bool char);
14836 int vec_any_le (vector unsigned char, vector unsigned char);
14837 int vec_any_le (vector bool char, vector signed char);
14838 int vec_any_le (vector signed char, vector bool char);
14839 int vec_any_le (vector signed char, vector signed char);
14840 int vec_any_le (vector bool short, vector unsigned short);
14841 int vec_any_le (vector unsigned short, vector bool short);
14842 int vec_any_le (vector unsigned short, vector unsigned short);
14843 int vec_any_le (vector bool short, vector signed short);
14844 int vec_any_le (vector signed short, vector bool short);
14845 int vec_any_le (vector signed short, vector signed short);
14846 int vec_any_le (vector bool int, vector unsigned int);
14847 int vec_any_le (vector unsigned int, vector bool int);
14848 int vec_any_le (vector unsigned int, vector unsigned int);
14849 int vec_any_le (vector bool int, vector signed int);
14850 int vec_any_le (vector signed int, vector bool int);
14851 int vec_any_le (vector signed int, vector signed int);
14852 int vec_any_le (vector float, vector float);
14854 int vec_any_lt (vector bool char, vector unsigned char);
14855 int vec_any_lt (vector unsigned char, vector bool char);
14856 int vec_any_lt (vector unsigned char, vector unsigned char);
14857 int vec_any_lt (vector bool char, vector signed char);
14858 int vec_any_lt (vector signed char, vector bool char);
14859 int vec_any_lt (vector signed char, vector signed char);
14860 int vec_any_lt (vector bool short, vector unsigned short);
14861 int vec_any_lt (vector unsigned short, vector bool short);
14862 int vec_any_lt (vector unsigned short, vector unsigned short);
14863 int vec_any_lt (vector bool short, vector signed short);
14864 int vec_any_lt (vector signed short, vector bool short);
14865 int vec_any_lt (vector signed short, vector signed short);
14866 int vec_any_lt (vector bool int, vector unsigned int);
14867 int vec_any_lt (vector unsigned int, vector bool int);
14868 int vec_any_lt (vector unsigned int, vector unsigned int);
14869 int vec_any_lt (vector bool int, vector signed int);
14870 int vec_any_lt (vector signed int, vector bool int);
14871 int vec_any_lt (vector signed int, vector signed int);
14872 int vec_any_lt (vector float, vector float);
14874 int vec_any_nan (vector float);
14876 int vec_any_ne (vector signed char, vector bool char);
14877 int vec_any_ne (vector signed char, vector signed char);
14878 int vec_any_ne (vector unsigned char, vector bool char);
14879 int vec_any_ne (vector unsigned char, vector unsigned char);
14880 int vec_any_ne (vector bool char, vector bool char);
14881 int vec_any_ne (vector bool char, vector unsigned char);
14882 int vec_any_ne (vector bool char, vector signed char);
14883 int vec_any_ne (vector signed short, vector bool short);
14884 int vec_any_ne (vector signed short, vector signed short);
14885 int vec_any_ne (vector unsigned short, vector bool short);
14886 int vec_any_ne (vector unsigned short, vector unsigned short);
14887 int vec_any_ne (vector bool short, vector bool short);
14888 int vec_any_ne (vector bool short, vector unsigned short);
14889 int vec_any_ne (vector bool short, vector signed short);
14890 int vec_any_ne (vector pixel, vector pixel);
14891 int vec_any_ne (vector signed int, vector bool int);
14892 int vec_any_ne (vector signed int, vector signed int);
14893 int vec_any_ne (vector unsigned int, vector bool int);
14894 int vec_any_ne (vector unsigned int, vector unsigned int);
14895 int vec_any_ne (vector bool int, vector bool int);
14896 int vec_any_ne (vector bool int, vector unsigned int);
14897 int vec_any_ne (vector bool int, vector signed int);
14898 int vec_any_ne (vector float, vector float);
14900 int vec_any_nge (vector float, vector float);
14902 int vec_any_ngt (vector float, vector float);
14904 int vec_any_nle (vector float, vector float);
14906 int vec_any_nlt (vector float, vector float);
14908 int vec_any_numeric (vector float);
14910 int vec_any_out (vector float, vector float);
14911 @end smallexample
14913 If the vector/scalar (VSX) instruction set is available, the following
14914 additional functions are available:
14916 @smallexample
14917 vector double vec_abs (vector double);
14918 vector double vec_add (vector double, vector double);
14919 vector double vec_and (vector double, vector double);
14920 vector double vec_and (vector double, vector bool long);
14921 vector double vec_and (vector bool long, vector double);
14922 vector long vec_and (vector long, vector long);
14923 vector long vec_and (vector long, vector bool long);
14924 vector long vec_and (vector bool long, vector long);
14925 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
14926 vector unsigned long vec_and (vector unsigned long, vector bool long);
14927 vector unsigned long vec_and (vector bool long, vector unsigned long);
14928 vector double vec_andc (vector double, vector double);
14929 vector double vec_andc (vector double, vector bool long);
14930 vector double vec_andc (vector bool long, vector double);
14931 vector long vec_andc (vector long, vector long);
14932 vector long vec_andc (vector long, vector bool long);
14933 vector long vec_andc (vector bool long, vector long);
14934 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
14935 vector unsigned long vec_andc (vector unsigned long, vector bool long);
14936 vector unsigned long vec_andc (vector bool long, vector unsigned long);
14937 vector double vec_ceil (vector double);
14938 vector bool long vec_cmpeq (vector double, vector double);
14939 vector bool long vec_cmpge (vector double, vector double);
14940 vector bool long vec_cmpgt (vector double, vector double);
14941 vector bool long vec_cmple (vector double, vector double);
14942 vector bool long vec_cmplt (vector double, vector double);
14943 vector double vec_cpsgn (vector double, vector double);
14944 vector float vec_div (vector float, vector float);
14945 vector double vec_div (vector double, vector double);
14946 vector long vec_div (vector long, vector long);
14947 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
14948 vector double vec_floor (vector double);
14949 vector double vec_ld (int, const vector double *);
14950 vector double vec_ld (int, const double *);
14951 vector double vec_ldl (int, const vector double *);
14952 vector double vec_ldl (int, const double *);
14953 vector unsigned char vec_lvsl (int, const volatile double *);
14954 vector unsigned char vec_lvsr (int, const volatile double *);
14955 vector double vec_madd (vector double, vector double, vector double);
14956 vector double vec_max (vector double, vector double);
14957 vector signed long vec_mergeh (vector signed long, vector signed long);
14958 vector signed long vec_mergeh (vector signed long, vector bool long);
14959 vector signed long vec_mergeh (vector bool long, vector signed long);
14960 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
14961 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
14962 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
14963 vector signed long vec_mergel (vector signed long, vector signed long);
14964 vector signed long vec_mergel (vector signed long, vector bool long);
14965 vector signed long vec_mergel (vector bool long, vector signed long);
14966 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
14967 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
14968 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
14969 vector double vec_min (vector double, vector double);
14970 vector float vec_msub (vector float, vector float, vector float);
14971 vector double vec_msub (vector double, vector double, vector double);
14972 vector float vec_mul (vector float, vector float);
14973 vector double vec_mul (vector double, vector double);
14974 vector long vec_mul (vector long, vector long);
14975 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
14976 vector float vec_nearbyint (vector float);
14977 vector double vec_nearbyint (vector double);
14978 vector float vec_nmadd (vector float, vector float, vector float);
14979 vector double vec_nmadd (vector double, vector double, vector double);
14980 vector double vec_nmsub (vector double, vector double, vector double);
14981 vector double vec_nor (vector double, vector double);
14982 vector long vec_nor (vector long, vector long);
14983 vector long vec_nor (vector long, vector bool long);
14984 vector long vec_nor (vector bool long, vector long);
14985 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
14986 vector unsigned long vec_nor (vector unsigned long, vector bool long);
14987 vector unsigned long vec_nor (vector bool long, vector unsigned long);
14988 vector double vec_or (vector double, vector double);
14989 vector double vec_or (vector double, vector bool long);
14990 vector double vec_or (vector bool long, vector double);
14991 vector long vec_or (vector long, vector long);
14992 vector long vec_or (vector long, vector bool long);
14993 vector long vec_or (vector bool long, vector long);
14994 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
14995 vector unsigned long vec_or (vector unsigned long, vector bool long);
14996 vector unsigned long vec_or (vector bool long, vector unsigned long);
14997 vector double vec_perm (vector double, vector double, vector unsigned char);
14998 vector long vec_perm (vector long, vector long, vector unsigned char);
14999 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15000                                vector unsigned char);
15001 vector double vec_rint (vector double);
15002 vector double vec_recip (vector double, vector double);
15003 vector double vec_rsqrt (vector double);
15004 vector double vec_rsqrte (vector double);
15005 vector double vec_sel (vector double, vector double, vector bool long);
15006 vector double vec_sel (vector double, vector double, vector unsigned long);
15007 vector long vec_sel (vector long, vector long, vector long);
15008 vector long vec_sel (vector long, vector long, vector unsigned long);
15009 vector long vec_sel (vector long, vector long, vector bool long);
15010 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15011                               vector long);
15012 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15013                               vector unsigned long);
15014 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15015                               vector bool long);
15016 vector double vec_splats (double);
15017 vector signed long vec_splats (signed long);
15018 vector unsigned long vec_splats (unsigned long);
15019 vector float vec_sqrt (vector float);
15020 vector double vec_sqrt (vector double);
15021 void vec_st (vector double, int, vector double *);
15022 void vec_st (vector double, int, double *);
15023 vector double vec_sub (vector double, vector double);
15024 vector double vec_trunc (vector double);
15025 vector double vec_xor (vector double, vector double);
15026 vector double vec_xor (vector double, vector bool long);
15027 vector double vec_xor (vector bool long, vector double);
15028 vector long vec_xor (vector long, vector long);
15029 vector long vec_xor (vector long, vector bool long);
15030 vector long vec_xor (vector bool long, vector long);
15031 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15032 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15033 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15034 int vec_all_eq (vector double, vector double);
15035 int vec_all_ge (vector double, vector double);
15036 int vec_all_gt (vector double, vector double);
15037 int vec_all_le (vector double, vector double);
15038 int vec_all_lt (vector double, vector double);
15039 int vec_all_nan (vector double);
15040 int vec_all_ne (vector double, vector double);
15041 int vec_all_nge (vector double, vector double);
15042 int vec_all_ngt (vector double, vector double);
15043 int vec_all_nle (vector double, vector double);
15044 int vec_all_nlt (vector double, vector double);
15045 int vec_all_numeric (vector double);
15046 int vec_any_eq (vector double, vector double);
15047 int vec_any_ge (vector double, vector double);
15048 int vec_any_gt (vector double, vector double);
15049 int vec_any_le (vector double, vector double);
15050 int vec_any_lt (vector double, vector double);
15051 int vec_any_nan (vector double);
15052 int vec_any_ne (vector double, vector double);
15053 int vec_any_nge (vector double, vector double);
15054 int vec_any_ngt (vector double, vector double);
15055 int vec_any_nle (vector double, vector double);
15056 int vec_any_nlt (vector double, vector double);
15057 int vec_any_numeric (vector double);
15059 vector double vec_vsx_ld (int, const vector double *);
15060 vector double vec_vsx_ld (int, const double *);
15061 vector float vec_vsx_ld (int, const vector float *);
15062 vector float vec_vsx_ld (int, const float *);
15063 vector bool int vec_vsx_ld (int, const vector bool int *);
15064 vector signed int vec_vsx_ld (int, const vector signed int *);
15065 vector signed int vec_vsx_ld (int, const int *);
15066 vector signed int vec_vsx_ld (int, const long *);
15067 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15068 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15069 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15070 vector bool short vec_vsx_ld (int, const vector bool short *);
15071 vector pixel vec_vsx_ld (int, const vector pixel *);
15072 vector signed short vec_vsx_ld (int, const vector signed short *);
15073 vector signed short vec_vsx_ld (int, const short *);
15074 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15075 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15076 vector bool char vec_vsx_ld (int, const vector bool char *);
15077 vector signed char vec_vsx_ld (int, const vector signed char *);
15078 vector signed char vec_vsx_ld (int, const signed char *);
15079 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15080 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15082 void vec_vsx_st (vector double, int, vector double *);
15083 void vec_vsx_st (vector double, int, double *);
15084 void vec_vsx_st (vector float, int, vector float *);
15085 void vec_vsx_st (vector float, int, float *);
15086 void vec_vsx_st (vector signed int, int, vector signed int *);
15087 void vec_vsx_st (vector signed int, int, int *);
15088 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15089 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15090 void vec_vsx_st (vector bool int, int, vector bool int *);
15091 void vec_vsx_st (vector bool int, int, unsigned int *);
15092 void vec_vsx_st (vector bool int, int, int *);
15093 void vec_vsx_st (vector signed short, int, vector signed short *);
15094 void vec_vsx_st (vector signed short, int, short *);
15095 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15096 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15097 void vec_vsx_st (vector bool short, int, vector bool short *);
15098 void vec_vsx_st (vector bool short, int, unsigned short *);
15099 void vec_vsx_st (vector pixel, int, vector pixel *);
15100 void vec_vsx_st (vector pixel, int, unsigned short *);
15101 void vec_vsx_st (vector pixel, int, short *);
15102 void vec_vsx_st (vector bool short, int, short *);
15103 void vec_vsx_st (vector signed char, int, vector signed char *);
15104 void vec_vsx_st (vector signed char, int, signed char *);
15105 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15106 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15107 void vec_vsx_st (vector bool char, int, vector bool char *);
15108 void vec_vsx_st (vector bool char, int, unsigned char *);
15109 void vec_vsx_st (vector bool char, int, signed char *);
15111 vector double vec_xxpermdi (vector double, vector double, int);
15112 vector float vec_xxpermdi (vector float, vector float, int);
15113 vector long long vec_xxpermdi (vector long long, vector long long, int);
15114 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15115                                         vector unsigned long long, int);
15116 vector int vec_xxpermdi (vector int, vector int, int);
15117 vector unsigned int vec_xxpermdi (vector unsigned int,
15118                                   vector unsigned int, int);
15119 vector short vec_xxpermdi (vector short, vector short, int);
15120 vector unsigned short vec_xxpermdi (vector unsigned short,
15121                                     vector unsigned short, int);
15122 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15123 vector unsigned char vec_xxpermdi (vector unsigned char,
15124                                    vector unsigned char, int);
15126 vector double vec_xxsldi (vector double, vector double, int);
15127 vector float vec_xxsldi (vector float, vector float, int);
15128 vector long long vec_xxsldi (vector long long, vector long long, int);
15129 vector unsigned long long vec_xxsldi (vector unsigned long long,
15130                                       vector unsigned long long, int);
15131 vector int vec_xxsldi (vector int, vector int, int);
15132 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15133 vector short vec_xxsldi (vector short, vector short, int);
15134 vector unsigned short vec_xxsldi (vector unsigned short,
15135                                   vector unsigned short, int);
15136 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15137 vector unsigned char vec_xxsldi (vector unsigned char,
15138                                  vector unsigned char, int);
15139 @end smallexample
15141 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15142 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15143 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
15144 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15145 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15147 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15148 instruction set is available, the following additional functions are
15149 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
15150 can use @var{vector long} instead of @var{vector long long},
15151 @var{vector bool long} instead of @var{vector bool long long}, and
15152 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15154 @smallexample
15155 vector long long vec_abs (vector long long);
15157 vector long long vec_add (vector long long, vector long long);
15158 vector unsigned long long vec_add (vector unsigned long long,
15159                                    vector unsigned long long);
15161 int vec_all_eq (vector long long, vector long long);
15162 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15163 int vec_all_ge (vector long long, vector long long);
15164 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15165 int vec_all_gt (vector long long, vector long long);
15166 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15167 int vec_all_le (vector long long, vector long long);
15168 int vec_all_le (vector unsigned long long, vector unsigned long long);
15169 int vec_all_lt (vector long long, vector long long);
15170 int vec_all_lt (vector unsigned long long, vector unsigned long long);
15171 int vec_all_ne (vector long long, vector long long);
15172 int vec_all_ne (vector unsigned long long, vector unsigned long long);
15174 int vec_any_eq (vector long long, vector long long);
15175 int vec_any_eq (vector unsigned long long, vector unsigned long long);
15176 int vec_any_ge (vector long long, vector long long);
15177 int vec_any_ge (vector unsigned long long, vector unsigned long long);
15178 int vec_any_gt (vector long long, vector long long);
15179 int vec_any_gt (vector unsigned long long, vector unsigned long long);
15180 int vec_any_le (vector long long, vector long long);
15181 int vec_any_le (vector unsigned long long, vector unsigned long long);
15182 int vec_any_lt (vector long long, vector long long);
15183 int vec_any_lt (vector unsigned long long, vector unsigned long long);
15184 int vec_any_ne (vector long long, vector long long);
15185 int vec_any_ne (vector unsigned long long, vector unsigned long long);
15187 vector long long vec_eqv (vector long long, vector long long);
15188 vector long long vec_eqv (vector bool long long, vector long long);
15189 vector long long vec_eqv (vector long long, vector bool long long);
15190 vector unsigned long long vec_eqv (vector unsigned long long,
15191                                    vector unsigned long long);
15192 vector unsigned long long vec_eqv (vector bool long long,
15193                                    vector unsigned long long);
15194 vector unsigned long long vec_eqv (vector unsigned long long,
15195                                    vector bool long long);
15196 vector int vec_eqv (vector int, vector int);
15197 vector int vec_eqv (vector bool int, vector int);
15198 vector int vec_eqv (vector int, vector bool int);
15199 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15200 vector unsigned int vec_eqv (vector bool unsigned int,
15201                              vector unsigned int);
15202 vector unsigned int vec_eqv (vector unsigned int,
15203                              vector bool unsigned int);
15204 vector short vec_eqv (vector short, vector short);
15205 vector short vec_eqv (vector bool short, vector short);
15206 vector short vec_eqv (vector short, vector bool short);
15207 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15208 vector unsigned short vec_eqv (vector bool unsigned short,
15209                                vector unsigned short);
15210 vector unsigned short vec_eqv (vector unsigned short,
15211                                vector bool unsigned short);
15212 vector signed char vec_eqv (vector signed char, vector signed char);
15213 vector signed char vec_eqv (vector bool signed char, vector signed char);
15214 vector signed char vec_eqv (vector signed char, vector bool signed char);
15215 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15216 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15217 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15219 vector long long vec_max (vector long long, vector long long);
15220 vector unsigned long long vec_max (vector unsigned long long,
15221                                    vector unsigned long long);
15223 vector signed int vec_mergee (vector signed int, vector signed int);
15224 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
15225 vector bool int vec_mergee (vector bool int, vector bool int);
15227 vector signed int vec_mergeo (vector signed int, vector signed int);
15228 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
15229 vector bool int vec_mergeo (vector bool int, vector bool int);
15231 vector long long vec_min (vector long long, vector long long);
15232 vector unsigned long long vec_min (vector unsigned long long,
15233                                    vector unsigned long long);
15235 vector long long vec_nand (vector long long, vector long long);
15236 vector long long vec_nand (vector bool long long, vector long long);
15237 vector long long vec_nand (vector long long, vector bool long long);
15238 vector unsigned long long vec_nand (vector unsigned long long,
15239                                     vector unsigned long long);
15240 vector unsigned long long vec_nand (vector bool long long,
15241                                    vector unsigned long long);
15242 vector unsigned long long vec_nand (vector unsigned long long,
15243                                     vector bool long long);
15244 vector int vec_nand (vector int, vector int);
15245 vector int vec_nand (vector bool int, vector int);
15246 vector int vec_nand (vector int, vector bool int);
15247 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15248 vector unsigned int vec_nand (vector bool unsigned int,
15249                               vector unsigned int);
15250 vector unsigned int vec_nand (vector unsigned int,
15251                               vector bool unsigned int);
15252 vector short vec_nand (vector short, vector short);
15253 vector short vec_nand (vector bool short, vector short);
15254 vector short vec_nand (vector short, vector bool short);
15255 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15256 vector unsigned short vec_nand (vector bool unsigned short,
15257                                 vector unsigned short);
15258 vector unsigned short vec_nand (vector unsigned short,
15259                                 vector bool unsigned short);
15260 vector signed char vec_nand (vector signed char, vector signed char);
15261 vector signed char vec_nand (vector bool signed char, vector signed char);
15262 vector signed char vec_nand (vector signed char, vector bool signed char);
15263 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15264 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15265 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15267 vector long long vec_orc (vector long long, vector long long);
15268 vector long long vec_orc (vector bool long long, vector long long);
15269 vector long long vec_orc (vector long long, vector bool long long);
15270 vector unsigned long long vec_orc (vector unsigned long long,
15271                                    vector unsigned long long);
15272 vector unsigned long long vec_orc (vector bool long long,
15273                                    vector unsigned long long);
15274 vector unsigned long long vec_orc (vector unsigned long long,
15275                                    vector bool long long);
15276 vector int vec_orc (vector int, vector int);
15277 vector int vec_orc (vector bool int, vector int);
15278 vector int vec_orc (vector int, vector bool int);
15279 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15280 vector unsigned int vec_orc (vector bool unsigned int,
15281                              vector unsigned int);
15282 vector unsigned int vec_orc (vector unsigned int,
15283                              vector bool unsigned int);
15284 vector short vec_orc (vector short, vector short);
15285 vector short vec_orc (vector bool short, vector short);
15286 vector short vec_orc (vector short, vector bool short);
15287 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15288 vector unsigned short vec_orc (vector bool unsigned short,
15289                                vector unsigned short);
15290 vector unsigned short vec_orc (vector unsigned short,
15291                                vector bool unsigned short);
15292 vector signed char vec_orc (vector signed char, vector signed char);
15293 vector signed char vec_orc (vector bool signed char, vector signed char);
15294 vector signed char vec_orc (vector signed char, vector bool signed char);
15295 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15296 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15297 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15299 vector int vec_pack (vector long long, vector long long);
15300 vector unsigned int vec_pack (vector unsigned long long,
15301                               vector unsigned long long);
15302 vector bool int vec_pack (vector bool long long, vector bool long long);
15304 vector int vec_packs (vector long long, vector long long);
15305 vector unsigned int vec_packs (vector unsigned long long,
15306                                vector unsigned long long);
15308 vector unsigned int vec_packsu (vector long long, vector long long);
15309 vector unsigned int vec_packsu (vector unsigned long long,
15310                                 vector unsigned long long);
15312 vector long long vec_rl (vector long long,
15313                          vector unsigned long long);
15314 vector long long vec_rl (vector unsigned long long,
15315                          vector unsigned long long);
15317 vector long long vec_sl (vector long long, vector unsigned long long);
15318 vector long long vec_sl (vector unsigned long long,
15319                          vector unsigned long long);
15321 vector long long vec_sr (vector long long, vector unsigned long long);
15322 vector unsigned long long char vec_sr (vector unsigned long long,
15323                                        vector unsigned long long);
15325 vector long long vec_sra (vector long long, vector unsigned long long);
15326 vector unsigned long long vec_sra (vector unsigned long long,
15327                                    vector unsigned long long);
15329 vector long long vec_sub (vector long long, vector long long);
15330 vector unsigned long long vec_sub (vector unsigned long long,
15331                                    vector unsigned long long);
15333 vector long long vec_unpackh (vector int);
15334 vector unsigned long long vec_unpackh (vector unsigned int);
15336 vector long long vec_unpackl (vector int);
15337 vector unsigned long long vec_unpackl (vector unsigned int);
15339 vector long long vec_vaddudm (vector long long, vector long long);
15340 vector long long vec_vaddudm (vector bool long long, vector long long);
15341 vector long long vec_vaddudm (vector long long, vector bool long long);
15342 vector unsigned long long vec_vaddudm (vector unsigned long long,
15343                                        vector unsigned long long);
15344 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15345                                        vector unsigned long long);
15346 vector unsigned long long vec_vaddudm (vector unsigned long long,
15347                                        vector bool unsigned long long);
15349 vector long long vec_vbpermq (vector signed char, vector signed char);
15350 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15352 vector long long vec_cntlz (vector long long);
15353 vector unsigned long long vec_cntlz (vector unsigned long long);
15354 vector int vec_cntlz (vector int);
15355 vector unsigned int vec_cntlz (vector int);
15356 vector short vec_cntlz (vector short);
15357 vector unsigned short vec_cntlz (vector unsigned short);
15358 vector signed char vec_cntlz (vector signed char);
15359 vector unsigned char vec_cntlz (vector unsigned char);
15361 vector long long vec_vclz (vector long long);
15362 vector unsigned long long vec_vclz (vector unsigned long long);
15363 vector int vec_vclz (vector int);
15364 vector unsigned int vec_vclz (vector int);
15365 vector short vec_vclz (vector short);
15366 vector unsigned short vec_vclz (vector unsigned short);
15367 vector signed char vec_vclz (vector signed char);
15368 vector unsigned char vec_vclz (vector unsigned char);
15370 vector signed char vec_vclzb (vector signed char);
15371 vector unsigned char vec_vclzb (vector unsigned char);
15373 vector long long vec_vclzd (vector long long);
15374 vector unsigned long long vec_vclzd (vector unsigned long long);
15376 vector short vec_vclzh (vector short);
15377 vector unsigned short vec_vclzh (vector unsigned short);
15379 vector int vec_vclzw (vector int);
15380 vector unsigned int vec_vclzw (vector int);
15382 vector signed char vec_vgbbd (vector signed char);
15383 vector unsigned char vec_vgbbd (vector unsigned char);
15385 vector long long vec_vmaxsd (vector long long, vector long long);
15387 vector unsigned long long vec_vmaxud (vector unsigned long long,
15388                                       unsigned vector long long);
15390 vector long long vec_vminsd (vector long long, vector long long);
15392 vector unsigned long long vec_vminud (vector long long,
15393                                       vector long long);
15395 vector int vec_vpksdss (vector long long, vector long long);
15396 vector unsigned int vec_vpksdss (vector long long, vector long long);
15398 vector unsigned int vec_vpkudus (vector unsigned long long,
15399                                  vector unsigned long long);
15401 vector int vec_vpkudum (vector long long, vector long long);
15402 vector unsigned int vec_vpkudum (vector unsigned long long,
15403                                  vector unsigned long long);
15404 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15406 vector long long vec_vpopcnt (vector long long);
15407 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15408 vector int vec_vpopcnt (vector int);
15409 vector unsigned int vec_vpopcnt (vector int);
15410 vector short vec_vpopcnt (vector short);
15411 vector unsigned short vec_vpopcnt (vector unsigned short);
15412 vector signed char vec_vpopcnt (vector signed char);
15413 vector unsigned char vec_vpopcnt (vector unsigned char);
15415 vector signed char vec_vpopcntb (vector signed char);
15416 vector unsigned char vec_vpopcntb (vector unsigned char);
15418 vector long long vec_vpopcntd (vector long long);
15419 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15421 vector short vec_vpopcnth (vector short);
15422 vector unsigned short vec_vpopcnth (vector unsigned short);
15424 vector int vec_vpopcntw (vector int);
15425 vector unsigned int vec_vpopcntw (vector int);
15427 vector long long vec_vrld (vector long long, vector unsigned long long);
15428 vector unsigned long long vec_vrld (vector unsigned long long,
15429                                     vector unsigned long long);
15431 vector long long vec_vsld (vector long long, vector unsigned long long);
15432 vector long long vec_vsld (vector unsigned long long,
15433                            vector unsigned long long);
15435 vector long long vec_vsrad (vector long long, vector unsigned long long);
15436 vector unsigned long long vec_vsrad (vector unsigned long long,
15437                                      vector unsigned long long);
15439 vector long long vec_vsrd (vector long long, vector unsigned long long);
15440 vector unsigned long long char vec_vsrd (vector unsigned long long,
15441                                          vector unsigned long long);
15443 vector long long vec_vsubudm (vector long long, vector long long);
15444 vector long long vec_vsubudm (vector bool long long, vector long long);
15445 vector long long vec_vsubudm (vector long long, vector bool long long);
15446 vector unsigned long long vec_vsubudm (vector unsigned long long,
15447                                        vector unsigned long long);
15448 vector unsigned long long vec_vsubudm (vector bool long long,
15449                                        vector unsigned long long);
15450 vector unsigned long long vec_vsubudm (vector unsigned long long,
15451                                        vector bool long long);
15453 vector long long vec_vupkhsw (vector int);
15454 vector unsigned long long vec_vupkhsw (vector unsigned int);
15456 vector long long vec_vupklsw (vector int);
15457 vector unsigned long long vec_vupklsw (vector int);
15458 @end smallexample
15460 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15461 instruction set is available, the following additional functions are
15462 available for 64-bit targets.  New vector types
15463 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
15464 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
15465 builtins.
15467 The normal vector extract, and set operations work on
15468 @var{vector __int128_t} and @var{vector __uint128_t} types,
15469 but the index value must be 0.
15471 @smallexample
15472 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15473 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15475 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
15476 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
15478 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
15479                                 vector __int128_t);
15480 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
15481                                  vector __uint128_t);
15483 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
15484                                 vector __int128_t);
15485 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
15486                                  vector __uint128_t);
15488 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
15489                                 vector __int128_t);
15490 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
15491                                  vector __uint128_t);
15493 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
15494                                 vector __int128_t);
15495 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
15496                                  vector __uint128_t);
15498 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
15499 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
15501 __int128_t vec_vsubuqm (__int128_t, __int128_t);
15502 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
15504 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
15505 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
15506 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
15507 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
15508 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
15509 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
15510 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
15511 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
15512 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
15513 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
15514 @end smallexample
15516 If the cryptographic instructions are enabled (@option{-mcrypto} or
15517 @option{-mcpu=power8}), the following builtins are enabled.
15519 @smallexample
15520 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
15522 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
15523                                                     vector unsigned long long);
15525 vector unsigned long long __builtin_crypto_vcipherlast
15526                                      (vector unsigned long long,
15527                                       vector unsigned long long);
15529 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
15530                                                      vector unsigned long long);
15532 vector unsigned long long __builtin_crypto_vncipherlast
15533                                      (vector unsigned long long,
15534                                       vector unsigned long long);
15536 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
15537                                                 vector unsigned char,
15538                                                 vector unsigned char);
15540 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
15541                                                  vector unsigned short,
15542                                                  vector unsigned short);
15544 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
15545                                                vector unsigned int,
15546                                                vector unsigned int);
15548 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
15549                                                      vector unsigned long long,
15550                                                      vector unsigned long long);
15552 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
15553                                                vector unsigned char);
15555 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15556                                                 vector unsigned short);
15558 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15559                                               vector unsigned int);
15561 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15562                                                     vector unsigned long long);
15564 vector unsigned long long __builtin_crypto_vshasigmad
15565                                (vector unsigned long long, int, int);
15567 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15568                                                  int, int);
15569 @end smallexample
15571 The second argument to the @var{__builtin_crypto_vshasigmad} and
15572 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15573 integer that is 0 or 1.  The third argument to these builtin functions
15574 must be a constant integer in the range of 0 to 15.
15576 @node PowerPC Hardware Transactional Memory Built-in Functions
15577 @subsection PowerPC Hardware Transactional Memory Built-in Functions
15578 GCC provides two interfaces for accessing the Hardware Transactional
15579 Memory (HTM) instructions available on some of the PowerPC family
15580 of processors (eg, POWER8).  The two interfaces come in a low level
15581 interface, consisting of built-in functions specific to PowerPC and a
15582 higher level interface consisting of inline functions that are common
15583 between PowerPC and S/390.
15585 @subsubsection PowerPC HTM Low Level Built-in Functions
15587 The following low level built-in functions are available with
15588 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
15589 They all generate the machine instruction that is part of the name.
15591 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
15592 the full 4-bit condition register value set by their associated hardware
15593 instruction.  The header file @code{htmintrin.h} defines some macros that can
15594 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
15595 returns a simple true or false value depending on whether a transaction was
15596 successfully started or not.  The arguments of the builtins match exactly the
15597 type and order of the associated hardware instruction's operands, except for
15598 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
15599 Refer to the ISA manual for a description of each instruction's operands.
15601 @smallexample
15602 unsigned int __builtin_tbegin (unsigned int)
15603 unsigned int __builtin_tend (unsigned int)
15605 unsigned int __builtin_tabort (unsigned int)
15606 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
15607 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
15608 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
15609 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
15611 unsigned int __builtin_tcheck (void)
15612 unsigned int __builtin_treclaim (unsigned int)
15613 unsigned int __builtin_trechkpt (void)
15614 unsigned int __builtin_tsr (unsigned int)
15615 @end smallexample
15617 In addition to the above HTM built-ins, we have added built-ins for
15618 some common extended mnemonics of the HTM instructions:
15620 @smallexample
15621 unsigned int __builtin_tendall (void)
15622 unsigned int __builtin_tresume (void)
15623 unsigned int __builtin_tsuspend (void)
15624 @end smallexample
15626 The following set of built-in functions are available to gain access
15627 to the HTM specific special purpose registers.
15629 @smallexample
15630 unsigned long __builtin_get_texasr (void)
15631 unsigned long __builtin_get_texasru (void)
15632 unsigned long __builtin_get_tfhar (void)
15633 unsigned long __builtin_get_tfiar (void)
15635 void __builtin_set_texasr (unsigned long);
15636 void __builtin_set_texasru (unsigned long);
15637 void __builtin_set_tfhar (unsigned long);
15638 void __builtin_set_tfiar (unsigned long);
15639 @end smallexample
15641 Example usage of these low level built-in functions may look like:
15643 @smallexample
15644 #include <htmintrin.h>
15646 int num_retries = 10;
15648 while (1)
15649   @{
15650     if (__builtin_tbegin (0))
15651       @{
15652         /* Transaction State Initiated.  */
15653         if (is_locked (lock))
15654           __builtin_tabort (0);
15655         ... transaction code...
15656         __builtin_tend (0);
15657         break;
15658       @}
15659     else
15660       @{
15661         /* Transaction State Failed.  Use locks if the transaction
15662            failure is "persistent" or we've tried too many times.  */
15663         if (num_retries-- <= 0
15664             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
15665           @{
15666             acquire_lock (lock);
15667             ... non transactional fallback path...
15668             release_lock (lock);
15669             break;
15670           @}
15671       @}
15672   @}
15673 @end smallexample
15675 One final built-in function has been added that returns the value of
15676 the 2-bit Transaction State field of the Machine Status Register (MSR)
15677 as stored in @code{CR0}.
15679 @smallexample
15680 unsigned long __builtin_ttest (void)
15681 @end smallexample
15683 This built-in can be used to determine the current transaction state
15684 using the following code example:
15686 @smallexample
15687 #include <htmintrin.h>
15689 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
15691 if (tx_state == _HTM_TRANSACTIONAL)
15692   @{
15693     /* Code to use in transactional state.  */
15694   @}
15695 else if (tx_state == _HTM_NONTRANSACTIONAL)
15696   @{
15697     /* Code to use in non-transactional state.  */
15698   @}
15699 else if (tx_state == _HTM_SUSPENDED)
15700   @{
15701     /* Code to use in transaction suspended state.  */
15702   @}
15703 @end smallexample
15705 @subsubsection PowerPC HTM High Level Inline Functions
15707 The following high level HTM interface is made available by including
15708 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
15709 where CPU is `power8' or later.  This interface is common between PowerPC
15710 and S/390, allowing users to write one HTM source implementation that
15711 can be compiled and executed on either system.
15713 @smallexample
15714 long __TM_simple_begin (void)
15715 long __TM_begin (void* const TM_buff)
15716 long __TM_end (void)
15717 void __TM_abort (void)
15718 void __TM_named_abort (unsigned char const code)
15719 void __TM_resume (void)
15720 void __TM_suspend (void)
15722 long __TM_is_user_abort (void* const TM_buff)
15723 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
15724 long __TM_is_illegal (void* const TM_buff)
15725 long __TM_is_footprint_exceeded (void* const TM_buff)
15726 long __TM_nesting_depth (void* const TM_buff)
15727 long __TM_is_nested_too_deep(void* const TM_buff)
15728 long __TM_is_conflict(void* const TM_buff)
15729 long __TM_is_failure_persistent(void* const TM_buff)
15730 long __TM_failure_address(void* const TM_buff)
15731 long long __TM_failure_code(void* const TM_buff)
15732 @end smallexample
15734 Using these common set of HTM inline functions, we can create
15735 a more portable version of the HTM example in the previous
15736 section that will work on either PowerPC or S/390:
15738 @smallexample
15739 #include <htmxlintrin.h>
15741 int num_retries = 10;
15742 TM_buff_type TM_buff;
15744 while (1)
15745   @{
15746     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
15747       @{
15748         /* Transaction State Initiated.  */
15749         if (is_locked (lock))
15750           __TM_abort ();
15751         ... transaction code...
15752         __TM_end ();
15753         break;
15754       @}
15755     else
15756       @{
15757         /* Transaction State Failed.  Use locks if the transaction
15758            failure is "persistent" or we've tried too many times.  */
15759         if (num_retries-- <= 0
15760             || __TM_is_failure_persistent (TM_buff))
15761           @{
15762             acquire_lock (lock);
15763             ... non transactional fallback path...
15764             release_lock (lock);
15765             break;
15766           @}
15767       @}
15768   @}
15769 @end smallexample
15771 @node RX Built-in Functions
15772 @subsection RX Built-in Functions
15773 GCC supports some of the RX instructions which cannot be expressed in
15774 the C programming language via the use of built-in functions.  The
15775 following functions are supported:
15777 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
15778 Generates the @code{brk} machine instruction.
15779 @end deftypefn
15781 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
15782 Generates the @code{clrpsw} machine instruction to clear the specified
15783 bit in the processor status word.
15784 @end deftypefn
15786 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
15787 Generates the @code{int} machine instruction to generate an interrupt
15788 with the specified value.
15789 @end deftypefn
15791 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
15792 Generates the @code{machi} machine instruction to add the result of
15793 multiplying the top 16 bits of the two arguments into the
15794 accumulator.
15795 @end deftypefn
15797 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
15798 Generates the @code{maclo} machine instruction to add the result of
15799 multiplying the bottom 16 bits of the two arguments into the
15800 accumulator.
15801 @end deftypefn
15803 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
15804 Generates the @code{mulhi} machine instruction to place the result of
15805 multiplying the top 16 bits of the two arguments into the
15806 accumulator.
15807 @end deftypefn
15809 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
15810 Generates the @code{mullo} machine instruction to place the result of
15811 multiplying the bottom 16 bits of the two arguments into the
15812 accumulator.
15813 @end deftypefn
15815 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
15816 Generates the @code{mvfachi} machine instruction to read the top
15817 32 bits of the accumulator.
15818 @end deftypefn
15820 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
15821 Generates the @code{mvfacmi} machine instruction to read the middle
15822 32 bits of the accumulator.
15823 @end deftypefn
15825 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
15826 Generates the @code{mvfc} machine instruction which reads the control
15827 register specified in its argument and returns its value.
15828 @end deftypefn
15830 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
15831 Generates the @code{mvtachi} machine instruction to set the top
15832 32 bits of the accumulator.
15833 @end deftypefn
15835 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
15836 Generates the @code{mvtaclo} machine instruction to set the bottom
15837 32 bits of the accumulator.
15838 @end deftypefn
15840 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
15841 Generates the @code{mvtc} machine instruction which sets control
15842 register number @code{reg} to @code{val}.
15843 @end deftypefn
15845 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
15846 Generates the @code{mvtipl} machine instruction set the interrupt
15847 priority level.
15848 @end deftypefn
15850 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
15851 Generates the @code{racw} machine instruction to round the accumulator
15852 according to the specified mode.
15853 @end deftypefn
15855 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
15856 Generates the @code{revw} machine instruction which swaps the bytes in
15857 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
15858 and also bits 16--23 occupy bits 24--31 and vice versa.
15859 @end deftypefn
15861 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
15862 Generates the @code{rmpa} machine instruction which initiates a
15863 repeated multiply and accumulate sequence.
15864 @end deftypefn
15866 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
15867 Generates the @code{round} machine instruction which returns the
15868 floating-point argument rounded according to the current rounding mode
15869 set in the floating-point status word register.
15870 @end deftypefn
15872 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
15873 Generates the @code{sat} machine instruction which returns the
15874 saturated value of the argument.
15875 @end deftypefn
15877 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
15878 Generates the @code{setpsw} machine instruction to set the specified
15879 bit in the processor status word.
15880 @end deftypefn
15882 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
15883 Generates the @code{wait} machine instruction.
15884 @end deftypefn
15886 @node S/390 System z Built-in Functions
15887 @subsection S/390 System z Built-in Functions
15888 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
15889 Generates the @code{tbegin} machine instruction starting a
15890 non-constraint hardware transaction.  If the parameter is non-NULL the
15891 memory area is used to store the transaction diagnostic buffer and
15892 will be passed as first operand to @code{tbegin}.  This buffer can be
15893 defined using the @code{struct __htm_tdb} C struct defined in
15894 @code{htmintrin.h} and must reside on a double-word boundary.  The
15895 second tbegin operand is set to @code{0xff0c}. This enables
15896 save/restore of all GPRs and disables aborts for FPR and AR
15897 manipulations inside the transaction body.  The condition code set by
15898 the tbegin instruction is returned as integer value.  The tbegin
15899 instruction by definition overwrites the content of all FPRs.  The
15900 compiler will generate code which saves and restores the FPRs.  For
15901 soft-float code it is recommended to used the @code{*_nofloat}
15902 variant.  In order to prevent a TDB from being written it is required
15903 to pass an constant zero value as parameter.  Passing the zero value
15904 through a variable is not sufficient.  Although modifications of
15905 access registers inside the transaction will not trigger an
15906 transaction abort it is not supported to actually modify them.  Access
15907 registers do not get saved when entering a transaction. They will have
15908 undefined state when reaching the abort code.
15909 @end deftypefn
15911 Macros for the possible return codes of tbegin are defined in the
15912 @code{htmintrin.h} header file:
15914 @table @code
15915 @item _HTM_TBEGIN_STARTED
15916 @code{tbegin} has been executed as part of normal processing.  The
15917 transaction body is supposed to be executed.
15918 @item _HTM_TBEGIN_INDETERMINATE
15919 The transaction was aborted due to an indeterminate condition which
15920 might be persistent.
15921 @item _HTM_TBEGIN_TRANSIENT
15922 The transaction aborted due to a transient failure.  The transaction
15923 should be re-executed in that case.
15924 @item _HTM_TBEGIN_PERSISTENT
15925 The transaction aborted due to a persistent failure.  Re-execution
15926 under same circumstances will not be productive.
15927 @end table
15929 @defmac _HTM_FIRST_USER_ABORT_CODE
15930 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
15931 specifies the first abort code which can be used for
15932 @code{__builtin_tabort}.  Values below this threshold are reserved for
15933 machine use.
15934 @end defmac
15936 @deftp {Data type} {struct __htm_tdb}
15937 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
15938 the structure of the transaction diagnostic block as specified in the
15939 Principles of Operation manual chapter 5-91.
15940 @end deftp
15942 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
15943 Same as @code{__builtin_tbegin} but without FPR saves and restores.
15944 Using this variant in code making use of FPRs will leave the FPRs in
15945 undefined state when entering the transaction abort handler code.
15946 @end deftypefn
15948 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
15949 In addition to @code{__builtin_tbegin} a loop for transient failures
15950 is generated.  If tbegin returns a condition code of 2 the transaction
15951 will be retried as often as specified in the second argument.  The
15952 perform processor assist instruction is used to tell the CPU about the
15953 number of fails so far.
15954 @end deftypefn
15956 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
15957 Same as @code{__builtin_tbegin_retry} but without FPR saves and
15958 restores.  Using this variant in code making use of FPRs will leave
15959 the FPRs in undefined state when entering the transaction abort
15960 handler code.
15961 @end deftypefn
15963 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
15964 Generates the @code{tbeginc} machine instruction starting a constraint
15965 hardware transaction.  The second operand is set to @code{0xff08}.
15966 @end deftypefn
15968 @deftypefn {Built-in Function} int __builtin_tend (void)
15969 Generates the @code{tend} machine instruction finishing a transaction
15970 and making the changes visible to other threads.  The condition code
15971 generated by tend is returned as integer value.
15972 @end deftypefn
15974 @deftypefn {Built-in Function} void __builtin_tabort (int)
15975 Generates the @code{tabort} machine instruction with the specified
15976 abort code.  Abort codes from 0 through 255 are reserved and will
15977 result in an error message.
15978 @end deftypefn
15980 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
15981 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
15982 integer parameter is loaded into rX and a value of zero is loaded into
15983 rY.  The integer parameter specifies the number of times the
15984 transaction repeatedly aborted.
15985 @end deftypefn
15987 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
15988 Generates the @code{etnd} machine instruction.  The current nesting
15989 depth is returned as integer value.  For a nesting depth of 0 the code
15990 is not executed as part of an transaction.
15991 @end deftypefn
15993 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
15995 Generates the @code{ntstg} machine instruction.  The second argument
15996 is written to the first arguments location.  The store operation will
15997 not be rolled-back in case of an transaction abort.
15998 @end deftypefn
16000 @node SH Built-in Functions
16001 @subsection SH Built-in Functions
16002 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16003 families of processors:
16005 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16006 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16007 used by system code that manages threads and execution contexts.  The compiler
16008 normally does not generate code that modifies the contents of @samp{GBR} and
16009 thus the value is preserved across function calls.  Changing the @samp{GBR}
16010 value in user code must be done with caution, since the compiler might use
16011 @samp{GBR} in order to access thread local variables.
16013 @end deftypefn
16015 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16016 Returns the value that is currently set in the @samp{GBR} register.
16017 Memory loads and stores that use the thread pointer as a base address are
16018 turned into @samp{GBR} based displacement loads and stores, if possible.
16019 For example:
16020 @smallexample
16021 struct my_tcb
16023    int a, b, c, d, e;
16026 int get_tcb_value (void)
16028   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16029   return ((my_tcb*)__builtin_thread_pointer ())->c;
16032 @end smallexample
16033 @end deftypefn
16035 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16036 Returns the value that is currently set in the @samp{FPSCR} register.
16037 @end deftypefn
16039 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16040 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16041 preserving the current values of the FR, SZ and PR bits.
16042 @end deftypefn
16044 @node SPARC VIS Built-in Functions
16045 @subsection SPARC VIS Built-in Functions
16047 GCC supports SIMD operations on the SPARC using both the generic vector
16048 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16049 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16050 switch, the VIS extension is exposed as the following built-in functions:
16052 @smallexample
16053 typedef int v1si __attribute__ ((vector_size (4)));
16054 typedef int v2si __attribute__ ((vector_size (8)));
16055 typedef short v4hi __attribute__ ((vector_size (8)));
16056 typedef short v2hi __attribute__ ((vector_size (4)));
16057 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16058 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16060 void __builtin_vis_write_gsr (int64_t);
16061 int64_t __builtin_vis_read_gsr (void);
16063 void * __builtin_vis_alignaddr (void *, long);
16064 void * __builtin_vis_alignaddrl (void *, long);
16065 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16066 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16067 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16068 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16070 v4hi __builtin_vis_fexpand (v4qi);
16072 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16073 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16074 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16075 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16076 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16077 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16078 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16080 v4qi __builtin_vis_fpack16 (v4hi);
16081 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16082 v2hi __builtin_vis_fpackfix (v2si);
16083 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16085 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16087 long __builtin_vis_edge8 (void *, void *);
16088 long __builtin_vis_edge8l (void *, void *);
16089 long __builtin_vis_edge16 (void *, void *);
16090 long __builtin_vis_edge16l (void *, void *);
16091 long __builtin_vis_edge32 (void *, void *);
16092 long __builtin_vis_edge32l (void *, void *);
16094 long __builtin_vis_fcmple16 (v4hi, v4hi);
16095 long __builtin_vis_fcmple32 (v2si, v2si);
16096 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16097 long __builtin_vis_fcmpne32 (v2si, v2si);
16098 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16099 long __builtin_vis_fcmpgt32 (v2si, v2si);
16100 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16101 long __builtin_vis_fcmpeq32 (v2si, v2si);
16103 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16104 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16105 v2si __builtin_vis_fpadd32 (v2si, v2si);
16106 v1si __builtin_vis_fpadd32s (v1si, v1si);
16107 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16108 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16109 v2si __builtin_vis_fpsub32 (v2si, v2si);
16110 v1si __builtin_vis_fpsub32s (v1si, v1si);
16112 long __builtin_vis_array8 (long, long);
16113 long __builtin_vis_array16 (long, long);
16114 long __builtin_vis_array32 (long, long);
16115 @end smallexample
16117 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16118 functions also become available:
16120 @smallexample
16121 long __builtin_vis_bmask (long, long);
16122 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16123 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16124 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16125 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16127 long __builtin_vis_edge8n (void *, void *);
16128 long __builtin_vis_edge8ln (void *, void *);
16129 long __builtin_vis_edge16n (void *, void *);
16130 long __builtin_vis_edge16ln (void *, void *);
16131 long __builtin_vis_edge32n (void *, void *);
16132 long __builtin_vis_edge32ln (void *, void *);
16133 @end smallexample
16135 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16136 functions also become available:
16138 @smallexample
16139 void __builtin_vis_cmask8 (long);
16140 void __builtin_vis_cmask16 (long);
16141 void __builtin_vis_cmask32 (long);
16143 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16145 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16146 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16147 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16148 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16149 v2si __builtin_vis_fsll16 (v2si, v2si);
16150 v2si __builtin_vis_fslas16 (v2si, v2si);
16151 v2si __builtin_vis_fsrl16 (v2si, v2si);
16152 v2si __builtin_vis_fsra16 (v2si, v2si);
16154 long __builtin_vis_pdistn (v8qi, v8qi);
16156 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16158 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16159 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16161 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16162 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16163 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16164 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16165 v2si __builtin_vis_fpadds32 (v2si, v2si);
16166 v1si __builtin_vis_fpadds32s (v1si, v1si);
16167 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16168 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16170 long __builtin_vis_fucmple8 (v8qi, v8qi);
16171 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16172 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16173 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16175 float __builtin_vis_fhadds (float, float);
16176 double __builtin_vis_fhaddd (double, double);
16177 float __builtin_vis_fhsubs (float, float);
16178 double __builtin_vis_fhsubd (double, double);
16179 float __builtin_vis_fnhadds (float, float);
16180 double __builtin_vis_fnhaddd (double, double);
16182 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16183 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16184 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16185 @end smallexample
16187 @node SPU Built-in Functions
16188 @subsection SPU Built-in Functions
16190 GCC provides extensions for the SPU processor as described in the
16191 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16192 found at @uref{http://cell.scei.co.jp/} or
16193 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
16194 implementation differs in several ways.
16196 @itemize @bullet
16198 @item
16199 The optional extension of specifying vector constants in parentheses is
16200 not supported.
16202 @item
16203 A vector initializer requires no cast if the vector constant is of the
16204 same type as the variable it is initializing.
16206 @item
16207 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16208 vector type is the default signedness of the base type.  The default
16209 varies depending on the operating system, so a portable program should
16210 always specify the signedness.
16212 @item
16213 By default, the keyword @code{__vector} is added. The macro
16214 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16215 undefined.
16217 @item
16218 GCC allows using a @code{typedef} name as the type specifier for a
16219 vector type.
16221 @item
16222 For C, overloaded functions are implemented with macros so the following
16223 does not work:
16225 @smallexample
16226   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16227 @end smallexample
16229 @noindent
16230 Since @code{spu_add} is a macro, the vector constant in the example
16231 is treated as four separate arguments.  Wrap the entire argument in
16232 parentheses for this to work.
16234 @item
16235 The extended version of @code{__builtin_expect} is not supported.
16237 @end itemize
16239 @emph{Note:} Only the interface described in the aforementioned
16240 specification is supported. Internally, GCC uses built-in functions to
16241 implement the required functionality, but these are not supported and
16242 are subject to change without notice.
16244 @node TI C6X Built-in Functions
16245 @subsection TI C6X Built-in Functions
16247 GCC provides intrinsics to access certain instructions of the TI C6X
16248 processors.  These intrinsics, listed below, are available after
16249 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
16250 to C6X instructions.
16252 @smallexample
16254 int _sadd (int, int)
16255 int _ssub (int, int)
16256 int _sadd2 (int, int)
16257 int _ssub2 (int, int)
16258 long long _mpy2 (int, int)
16259 long long _smpy2 (int, int)
16260 int _add4 (int, int)
16261 int _sub4 (int, int)
16262 int _saddu4 (int, int)
16264 int _smpy (int, int)
16265 int _smpyh (int, int)
16266 int _smpyhl (int, int)
16267 int _smpylh (int, int)
16269 int _sshl (int, int)
16270 int _subc (int, int)
16272 int _avg2 (int, int)
16273 int _avgu4 (int, int)
16275 int _clrr (int, int)
16276 int _extr (int, int)
16277 int _extru (int, int)
16278 int _abs (int)
16279 int _abs2 (int)
16281 @end smallexample
16283 @node TILE-Gx Built-in Functions
16284 @subsection TILE-Gx Built-in Functions
16286 GCC provides intrinsics to access every instruction of the TILE-Gx
16287 processor.  The intrinsics are of the form:
16289 @smallexample
16291 unsigned long long __insn_@var{op} (...)
16293 @end smallexample
16295 Where @var{op} is the name of the instruction.  Refer to the ISA manual
16296 for the complete list of instructions.
16298 GCC also provides intrinsics to directly access the network registers.
16299 The intrinsics are:
16301 @smallexample
16303 unsigned long long __tile_idn0_receive (void)
16304 unsigned long long __tile_idn1_receive (void)
16305 unsigned long long __tile_udn0_receive (void)
16306 unsigned long long __tile_udn1_receive (void)
16307 unsigned long long __tile_udn2_receive (void)
16308 unsigned long long __tile_udn3_receive (void)
16309 void __tile_idn_send (unsigned long long)
16310 void __tile_udn_send (unsigned long long)
16312 @end smallexample
16314 The intrinsic @code{void __tile_network_barrier (void)} is used to
16315 guarantee that no network operations before it are reordered with
16316 those after it.
16318 @node TILEPro Built-in Functions
16319 @subsection TILEPro Built-in Functions
16321 GCC provides intrinsics to access every instruction of the TILEPro
16322 processor.  The intrinsics are of the form:
16324 @smallexample
16326 unsigned __insn_@var{op} (...)
16328 @end smallexample
16330 @noindent
16331 where @var{op} is the name of the instruction.  Refer to the ISA manual
16332 for the complete list of instructions.
16334 GCC also provides intrinsics to directly access the network registers.
16335 The intrinsics are:
16337 @smallexample
16339 unsigned __tile_idn0_receive (void)
16340 unsigned __tile_idn1_receive (void)
16341 unsigned __tile_sn_receive (void)
16342 unsigned __tile_udn0_receive (void)
16343 unsigned __tile_udn1_receive (void)
16344 unsigned __tile_udn2_receive (void)
16345 unsigned __tile_udn3_receive (void)
16346 void __tile_idn_send (unsigned)
16347 void __tile_sn_send (unsigned)
16348 void __tile_udn_send (unsigned)
16350 @end smallexample
16352 The intrinsic @code{void __tile_network_barrier (void)} is used to
16353 guarantee that no network operations before it are reordered with
16354 those after it.
16356 @node x86 Built-in Functions
16357 @subsection x86 Built-in Functions
16359 These built-in functions are available for the x86-32 and x86-64 family
16360 of computers, depending on the command-line switches used.
16362 If you specify command-line switches such as @option{-msse},
16363 the compiler could use the extended instruction sets even if the built-ins
16364 are not used explicitly in the program.  For this reason, applications
16365 that perform run-time CPU detection must compile separate files for each
16366 supported architecture, using the appropriate flags.  In particular,
16367 the file containing the CPU detection code should be compiled without
16368 these options.
16370 The following machine modes are available for use with MMX built-in functions
16371 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
16372 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
16373 vector of eight 8-bit integers.  Some of the built-in functions operate on
16374 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
16376 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
16377 of two 32-bit floating-point values.
16379 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
16380 floating-point values.  Some instructions use a vector of four 32-bit
16381 integers, these use @code{V4SI}.  Finally, some instructions operate on an
16382 entire vector register, interpreting it as a 128-bit integer, these use mode
16383 @code{TI}.
16385 In 64-bit mode, the x86-64 family of processors uses additional built-in
16386 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
16387 floating point and @code{TC} 128-bit complex floating-point values.
16389 The following floating-point built-in functions are available in 64-bit
16390 mode.  All of them implement the function that is part of the name.
16392 @smallexample
16393 __float128 __builtin_fabsq (__float128)
16394 __float128 __builtin_copysignq (__float128, __float128)
16395 @end smallexample
16397 The following built-in function is always available.
16399 @table @code
16400 @item void __builtin_ia32_pause (void)
16401 Generates the @code{pause} machine instruction with a compiler memory
16402 barrier.
16403 @end table
16405 The following floating-point built-in functions are made available in the
16406 64-bit mode.
16408 @table @code
16409 @item __float128 __builtin_infq (void)
16410 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
16411 @findex __builtin_infq
16413 @item __float128 __builtin_huge_valq (void)
16414 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
16415 @findex __builtin_huge_valq
16416 @end table
16418 The following built-in functions are always available and can be used to
16419 check the target platform type.
16421 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
16422 This function runs the CPU detection code to check the type of CPU and the
16423 features supported.  This built-in function needs to be invoked along with the built-in functions
16424 to check CPU type and features, @code{__builtin_cpu_is} and
16425 @code{__builtin_cpu_supports}, only when used in a function that is
16426 executed before any constructors are called.  The CPU detection code is
16427 automatically executed in a very high priority constructor.
16429 For example, this function has to be used in @code{ifunc} resolvers that
16430 check for CPU type using the built-in functions @code{__builtin_cpu_is}
16431 and @code{__builtin_cpu_supports}, or in constructors on targets that
16432 don't support constructor priority.
16433 @smallexample
16435 static void (*resolve_memcpy (void)) (void)
16437   // ifunc resolvers fire before constructors, explicitly call the init
16438   // function.
16439   __builtin_cpu_init ();
16440   if (__builtin_cpu_supports ("ssse3"))
16441     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
16442   else
16443     return default_memcpy;
16446 void *memcpy (void *, const void *, size_t)
16447      __attribute__ ((ifunc ("resolve_memcpy")));
16448 @end smallexample
16450 @end deftypefn
16452 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
16453 This function returns a positive integer if the run-time CPU
16454 is of type @var{cpuname}
16455 and returns @code{0} otherwise. The following CPU names can be detected:
16457 @table @samp
16458 @item intel
16459 Intel CPU.
16461 @item atom
16462 Intel Atom CPU.
16464 @item core2
16465 Intel Core 2 CPU.
16467 @item corei7
16468 Intel Core i7 CPU.
16470 @item nehalem
16471 Intel Core i7 Nehalem CPU.
16473 @item westmere
16474 Intel Core i7 Westmere CPU.
16476 @item sandybridge
16477 Intel Core i7 Sandy Bridge CPU.
16479 @item amd
16480 AMD CPU.
16482 @item amdfam10h
16483 AMD Family 10h CPU.
16485 @item barcelona
16486 AMD Family 10h Barcelona CPU.
16488 @item shanghai
16489 AMD Family 10h Shanghai CPU.
16491 @item istanbul
16492 AMD Family 10h Istanbul CPU.
16494 @item btver1
16495 AMD Family 14h CPU.
16497 @item amdfam15h
16498 AMD Family 15h CPU.
16500 @item bdver1
16501 AMD Family 15h Bulldozer version 1.
16503 @item bdver2
16504 AMD Family 15h Bulldozer version 2.
16506 @item bdver3
16507 AMD Family 15h Bulldozer version 3.
16509 @item bdver4
16510 AMD Family 15h Bulldozer version 4.
16512 @item btver2
16513 AMD Family 16h CPU.
16514 @end table
16516 Here is an example:
16517 @smallexample
16518 if (__builtin_cpu_is ("corei7"))
16519   @{
16520      do_corei7 (); // Core i7 specific implementation.
16521   @}
16522 else
16523   @{
16524      do_generic (); // Generic implementation.
16525   @}
16526 @end smallexample
16527 @end deftypefn
16529 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
16530 This function returns a positive integer if the run-time CPU
16531 supports @var{feature}
16532 and returns @code{0} otherwise. The following features can be detected:
16534 @table @samp
16535 @item cmov
16536 CMOV instruction.
16537 @item mmx
16538 MMX instructions.
16539 @item popcnt
16540 POPCNT instruction.
16541 @item sse
16542 SSE instructions.
16543 @item sse2
16544 SSE2 instructions.
16545 @item sse3
16546 SSE3 instructions.
16547 @item ssse3
16548 SSSE3 instructions.
16549 @item sse4.1
16550 SSE4.1 instructions.
16551 @item sse4.2
16552 SSE4.2 instructions.
16553 @item avx
16554 AVX instructions.
16555 @item avx2
16556 AVX2 instructions.
16557 @item avx512f
16558 AVX512F instructions.
16559 @end table
16561 Here is an example:
16562 @smallexample
16563 if (__builtin_cpu_supports ("popcnt"))
16564   @{
16565      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
16566   @}
16567 else
16568   @{
16569      count = generic_countbits (n); //generic implementation.
16570   @}
16571 @end smallexample
16572 @end deftypefn
16575 The following built-in functions are made available by @option{-mmmx}.
16576 All of them generate the machine instruction that is part of the name.
16578 @smallexample
16579 v8qi __builtin_ia32_paddb (v8qi, v8qi)
16580 v4hi __builtin_ia32_paddw (v4hi, v4hi)
16581 v2si __builtin_ia32_paddd (v2si, v2si)
16582 v8qi __builtin_ia32_psubb (v8qi, v8qi)
16583 v4hi __builtin_ia32_psubw (v4hi, v4hi)
16584 v2si __builtin_ia32_psubd (v2si, v2si)
16585 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
16586 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
16587 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
16588 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
16589 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
16590 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
16591 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
16592 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
16593 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
16594 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
16595 di __builtin_ia32_pand (di, di)
16596 di __builtin_ia32_pandn (di,di)
16597 di __builtin_ia32_por (di, di)
16598 di __builtin_ia32_pxor (di, di)
16599 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
16600 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
16601 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
16602 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
16603 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
16604 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
16605 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
16606 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
16607 v2si __builtin_ia32_punpckhdq (v2si, v2si)
16608 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
16609 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
16610 v2si __builtin_ia32_punpckldq (v2si, v2si)
16611 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
16612 v4hi __builtin_ia32_packssdw (v2si, v2si)
16613 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
16615 v4hi __builtin_ia32_psllw (v4hi, v4hi)
16616 v2si __builtin_ia32_pslld (v2si, v2si)
16617 v1di __builtin_ia32_psllq (v1di, v1di)
16618 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
16619 v2si __builtin_ia32_psrld (v2si, v2si)
16620 v1di __builtin_ia32_psrlq (v1di, v1di)
16621 v4hi __builtin_ia32_psraw (v4hi, v4hi)
16622 v2si __builtin_ia32_psrad (v2si, v2si)
16623 v4hi __builtin_ia32_psllwi (v4hi, int)
16624 v2si __builtin_ia32_pslldi (v2si, int)
16625 v1di __builtin_ia32_psllqi (v1di, int)
16626 v4hi __builtin_ia32_psrlwi (v4hi, int)
16627 v2si __builtin_ia32_psrldi (v2si, int)
16628 v1di __builtin_ia32_psrlqi (v1di, int)
16629 v4hi __builtin_ia32_psrawi (v4hi, int)
16630 v2si __builtin_ia32_psradi (v2si, int)
16632 @end smallexample
16634 The following built-in functions are made available either with
16635 @option{-msse}, or with a combination of @option{-m3dnow} and
16636 @option{-march=athlon}.  All of them generate the machine
16637 instruction that is part of the name.
16639 @smallexample
16640 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
16641 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
16642 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
16643 v1di __builtin_ia32_psadbw (v8qi, v8qi)
16644 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
16645 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
16646 v8qi __builtin_ia32_pminub (v8qi, v8qi)
16647 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
16648 int __builtin_ia32_pmovmskb (v8qi)
16649 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
16650 void __builtin_ia32_movntq (di *, di)
16651 void __builtin_ia32_sfence (void)
16652 @end smallexample
16654 The following built-in functions are available when @option{-msse} is used.
16655 All of them generate the machine instruction that is part of the name.
16657 @smallexample
16658 int __builtin_ia32_comieq (v4sf, v4sf)
16659 int __builtin_ia32_comineq (v4sf, v4sf)
16660 int __builtin_ia32_comilt (v4sf, v4sf)
16661 int __builtin_ia32_comile (v4sf, v4sf)
16662 int __builtin_ia32_comigt (v4sf, v4sf)
16663 int __builtin_ia32_comige (v4sf, v4sf)
16664 int __builtin_ia32_ucomieq (v4sf, v4sf)
16665 int __builtin_ia32_ucomineq (v4sf, v4sf)
16666 int __builtin_ia32_ucomilt (v4sf, v4sf)
16667 int __builtin_ia32_ucomile (v4sf, v4sf)
16668 int __builtin_ia32_ucomigt (v4sf, v4sf)
16669 int __builtin_ia32_ucomige (v4sf, v4sf)
16670 v4sf __builtin_ia32_addps (v4sf, v4sf)
16671 v4sf __builtin_ia32_subps (v4sf, v4sf)
16672 v4sf __builtin_ia32_mulps (v4sf, v4sf)
16673 v4sf __builtin_ia32_divps (v4sf, v4sf)
16674 v4sf __builtin_ia32_addss (v4sf, v4sf)
16675 v4sf __builtin_ia32_subss (v4sf, v4sf)
16676 v4sf __builtin_ia32_mulss (v4sf, v4sf)
16677 v4sf __builtin_ia32_divss (v4sf, v4sf)
16678 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
16679 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
16680 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
16681 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
16682 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
16683 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
16684 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
16685 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
16686 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
16687 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
16688 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
16689 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
16690 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
16691 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
16692 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
16693 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
16694 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
16695 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
16696 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
16697 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
16698 v4sf __builtin_ia32_maxps (v4sf, v4sf)
16699 v4sf __builtin_ia32_maxss (v4sf, v4sf)
16700 v4sf __builtin_ia32_minps (v4sf, v4sf)
16701 v4sf __builtin_ia32_minss (v4sf, v4sf)
16702 v4sf __builtin_ia32_andps (v4sf, v4sf)
16703 v4sf __builtin_ia32_andnps (v4sf, v4sf)
16704 v4sf __builtin_ia32_orps (v4sf, v4sf)
16705 v4sf __builtin_ia32_xorps (v4sf, v4sf)
16706 v4sf __builtin_ia32_movss (v4sf, v4sf)
16707 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
16708 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
16709 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
16710 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
16711 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
16712 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
16713 v2si __builtin_ia32_cvtps2pi (v4sf)
16714 int __builtin_ia32_cvtss2si (v4sf)
16715 v2si __builtin_ia32_cvttps2pi (v4sf)
16716 int __builtin_ia32_cvttss2si (v4sf)
16717 v4sf __builtin_ia32_rcpps (v4sf)
16718 v4sf __builtin_ia32_rsqrtps (v4sf)
16719 v4sf __builtin_ia32_sqrtps (v4sf)
16720 v4sf __builtin_ia32_rcpss (v4sf)
16721 v4sf __builtin_ia32_rsqrtss (v4sf)
16722 v4sf __builtin_ia32_sqrtss (v4sf)
16723 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
16724 void __builtin_ia32_movntps (float *, v4sf)
16725 int __builtin_ia32_movmskps (v4sf)
16726 @end smallexample
16728 The following built-in functions are available when @option{-msse} is used.
16730 @table @code
16731 @item v4sf __builtin_ia32_loadups (float *)
16732 Generates the @code{movups} machine instruction as a load from memory.
16733 @item void __builtin_ia32_storeups (float *, v4sf)
16734 Generates the @code{movups} machine instruction as a store to memory.
16735 @item v4sf __builtin_ia32_loadss (float *)
16736 Generates the @code{movss} machine instruction as a load from memory.
16737 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
16738 Generates the @code{movhps} machine instruction as a load from memory.
16739 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
16740 Generates the @code{movlps} machine instruction as a load from memory
16741 @item void __builtin_ia32_storehps (v2sf *, v4sf)
16742 Generates the @code{movhps} machine instruction as a store to memory.
16743 @item void __builtin_ia32_storelps (v2sf *, v4sf)
16744 Generates the @code{movlps} machine instruction as a store to memory.
16745 @end table
16747 The following built-in functions are available when @option{-msse2} is used.
16748 All of them generate the machine instruction that is part of the name.
16750 @smallexample
16751 int __builtin_ia32_comisdeq (v2df, v2df)
16752 int __builtin_ia32_comisdlt (v2df, v2df)
16753 int __builtin_ia32_comisdle (v2df, v2df)
16754 int __builtin_ia32_comisdgt (v2df, v2df)
16755 int __builtin_ia32_comisdge (v2df, v2df)
16756 int __builtin_ia32_comisdneq (v2df, v2df)
16757 int __builtin_ia32_ucomisdeq (v2df, v2df)
16758 int __builtin_ia32_ucomisdlt (v2df, v2df)
16759 int __builtin_ia32_ucomisdle (v2df, v2df)
16760 int __builtin_ia32_ucomisdgt (v2df, v2df)
16761 int __builtin_ia32_ucomisdge (v2df, v2df)
16762 int __builtin_ia32_ucomisdneq (v2df, v2df)
16763 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
16764 v2df __builtin_ia32_cmpltpd (v2df, v2df)
16765 v2df __builtin_ia32_cmplepd (v2df, v2df)
16766 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
16767 v2df __builtin_ia32_cmpgepd (v2df, v2df)
16768 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
16769 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
16770 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
16771 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
16772 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
16773 v2df __builtin_ia32_cmpngepd (v2df, v2df)
16774 v2df __builtin_ia32_cmpordpd (v2df, v2df)
16775 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
16776 v2df __builtin_ia32_cmpltsd (v2df, v2df)
16777 v2df __builtin_ia32_cmplesd (v2df, v2df)
16778 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
16779 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
16780 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
16781 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
16782 v2df __builtin_ia32_cmpordsd (v2df, v2df)
16783 v2di __builtin_ia32_paddq (v2di, v2di)
16784 v2di __builtin_ia32_psubq (v2di, v2di)
16785 v2df __builtin_ia32_addpd (v2df, v2df)
16786 v2df __builtin_ia32_subpd (v2df, v2df)
16787 v2df __builtin_ia32_mulpd (v2df, v2df)
16788 v2df __builtin_ia32_divpd (v2df, v2df)
16789 v2df __builtin_ia32_addsd (v2df, v2df)
16790 v2df __builtin_ia32_subsd (v2df, v2df)
16791 v2df __builtin_ia32_mulsd (v2df, v2df)
16792 v2df __builtin_ia32_divsd (v2df, v2df)
16793 v2df __builtin_ia32_minpd (v2df, v2df)
16794 v2df __builtin_ia32_maxpd (v2df, v2df)
16795 v2df __builtin_ia32_minsd (v2df, v2df)
16796 v2df __builtin_ia32_maxsd (v2df, v2df)
16797 v2df __builtin_ia32_andpd (v2df, v2df)
16798 v2df __builtin_ia32_andnpd (v2df, v2df)
16799 v2df __builtin_ia32_orpd (v2df, v2df)
16800 v2df __builtin_ia32_xorpd (v2df, v2df)
16801 v2df __builtin_ia32_movsd (v2df, v2df)
16802 v2df __builtin_ia32_unpckhpd (v2df, v2df)
16803 v2df __builtin_ia32_unpcklpd (v2df, v2df)
16804 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
16805 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
16806 v4si __builtin_ia32_paddd128 (v4si, v4si)
16807 v2di __builtin_ia32_paddq128 (v2di, v2di)
16808 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
16809 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
16810 v4si __builtin_ia32_psubd128 (v4si, v4si)
16811 v2di __builtin_ia32_psubq128 (v2di, v2di)
16812 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
16813 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
16814 v2di __builtin_ia32_pand128 (v2di, v2di)
16815 v2di __builtin_ia32_pandn128 (v2di, v2di)
16816 v2di __builtin_ia32_por128 (v2di, v2di)
16817 v2di __builtin_ia32_pxor128 (v2di, v2di)
16818 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
16819 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
16820 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
16821 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
16822 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
16823 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
16824 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
16825 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
16826 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
16827 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
16828 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
16829 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
16830 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
16831 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
16832 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
16833 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
16834 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
16835 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
16836 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
16837 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
16838 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
16839 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
16840 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
16841 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
16842 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
16843 v2df __builtin_ia32_loadupd (double *)
16844 void __builtin_ia32_storeupd (double *, v2df)
16845 v2df __builtin_ia32_loadhpd (v2df, double const *)
16846 v2df __builtin_ia32_loadlpd (v2df, double const *)
16847 int __builtin_ia32_movmskpd (v2df)
16848 int __builtin_ia32_pmovmskb128 (v16qi)
16849 void __builtin_ia32_movnti (int *, int)
16850 void __builtin_ia32_movnti64 (long long int *, long long int)
16851 void __builtin_ia32_movntpd (double *, v2df)
16852 void __builtin_ia32_movntdq (v2df *, v2df)
16853 v4si __builtin_ia32_pshufd (v4si, int)
16854 v8hi __builtin_ia32_pshuflw (v8hi, int)
16855 v8hi __builtin_ia32_pshufhw (v8hi, int)
16856 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
16857 v2df __builtin_ia32_sqrtpd (v2df)
16858 v2df __builtin_ia32_sqrtsd (v2df)
16859 v2df __builtin_ia32_shufpd (v2df, v2df, int)
16860 v2df __builtin_ia32_cvtdq2pd (v4si)
16861 v4sf __builtin_ia32_cvtdq2ps (v4si)
16862 v4si __builtin_ia32_cvtpd2dq (v2df)
16863 v2si __builtin_ia32_cvtpd2pi (v2df)
16864 v4sf __builtin_ia32_cvtpd2ps (v2df)
16865 v4si __builtin_ia32_cvttpd2dq (v2df)
16866 v2si __builtin_ia32_cvttpd2pi (v2df)
16867 v2df __builtin_ia32_cvtpi2pd (v2si)
16868 int __builtin_ia32_cvtsd2si (v2df)
16869 int __builtin_ia32_cvttsd2si (v2df)
16870 long long __builtin_ia32_cvtsd2si64 (v2df)
16871 long long __builtin_ia32_cvttsd2si64 (v2df)
16872 v4si __builtin_ia32_cvtps2dq (v4sf)
16873 v2df __builtin_ia32_cvtps2pd (v4sf)
16874 v4si __builtin_ia32_cvttps2dq (v4sf)
16875 v2df __builtin_ia32_cvtsi2sd (v2df, int)
16876 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
16877 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
16878 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
16879 void __builtin_ia32_clflush (const void *)
16880 void __builtin_ia32_lfence (void)
16881 void __builtin_ia32_mfence (void)
16882 v16qi __builtin_ia32_loaddqu (const char *)
16883 void __builtin_ia32_storedqu (char *, v16qi)
16884 v1di __builtin_ia32_pmuludq (v2si, v2si)
16885 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
16886 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
16887 v4si __builtin_ia32_pslld128 (v4si, v4si)
16888 v2di __builtin_ia32_psllq128 (v2di, v2di)
16889 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
16890 v4si __builtin_ia32_psrld128 (v4si, v4si)
16891 v2di __builtin_ia32_psrlq128 (v2di, v2di)
16892 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
16893 v4si __builtin_ia32_psrad128 (v4si, v4si)
16894 v2di __builtin_ia32_pslldqi128 (v2di, int)
16895 v8hi __builtin_ia32_psllwi128 (v8hi, int)
16896 v4si __builtin_ia32_pslldi128 (v4si, int)
16897 v2di __builtin_ia32_psllqi128 (v2di, int)
16898 v2di __builtin_ia32_psrldqi128 (v2di, int)
16899 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
16900 v4si __builtin_ia32_psrldi128 (v4si, int)
16901 v2di __builtin_ia32_psrlqi128 (v2di, int)
16902 v8hi __builtin_ia32_psrawi128 (v8hi, int)
16903 v4si __builtin_ia32_psradi128 (v4si, int)
16904 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
16905 v2di __builtin_ia32_movq128 (v2di)
16906 @end smallexample
16908 The following built-in functions are available when @option{-msse3} is used.
16909 All of them generate the machine instruction that is part of the name.
16911 @smallexample
16912 v2df __builtin_ia32_addsubpd (v2df, v2df)
16913 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
16914 v2df __builtin_ia32_haddpd (v2df, v2df)
16915 v4sf __builtin_ia32_haddps (v4sf, v4sf)
16916 v2df __builtin_ia32_hsubpd (v2df, v2df)
16917 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
16918 v16qi __builtin_ia32_lddqu (char const *)
16919 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
16920 v4sf __builtin_ia32_movshdup (v4sf)
16921 v4sf __builtin_ia32_movsldup (v4sf)
16922 void __builtin_ia32_mwait (unsigned int, unsigned int)
16923 @end smallexample
16925 The following built-in functions are available when @option{-mssse3} is used.
16926 All of them generate the machine instruction that is part of the name.
16928 @smallexample
16929 v2si __builtin_ia32_phaddd (v2si, v2si)
16930 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
16931 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
16932 v2si __builtin_ia32_phsubd (v2si, v2si)
16933 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
16934 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
16935 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
16936 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
16937 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
16938 v8qi __builtin_ia32_psignb (v8qi, v8qi)
16939 v2si __builtin_ia32_psignd (v2si, v2si)
16940 v4hi __builtin_ia32_psignw (v4hi, v4hi)
16941 v1di __builtin_ia32_palignr (v1di, v1di, int)
16942 v8qi __builtin_ia32_pabsb (v8qi)
16943 v2si __builtin_ia32_pabsd (v2si)
16944 v4hi __builtin_ia32_pabsw (v4hi)
16945 @end smallexample
16947 The following built-in functions are available when @option{-mssse3} is used.
16948 All of them generate the machine instruction that is part of the name.
16950 @smallexample
16951 v4si __builtin_ia32_phaddd128 (v4si, v4si)
16952 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
16953 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
16954 v4si __builtin_ia32_phsubd128 (v4si, v4si)
16955 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
16956 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
16957 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
16958 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
16959 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
16960 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
16961 v4si __builtin_ia32_psignd128 (v4si, v4si)
16962 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
16963 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
16964 v16qi __builtin_ia32_pabsb128 (v16qi)
16965 v4si __builtin_ia32_pabsd128 (v4si)
16966 v8hi __builtin_ia32_pabsw128 (v8hi)
16967 @end smallexample
16969 The following built-in functions are available when @option{-msse4.1} is
16970 used.  All of them generate the machine instruction that is part of the
16971 name.
16973 @smallexample
16974 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
16975 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
16976 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
16977 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
16978 v2df __builtin_ia32_dppd (v2df, v2df, const int)
16979 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
16980 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
16981 v2di __builtin_ia32_movntdqa (v2di *);
16982 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
16983 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
16984 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
16985 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
16986 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
16987 v8hi __builtin_ia32_phminposuw128 (v8hi)
16988 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
16989 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
16990 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
16991 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
16992 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
16993 v4si __builtin_ia32_pminsd128 (v4si, v4si)
16994 v4si __builtin_ia32_pminud128 (v4si, v4si)
16995 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
16996 v4si __builtin_ia32_pmovsxbd128 (v16qi)
16997 v2di __builtin_ia32_pmovsxbq128 (v16qi)
16998 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
16999 v2di __builtin_ia32_pmovsxdq128 (v4si)
17000 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17001 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17002 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17003 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17004 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17005 v2di __builtin_ia32_pmovzxdq128 (v4si)
17006 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17007 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17008 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17009 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17010 int __builtin_ia32_ptestc128 (v2di, v2di)
17011 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17012 int __builtin_ia32_ptestz128 (v2di, v2di)
17013 v2df __builtin_ia32_roundpd (v2df, const int)
17014 v4sf __builtin_ia32_roundps (v4sf, const int)
17015 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17016 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17017 @end smallexample
17019 The following built-in functions are available when @option{-msse4.1} is
17020 used.
17022 @table @code
17023 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17024 Generates the @code{insertps} machine instruction.
17025 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17026 Generates the @code{pextrb} machine instruction.
17027 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17028 Generates the @code{pinsrb} machine instruction.
17029 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17030 Generates the @code{pinsrd} machine instruction.
17031 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
17032 Generates the @code{pinsrq} machine instruction in 64bit mode.
17033 @end table
17035 The following built-in functions are changed to generate new SSE4.1
17036 instructions when @option{-msse4.1} is used.
17038 @table @code
17039 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
17040 Generates the @code{extractps} machine instruction.
17041 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
17042 Generates the @code{pextrd} machine instruction.
17043 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
17044 Generates the @code{pextrq} machine instruction in 64bit mode.
17045 @end table
17047 The following built-in functions are available when @option{-msse4.2} is
17048 used.  All of them generate the machine instruction that is part of the
17049 name.
17051 @smallexample
17052 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
17053 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
17054 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
17055 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
17056 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
17057 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
17058 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
17059 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
17060 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
17061 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
17062 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
17063 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
17064 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
17065 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
17066 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
17067 @end smallexample
17069 The following built-in functions are available when @option{-msse4.2} is
17070 used.
17072 @table @code
17073 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
17074 Generates the @code{crc32b} machine instruction.
17075 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
17076 Generates the @code{crc32w} machine instruction.
17077 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
17078 Generates the @code{crc32l} machine instruction.
17079 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
17080 Generates the @code{crc32q} machine instruction.
17081 @end table
17083 The following built-in functions are changed to generate new SSE4.2
17084 instructions when @option{-msse4.2} is used.
17086 @table @code
17087 @item int __builtin_popcount (unsigned int)
17088 Generates the @code{popcntl} machine instruction.
17089 @item int __builtin_popcountl (unsigned long)
17090 Generates the @code{popcntl} or @code{popcntq} machine instruction,
17091 depending on the size of @code{unsigned long}.
17092 @item int __builtin_popcountll (unsigned long long)
17093 Generates the @code{popcntq} machine instruction.
17094 @end table
17096 The following built-in functions are available when @option{-mavx} is
17097 used. All of them generate the machine instruction that is part of the
17098 name.
17100 @smallexample
17101 v4df __builtin_ia32_addpd256 (v4df,v4df)
17102 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
17103 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
17104 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
17105 v4df __builtin_ia32_andnpd256 (v4df,v4df)
17106 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
17107 v4df __builtin_ia32_andpd256 (v4df,v4df)
17108 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
17109 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
17110 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
17111 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
17112 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
17113 v2df __builtin_ia32_cmppd (v2df,v2df,int)
17114 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
17115 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
17116 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
17117 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
17118 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
17119 v4df __builtin_ia32_cvtdq2pd256 (v4si)
17120 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
17121 v4si __builtin_ia32_cvtpd2dq256 (v4df)
17122 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
17123 v8si __builtin_ia32_cvtps2dq256 (v8sf)
17124 v4df __builtin_ia32_cvtps2pd256 (v4sf)
17125 v4si __builtin_ia32_cvttpd2dq256 (v4df)
17126 v8si __builtin_ia32_cvttps2dq256 (v8sf)
17127 v4df __builtin_ia32_divpd256 (v4df,v4df)
17128 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
17129 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
17130 v4df __builtin_ia32_haddpd256 (v4df,v4df)
17131 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
17132 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
17133 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
17134 v32qi __builtin_ia32_lddqu256 (pcchar)
17135 v32qi __builtin_ia32_loaddqu256 (pcchar)
17136 v4df __builtin_ia32_loadupd256 (pcdouble)
17137 v8sf __builtin_ia32_loadups256 (pcfloat)
17138 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
17139 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
17140 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
17141 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
17142 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
17143 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
17144 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
17145 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
17146 v4df __builtin_ia32_maxpd256 (v4df,v4df)
17147 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
17148 v4df __builtin_ia32_minpd256 (v4df,v4df)
17149 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
17150 v4df __builtin_ia32_movddup256 (v4df)
17151 int __builtin_ia32_movmskpd256 (v4df)
17152 int __builtin_ia32_movmskps256 (v8sf)
17153 v8sf __builtin_ia32_movshdup256 (v8sf)
17154 v8sf __builtin_ia32_movsldup256 (v8sf)
17155 v4df __builtin_ia32_mulpd256 (v4df,v4df)
17156 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
17157 v4df __builtin_ia32_orpd256 (v4df,v4df)
17158 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
17159 v2df __builtin_ia32_pd_pd256 (v4df)
17160 v4df __builtin_ia32_pd256_pd (v2df)
17161 v4sf __builtin_ia32_ps_ps256 (v8sf)
17162 v8sf __builtin_ia32_ps256_ps (v4sf)
17163 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
17164 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
17165 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
17166 v8sf __builtin_ia32_rcpps256 (v8sf)
17167 v4df __builtin_ia32_roundpd256 (v4df,int)
17168 v8sf __builtin_ia32_roundps256 (v8sf,int)
17169 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
17170 v8sf __builtin_ia32_rsqrtps256 (v8sf)
17171 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
17172 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
17173 v4si __builtin_ia32_si_si256 (v8si)
17174 v8si __builtin_ia32_si256_si (v4si)
17175 v4df __builtin_ia32_sqrtpd256 (v4df)
17176 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
17177 v8sf __builtin_ia32_sqrtps256 (v8sf)
17178 void __builtin_ia32_storedqu256 (pchar,v32qi)
17179 void __builtin_ia32_storeupd256 (pdouble,v4df)
17180 void __builtin_ia32_storeups256 (pfloat,v8sf)
17181 v4df __builtin_ia32_subpd256 (v4df,v4df)
17182 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
17183 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
17184 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
17185 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
17186 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
17187 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
17188 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
17189 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
17190 v4sf __builtin_ia32_vbroadcastss (pcfloat)
17191 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
17192 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
17193 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
17194 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
17195 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
17196 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
17197 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
17198 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
17199 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
17200 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
17201 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
17202 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
17203 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
17204 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
17205 v2df __builtin_ia32_vpermilpd (v2df,int)
17206 v4df __builtin_ia32_vpermilpd256 (v4df,int)
17207 v4sf __builtin_ia32_vpermilps (v4sf,int)
17208 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
17209 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
17210 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
17211 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
17212 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
17213 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
17214 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
17215 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
17216 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
17217 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
17218 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
17219 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
17220 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
17221 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
17222 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
17223 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
17224 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
17225 void __builtin_ia32_vzeroall (void)
17226 void __builtin_ia32_vzeroupper (void)
17227 v4df __builtin_ia32_xorpd256 (v4df,v4df)
17228 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
17229 @end smallexample
17231 The following built-in functions are available when @option{-mavx2} is
17232 used. All of them generate the machine instruction that is part of the
17233 name.
17235 @smallexample
17236 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
17237 v32qi __builtin_ia32_pabsb256 (v32qi)
17238 v16hi __builtin_ia32_pabsw256 (v16hi)
17239 v8si __builtin_ia32_pabsd256 (v8si)
17240 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
17241 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
17242 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
17243 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
17244 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
17245 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
17246 v8si __builtin_ia32_paddd256 (v8si,v8si)
17247 v4di __builtin_ia32_paddq256 (v4di,v4di)
17248 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
17249 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
17250 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
17251 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
17252 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
17253 v4di __builtin_ia32_andsi256 (v4di,v4di)
17254 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
17255 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
17256 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
17257 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
17258 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
17259 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
17260 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
17261 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
17262 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
17263 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
17264 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
17265 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
17266 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
17267 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
17268 v8si __builtin_ia32_phaddd256 (v8si,v8si)
17269 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
17270 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
17271 v8si __builtin_ia32_phsubd256 (v8si,v8si)
17272 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
17273 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
17274 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
17275 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
17276 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
17277 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
17278 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
17279 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
17280 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
17281 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
17282 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
17283 v8si __builtin_ia32_pminsd256 (v8si,v8si)
17284 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
17285 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
17286 v8si __builtin_ia32_pminud256 (v8si,v8si)
17287 int __builtin_ia32_pmovmskb256 (v32qi)
17288 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
17289 v8si __builtin_ia32_pmovsxbd256 (v16qi)
17290 v4di __builtin_ia32_pmovsxbq256 (v16qi)
17291 v8si __builtin_ia32_pmovsxwd256 (v8hi)
17292 v4di __builtin_ia32_pmovsxwq256 (v8hi)
17293 v4di __builtin_ia32_pmovsxdq256 (v4si)
17294 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
17295 v8si __builtin_ia32_pmovzxbd256 (v16qi)
17296 v4di __builtin_ia32_pmovzxbq256 (v16qi)
17297 v8si __builtin_ia32_pmovzxwd256 (v8hi)
17298 v4di __builtin_ia32_pmovzxwq256 (v8hi)
17299 v4di __builtin_ia32_pmovzxdq256 (v4si)
17300 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
17301 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
17302 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
17303 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
17304 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
17305 v8si __builtin_ia32_pmulld256 (v8si,v8si)
17306 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
17307 v4di __builtin_ia32_por256 (v4di,v4di)
17308 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
17309 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
17310 v8si __builtin_ia32_pshufd256 (v8si,int)
17311 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
17312 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
17313 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
17314 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
17315 v8si __builtin_ia32_psignd256 (v8si,v8si)
17316 v4di __builtin_ia32_pslldqi256 (v4di,int)
17317 v16hi __builtin_ia32_psllwi256 (16hi,int)
17318 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
17319 v8si __builtin_ia32_pslldi256 (v8si,int)
17320 v8si __builtin_ia32_pslld256(v8si,v4si)
17321 v4di __builtin_ia32_psllqi256 (v4di,int)
17322 v4di __builtin_ia32_psllq256(v4di,v2di)
17323 v16hi __builtin_ia32_psrawi256 (v16hi,int)
17324 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
17325 v8si __builtin_ia32_psradi256 (v8si,int)
17326 v8si __builtin_ia32_psrad256 (v8si,v4si)
17327 v4di __builtin_ia32_psrldqi256 (v4di, int)
17328 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
17329 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
17330 v8si __builtin_ia32_psrldi256 (v8si,int)
17331 v8si __builtin_ia32_psrld256 (v8si,v4si)
17332 v4di __builtin_ia32_psrlqi256 (v4di,int)
17333 v4di __builtin_ia32_psrlq256(v4di,v2di)
17334 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
17335 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
17336 v8si __builtin_ia32_psubd256 (v8si,v8si)
17337 v4di __builtin_ia32_psubq256 (v4di,v4di)
17338 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
17339 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
17340 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
17341 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
17342 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
17343 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
17344 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
17345 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
17346 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
17347 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
17348 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
17349 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
17350 v4di __builtin_ia32_pxor256 (v4di,v4di)
17351 v4di __builtin_ia32_movntdqa256 (pv4di)
17352 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
17353 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
17354 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
17355 v4di __builtin_ia32_vbroadcastsi256 (v2di)
17356 v4si __builtin_ia32_pblendd128 (v4si,v4si)
17357 v8si __builtin_ia32_pblendd256 (v8si,v8si)
17358 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
17359 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
17360 v8si __builtin_ia32_pbroadcastd256 (v4si)
17361 v4di __builtin_ia32_pbroadcastq256 (v2di)
17362 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
17363 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
17364 v4si __builtin_ia32_pbroadcastd128 (v4si)
17365 v2di __builtin_ia32_pbroadcastq128 (v2di)
17366 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
17367 v4df __builtin_ia32_permdf256 (v4df,int)
17368 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
17369 v4di __builtin_ia32_permdi256 (v4di,int)
17370 v4di __builtin_ia32_permti256 (v4di,v4di,int)
17371 v4di __builtin_ia32_extract128i256 (v4di,int)
17372 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
17373 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
17374 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
17375 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
17376 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
17377 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
17378 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
17379 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
17380 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
17381 v8si __builtin_ia32_psllv8si (v8si,v8si)
17382 v4si __builtin_ia32_psllv4si (v4si,v4si)
17383 v4di __builtin_ia32_psllv4di (v4di,v4di)
17384 v2di __builtin_ia32_psllv2di (v2di,v2di)
17385 v8si __builtin_ia32_psrav8si (v8si,v8si)
17386 v4si __builtin_ia32_psrav4si (v4si,v4si)
17387 v8si __builtin_ia32_psrlv8si (v8si,v8si)
17388 v4si __builtin_ia32_psrlv4si (v4si,v4si)
17389 v4di __builtin_ia32_psrlv4di (v4di,v4di)
17390 v2di __builtin_ia32_psrlv2di (v2di,v2di)
17391 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
17392 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
17393 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
17394 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
17395 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
17396 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
17397 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
17398 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
17399 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
17400 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
17401 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
17402 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
17403 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
17404 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
17405 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
17406 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
17407 @end smallexample
17409 The following built-in functions are available when @option{-maes} is
17410 used.  All of them generate the machine instruction that is part of the
17411 name.
17413 @smallexample
17414 v2di __builtin_ia32_aesenc128 (v2di, v2di)
17415 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
17416 v2di __builtin_ia32_aesdec128 (v2di, v2di)
17417 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
17418 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
17419 v2di __builtin_ia32_aesimc128 (v2di)
17420 @end smallexample
17422 The following built-in function is available when @option{-mpclmul} is
17423 used.
17425 @table @code
17426 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
17427 Generates the @code{pclmulqdq} machine instruction.
17428 @end table
17430 The following built-in function is available when @option{-mfsgsbase} is
17431 used.  All of them generate the machine instruction that is part of the
17432 name.
17434 @smallexample
17435 unsigned int __builtin_ia32_rdfsbase32 (void)
17436 unsigned long long __builtin_ia32_rdfsbase64 (void)
17437 unsigned int __builtin_ia32_rdgsbase32 (void)
17438 unsigned long long __builtin_ia32_rdgsbase64 (void)
17439 void _writefsbase_u32 (unsigned int)
17440 void _writefsbase_u64 (unsigned long long)
17441 void _writegsbase_u32 (unsigned int)
17442 void _writegsbase_u64 (unsigned long long)
17443 @end smallexample
17445 The following built-in function is available when @option{-mrdrnd} is
17446 used.  All of them generate the machine instruction that is part of the
17447 name.
17449 @smallexample
17450 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
17451 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
17452 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
17453 @end smallexample
17455 The following built-in functions are available when @option{-msse4a} is used.
17456 All of them generate the machine instruction that is part of the name.
17458 @smallexample
17459 void __builtin_ia32_movntsd (double *, v2df)
17460 void __builtin_ia32_movntss (float *, v4sf)
17461 v2di __builtin_ia32_extrq  (v2di, v16qi)
17462 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
17463 v2di __builtin_ia32_insertq (v2di, v2di)
17464 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
17465 @end smallexample
17467 The following built-in functions are available when @option{-mxop} is used.
17468 @smallexample
17469 v2df __builtin_ia32_vfrczpd (v2df)
17470 v4sf __builtin_ia32_vfrczps (v4sf)
17471 v2df __builtin_ia32_vfrczsd (v2df)
17472 v4sf __builtin_ia32_vfrczss (v4sf)
17473 v4df __builtin_ia32_vfrczpd256 (v4df)
17474 v8sf __builtin_ia32_vfrczps256 (v8sf)
17475 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
17476 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
17477 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
17478 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
17479 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
17480 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
17481 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
17482 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
17483 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
17484 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
17485 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
17486 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
17487 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
17488 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
17489 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17490 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
17491 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
17492 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
17493 v4si __builtin_ia32_vpcomequd (v4si, v4si)
17494 v2di __builtin_ia32_vpcomequq (v2di, v2di)
17495 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
17496 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17497 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
17498 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
17499 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
17500 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
17501 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
17502 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
17503 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
17504 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
17505 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
17506 v4si __builtin_ia32_vpcomged (v4si, v4si)
17507 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
17508 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
17509 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
17510 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
17511 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
17512 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
17513 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
17514 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
17515 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
17516 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
17517 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
17518 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
17519 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
17520 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
17521 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
17522 v4si __builtin_ia32_vpcomled (v4si, v4si)
17523 v2di __builtin_ia32_vpcomleq (v2di, v2di)
17524 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
17525 v4si __builtin_ia32_vpcomleud (v4si, v4si)
17526 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
17527 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
17528 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
17529 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
17530 v4si __builtin_ia32_vpcomltd (v4si, v4si)
17531 v2di __builtin_ia32_vpcomltq (v2di, v2di)
17532 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
17533 v4si __builtin_ia32_vpcomltud (v4si, v4si)
17534 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
17535 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
17536 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
17537 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
17538 v4si __builtin_ia32_vpcomned (v4si, v4si)
17539 v2di __builtin_ia32_vpcomneq (v2di, v2di)
17540 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
17541 v4si __builtin_ia32_vpcomneud (v4si, v4si)
17542 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
17543 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
17544 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
17545 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
17546 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
17547 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
17548 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
17549 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
17550 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
17551 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
17552 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
17553 v4si __builtin_ia32_vphaddbd (v16qi)
17554 v2di __builtin_ia32_vphaddbq (v16qi)
17555 v8hi __builtin_ia32_vphaddbw (v16qi)
17556 v2di __builtin_ia32_vphadddq (v4si)
17557 v4si __builtin_ia32_vphaddubd (v16qi)
17558 v2di __builtin_ia32_vphaddubq (v16qi)
17559 v8hi __builtin_ia32_vphaddubw (v16qi)
17560 v2di __builtin_ia32_vphaddudq (v4si)
17561 v4si __builtin_ia32_vphadduwd (v8hi)
17562 v2di __builtin_ia32_vphadduwq (v8hi)
17563 v4si __builtin_ia32_vphaddwd (v8hi)
17564 v2di __builtin_ia32_vphaddwq (v8hi)
17565 v8hi __builtin_ia32_vphsubbw (v16qi)
17566 v2di __builtin_ia32_vphsubdq (v4si)
17567 v4si __builtin_ia32_vphsubwd (v8hi)
17568 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
17569 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
17570 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
17571 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
17572 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
17573 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
17574 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
17575 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
17576 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
17577 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
17578 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
17579 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
17580 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
17581 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
17582 v4si __builtin_ia32_vprotd (v4si, v4si)
17583 v2di __builtin_ia32_vprotq (v2di, v2di)
17584 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
17585 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
17586 v4si __builtin_ia32_vpshad (v4si, v4si)
17587 v2di __builtin_ia32_vpshaq (v2di, v2di)
17588 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
17589 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
17590 v4si __builtin_ia32_vpshld (v4si, v4si)
17591 v2di __builtin_ia32_vpshlq (v2di, v2di)
17592 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
17593 @end smallexample
17595 The following built-in functions are available when @option{-mfma4} is used.
17596 All of them generate the machine instruction that is part of the name.
17598 @smallexample
17599 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
17600 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
17601 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
17602 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
17603 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
17604 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
17605 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
17606 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
17607 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
17608 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
17609 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
17610 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
17611 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
17612 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
17613 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
17614 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
17615 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
17616 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
17617 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
17618 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
17619 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
17620 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
17621 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
17622 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
17623 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
17624 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
17625 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
17626 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
17627 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
17628 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
17629 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
17630 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
17632 @end smallexample
17634 The following built-in functions are available when @option{-mlwp} is used.
17636 @smallexample
17637 void __builtin_ia32_llwpcb16 (void *);
17638 void __builtin_ia32_llwpcb32 (void *);
17639 void __builtin_ia32_llwpcb64 (void *);
17640 void * __builtin_ia32_llwpcb16 (void);
17641 void * __builtin_ia32_llwpcb32 (void);
17642 void * __builtin_ia32_llwpcb64 (void);
17643 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
17644 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
17645 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
17646 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
17647 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
17648 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
17649 @end smallexample
17651 The following built-in functions are available when @option{-mbmi} is used.
17652 All of them generate the machine instruction that is part of the name.
17653 @smallexample
17654 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
17655 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
17656 @end smallexample
17658 The following built-in functions are available when @option{-mbmi2} is used.
17659 All of them generate the machine instruction that is part of the name.
17660 @smallexample
17661 unsigned int _bzhi_u32 (unsigned int, unsigned int)
17662 unsigned int _pdep_u32 (unsigned int, unsigned int)
17663 unsigned int _pext_u32 (unsigned int, unsigned int)
17664 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
17665 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
17666 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
17667 @end smallexample
17669 The following built-in functions are available when @option{-mlzcnt} is used.
17670 All of them generate the machine instruction that is part of the name.
17671 @smallexample
17672 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
17673 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
17674 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
17675 @end smallexample
17677 The following built-in functions are available when @option{-mfxsr} is used.
17678 All of them generate the machine instruction that is part of the name.
17679 @smallexample
17680 void __builtin_ia32_fxsave (void *)
17681 void __builtin_ia32_fxrstor (void *)
17682 void __builtin_ia32_fxsave64 (void *)
17683 void __builtin_ia32_fxrstor64 (void *)
17684 @end smallexample
17686 The following built-in functions are available when @option{-mxsave} is used.
17687 All of them generate the machine instruction that is part of the name.
17688 @smallexample
17689 void __builtin_ia32_xsave (void *, long long)
17690 void __builtin_ia32_xrstor (void *, long long)
17691 void __builtin_ia32_xsave64 (void *, long long)
17692 void __builtin_ia32_xrstor64 (void *, long long)
17693 @end smallexample
17695 The following built-in functions are available when @option{-mxsaveopt} is used.
17696 All of them generate the machine instruction that is part of the name.
17697 @smallexample
17698 void __builtin_ia32_xsaveopt (void *, long long)
17699 void __builtin_ia32_xsaveopt64 (void *, long long)
17700 @end smallexample
17702 The following built-in functions are available when @option{-mtbm} is used.
17703 Both of them generate the immediate form of the bextr machine instruction.
17704 @smallexample
17705 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
17706 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
17707 @end smallexample
17710 The following built-in functions are available when @option{-m3dnow} is used.
17711 All of them generate the machine instruction that is part of the name.
17713 @smallexample
17714 void __builtin_ia32_femms (void)
17715 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
17716 v2si __builtin_ia32_pf2id (v2sf)
17717 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
17718 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
17719 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
17720 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
17721 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
17722 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
17723 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
17724 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
17725 v2sf __builtin_ia32_pfrcp (v2sf)
17726 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
17727 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
17728 v2sf __builtin_ia32_pfrsqrt (v2sf)
17729 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
17730 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
17731 v2sf __builtin_ia32_pi2fd (v2si)
17732 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
17733 @end smallexample
17735 The following built-in functions are available when both @option{-m3dnow}
17736 and @option{-march=athlon} are used.  All of them generate the machine
17737 instruction that is part of the name.
17739 @smallexample
17740 v2si __builtin_ia32_pf2iw (v2sf)
17741 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
17742 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
17743 v2sf __builtin_ia32_pi2fw (v2si)
17744 v2sf __builtin_ia32_pswapdsf (v2sf)
17745 v2si __builtin_ia32_pswapdsi (v2si)
17746 @end smallexample
17748 The following built-in functions are available when @option{-mrtm} is used
17749 They are used for restricted transactional memory. These are the internal
17750 low level functions. Normally the functions in 
17751 @ref{x86 transactional memory intrinsics} should be used instead.
17753 @smallexample
17754 int __builtin_ia32_xbegin ()
17755 void __builtin_ia32_xend ()
17756 void __builtin_ia32_xabort (status)
17757 int __builtin_ia32_xtest ()
17758 @end smallexample
17760 @node x86 transactional memory intrinsics
17761 @subsection x86 Transactional Memory Intrinsics
17763 These hardware transactional memory intrinsics for x86 allow you to use
17764 memory transactions with RTM (Restricted Transactional Memory).
17765 This support is enabled with the @option{-mrtm} option.
17766 For using HLE (Hardware Lock Elision) see 
17767 @ref{x86 specific memory model extensions for transactional memory} instead.
17769 A memory transaction commits all changes to memory in an atomic way,
17770 as visible to other threads. If the transaction fails it is rolled back
17771 and all side effects discarded.
17773 Generally there is no guarantee that a memory transaction ever succeeds
17774 and suitable fallback code always needs to be supplied.
17776 @deftypefn {RTM Function} {unsigned} _xbegin ()
17777 Start a RTM (Restricted Transactional Memory) transaction. 
17778 Returns @code{_XBEGIN_STARTED} when the transaction
17779 started successfully (note this is not 0, so the constant has to be 
17780 explicitly tested).  
17782 If the transaction aborts, all side-effects 
17783 are undone and an abort code encoded as a bit mask is returned.
17784 The following macros are defined:
17786 @table @code
17787 @item _XABORT_EXPLICIT
17788 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
17789 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
17790 @item _XABORT_RETRY
17791 Transaction retry is possible.
17792 @item _XABORT_CONFLICT
17793 Transaction abort due to a memory conflict with another thread.
17794 @item _XABORT_CAPACITY
17795 Transaction abort due to the transaction using too much memory.
17796 @item _XABORT_DEBUG
17797 Transaction abort due to a debug trap.
17798 @item _XABORT_NESTED
17799 Transaction abort in an inner nested transaction.
17800 @end table
17802 There is no guarantee
17803 any transaction ever succeeds, so there always needs to be a valid
17804 fallback path.
17805 @end deftypefn
17807 @deftypefn {RTM Function} {void} _xend ()
17808 Commit the current transaction. When no transaction is active this faults.
17809 All memory side-effects of the transaction become visible
17810 to other threads in an atomic manner.
17811 @end deftypefn
17813 @deftypefn {RTM Function} {int} _xtest ()
17814 Return a nonzero value if a transaction is currently active, otherwise 0.
17815 @end deftypefn
17817 @deftypefn {RTM Function} {void} _xabort (status)
17818 Abort the current transaction. When no transaction is active this is a no-op.
17819 The @var{status} is an 8-bit constant; its value is encoded in the return 
17820 value from @code{_xbegin}.
17821 @end deftypefn
17823 Here is an example showing handling for @code{_XABORT_RETRY}
17824 and a fallback path for other failures:
17826 @smallexample
17827 #include <immintrin.h>
17829 int n_tries, max_tries;
17830 unsigned status = _XABORT_EXPLICIT;
17833 for (n_tries = 0; n_tries < max_tries; n_tries++) 
17834   @{
17835     status = _xbegin ();
17836     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
17837       break;
17838   @}
17839 if (status == _XBEGIN_STARTED) 
17840   @{
17841     ... transaction code...
17842     _xend ();
17843   @} 
17844 else 
17845   @{
17846     ... non-transactional fallback path...
17847   @}
17848 @end smallexample
17850 @noindent
17851 Note that, in most cases, the transactional and non-transactional code
17852 must synchronize together to ensure consistency.
17854 @node Target Format Checks
17855 @section Format Checks Specific to Particular Target Machines
17857 For some target machines, GCC supports additional options to the
17858 format attribute
17859 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17861 @menu
17862 * Solaris Format Checks::
17863 * Darwin Format Checks::
17864 @end menu
17866 @node Solaris Format Checks
17867 @subsection Solaris Format Checks
17869 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17870 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
17871 conversions, and the two-argument @code{%b} conversion for displaying
17872 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
17874 @node Darwin Format Checks
17875 @subsection Darwin Format Checks
17877 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17878 attribute context.  Declarations made with such attribution are parsed for correct syntax
17879 and format argument types.  However, parsing of the format string itself is currently undefined
17880 and is not carried out by this version of the compiler.
17882 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17883 also be used as format arguments.  Note that the relevant headers are only likely to be
17884 available on Darwin (OSX) installations.  On such installations, the XCode and system
17885 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17886 associated functions.
17888 @node Pragmas
17889 @section Pragmas Accepted by GCC
17890 @cindex pragmas
17891 @cindex @code{#pragma}
17893 GCC supports several types of pragmas, primarily in order to compile
17894 code originally written for other compilers.  Note that in general
17895 we do not recommend the use of pragmas; @xref{Function Attributes},
17896 for further explanation.
17898 @menu
17899 * ARM Pragmas::
17900 * M32C Pragmas::
17901 * MeP Pragmas::
17902 * RS/6000 and PowerPC Pragmas::
17903 * Darwin Pragmas::
17904 * Solaris Pragmas::
17905 * Symbol-Renaming Pragmas::
17906 * Structure-Packing Pragmas::
17907 * Weak Pragmas::
17908 * Diagnostic Pragmas::
17909 * Visibility Pragmas::
17910 * Push/Pop Macro Pragmas::
17911 * Function Specific Option Pragmas::
17912 * Loop-Specific Pragmas::
17913 @end menu
17915 @node ARM Pragmas
17916 @subsection ARM Pragmas
17918 The ARM target defines pragmas for controlling the default addition of
17919 @code{long_call} and @code{short_call} attributes to functions.
17920 @xref{Function Attributes}, for information about the effects of these
17921 attributes.
17923 @table @code
17924 @item long_calls
17925 @cindex pragma, long_calls
17926 Set all subsequent functions to have the @code{long_call} attribute.
17928 @item no_long_calls
17929 @cindex pragma, no_long_calls
17930 Set all subsequent functions to have the @code{short_call} attribute.
17932 @item long_calls_off
17933 @cindex pragma, long_calls_off
17934 Do not affect the @code{long_call} or @code{short_call} attributes of
17935 subsequent functions.
17936 @end table
17938 @node M32C Pragmas
17939 @subsection M32C Pragmas
17941 @table @code
17942 @item GCC memregs @var{number}
17943 @cindex pragma, memregs
17944 Overrides the command-line option @code{-memregs=} for the current
17945 file.  Use with care!  This pragma must be before any function in the
17946 file, and mixing different memregs values in different objects may
17947 make them incompatible.  This pragma is useful when a
17948 performance-critical function uses a memreg for temporary values,
17949 as it may allow you to reduce the number of memregs used.
17951 @item ADDRESS @var{name} @var{address}
17952 @cindex pragma, address
17953 For any declared symbols matching @var{name}, this does three things
17954 to that symbol: it forces the symbol to be located at the given
17955 address (a number), it forces the symbol to be volatile, and it
17956 changes the symbol's scope to be static.  This pragma exists for
17957 compatibility with other compilers, but note that the common
17958 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17959 instead).  Example:
17961 @smallexample
17962 #pragma ADDRESS port3 0x103
17963 char port3;
17964 @end smallexample
17966 @end table
17968 @node MeP Pragmas
17969 @subsection MeP Pragmas
17971 @table @code
17973 @item custom io_volatile (on|off)
17974 @cindex pragma, custom io_volatile
17975 Overrides the command-line option @code{-mio-volatile} for the current
17976 file.  Note that for compatibility with future GCC releases, this
17977 option should only be used once before any @code{io} variables in each
17978 file.
17980 @item GCC coprocessor available @var{registers}
17981 @cindex pragma, coprocessor available
17982 Specifies which coprocessor registers are available to the register
17983 allocator.  @var{registers} may be a single register, register range
17984 separated by ellipses, or comma-separated list of those.  Example:
17986 @smallexample
17987 #pragma GCC coprocessor available $c0...$c10, $c28
17988 @end smallexample
17990 @item GCC coprocessor call_saved @var{registers}
17991 @cindex pragma, coprocessor call_saved
17992 Specifies which coprocessor registers are to be saved and restored by
17993 any function using them.  @var{registers} may be a single register,
17994 register range separated by ellipses, or comma-separated list of
17995 those.  Example:
17997 @smallexample
17998 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17999 @end smallexample
18001 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
18002 @cindex pragma, coprocessor subclass
18003 Creates and defines a register class.  These register classes can be
18004 used by inline @code{asm} constructs.  @var{registers} may be a single
18005 register, register range separated by ellipses, or comma-separated
18006 list of those.  Example:
18008 @smallexample
18009 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
18011 asm ("cpfoo %0" : "=B" (x));
18012 @end smallexample
18014 @item GCC disinterrupt @var{name} , @var{name} @dots{}
18015 @cindex pragma, disinterrupt
18016 For the named functions, the compiler adds code to disable interrupts
18017 for the duration of those functions.  If any functions so named 
18018 are not encountered in the source, a warning is emitted that the pragma is
18019 not used.  Examples:
18021 @smallexample
18022 #pragma disinterrupt foo
18023 #pragma disinterrupt bar, grill
18024 int foo () @{ @dots{} @}
18025 @end smallexample
18027 @item GCC call @var{name} , @var{name} @dots{}
18028 @cindex pragma, call
18029 For the named functions, the compiler always uses a register-indirect
18030 call model when calling the named functions.  Examples:
18032 @smallexample
18033 extern int foo ();
18034 #pragma call foo
18035 @end smallexample
18037 @end table
18039 @node RS/6000 and PowerPC Pragmas
18040 @subsection RS/6000 and PowerPC Pragmas
18042 The RS/6000 and PowerPC targets define one pragma for controlling
18043 whether or not the @code{longcall} attribute is added to function
18044 declarations by default.  This pragma overrides the @option{-mlongcall}
18045 option, but not the @code{longcall} and @code{shortcall} attributes.
18046 @xref{RS/6000 and PowerPC Options}, for more information about when long
18047 calls are and are not necessary.
18049 @table @code
18050 @item longcall (1)
18051 @cindex pragma, longcall
18052 Apply the @code{longcall} attribute to all subsequent function
18053 declarations.
18055 @item longcall (0)
18056 Do not apply the @code{longcall} attribute to subsequent function
18057 declarations.
18058 @end table
18060 @c Describe h8300 pragmas here.
18061 @c Describe sh pragmas here.
18062 @c Describe v850 pragmas here.
18064 @node Darwin Pragmas
18065 @subsection Darwin Pragmas
18067 The following pragmas are available for all architectures running the
18068 Darwin operating system.  These are useful for compatibility with other
18069 Mac OS compilers.
18071 @table @code
18072 @item mark @var{tokens}@dots{}
18073 @cindex pragma, mark
18074 This pragma is accepted, but has no effect.
18076 @item options align=@var{alignment}
18077 @cindex pragma, options align
18078 This pragma sets the alignment of fields in structures.  The values of
18079 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
18080 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
18081 properly; to restore the previous setting, use @code{reset} for the
18082 @var{alignment}.
18084 @item segment @var{tokens}@dots{}
18085 @cindex pragma, segment
18086 This pragma is accepted, but has no effect.
18088 @item unused (@var{var} [, @var{var}]@dots{})
18089 @cindex pragma, unused
18090 This pragma declares variables to be possibly unused.  GCC does not
18091 produce warnings for the listed variables.  The effect is similar to
18092 that of the @code{unused} attribute, except that this pragma may appear
18093 anywhere within the variables' scopes.
18094 @end table
18096 @node Solaris Pragmas
18097 @subsection Solaris Pragmas
18099 The Solaris target supports @code{#pragma redefine_extname}
18100 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
18101 @code{#pragma} directives for compatibility with the system compiler.
18103 @table @code
18104 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
18105 @cindex pragma, align
18107 Increase the minimum alignment of each @var{variable} to @var{alignment}.
18108 This is the same as GCC's @code{aligned} attribute @pxref{Variable
18109 Attributes}).  Macro expansion occurs on the arguments to this pragma
18110 when compiling C and Objective-C@.  It does not currently occur when
18111 compiling C++, but this is a bug which may be fixed in a future
18112 release.
18114 @item fini (@var{function} [, @var{function}]...)
18115 @cindex pragma, fini
18117 This pragma causes each listed @var{function} to be called after
18118 main, or during shared module unloading, by adding a call to the
18119 @code{.fini} section.
18121 @item init (@var{function} [, @var{function}]...)
18122 @cindex pragma, init
18124 This pragma causes each listed @var{function} to be called during
18125 initialization (before @code{main}) or during shared module loading, by
18126 adding a call to the @code{.init} section.
18128 @end table
18130 @node Symbol-Renaming Pragmas
18131 @subsection Symbol-Renaming Pragmas
18133 GCC supports a @code{#pragma} directive that changes the name used in
18134 assembly for a given declaration. While this pragma is supported on all
18135 platforms, it is intended primarily to provide compatibility with the
18136 Solaris system headers. This effect can also be achieved using the asm
18137 labels extension (@pxref{Asm Labels}).
18139 @table @code
18140 @item redefine_extname @var{oldname} @var{newname}
18141 @cindex pragma, redefine_extname
18143 This pragma gives the C function @var{oldname} the assembly symbol
18144 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
18145 is defined if this pragma is available (currently on all platforms).
18146 @end table
18148 This pragma and the asm labels extension interact in a complicated
18149 manner.  Here are some corner cases you may want to be aware of:
18151 @enumerate
18152 @item This pragma silently applies only to declarations with external
18153 linkage.  Asm labels do not have this restriction.
18155 @item In C++, this pragma silently applies only to declarations with
18156 ``C'' linkage.  Again, asm labels do not have this restriction.
18158 @item If either of the ways of changing the assembly name of a
18159 declaration are applied to a declaration whose assembly name has
18160 already been determined (either by a previous use of one of these
18161 features, or because the compiler needed the assembly name in order to
18162 generate code), and the new name is different, a warning issues and
18163 the name does not change.
18165 @item The @var{oldname} used by @code{#pragma redefine_extname} is
18166 always the C-language name.
18167 @end enumerate
18169 @node Structure-Packing Pragmas
18170 @subsection Structure-Packing Pragmas
18172 For compatibility with Microsoft Windows compilers, GCC supports a
18173 set of @code{#pragma} directives that change the maximum alignment of
18174 members of structures (other than zero-width bit-fields), unions, and
18175 classes subsequently defined. The @var{n} value below always is required
18176 to be a small power of two and specifies the new alignment in bytes.
18178 @enumerate
18179 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
18180 @item @code{#pragma pack()} sets the alignment to the one that was in
18181 effect when compilation started (see also command-line option
18182 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
18183 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
18184 setting on an internal stack and then optionally sets the new alignment.
18185 @item @code{#pragma pack(pop)} restores the alignment setting to the one
18186 saved at the top of the internal stack (and removes that stack entry).
18187 Note that @code{#pragma pack([@var{n}])} does not influence this internal
18188 stack; thus it is possible to have @code{#pragma pack(push)} followed by
18189 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
18190 @code{#pragma pack(pop)}.
18191 @end enumerate
18193 Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct}
18194 @code{#pragma} which lays out a structure as the documented
18195 @code{__attribute__ ((ms_struct))}.
18196 @enumerate
18197 @item @code{#pragma ms_struct on} turns on the layout for structures
18198 declared.
18199 @item @code{#pragma ms_struct off} turns off the layout for structures
18200 declared.
18201 @item @code{#pragma ms_struct reset} goes back to the default layout.
18202 @end enumerate
18204 @node Weak Pragmas
18205 @subsection Weak Pragmas
18207 For compatibility with SVR4, GCC supports a set of @code{#pragma}
18208 directives for declaring symbols to be weak, and defining weak
18209 aliases.
18211 @table @code
18212 @item #pragma weak @var{symbol}
18213 @cindex pragma, weak
18214 This pragma declares @var{symbol} to be weak, as if the declaration
18215 had the attribute of the same name.  The pragma may appear before
18216 or after the declaration of @var{symbol}.  It is not an error for
18217 @var{symbol} to never be defined at all.
18219 @item #pragma weak @var{symbol1} = @var{symbol2}
18220 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
18221 It is an error if @var{symbol2} is not defined in the current
18222 translation unit.
18223 @end table
18225 @node Diagnostic Pragmas
18226 @subsection Diagnostic Pragmas
18228 GCC allows the user to selectively enable or disable certain types of
18229 diagnostics, and change the kind of the diagnostic.  For example, a
18230 project's policy might require that all sources compile with
18231 @option{-Werror} but certain files might have exceptions allowing
18232 specific types of warnings.  Or, a project might selectively enable
18233 diagnostics and treat them as errors depending on which preprocessor
18234 macros are defined.
18236 @table @code
18237 @item #pragma GCC diagnostic @var{kind} @var{option}
18238 @cindex pragma, diagnostic
18240 Modifies the disposition of a diagnostic.  Note that not all
18241 diagnostics are modifiable; at the moment only warnings (normally
18242 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
18243 Use @option{-fdiagnostics-show-option} to determine which diagnostics
18244 are controllable and which option controls them.
18246 @var{kind} is @samp{error} to treat this diagnostic as an error,
18247 @samp{warning} to treat it like a warning (even if @option{-Werror} is
18248 in effect), or @samp{ignored} if the diagnostic is to be ignored.
18249 @var{option} is a double quoted string that matches the command-line
18250 option.
18252 @smallexample
18253 #pragma GCC diagnostic warning "-Wformat"
18254 #pragma GCC diagnostic error "-Wformat"
18255 #pragma GCC diagnostic ignored "-Wformat"
18256 @end smallexample
18258 Note that these pragmas override any command-line options.  GCC keeps
18259 track of the location of each pragma, and issues diagnostics according
18260 to the state as of that point in the source file.  Thus, pragmas occurring
18261 after a line do not affect diagnostics caused by that line.
18263 @item #pragma GCC diagnostic push
18264 @itemx #pragma GCC diagnostic pop
18266 Causes GCC to remember the state of the diagnostics as of each
18267 @code{push}, and restore to that point at each @code{pop}.  If a
18268 @code{pop} has no matching @code{push}, the command-line options are
18269 restored.
18271 @smallexample
18272 #pragma GCC diagnostic error "-Wuninitialized"
18273   foo(a);                       /* error is given for this one */
18274 #pragma GCC diagnostic push
18275 #pragma GCC diagnostic ignored "-Wuninitialized"
18276   foo(b);                       /* no diagnostic for this one */
18277 #pragma GCC diagnostic pop
18278   foo(c);                       /* error is given for this one */
18279 #pragma GCC diagnostic pop
18280   foo(d);                       /* depends on command-line options */
18281 @end smallexample
18283 @end table
18285 GCC also offers a simple mechanism for printing messages during
18286 compilation.
18288 @table @code
18289 @item #pragma message @var{string}
18290 @cindex pragma, diagnostic
18292 Prints @var{string} as a compiler message on compilation.  The message
18293 is informational only, and is neither a compilation warning nor an error.
18295 @smallexample
18296 #pragma message "Compiling " __FILE__ "..."
18297 @end smallexample
18299 @var{string} may be parenthesized, and is printed with location
18300 information.  For example,
18302 @smallexample
18303 #define DO_PRAGMA(x) _Pragma (#x)
18304 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
18306 TODO(Remember to fix this)
18307 @end smallexample
18309 @noindent
18310 prints @samp{/tmp/file.c:4: note: #pragma message:
18311 TODO - Remember to fix this}.
18313 @end table
18315 @node Visibility Pragmas
18316 @subsection Visibility Pragmas
18318 @table @code
18319 @item #pragma GCC visibility push(@var{visibility})
18320 @itemx #pragma GCC visibility pop
18321 @cindex pragma, visibility
18323 This pragma allows the user to set the visibility for multiple
18324 declarations without having to give each a visibility attribute
18325 (@pxref{Function Attributes}).
18327 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
18328 declarations.  Class members and template specializations are not
18329 affected; if you want to override the visibility for a particular
18330 member or instantiation, you must use an attribute.
18332 @end table
18335 @node Push/Pop Macro Pragmas
18336 @subsection Push/Pop Macro Pragmas
18338 For compatibility with Microsoft Windows compilers, GCC supports
18339 @samp{#pragma push_macro(@var{"macro_name"})}
18340 and @samp{#pragma pop_macro(@var{"macro_name"})}.
18342 @table @code
18343 @item #pragma push_macro(@var{"macro_name"})
18344 @cindex pragma, push_macro
18345 This pragma saves the value of the macro named as @var{macro_name} to
18346 the top of the stack for this macro.
18348 @item #pragma pop_macro(@var{"macro_name"})
18349 @cindex pragma, pop_macro
18350 This pragma sets the value of the macro named as @var{macro_name} to
18351 the value on top of the stack for this macro. If the stack for
18352 @var{macro_name} is empty, the value of the macro remains unchanged.
18353 @end table
18355 For example:
18357 @smallexample
18358 #define X  1
18359 #pragma push_macro("X")
18360 #undef X
18361 #define X -1
18362 #pragma pop_macro("X")
18363 int x [X];
18364 @end smallexample
18366 @noindent
18367 In this example, the definition of X as 1 is saved by @code{#pragma
18368 push_macro} and restored by @code{#pragma pop_macro}.
18370 @node Function Specific Option Pragmas
18371 @subsection Function Specific Option Pragmas
18373 @table @code
18374 @item #pragma GCC target (@var{"string"}...)
18375 @cindex pragma GCC target
18377 This pragma allows you to set target specific options for functions
18378 defined later in the source file.  One or more strings can be
18379 specified.  Each function that is defined after this point is as
18380 if @code{attribute((target("STRING")))} was specified for that
18381 function.  The parenthesis around the options is optional.
18382 @xref{Function Attributes}, for more information about the
18383 @code{target} attribute and the attribute syntax.
18385 The @code{#pragma GCC target} pragma is presently implemented for
18386 x86, PowerPC, and Nios II targets only.
18387 @end table
18389 @table @code
18390 @item #pragma GCC optimize (@var{"string"}...)
18391 @cindex pragma GCC optimize
18393 This pragma allows you to set global optimization options for functions
18394 defined later in the source file.  One or more strings can be
18395 specified.  Each function that is defined after this point is as
18396 if @code{attribute((optimize("STRING")))} was specified for that
18397 function.  The parenthesis around the options is optional.
18398 @xref{Function Attributes}, for more information about the
18399 @code{optimize} attribute and the attribute syntax.
18400 @end table
18402 @table @code
18403 @item #pragma GCC push_options
18404 @itemx #pragma GCC pop_options
18405 @cindex pragma GCC push_options
18406 @cindex pragma GCC pop_options
18408 These pragmas maintain a stack of the current target and optimization
18409 options.  It is intended for include files where you temporarily want
18410 to switch to using a different @samp{#pragma GCC target} or
18411 @samp{#pragma GCC optimize} and then to pop back to the previous
18412 options.
18413 @end table
18415 @table @code
18416 @item #pragma GCC reset_options
18417 @cindex pragma GCC reset_options
18419 This pragma clears the current @code{#pragma GCC target} and
18420 @code{#pragma GCC optimize} to use the default switches as specified
18421 on the command line.
18422 @end table
18424 @node Loop-Specific Pragmas
18425 @subsection Loop-Specific Pragmas
18427 @table @code
18428 @item #pragma GCC ivdep
18429 @cindex pragma GCC ivdep
18430 @end table
18432 With this pragma, the programmer asserts that there are no loop-carried
18433 dependencies which would prevent consecutive iterations of
18434 the following loop from executing concurrently with SIMD
18435 (single instruction multiple data) instructions.
18437 For example, the compiler can only unconditionally vectorize the following
18438 loop with the pragma:
18440 @smallexample
18441 void foo (int n, int *a, int *b, int *c)
18443   int i, j;
18444 #pragma GCC ivdep
18445   for (i = 0; i < n; ++i)
18446     a[i] = b[i] + c[i];
18448 @end smallexample
18450 @noindent
18451 In this example, using the @code{restrict} qualifier had the same
18452 effect. In the following example, that would not be possible. Assume
18453 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
18454 that it can unconditionally vectorize the following loop:
18456 @smallexample
18457 void ignore_vec_dep (int *a, int k, int c, int m)
18459 #pragma GCC ivdep
18460   for (int i = 0; i < m; i++)
18461     a[i] = a[i + k] * c;
18463 @end smallexample
18466 @node Unnamed Fields
18467 @section Unnamed Structure and Union Fields
18468 @cindex @code{struct}
18469 @cindex @code{union}
18471 As permitted by ISO C11 and for compatibility with other compilers,
18472 GCC allows you to define
18473 a structure or union that contains, as fields, structures and unions
18474 without names.  For example:
18476 @smallexample
18477 struct @{
18478   int a;
18479   union @{
18480     int b;
18481     float c;
18482   @};
18483   int d;
18484 @} foo;
18485 @end smallexample
18487 @noindent
18488 In this example, you are able to access members of the unnamed
18489 union with code like @samp{foo.b}.  Note that only unnamed structs and
18490 unions are allowed, you may not have, for example, an unnamed
18491 @code{int}.
18493 You must never create such structures that cause ambiguous field definitions.
18494 For example, in this structure:
18496 @smallexample
18497 struct @{
18498   int a;
18499   struct @{
18500     int a;
18501   @};
18502 @} foo;
18503 @end smallexample
18505 @noindent
18506 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
18507 The compiler gives errors for such constructs.
18509 @opindex fms-extensions
18510 Unless @option{-fms-extensions} is used, the unnamed field must be a
18511 structure or union definition without a tag (for example, @samp{struct
18512 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
18513 also be a definition with a tag such as @samp{struct foo @{ int a;
18514 @};}, a reference to a previously defined structure or union such as
18515 @samp{struct foo;}, or a reference to a @code{typedef} name for a
18516 previously defined structure or union type.
18518 @opindex fplan9-extensions
18519 The option @option{-fplan9-extensions} enables
18520 @option{-fms-extensions} as well as two other extensions.  First, a
18521 pointer to a structure is automatically converted to a pointer to an
18522 anonymous field for assignments and function calls.  For example:
18524 @smallexample
18525 struct s1 @{ int a; @};
18526 struct s2 @{ struct s1; @};
18527 extern void f1 (struct s1 *);
18528 void f2 (struct s2 *p) @{ f1 (p); @}
18529 @end smallexample
18531 @noindent
18532 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
18533 converted into a pointer to the anonymous field.
18535 Second, when the type of an anonymous field is a @code{typedef} for a
18536 @code{struct} or @code{union}, code may refer to the field using the
18537 name of the @code{typedef}.
18539 @smallexample
18540 typedef struct @{ int a; @} s1;
18541 struct s2 @{ s1; @};
18542 s1 f1 (struct s2 *p) @{ return p->s1; @}
18543 @end smallexample
18545 These usages are only permitted when they are not ambiguous.
18547 @node Thread-Local
18548 @section Thread-Local Storage
18549 @cindex Thread-Local Storage
18550 @cindex @acronym{TLS}
18551 @cindex @code{__thread}
18553 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
18554 are allocated such that there is one instance of the variable per extant
18555 thread.  The runtime model GCC uses to implement this originates
18556 in the IA-64 processor-specific ABI, but has since been migrated
18557 to other processors as well.  It requires significant support from
18558 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
18559 system libraries (@file{libc.so} and @file{libpthread.so}), so it
18560 is not available everywhere.
18562 At the user level, the extension is visible with a new storage
18563 class keyword: @code{__thread}.  For example:
18565 @smallexample
18566 __thread int i;
18567 extern __thread struct state s;
18568 static __thread char *p;
18569 @end smallexample
18571 The @code{__thread} specifier may be used alone, with the @code{extern}
18572 or @code{static} specifiers, but with no other storage class specifier.
18573 When used with @code{extern} or @code{static}, @code{__thread} must appear
18574 immediately after the other storage class specifier.
18576 The @code{__thread} specifier may be applied to any global, file-scoped
18577 static, function-scoped static, or static data member of a class.  It may
18578 not be applied to block-scoped automatic or non-static data member.
18580 When the address-of operator is applied to a thread-local variable, it is
18581 evaluated at run time and returns the address of the current thread's
18582 instance of that variable.  An address so obtained may be used by any
18583 thread.  When a thread terminates, any pointers to thread-local variables
18584 in that thread become invalid.
18586 No static initialization may refer to the address of a thread-local variable.
18588 In C++, if an initializer is present for a thread-local variable, it must
18589 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
18590 standard.
18592 See @uref{http://www.akkadia.org/drepper/tls.pdf,
18593 ELF Handling For Thread-Local Storage} for a detailed explanation of
18594 the four thread-local storage addressing models, and how the runtime
18595 is expected to function.
18597 @menu
18598 * C99 Thread-Local Edits::
18599 * C++98 Thread-Local Edits::
18600 @end menu
18602 @node C99 Thread-Local Edits
18603 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
18605 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
18606 that document the exact semantics of the language extension.
18608 @itemize @bullet
18609 @item
18610 @cite{5.1.2  Execution environments}
18612 Add new text after paragraph 1
18614 @quotation
18615 Within either execution environment, a @dfn{thread} is a flow of
18616 control within a program.  It is implementation defined whether
18617 or not there may be more than one thread associated with a program.
18618 It is implementation defined how threads beyond the first are
18619 created, the name and type of the function called at thread
18620 startup, and how threads may be terminated.  However, objects
18621 with thread storage duration shall be initialized before thread
18622 startup.
18623 @end quotation
18625 @item
18626 @cite{6.2.4  Storage durations of objects}
18628 Add new text before paragraph 3
18630 @quotation
18631 An object whose identifier is declared with the storage-class
18632 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
18633 Its lifetime is the entire execution of the thread, and its
18634 stored value is initialized only once, prior to thread startup.
18635 @end quotation
18637 @item
18638 @cite{6.4.1  Keywords}
18640 Add @code{__thread}.
18642 @item
18643 @cite{6.7.1  Storage-class specifiers}
18645 Add @code{__thread} to the list of storage class specifiers in
18646 paragraph 1.
18648 Change paragraph 2 to
18650 @quotation
18651 With the exception of @code{__thread}, at most one storage-class
18652 specifier may be given [@dots{}].  The @code{__thread} specifier may
18653 be used alone, or immediately following @code{extern} or
18654 @code{static}.
18655 @end quotation
18657 Add new text after paragraph 6
18659 @quotation
18660 The declaration of an identifier for a variable that has
18661 block scope that specifies @code{__thread} shall also
18662 specify either @code{extern} or @code{static}.
18664 The @code{__thread} specifier shall be used only with
18665 variables.
18666 @end quotation
18667 @end itemize
18669 @node C++98 Thread-Local Edits
18670 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18672 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18673 that document the exact semantics of the language extension.
18675 @itemize @bullet
18676 @item
18677 @b{[intro.execution]}
18679 New text after paragraph 4
18681 @quotation
18682 A @dfn{thread} is a flow of control within the abstract machine.
18683 It is implementation defined whether or not there may be more than
18684 one thread.
18685 @end quotation
18687 New text after paragraph 7
18689 @quotation
18690 It is unspecified whether additional action must be taken to
18691 ensure when and whether side effects are visible to other threads.
18692 @end quotation
18694 @item
18695 @b{[lex.key]}
18697 Add @code{__thread}.
18699 @item
18700 @b{[basic.start.main]}
18702 Add after paragraph 5
18704 @quotation
18705 The thread that begins execution at the @code{main} function is called
18706 the @dfn{main thread}.  It is implementation defined how functions
18707 beginning threads other than the main thread are designated or typed.
18708 A function so designated, as well as the @code{main} function, is called
18709 a @dfn{thread startup function}.  It is implementation defined what
18710 happens if a thread startup function returns.  It is implementation
18711 defined what happens to other threads when any thread calls @code{exit}.
18712 @end quotation
18714 @item
18715 @b{[basic.start.init]}
18717 Add after paragraph 4
18719 @quotation
18720 The storage for an object of thread storage duration shall be
18721 statically initialized before the first statement of the thread startup
18722 function.  An object of thread storage duration shall not require
18723 dynamic initialization.
18724 @end quotation
18726 @item
18727 @b{[basic.start.term]}
18729 Add after paragraph 3
18731 @quotation
18732 The type of an object with thread storage duration shall not have a
18733 non-trivial destructor, nor shall it be an array type whose elements
18734 (directly or indirectly) have non-trivial destructors.
18735 @end quotation
18737 @item
18738 @b{[basic.stc]}
18740 Add ``thread storage duration'' to the list in paragraph 1.
18742 Change paragraph 2
18744 @quotation
18745 Thread, static, and automatic storage durations are associated with
18746 objects introduced by declarations [@dots{}].
18747 @end quotation
18749 Add @code{__thread} to the list of specifiers in paragraph 3.
18751 @item
18752 @b{[basic.stc.thread]}
18754 New section before @b{[basic.stc.static]}
18756 @quotation
18757 The keyword @code{__thread} applied to a non-local object gives the
18758 object thread storage duration.
18760 A local variable or class data member declared both @code{static}
18761 and @code{__thread} gives the variable or member thread storage
18762 duration.
18763 @end quotation
18765 @item
18766 @b{[basic.stc.static]}
18768 Change paragraph 1
18770 @quotation
18771 All objects that have neither thread storage duration, dynamic
18772 storage duration nor are local [@dots{}].
18773 @end quotation
18775 @item
18776 @b{[dcl.stc]}
18778 Add @code{__thread} to the list in paragraph 1.
18780 Change paragraph 1
18782 @quotation
18783 With the exception of @code{__thread}, at most one
18784 @var{storage-class-specifier} shall appear in a given
18785 @var{decl-specifier-seq}.  The @code{__thread} specifier may
18786 be used alone, or immediately following the @code{extern} or
18787 @code{static} specifiers.  [@dots{}]
18788 @end quotation
18790 Add after paragraph 5
18792 @quotation
18793 The @code{__thread} specifier can be applied only to the names of objects
18794 and to anonymous unions.
18795 @end quotation
18797 @item
18798 @b{[class.mem]}
18800 Add after paragraph 6
18802 @quotation
18803 Non-@code{static} members shall not be @code{__thread}.
18804 @end quotation
18805 @end itemize
18807 @node Binary constants
18808 @section Binary Constants using the @samp{0b} Prefix
18809 @cindex Binary constants using the @samp{0b} prefix
18811 Integer constants can be written as binary constants, consisting of a
18812 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18813 @samp{0B}.  This is particularly useful in environments that operate a
18814 lot on the bit level (like microcontrollers).
18816 The following statements are identical:
18818 @smallexample
18819 i =       42;
18820 i =     0x2a;
18821 i =      052;
18822 i = 0b101010;
18823 @end smallexample
18825 The type of these constants follows the same rules as for octal or
18826 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18827 can be applied.
18829 @node C++ Extensions
18830 @chapter Extensions to the C++ Language
18831 @cindex extensions, C++ language
18832 @cindex C++ language extensions
18834 The GNU compiler provides these extensions to the C++ language (and you
18835 can also use most of the C language extensions in your C++ programs).  If you
18836 want to write code that checks whether these features are available, you can
18837 test for the GNU compiler the same way as for C programs: check for a
18838 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
18839 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18840 Predefined Macros,cpp,The GNU C Preprocessor}).
18842 @menu
18843 * C++ Volatiles::       What constitutes an access to a volatile object.
18844 * Restricted Pointers:: C99 restricted pointers and references.
18845 * Vague Linkage::       Where G++ puts inlines, vtables and such.
18846 * C++ Interface::       You can use a single C++ header file for both
18847                         declarations and definitions.
18848 * Template Instantiation:: Methods for ensuring that exactly one copy of
18849                         each needed template instantiation is emitted.
18850 * Bound member functions:: You can extract a function pointer to the
18851                         method denoted by a @samp{->*} or @samp{.*} expression.
18852 * C++ Attributes::      Variable, function, and type attributes for C++ only.
18853 * Function Multiversioning::   Declaring multiple function versions.
18854 * Namespace Association:: Strong using-directives for namespace association.
18855 * Type Traits::         Compiler support for type traits
18856 * Java Exceptions::     Tweaking exception handling to work with Java.
18857 * Deprecated Features:: Things will disappear from G++.
18858 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18859 @end menu
18861 @node C++ Volatiles
18862 @section When is a Volatile C++ Object Accessed?
18863 @cindex accessing volatiles
18864 @cindex volatile read
18865 @cindex volatile write
18866 @cindex volatile access
18868 The C++ standard differs from the C standard in its treatment of
18869 volatile objects.  It fails to specify what constitutes a volatile
18870 access, except to say that C++ should behave in a similar manner to C
18871 with respect to volatiles, where possible.  However, the different
18872 lvalueness of expressions between C and C++ complicate the behavior.
18873 G++ behaves the same as GCC for volatile access, @xref{C
18874 Extensions,,Volatiles}, for a description of GCC's behavior.
18876 The C and C++ language specifications differ when an object is
18877 accessed in a void context:
18879 @smallexample
18880 volatile int *src = @var{somevalue};
18881 *src;
18882 @end smallexample
18884 The C++ standard specifies that such expressions do not undergo lvalue
18885 to rvalue conversion, and that the type of the dereferenced object may
18886 be incomplete.  The C++ standard does not specify explicitly that it
18887 is lvalue to rvalue conversion that is responsible for causing an
18888 access.  There is reason to believe that it is, because otherwise
18889 certain simple expressions become undefined.  However, because it
18890 would surprise most programmers, G++ treats dereferencing a pointer to
18891 volatile object of complete type as GCC would do for an equivalent
18892 type in C@.  When the object has incomplete type, G++ issues a
18893 warning; if you wish to force an error, you must force a conversion to
18894 rvalue with, for instance, a static cast.
18896 When using a reference to volatile, G++ does not treat equivalent
18897 expressions as accesses to volatiles, but instead issues a warning that
18898 no volatile is accessed.  The rationale for this is that otherwise it
18899 becomes difficult to determine where volatile access occur, and not
18900 possible to ignore the return value from functions returning volatile
18901 references.  Again, if you wish to force a read, cast the reference to
18902 an rvalue.
18904 G++ implements the same behavior as GCC does when assigning to a
18905 volatile object---there is no reread of the assigned-to object, the
18906 assigned rvalue is reused.  Note that in C++ assignment expressions
18907 are lvalues, and if used as an lvalue, the volatile object is
18908 referred to.  For instance, @var{vref} refers to @var{vobj}, as
18909 expected, in the following example:
18911 @smallexample
18912 volatile int vobj;
18913 volatile int &vref = vobj = @var{something};
18914 @end smallexample
18916 @node Restricted Pointers
18917 @section Restricting Pointer Aliasing
18918 @cindex restricted pointers
18919 @cindex restricted references
18920 @cindex restricted this pointer
18922 As with the C front end, G++ understands the C99 feature of restricted pointers,
18923 specified with the @code{__restrict__}, or @code{__restrict} type
18924 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
18925 language flag, @code{restrict} is not a keyword in C++.
18927 In addition to allowing restricted pointers, you can specify restricted
18928 references, which indicate that the reference is not aliased in the local
18929 context.
18931 @smallexample
18932 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18934   /* @r{@dots{}} */
18936 @end smallexample
18938 @noindent
18939 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18940 @var{rref} refers to a (different) unaliased integer.
18942 You may also specify whether a member function's @var{this} pointer is
18943 unaliased by using @code{__restrict__} as a member function qualifier.
18945 @smallexample
18946 void T::fn () __restrict__
18948   /* @r{@dots{}} */
18950 @end smallexample
18952 @noindent
18953 Within the body of @code{T::fn}, @var{this} has the effective
18954 definition @code{T *__restrict__ const this}.  Notice that the
18955 interpretation of a @code{__restrict__} member function qualifier is
18956 different to that of @code{const} or @code{volatile} qualifier, in that it
18957 is applied to the pointer rather than the object.  This is consistent with
18958 other compilers that implement restricted pointers.
18960 As with all outermost parameter qualifiers, @code{__restrict__} is
18961 ignored in function definition matching.  This means you only need to
18962 specify @code{__restrict__} in a function definition, rather than
18963 in a function prototype as well.
18965 @node Vague Linkage
18966 @section Vague Linkage
18967 @cindex vague linkage
18969 There are several constructs in C++ that require space in the object
18970 file but are not clearly tied to a single translation unit.  We say that
18971 these constructs have ``vague linkage''.  Typically such constructs are
18972 emitted wherever they are needed, though sometimes we can be more
18973 clever.
18975 @table @asis
18976 @item Inline Functions
18977 Inline functions are typically defined in a header file which can be
18978 included in many different compilations.  Hopefully they can usually be
18979 inlined, but sometimes an out-of-line copy is necessary, if the address
18980 of the function is taken or if inlining fails.  In general, we emit an
18981 out-of-line copy in all translation units where one is needed.  As an
18982 exception, we only emit inline virtual functions with the vtable, since
18983 it always requires a copy.
18985 Local static variables and string constants used in an inline function
18986 are also considered to have vague linkage, since they must be shared
18987 between all inlined and out-of-line instances of the function.
18989 @item VTables
18990 @cindex vtable
18991 C++ virtual functions are implemented in most compilers using a lookup
18992 table, known as a vtable.  The vtable contains pointers to the virtual
18993 functions provided by a class, and each object of the class contains a
18994 pointer to its vtable (or vtables, in some multiple-inheritance
18995 situations).  If the class declares any non-inline, non-pure virtual
18996 functions, the first one is chosen as the ``key method'' for the class,
18997 and the vtable is only emitted in the translation unit where the key
18998 method is defined.
19000 @emph{Note:} If the chosen key method is later defined as inline, the
19001 vtable is still emitted in every translation unit that defines it.
19002 Make sure that any inline virtuals are declared inline in the class
19003 body, even if they are not defined there.
19005 @item @code{type_info} objects
19006 @cindex @code{type_info}
19007 @cindex RTTI
19008 C++ requires information about types to be written out in order to
19009 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
19010 For polymorphic classes (classes with virtual functions), the @samp{type_info}
19011 object is written out along with the vtable so that @samp{dynamic_cast}
19012 can determine the dynamic type of a class object at run time.  For all
19013 other types, we write out the @samp{type_info} object when it is used: when
19014 applying @samp{typeid} to an expression, throwing an object, or
19015 referring to a type in a catch clause or exception specification.
19017 @item Template Instantiations
19018 Most everything in this section also applies to template instantiations,
19019 but there are other options as well.
19020 @xref{Template Instantiation,,Where's the Template?}.
19022 @end table
19024 When used with GNU ld version 2.8 or later on an ELF system such as
19025 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
19026 these constructs will be discarded at link time.  This is known as
19027 COMDAT support.
19029 On targets that don't support COMDAT, but do support weak symbols, GCC
19030 uses them.  This way one copy overrides all the others, but
19031 the unused copies still take up space in the executable.
19033 For targets that do not support either COMDAT or weak symbols,
19034 most entities with vague linkage are emitted as local symbols to
19035 avoid duplicate definition errors from the linker.  This does not happen
19036 for local statics in inlines, however, as having multiple copies
19037 almost certainly breaks things.
19039 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
19040 another way to control placement of these constructs.
19042 @node C++ Interface
19043 @section C++ Interface and Implementation Pragmas
19045 @cindex interface and implementation headers, C++
19046 @cindex C++ interface and implementation headers
19047 @cindex pragmas, interface and implementation
19049 @code{#pragma interface} and @code{#pragma implementation} provide the
19050 user with a way of explicitly directing the compiler to emit entities
19051 with vague linkage (and debugging information) in a particular
19052 translation unit.
19054 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
19055 by COMDAT support and the ``key method'' heuristic
19056 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
19057 program to grow due to unnecessary out-of-line copies of inline
19058 functions.
19060 @table @code
19061 @item #pragma interface
19062 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
19063 @kindex #pragma interface
19064 Use this directive in @emph{header files} that define object classes, to save
19065 space in most of the object files that use those classes.  Normally,
19066 local copies of certain information (backup copies of inline member
19067 functions, debugging information, and the internal tables that implement
19068 virtual functions) must be kept in each object file that includes class
19069 definitions.  You can use this pragma to avoid such duplication.  When a
19070 header file containing @samp{#pragma interface} is included in a
19071 compilation, this auxiliary information is not generated (unless
19072 the main input source file itself uses @samp{#pragma implementation}).
19073 Instead, the object files contain references to be resolved at link
19074 time.
19076 The second form of this directive is useful for the case where you have
19077 multiple headers with the same name in different directories.  If you
19078 use this form, you must specify the same string to @samp{#pragma
19079 implementation}.
19081 @item #pragma implementation
19082 @itemx #pragma implementation "@var{objects}.h"
19083 @kindex #pragma implementation
19084 Use this pragma in a @emph{main input file}, when you want full output from
19085 included header files to be generated (and made globally visible).  The
19086 included header file, in turn, should use @samp{#pragma interface}.
19087 Backup copies of inline member functions, debugging information, and the
19088 internal tables used to implement virtual functions are all generated in
19089 implementation files.
19091 @cindex implied @code{#pragma implementation}
19092 @cindex @code{#pragma implementation}, implied
19093 @cindex naming convention, implementation headers
19094 If you use @samp{#pragma implementation} with no argument, it applies to
19095 an include file with the same basename@footnote{A file's @dfn{basename}
19096 is the name stripped of all leading path information and of trailing
19097 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
19098 file.  For example, in @file{allclass.cc}, giving just
19099 @samp{#pragma implementation}
19100 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
19102 Use the string argument if you want a single implementation file to
19103 include code from multiple header files.  (You must also use
19104 @samp{#include} to include the header file; @samp{#pragma
19105 implementation} only specifies how to use the file---it doesn't actually
19106 include it.)
19108 There is no way to split up the contents of a single header file into
19109 multiple implementation files.
19110 @end table
19112 @cindex inlining and C++ pragmas
19113 @cindex C++ pragmas, effect on inlining
19114 @cindex pragmas in C++, effect on inlining
19115 @samp{#pragma implementation} and @samp{#pragma interface} also have an
19116 effect on function inlining.
19118 If you define a class in a header file marked with @samp{#pragma
19119 interface}, the effect on an inline function defined in that class is
19120 similar to an explicit @code{extern} declaration---the compiler emits
19121 no code at all to define an independent version of the function.  Its
19122 definition is used only for inlining with its callers.
19124 @opindex fno-implement-inlines
19125 Conversely, when you include the same header file in a main source file
19126 that declares it as @samp{#pragma implementation}, the compiler emits
19127 code for the function itself; this defines a version of the function
19128 that can be found via pointers (or by callers compiled without
19129 inlining).  If all calls to the function can be inlined, you can avoid
19130 emitting the function by compiling with @option{-fno-implement-inlines}.
19131 If any calls are not inlined, you will get linker errors.
19133 @node Template Instantiation
19134 @section Where's the Template?
19135 @cindex template instantiation
19137 C++ templates are the first language feature to require more
19138 intelligence from the environment than one usually finds on a UNIX
19139 system.  Somehow the compiler and linker have to make sure that each
19140 template instance occurs exactly once in the executable if it is needed,
19141 and not at all otherwise.  There are two basic approaches to this
19142 problem, which are referred to as the Borland model and the Cfront model.
19144 @table @asis
19145 @item Borland model
19146 Borland C++ solved the template instantiation problem by adding the code
19147 equivalent of common blocks to their linker; the compiler emits template
19148 instances in each translation unit that uses them, and the linker
19149 collapses them together.  The advantage of this model is that the linker
19150 only has to consider the object files themselves; there is no external
19151 complexity to worry about.  This disadvantage is that compilation time
19152 is increased because the template code is being compiled repeatedly.
19153 Code written for this model tends to include definitions of all
19154 templates in the header file, since they must be seen to be
19155 instantiated.
19157 @item Cfront model
19158 The AT&T C++ translator, Cfront, solved the template instantiation
19159 problem by creating the notion of a template repository, an
19160 automatically maintained place where template instances are stored.  A
19161 more modern version of the repository works as follows: As individual
19162 object files are built, the compiler places any template definitions and
19163 instantiations encountered in the repository.  At link time, the link
19164 wrapper adds in the objects in the repository and compiles any needed
19165 instances that were not previously emitted.  The advantages of this
19166 model are more optimal compilation speed and the ability to use the
19167 system linker; to implement the Borland model a compiler vendor also
19168 needs to replace the linker.  The disadvantages are vastly increased
19169 complexity, and thus potential for error; for some code this can be
19170 just as transparent, but in practice it can been very difficult to build
19171 multiple programs in one directory and one program in multiple
19172 directories.  Code written for this model tends to separate definitions
19173 of non-inline member templates into a separate file, which should be
19174 compiled separately.
19175 @end table
19177 When used with GNU ld version 2.8 or later on an ELF system such as
19178 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
19179 Borland model.  On other systems, G++ implements neither automatic
19180 model.
19182 You have the following options for dealing with template instantiations:
19184 @enumerate
19185 @item
19186 @opindex frepo
19187 Compile your template-using code with @option{-frepo}.  The compiler
19188 generates files with the extension @samp{.rpo} listing all of the
19189 template instantiations used in the corresponding object files that
19190 could be instantiated there; the link wrapper, @samp{collect2},
19191 then updates the @samp{.rpo} files to tell the compiler where to place
19192 those instantiations and rebuild any affected object files.  The
19193 link-time overhead is negligible after the first pass, as the compiler
19194 continues to place the instantiations in the same files.
19196 This is your best option for application code written for the Borland
19197 model, as it just works.  Code written for the Cfront model 
19198 needs to be modified so that the template definitions are available at
19199 one or more points of instantiation; usually this is as simple as adding
19200 @code{#include <tmethods.cc>} to the end of each template header.
19202 For library code, if you want the library to provide all of the template
19203 instantiations it needs, just try to link all of its object files
19204 together; the link will fail, but cause the instantiations to be
19205 generated as a side effect.  Be warned, however, that this may cause
19206 conflicts if multiple libraries try to provide the same instantiations.
19207 For greater control, use explicit instantiation as described in the next
19208 option.
19210 @item
19211 @opindex fno-implicit-templates
19212 Compile your code with @option{-fno-implicit-templates} to disable the
19213 implicit generation of template instances, and explicitly instantiate
19214 all the ones you use.  This approach requires more knowledge of exactly
19215 which instances you need than do the others, but it's less
19216 mysterious and allows greater control.  You can scatter the explicit
19217 instantiations throughout your program, perhaps putting them in the
19218 translation units where the instances are used or the translation units
19219 that define the templates themselves; you can put all of the explicit
19220 instantiations you need into one big file; or you can create small files
19221 like
19223 @smallexample
19224 #include "Foo.h"
19225 #include "Foo.cc"
19227 template class Foo<int>;
19228 template ostream& operator <<
19229                 (ostream&, const Foo<int>&);
19230 @end smallexample
19232 @noindent
19233 for each of the instances you need, and create a template instantiation
19234 library from those.
19236 If you are using Cfront-model code, you can probably get away with not
19237 using @option{-fno-implicit-templates} when compiling files that don't
19238 @samp{#include} the member template definitions.
19240 If you use one big file to do the instantiations, you may want to
19241 compile it without @option{-fno-implicit-templates} so you get all of the
19242 instances required by your explicit instantiations (but not by any
19243 other files) without having to specify them as well.
19245 The ISO C++ 2011 standard allows forward declaration of explicit
19246 instantiations (with @code{extern}). G++ supports explicit instantiation
19247 declarations in C++98 mode and has extended the template instantiation
19248 syntax to support instantiation of the compiler support data for a
19249 template class (i.e.@: the vtable) without instantiating any of its
19250 members (with @code{inline}), and instantiation of only the static data
19251 members of a template class, without the support data or member
19252 functions (with @code{static}):
19254 @smallexample
19255 extern template int max (int, int);
19256 inline template class Foo<int>;
19257 static template class Foo<int>;
19258 @end smallexample
19260 @item
19261 Do nothing.  Pretend G++ does implement automatic instantiation
19262 management.  Code written for the Borland model works fine, but
19263 each translation unit contains instances of each of the templates it
19264 uses.  In a large program, this can lead to an unacceptable amount of code
19265 duplication.
19266 @end enumerate
19268 @node Bound member functions
19269 @section Extracting the Function Pointer from a Bound Pointer to Member Function
19270 @cindex pmf
19271 @cindex pointer to member function
19272 @cindex bound pointer to member function
19274 In C++, pointer to member functions (PMFs) are implemented using a wide
19275 pointer of sorts to handle all the possible call mechanisms; the PMF
19276 needs to store information about how to adjust the @samp{this} pointer,
19277 and if the function pointed to is virtual, where to find the vtable, and
19278 where in the vtable to look for the member function.  If you are using
19279 PMFs in an inner loop, you should really reconsider that decision.  If
19280 that is not an option, you can extract the pointer to the function that
19281 would be called for a given object/PMF pair and call it directly inside
19282 the inner loop, to save a bit of time.
19284 Note that you still pay the penalty for the call through a
19285 function pointer; on most modern architectures, such a call defeats the
19286 branch prediction features of the CPU@.  This is also true of normal
19287 virtual function calls.
19289 The syntax for this extension is
19291 @smallexample
19292 extern A a;
19293 extern int (A::*fp)();
19294 typedef int (*fptr)(A *);
19296 fptr p = (fptr)(a.*fp);
19297 @end smallexample
19299 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
19300 no object is needed to obtain the address of the function.  They can be
19301 converted to function pointers directly:
19303 @smallexample
19304 fptr p1 = (fptr)(&A::foo);
19305 @end smallexample
19307 @opindex Wno-pmf-conversions
19308 You must specify @option{-Wno-pmf-conversions} to use this extension.
19310 @node C++ Attributes
19311 @section C++-Specific Variable, Function, and Type Attributes
19313 Some attributes only make sense for C++ programs.
19315 @table @code
19316 @item abi_tag ("@var{tag}", ...)
19317 @cindex @code{abi_tag} function attribute
19318 @cindex @code{abi_tag} variable attribute
19319 @cindex @code{abi_tag} type attribute
19320 The @code{abi_tag} attribute can be applied to a function, variable, or class
19321 declaration.  It modifies the mangled name of the entity to
19322 incorporate the tag name, in order to distinguish the function or
19323 class from an earlier version with a different ABI; perhaps the class
19324 has changed size, or the function has a different return type that is
19325 not encoded in the mangled name.
19327 The attribute can also be applied to an inline namespace, but does not
19328 affect the mangled name of the namespace; in this case it is only used
19329 for @option{-Wabi-tag} warnings and automatic tagging of functions and
19330 variables.  Tagging inline namespaces is generally preferable to
19331 tagging individual declarations, but the latter is sometimes
19332 necessary, such as when only certain members of a class need to be
19333 tagged.
19335 The argument can be a list of strings of arbitrary length.  The
19336 strings are sorted on output, so the order of the list is
19337 unimportant.
19339 A redeclaration of an entity must not add new ABI tags,
19340 since doing so would change the mangled name.
19342 The ABI tags apply to a name, so all instantiations and
19343 specializations of a template have the same tags.  The attribute will
19344 be ignored if applied to an explicit specialization or instantiation.
19346 The @option{-Wabi-tag} flag enables a warning about a class which does
19347 not have all the ABI tags used by its subobjects and virtual functions; for users with code
19348 that needs to coexist with an earlier ABI, using this option can help
19349 to find all affected types that need to be tagged.
19351 When a type involving an ABI tag is used as the type of a variable or
19352 return type of a function where that tag is not already present in the
19353 signature of the function, the tag is automatically applied to the
19354 variable or function.  @option{-Wabi-tag} also warns about this
19355 situation; this warning can be avoided by explicitly tagging the
19356 variable or function or moving it into a tagged inline namespace.
19358 @item init_priority (@var{priority})
19359 @cindex @code{init_priority} variable attribute
19361 In Standard C++, objects defined at namespace scope are guaranteed to be
19362 initialized in an order in strict accordance with that of their definitions
19363 @emph{in a given translation unit}.  No guarantee is made for initializations
19364 across translation units.  However, GNU C++ allows users to control the
19365 order of initialization of objects defined at namespace scope with the
19366 @code{init_priority} attribute by specifying a relative @var{priority},
19367 a constant integral expression currently bounded between 101 and 65535
19368 inclusive.  Lower numbers indicate a higher priority.
19370 In the following example, @code{A} would normally be created before
19371 @code{B}, but the @code{init_priority} attribute reverses that order:
19373 @smallexample
19374 Some_Class  A  __attribute__ ((init_priority (2000)));
19375 Some_Class  B  __attribute__ ((init_priority (543)));
19376 @end smallexample
19378 @noindent
19379 Note that the particular values of @var{priority} do not matter; only their
19380 relative ordering.
19382 @item java_interface
19383 @cindex @code{java_interface} type attribute
19385 This type attribute informs C++ that the class is a Java interface.  It may
19386 only be applied to classes declared within an @code{extern "Java"} block.
19387 Calls to methods declared in this interface are dispatched using GCJ's
19388 interface table mechanism, instead of regular virtual table dispatch.
19390 @item warn_unused
19391 @cindex @code{warn_unused} type attribute
19393 For C++ types with non-trivial constructors and/or destructors it is
19394 impossible for the compiler to determine whether a variable of this
19395 type is truly unused if it is not referenced. This type attribute
19396 informs the compiler that variables of this type should be warned
19397 about if they appear to be unused, just like variables of fundamental
19398 types.
19400 This attribute is appropriate for types which just represent a value,
19401 such as @code{std::string}; it is not appropriate for types which
19402 control a resource, such as @code{std::mutex}.
19404 This attribute is also accepted in C, but it is unnecessary because C
19405 does not have constructors or destructors.
19407 @end table
19409 See also @ref{Namespace Association}.
19411 @node Function Multiversioning
19412 @section Function Multiversioning
19413 @cindex function versions
19415 With the GNU C++ front end, for x86 targets, you may specify multiple
19416 versions of a function, where each function is specialized for a
19417 specific target feature.  At runtime, the appropriate version of the
19418 function is automatically executed depending on the characteristics of
19419 the execution platform.  Here is an example.
19421 @smallexample
19422 __attribute__ ((target ("default")))
19423 int foo ()
19425   // The default version of foo.
19426   return 0;
19429 __attribute__ ((target ("sse4.2")))
19430 int foo ()
19432   // foo version for SSE4.2
19433   return 1;
19436 __attribute__ ((target ("arch=atom")))
19437 int foo ()
19439   // foo version for the Intel ATOM processor
19440   return 2;
19443 __attribute__ ((target ("arch=amdfam10")))
19444 int foo ()
19446   // foo version for the AMD Family 0x10 processors.
19447   return 3;
19450 int main ()
19452   int (*p)() = &foo;
19453   assert ((*p) () == foo ());
19454   return 0;
19456 @end smallexample
19458 In the above example, four versions of function foo are created. The
19459 first version of foo with the target attribute "default" is the default
19460 version.  This version gets executed when no other target specific
19461 version qualifies for execution on a particular platform. A new version
19462 of foo is created by using the same function signature but with a
19463 different target string.  Function foo is called or a pointer to it is
19464 taken just like a regular function.  GCC takes care of doing the
19465 dispatching to call the right version at runtime.  Refer to the
19466 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
19467 Function Multiversioning} for more details.
19469 @node Namespace Association
19470 @section Namespace Association
19472 @strong{Caution:} The semantics of this extension are equivalent
19473 to C++ 2011 inline namespaces.  Users should use inline namespaces
19474 instead as this extension will be removed in future versions of G++.
19476 A using-directive with @code{__attribute ((strong))} is stronger
19477 than a normal using-directive in two ways:
19479 @itemize @bullet
19480 @item
19481 Templates from the used namespace can be specialized and explicitly
19482 instantiated as though they were members of the using namespace.
19484 @item
19485 The using namespace is considered an associated namespace of all
19486 templates in the used namespace for purposes of argument-dependent
19487 name lookup.
19488 @end itemize
19490 The used namespace must be nested within the using namespace so that
19491 normal unqualified lookup works properly.
19493 This is useful for composing a namespace transparently from
19494 implementation namespaces.  For example:
19496 @smallexample
19497 namespace std @{
19498   namespace debug @{
19499     template <class T> struct A @{ @};
19500   @}
19501   using namespace debug __attribute ((__strong__));
19502   template <> struct A<int> @{ @};   // @r{OK to specialize}
19504   template <class T> void f (A<T>);
19507 int main()
19509   f (std::A<float>());             // @r{lookup finds} std::f
19510   f (std::A<int>());
19512 @end smallexample
19514 @node Type Traits
19515 @section Type Traits
19517 The C++ front end implements syntactic extensions that allow
19518 compile-time determination of 
19519 various characteristics of a type (or of a
19520 pair of types).
19522 @table @code
19523 @item __has_nothrow_assign (type)
19524 If @code{type} is const qualified or is a reference type then the trait is
19525 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
19526 is true, else if @code{type} is a cv class or union type with copy assignment
19527 operators that are known not to throw an exception then the trait is true,
19528 else it is false.  Requires: @code{type} shall be a complete type,
19529 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19531 @item __has_nothrow_copy (type)
19532 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
19533 @code{type} is a cv class or union type with copy constructors that
19534 are known not to throw an exception then the trait is true, else it is false.
19535 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
19536 @code{void}, or an array of unknown bound.
19538 @item __has_nothrow_constructor (type)
19539 If @code{__has_trivial_constructor (type)} is true then the trait is
19540 true, else if @code{type} is a cv class or union type (or array
19541 thereof) with a default constructor that is known not to throw an
19542 exception then the trait is true, else it is false.  Requires:
19543 @code{type} shall be a complete type, (possibly cv-qualified)
19544 @code{void}, or an array of unknown bound.
19546 @item __has_trivial_assign (type)
19547 If @code{type} is const qualified or is a reference type then the trait is
19548 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
19549 true, else if @code{type} is a cv class or union type with a trivial
19550 copy assignment ([class.copy]) then the trait is true, else it is
19551 false.  Requires: @code{type} shall be a complete type, (possibly
19552 cv-qualified) @code{void}, or an array of unknown bound.
19554 @item __has_trivial_copy (type)
19555 If @code{__is_pod (type)} is true or @code{type} is a reference type
19556 then the trait is true, else if @code{type} is a cv class or union type
19557 with a trivial copy constructor ([class.copy]) then the trait
19558 is true, else it is false.  Requires: @code{type} shall be a complete
19559 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19561 @item __has_trivial_constructor (type)
19562 If @code{__is_pod (type)} is true then the trait is true, else if
19563 @code{type} is a cv class or union type (or array thereof) with a
19564 trivial default constructor ([class.ctor]) then the trait is true,
19565 else it is false.  Requires: @code{type} shall be a complete
19566 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19568 @item __has_trivial_destructor (type)
19569 If @code{__is_pod (type)} is true or @code{type} is a reference type then
19570 the trait is true, else if @code{type} is a cv class or union type (or
19571 array thereof) with a trivial destructor ([class.dtor]) then the trait
19572 is true, else it is false.  Requires: @code{type} shall be a complete
19573 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19575 @item __has_virtual_destructor (type)
19576 If @code{type} is a class type with a virtual destructor
19577 ([class.dtor]) then the trait is true, else it is false.  Requires:
19578 @code{type} shall be a complete type, (possibly cv-qualified)
19579 @code{void}, or an array of unknown bound.
19581 @item __is_abstract (type)
19582 If @code{type} is an abstract class ([class.abstract]) then the trait
19583 is true, else it is false.  Requires: @code{type} shall be a complete
19584 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19586 @item __is_base_of (base_type, derived_type)
19587 If @code{base_type} is a base class of @code{derived_type}
19588 ([class.derived]) then the trait is true, otherwise it is false.
19589 Top-level cv qualifications of @code{base_type} and
19590 @code{derived_type} are ignored.  For the purposes of this trait, a
19591 class type is considered is own base.  Requires: if @code{__is_class
19592 (base_type)} and @code{__is_class (derived_type)} are true and
19593 @code{base_type} and @code{derived_type} are not the same type
19594 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
19595 type.  Diagnostic is produced if this requirement is not met.
19597 @item __is_class (type)
19598 If @code{type} is a cv class type, and not a union type
19599 ([basic.compound]) the trait is true, else it is false.
19601 @item __is_empty (type)
19602 If @code{__is_class (type)} is false then the trait is false.
19603 Otherwise @code{type} is considered empty if and only if: @code{type}
19604 has no non-static data members, or all non-static data members, if
19605 any, are bit-fields of length 0, and @code{type} has no virtual
19606 members, and @code{type} has no virtual base classes, and @code{type}
19607 has no base classes @code{base_type} for which
19608 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
19609 be a complete type, (possibly cv-qualified) @code{void}, or an array
19610 of unknown bound.
19612 @item __is_enum (type)
19613 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
19614 true, else it is false.
19616 @item __is_literal_type (type)
19617 If @code{type} is a literal type ([basic.types]) the trait is
19618 true, else it is false.  Requires: @code{type} shall be a complete type,
19619 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19621 @item __is_pod (type)
19622 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
19623 else it is false.  Requires: @code{type} shall be a complete type,
19624 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19626 @item __is_polymorphic (type)
19627 If @code{type} is a polymorphic class ([class.virtual]) then the trait
19628 is true, else it is false.  Requires: @code{type} shall be a complete
19629 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19631 @item __is_standard_layout (type)
19632 If @code{type} is a standard-layout type ([basic.types]) the trait is
19633 true, else it is false.  Requires: @code{type} shall be a complete
19634 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19636 @item __is_trivial (type)
19637 If @code{type} is a trivial type ([basic.types]) the trait is
19638 true, else it is false.  Requires: @code{type} shall be a complete
19639 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19641 @item __is_union (type)
19642 If @code{type} is a cv union type ([basic.compound]) the trait is
19643 true, else it is false.
19645 @item __underlying_type (type)
19646 The underlying type of @code{type}.  Requires: @code{type} shall be
19647 an enumeration type ([dcl.enum]).
19649 @end table
19651 @node Java Exceptions
19652 @section Java Exceptions
19654 The Java language uses a slightly different exception handling model
19655 from C++.  Normally, GNU C++ automatically detects when you are
19656 writing C++ code that uses Java exceptions, and handle them
19657 appropriately.  However, if C++ code only needs to execute destructors
19658 when Java exceptions are thrown through it, GCC guesses incorrectly.
19659 Sample problematic code is:
19661 @smallexample
19662   struct S @{ ~S(); @};
19663   extern void bar();    // @r{is written in Java, and may throw exceptions}
19664   void foo()
19665   @{
19666     S s;
19667     bar();
19668   @}
19669 @end smallexample
19671 @noindent
19672 The usual effect of an incorrect guess is a link failure, complaining of
19673 a missing routine called @samp{__gxx_personality_v0}.
19675 You can inform the compiler that Java exceptions are to be used in a
19676 translation unit, irrespective of what it might think, by writing
19677 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
19678 @samp{#pragma} must appear before any functions that throw or catch
19679 exceptions, or run destructors when exceptions are thrown through them.
19681 You cannot mix Java and C++ exceptions in the same translation unit.  It
19682 is believed to be safe to throw a C++ exception from one file through
19683 another file compiled for the Java exception model, or vice versa, but
19684 there may be bugs in this area.
19686 @node Deprecated Features
19687 @section Deprecated Features
19689 In the past, the GNU C++ compiler was extended to experiment with new
19690 features, at a time when the C++ language was still evolving.  Now that
19691 the C++ standard is complete, some of those features are superseded by
19692 superior alternatives.  Using the old features might cause a warning in
19693 some cases that the feature will be dropped in the future.  In other
19694 cases, the feature might be gone already.
19696 While the list below is not exhaustive, it documents some of the options
19697 that are now deprecated:
19699 @table @code
19700 @item -fexternal-templates
19701 @itemx -falt-external-templates
19702 These are two of the many ways for G++ to implement template
19703 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
19704 defines how template definitions have to be organized across
19705 implementation units.  G++ has an implicit instantiation mechanism that
19706 should work just fine for standard-conforming code.
19708 @item -fstrict-prototype
19709 @itemx -fno-strict-prototype
19710 Previously it was possible to use an empty prototype parameter list to
19711 indicate an unspecified number of parameters (like C), rather than no
19712 parameters, as C++ demands.  This feature has been removed, except where
19713 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
19714 @end table
19716 G++ allows a virtual function returning @samp{void *} to be overridden
19717 by one returning a different pointer type.  This extension to the
19718 covariant return type rules is now deprecated and will be removed from a
19719 future version.
19721 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19722 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19723 and are now removed from G++.  Code using these operators should be
19724 modified to use @code{std::min} and @code{std::max} instead.
19726 The named return value extension has been deprecated, and is now
19727 removed from G++.
19729 The use of initializer lists with new expressions has been deprecated,
19730 and is now removed from G++.
19732 Floating and complex non-type template parameters have been deprecated,
19733 and are now removed from G++.
19735 The implicit typename extension has been deprecated and is now
19736 removed from G++.
19738 The use of default arguments in function pointers, function typedefs
19739 and other places where they are not permitted by the standard is
19740 deprecated and will be removed from a future version of G++.
19742 G++ allows floating-point literals to appear in integral constant expressions,
19743 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19744 This extension is deprecated and will be removed from a future version.
19746 G++ allows static data members of const floating-point type to be declared
19747 with an initializer in a class definition. The standard only allows
19748 initializers for static members of const integral types and const
19749 enumeration types so this extension has been deprecated and will be removed
19750 from a future version.
19752 @node Backwards Compatibility
19753 @section Backwards Compatibility
19754 @cindex Backwards Compatibility
19755 @cindex ARM [Annotated C++ Reference Manual]
19757 Now that there is a definitive ISO standard C++, G++ has a specification
19758 to adhere to.  The C++ language evolved over time, and features that
19759 used to be acceptable in previous drafts of the standard, such as the ARM
19760 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
19761 compilation of C++ written to such drafts, G++ contains some backwards
19762 compatibilities.  @emph{All such backwards compatibility features are
19763 liable to disappear in future versions of G++.} They should be considered
19764 deprecated.   @xref{Deprecated Features}.
19766 @table @code
19767 @item For scope
19768 If a variable is declared at for scope, it used to remain in scope until
19769 the end of the scope that contained the for statement (rather than just
19770 within the for scope).  G++ retains this, but issues a warning, if such a
19771 variable is accessed outside the for scope.
19773 @item Implicit C language
19774 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19775 scope to set the language.  On such systems, all header files are
19776 implicitly scoped inside a C language scope.  Also, an empty prototype
19777 @code{()} is treated as an unspecified number of arguments, rather
19778 than no arguments, as C++ demands.
19779 @end table
19781 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
19782 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr