* doc/extend.texi (C Extensions): Update menu for moved Variable
[official-gcc.git] / gcc / doc / extend.texi
blobc29005964592d0d0cb9f7f200c50784aa5242726
1 @c Copyright (C) 1988-2015 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes::     Specifying attributes of types.
61 * Label Attributes::    Specifying attributes on labels.
62 * Attribute Syntax::    Formal syntax for attributes.
63 * Function Prototypes:: Prototype declarations and old-style definitions.
64 * C++ Comments::        C++ comments are recognized.
65 * Dollar Signs::        Dollar sign is allowed in identifiers.
66 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
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 @item lower
3258 @itemx upper
3259 @itemx either
3260 @cindex lower memory region on the MSP430
3261 @cindex upper memory region on the MSP430
3262 @cindex either memory region on the MSP430
3263 On the MSP430 target these attributes can be used to specify whether
3264 the function or variable should be placed into low memory, high
3265 memory, or the placement should be left to the linker to decide.  The
3266 attributes are only significant if compiling for the MSP430X
3267 architecture.
3269 The attributes work in conjunction with a linker script that has been
3270 augmented to specify where to place sections with a @code{.lower} and
3271 a @code{.upper} prefix.  So for example as well as placing the
3272 @code{.data} section the script would also specify the placement of a
3273 @code{.lower.data} and a @code{.upper.data} section.  The intention
3274 being that @code{lower} sections are placed into a small but easier to
3275 access memory region and the upper sections are placed into a larger, but
3276 slower to access region.
3278 The @code{either} attribute is special.  It tells the linker to place
3279 the object into the corresponding @code{lower} section if there is
3280 room for it.  If there is insufficient room then the object is placed
3281 into the corresponding @code{upper} section instead.  Note - the
3282 placement algorithm is not very sophisticated.  It will not attempt to
3283 find an optimal packing of the @code{lower} sections.  It just makes
3284 one pass over the objects and does the best that it can.  Using the
3285 @option{-ffunction-sections} and @option{-fdata-sections} command line
3286 options can help the packing however, since they produce smaller,
3287 easier to pack regions.
3289 @end table
3291 @c This is the end of the target-independent attribute table
3294 @node ARC Function Attributes
3295 @subsection ARC Function Attributes
3297 These function attributes are supported by the ARC back end:
3299 @table @code
3300 @item interrupt
3301 @cindex @code{interrupt} function attribute, ARC
3302 Use this attribute to indicate
3303 that the specified function is an interrupt handler.  The compiler generates
3304 function entry and exit sequences suitable for use in an interrupt handler
3305 when this attribute is present.
3307 On the ARC, you must specify the kind of interrupt to be handled
3308 in a parameter to the interrupt attribute like this:
3310 @smallexample
3311 void f () __attribute__ ((interrupt ("ilink1")));
3312 @end smallexample
3314 Permissible values for this parameter are: @w{@code{ilink1}} and
3315 @w{@code{ilink2}}.
3317 @item long_call
3318 @itemx medium_call
3319 @itemx short_call
3320 @cindex @code{long_call} function attribute, ARC
3321 @cindex @code{medium_call} function attribute, ARC
3322 @cindex @code{short_call} function attribute, ARC
3323 @cindex indirect calls, ARC
3324 These attributes specify how a particular function is called.
3325 These attributes override the
3326 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3327 command-line switches and @code{#pragma long_calls} settings.
3329 For ARC, a function marked with the @code{long_call} attribute is
3330 always called using register-indirect jump-and-link instructions,
3331 thereby enabling the called function to be placed anywhere within the
3332 32-bit address space.  A function marked with the @code{medium_call}
3333 attribute will always be close enough to be called with an unconditional
3334 branch-and-link instruction, which has a 25-bit offset from
3335 the call site.  A function marked with the @code{short_call}
3336 attribute will always be close enough to be called with a conditional
3337 branch-and-link instruction, which has a 21-bit offset from
3338 the call site.
3339 @end table
3341 @node ARM Function Attributes
3342 @subsection ARM Function Attributes
3344 These function attributes are supported for ARM targets:
3346 @table @code
3347 @item interrupt
3348 @cindex @code{interrupt} function attribute, ARM
3349 Use this attribute to indicate
3350 that the specified function is an interrupt handler.  The compiler generates
3351 function entry and exit sequences suitable for use in an interrupt handler
3352 when this attribute is present.
3354 You can specify the kind of interrupt to be handled by
3355 adding an optional parameter to the interrupt attribute like this:
3357 @smallexample
3358 void f () __attribute__ ((interrupt ("IRQ")));
3359 @end smallexample
3361 @noindent
3362 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3363 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3365 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3366 may be called with a word-aligned stack pointer.
3368 @item isr
3369 @cindex @code{isr} function attribute, ARM
3370 Use this attribute on ARM to write Interrupt Service Routines. This is an
3371 alias to the @code{interrupt} attribute above.
3373 @item long_call
3374 @itemx short_call
3375 @cindex @code{long_call} function attribute, ARM
3376 @cindex @code{short_call} function attribute, ARM
3377 @cindex indirect calls, ARM
3378 These attributes specify how a particular function is called.
3379 These attributes override the
3380 @option{-mlong-calls} (@pxref{ARM Options})
3381 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3382 @code{long_call} attribute indicates that the function might be far
3383 away from the call site and require a different (more expensive)
3384 calling sequence.   The @code{short_call} attribute always places
3385 the offset to the function from the call site into the @samp{BL}
3386 instruction directly.
3388 @item naked
3389 @cindex @code{naked} function attribute, ARM
3390 This attribute allows the compiler to construct the
3391 requisite function declaration, while allowing the body of the
3392 function to be assembly code. The specified function will not have
3393 prologue/epilogue sequences generated by the compiler. Only basic
3394 @code{asm} statements can safely be included in naked functions
3395 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3396 basic @code{asm} and C code may appear to work, they cannot be
3397 depended upon to work reliably and are not supported.
3399 @item pcs
3400 @cindex @code{pcs} function attribute, ARM
3402 The @code{pcs} attribute can be used to control the calling convention
3403 used for a function on ARM.  The attribute takes an argument that specifies
3404 the calling convention to use.
3406 When compiling using the AAPCS ABI (or a variant of it) then valid
3407 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3408 order to use a variant other than @code{"aapcs"} then the compiler must
3409 be permitted to use the appropriate co-processor registers (i.e., the
3410 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3411 For example,
3413 @smallexample
3414 /* Argument passed in r0, and result returned in r0+r1.  */
3415 double f2d (float) __attribute__((pcs("aapcs")));
3416 @end smallexample
3418 Variadic functions always use the @code{"aapcs"} calling convention and
3419 the compiler rejects attempts to specify an alternative.
3420 @end table
3422 @node AVR Function Attributes
3423 @subsection AVR Function Attributes
3425 These function attributes are supported by the AVR back end:
3427 @table @code
3428 @item interrupt
3429 @cindex @code{interrupt} function attribute, AVR
3430 Use this attribute to indicate
3431 that the specified function is an interrupt handler.  The compiler generates
3432 function entry and exit sequences suitable for use in an interrupt handler
3433 when this attribute is present.
3435 On the AVR, the hardware globally disables interrupts when an
3436 interrupt is executed.  The first instruction of an interrupt handler
3437 declared with this attribute is a @code{SEI} instruction to
3438 re-enable interrupts.  See also the @code{signal} function attribute
3439 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3440 @code{interrupt} are specified for the same function, @code{signal}
3441 is silently ignored.
3443 @item naked
3444 @cindex @code{naked} function attribute, AVR
3445 This attribute allows the compiler to construct the
3446 requisite function declaration, while allowing the body of the
3447 function to be assembly code. The specified function will not have
3448 prologue/epilogue sequences generated by the compiler. Only basic
3449 @code{asm} statements can safely be included in naked functions
3450 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3451 basic @code{asm} and C code may appear to work, they cannot be
3452 depended upon to work reliably and are not supported.
3454 @item OS_main
3455 @itemx OS_task
3456 @cindex @code{OS_main} function attribute, AVR
3457 @cindex @code{OS_task} function attribute, AVR
3458 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3459 do not save/restore any call-saved register in their prologue/epilogue.
3461 The @code{OS_main} attribute can be used when there @emph{is
3462 guarantee} that interrupts are disabled at the time when the function
3463 is entered.  This saves resources when the stack pointer has to be
3464 changed to set up a frame for local variables.
3466 The @code{OS_task} attribute can be used when there is @emph{no
3467 guarantee} that interrupts are disabled at that time when the function
3468 is entered like for, e@.g@. task functions in a multi-threading operating
3469 system. In that case, changing the stack pointer register is
3470 guarded by save/clear/restore of the global interrupt enable flag.
3472 The differences to the @code{naked} function attribute are:
3473 @itemize @bullet
3474 @item @code{naked} functions do not have a return instruction whereas 
3475 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3476 @code{RETI} return instruction.
3477 @item @code{naked} functions do not set up a frame for local variables
3478 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3479 as needed.
3480 @end itemize
3482 @item signal
3483 @cindex @code{signal} function attribute, AVR
3484 Use this attribute on the AVR to indicate that the specified
3485 function is an interrupt handler.  The compiler generates function
3486 entry and exit sequences suitable for use in an interrupt handler when this
3487 attribute is present.
3489 See also the @code{interrupt} function attribute. 
3491 The AVR hardware globally disables interrupts when an interrupt is executed.
3492 Interrupt handler functions defined with the @code{signal} attribute
3493 do not re-enable interrupts.  It is save to enable interrupts in a
3494 @code{signal} handler.  This ``save'' only applies to the code
3495 generated by the compiler and not to the IRQ layout of the
3496 application which is responsibility of the application.
3498 If both @code{signal} and @code{interrupt} are specified for the same
3499 function, @code{signal} is silently ignored.
3500 @end table
3502 @node Blackfin Function Attributes
3503 @subsection Blackfin Function Attributes
3505 These function attributes are supported by the Blackfin back end:
3507 @table @code
3509 @item exception_handler
3510 @cindex @code{exception_handler} function attribute
3511 @cindex exception handler functions, Blackfin
3512 Use this attribute on the Blackfin to indicate that the specified function
3513 is an exception handler.  The compiler generates function entry and
3514 exit sequences suitable for use in an exception handler when this
3515 attribute is present.
3517 @item interrupt_handler
3518 @cindex @code{interrupt_handler} function attribute, Blackfin
3519 Use this attribute to
3520 indicate that the specified function is an interrupt handler.  The compiler
3521 generates function entry and exit sequences suitable for use in an
3522 interrupt handler when this attribute is present.
3524 @item kspisusp
3525 @cindex @code{kspisusp} function attribute, Blackfin
3526 @cindex User stack pointer in interrupts on the Blackfin
3527 When used together with @code{interrupt_handler}, @code{exception_handler}
3528 or @code{nmi_handler}, code is generated to load the stack pointer
3529 from the USP register in the function prologue.
3531 @item l1_text
3532 @cindex @code{l1_text} function attribute, Blackfin
3533 This attribute specifies a function to be placed into L1 Instruction
3534 SRAM@. The function is put into a specific section named @code{.l1.text}.
3535 With @option{-mfdpic}, function calls with a such function as the callee
3536 or caller uses inlined PLT.
3538 @item l2
3539 @cindex @code{l2} function attribute, Blackfin
3540 This attribute specifies a function to be placed into L2
3541 SRAM. The function is put into a specific section named
3542 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3543 an inlined PLT.
3545 @item longcall
3546 @itemx shortcall
3547 @cindex indirect calls, Blackfin
3548 @cindex @code{longcall} function attribute, Blackfin
3549 @cindex @code{shortcall} function attribute, Blackfin
3550 The @code{longcall} attribute
3551 indicates that the function might be far away from the call site and
3552 require a different (more expensive) calling sequence.  The
3553 @code{shortcall} attribute indicates that the function is always close
3554 enough for the shorter calling sequence to be used.  These attributes
3555 override the @option{-mlongcall} switch.
3557 @item nesting
3558 @cindex @code{nesting} function attribute, Blackfin
3559 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3560 Use this attribute together with @code{interrupt_handler},
3561 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3562 entry code should enable nested interrupts or exceptions.
3564 @item nmi_handler
3565 @cindex @code{nmi_handler} function attribute, Blackfin
3566 @cindex NMI handler functions on the Blackfin processor
3567 Use this attribute on the Blackfin to indicate that the specified function
3568 is an NMI handler.  The compiler generates function entry and
3569 exit sequences suitable for use in an NMI handler when this
3570 attribute is present.
3572 @item saveall
3573 @cindex @code{saveall} function attribute, Blackfin
3574 @cindex save all registers on the Blackfin
3575 Use this attribute to indicate that
3576 all registers except the stack pointer should be saved in the prologue
3577 regardless of whether they are used or not.
3578 @end table
3580 @node CR16 Function Attributes
3581 @subsection CR16 Function Attributes
3583 These function attributes are supported by the CR16 back end:
3585 @table @code
3586 @item interrupt
3587 @cindex @code{interrupt} function attribute, CR16
3588 Use this attribute to indicate
3589 that the specified function is an interrupt handler.  The compiler generates
3590 function entry and exit sequences suitable for use in an interrupt handler
3591 when this attribute is present.
3592 @end table
3594 @node Epiphany Function Attributes
3595 @subsection Epiphany Function Attributes
3597 These function attributes are supported by the Epiphany back end:
3599 @table @code
3600 @item disinterrupt
3601 @cindex @code{disinterrupt} function attribute, Epiphany
3602 This attribute causes the compiler to emit
3603 instructions to disable interrupts for the duration of the given
3604 function.
3606 @item forwarder_section
3607 @cindex @code{forwarder_section} function attribute, Epiphany
3608 This attribute modifies the behavior of an interrupt handler.
3609 The interrupt handler may be in external memory which cannot be
3610 reached by a branch instruction, so generate a local memory trampoline
3611 to transfer control.  The single parameter identifies the section where
3612 the trampoline is placed.
3614 @item interrupt
3615 @cindex @code{interrupt} function attribute, Epiphany
3616 Use this attribute to indicate
3617 that the specified function is an interrupt handler.  The compiler generates
3618 function entry and exit sequences suitable for use in an interrupt handler
3619 when this attribute is present.  It may also generate
3620 a special section with code to initialize the interrupt vector table.
3622 On Epiphany targets one or more optional parameters can be added like this:
3624 @smallexample
3625 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3626 @end smallexample
3628 Permissible values for these parameters are: @w{@code{reset}},
3629 @w{@code{software_exception}}, @w{@code{page_miss}},
3630 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3631 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3632 Multiple parameters indicate that multiple entries in the interrupt
3633 vector table should be initialized for this function, i.e.@: for each
3634 parameter @w{@var{name}}, a jump to the function is emitted in
3635 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3636 entirely, in which case no interrupt vector table entry is provided.
3638 Note that interrupts are enabled inside the function
3639 unless the @code{disinterrupt} attribute is also specified.
3641 The following examples are all valid uses of these attributes on
3642 Epiphany targets:
3643 @smallexample
3644 void __attribute__ ((interrupt)) universal_handler ();
3645 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3646 void __attribute__ ((interrupt ("dma0, dma1"))) 
3647   universal_dma_handler ();
3648 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3649   fast_timer_handler ();
3650 void __attribute__ ((interrupt ("dma0, dma1"), 
3651                      forwarder_section ("tramp")))
3652   external_dma_handler ();
3653 @end smallexample
3655 @item long_call
3656 @itemx short_call
3657 @cindex @code{long_call} function attribute, Epiphany
3658 @cindex @code{short_call} function attribute, Epiphany
3659 @cindex indirect calls, Epiphany
3660 These attributes specify how a particular function is called.
3661 These attributes override the
3662 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3663 command-line switch and @code{#pragma long_calls} settings.
3664 @end table
3667 @node H8/300 Function Attributes
3668 @subsection H8/300 Function Attributes
3670 These function attributes are available for H8/300 targets:
3672 @table @code
3673 @item function_vector
3674 @cindex @code{function_vector} function attribute, H8/300
3675 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
3676 that the specified function should be called through the function vector.
3677 Calling a function through the function vector reduces code size; however,
3678 the function vector has a limited size (maximum 128 entries on the H8/300
3679 and 64 entries on the H8/300H and H8S)
3680 and shares space with the interrupt vector.
3682 @item interrupt_handler
3683 @cindex @code{interrupt_handler} function attribute, H8/300
3684 Use this attribute on the H8/300, H8/300H, and H8S to
3685 indicate that the specified function is an interrupt handler.  The compiler
3686 generates function entry and exit sequences suitable for use in an
3687 interrupt handler when this attribute is present.
3689 @item saveall
3690 @cindex @code{saveall} function attribute, H8/300
3691 @cindex save all registers on the H8/300, H8/300H, and H8S
3692 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3693 all registers except the stack pointer should be saved in the prologue
3694 regardless of whether they are used or not.
3695 @end table
3697 @node IA-64 Function Attributes
3698 @subsection IA-64 Function Attributes
3700 These function attributes are supported on IA-64 targets:
3702 @table @code
3703 @item syscall_linkage
3704 @cindex @code{syscall_linkage} function attribute, IA-64
3705 This attribute is used to modify the IA-64 calling convention by marking
3706 all input registers as live at all function exits.  This makes it possible
3707 to restart a system call after an interrupt without having to save/restore
3708 the input registers.  This also prevents kernel data from leaking into
3709 application code.
3711 @item version_id
3712 @cindex @code{version_id} function attribute, IA-64
3713 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
3714 symbol to contain a version string, thus allowing for function level
3715 versioning.  HP-UX system header files may use function level versioning
3716 for some system calls.
3718 @smallexample
3719 extern int foo () __attribute__((version_id ("20040821")));
3720 @end smallexample
3722 @noindent
3723 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
3724 @end table
3726 @node M32C Function Attributes
3727 @subsection M32C Function Attributes
3729 These function attributes are supported by the M32C back end:
3731 @table @code
3732 @item bank_switch
3733 @cindex @code{bank_switch} function attribute, M32C
3734 When added to an interrupt handler with the M32C port, causes the
3735 prologue and epilogue to use bank switching to preserve the registers
3736 rather than saving them on the stack.
3738 @item fast_interrupt
3739 @cindex @code{fast_interrupt} function attribute, M32C
3740 Use this attribute on the M32C port to indicate that the specified
3741 function is a fast interrupt handler.  This is just like the
3742 @code{interrupt} attribute, except that @code{freit} is used to return
3743 instead of @code{reit}.
3745 @item function_vector
3746 @cindex @code{function_vector} function attribute, M16C/M32C
3747 On M16C/M32C targets, the @code{function_vector} attribute declares a
3748 special page subroutine call function. Use of this attribute reduces
3749 the code size by 2 bytes for each call generated to the
3750 subroutine. The argument to the attribute is the vector number entry
3751 from the special page vector table which contains the 16 low-order
3752 bits of the subroutine's entry address. Each vector table has special
3753 page number (18 to 255) that is used in @code{jsrs} instructions.
3754 Jump addresses of the routines are generated by adding 0x0F0000 (in
3755 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
3756 2-byte addresses set in the vector table. Therefore you need to ensure
3757 that all the special page vector routines should get mapped within the
3758 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
3759 (for M32C).
3761 In the following example 2 bytes are saved for each call to
3762 function @code{foo}.
3764 @smallexample
3765 void foo (void) __attribute__((function_vector(0x18)));
3766 void foo (void)
3770 void bar (void)
3772     foo();
3774 @end smallexample
3776 If functions are defined in one file and are called in another file,
3777 then be sure to write this declaration in both files.
3779 This attribute is ignored for R8C target.
3781 @item interrupt
3782 @cindex @code{interrupt} function attribute, M32C
3783 Use this attribute to indicate
3784 that the specified function is an interrupt handler.  The compiler generates
3785 function entry and exit sequences suitable for use in an interrupt handler
3786 when this attribute is present.
3787 @end table
3789 @node M32R/D Function Attributes
3790 @subsection M32R/D Function Attributes
3792 These function attributes are supported by the M32R/D back end:
3794 @table @code
3795 @item interrupt
3796 @cindex @code{interrupt} function attribute, M32R/D
3797 Use this attribute to indicate
3798 that the specified function is an interrupt handler.  The compiler generates
3799 function entry and exit sequences suitable for use in an interrupt handler
3800 when this attribute is present.
3802 @item model (@var{model-name})
3803 @cindex @code{model} function attribute, M32R/D
3804 @cindex function addressability on the M32R/D
3806 On the M32R/D, use this attribute to set the addressability of an
3807 object, and of the code generated for a function.  The identifier
3808 @var{model-name} is one of @code{small}, @code{medium}, or
3809 @code{large}, representing each of the code models.
3811 Small model objects live in the lower 16MB of memory (so that their
3812 addresses can be loaded with the @code{ld24} instruction), and are
3813 callable with the @code{bl} instruction.
3815 Medium model objects may live anywhere in the 32-bit address space (the
3816 compiler generates @code{seth/add3} instructions to load their addresses),
3817 and are callable with the @code{bl} instruction.
3819 Large model objects may live anywhere in the 32-bit address space (the
3820 compiler generates @code{seth/add3} instructions to load their addresses),
3821 and may not be reachable with the @code{bl} instruction (the compiler
3822 generates the much slower @code{seth/add3/jl} instruction sequence).
3823 @end table
3825 @node m68k Function Attributes
3826 @subsection m68k Function Attributes
3828 These function attributes are supported by the m68k back end:
3830 @table @code
3831 @item interrupt
3832 @itemx interrupt_handler
3833 @cindex @code{interrupt} function attribute, m68k
3834 @cindex @code{interrupt_handler} function attribute, m68k
3835 Use this attribute to
3836 indicate that the specified function is an interrupt handler.  The compiler
3837 generates function entry and exit sequences suitable for use in an
3838 interrupt handler when this attribute is present.  Either name may be used.
3840 @item interrupt_thread
3841 @cindex @code{interrupt_thread} function attribute, fido
3842 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3843 that the specified function is an interrupt handler that is designed
3844 to run as a thread.  The compiler omits generate prologue/epilogue
3845 sequences and replaces the return instruction with a @code{sleep}
3846 instruction.  This attribute is available only on fido.
3847 @end table
3849 @node MCORE Function Attributes
3850 @subsection MCORE Function Attributes
3852 These function attributes are supported by the MCORE back end:
3854 @table @code
3855 @item naked
3856 @cindex @code{naked} function attribute, MCORE
3857 This attribute allows the compiler to construct the
3858 requisite function declaration, while allowing the body of the
3859 function to be assembly code. The specified function will not have
3860 prologue/epilogue sequences generated by the compiler. Only basic
3861 @code{asm} statements can safely be included in naked functions
3862 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3863 basic @code{asm} and C code may appear to work, they cannot be
3864 depended upon to work reliably and are not supported.
3865 @end table
3867 @node MeP Function Attributes
3868 @subsection MeP Function Attributes
3870 These function attributes are supported by the MeP back end:
3872 @table @code
3873 @item disinterrupt
3874 @cindex @code{disinterrupt} function attribute, MeP
3875 On MeP targets, this attribute causes the compiler to emit
3876 instructions to disable interrupts for the duration of the given
3877 function.
3879 @item interrupt
3880 @cindex @code{interrupt} function attribute, MeP
3881 Use this attribute to indicate
3882 that the specified function is an interrupt handler.  The compiler generates
3883 function entry and exit sequences suitable for use in an interrupt handler
3884 when this attribute is present.
3886 @item near
3887 @cindex @code{near} function attribute, MeP
3888 This attribute causes the compiler to assume the called
3889 function is close enough to use the normal calling convention,
3890 overriding the @option{-mtf} command-line option.
3892 @item far
3893 @cindex @code{far} function attribute, MeP
3894 On MeP targets this causes the compiler to use a calling convention
3895 that assumes the called function is too far away for the built-in
3896 addressing modes.
3898 @item vliw
3899 @cindex @code{vliw} function attribute, MeP
3900 The @code{vliw} attribute tells the compiler to emit
3901 instructions in VLIW mode instead of core mode.  Note that this
3902 attribute is not allowed unless a VLIW coprocessor has been configured
3903 and enabled through command-line options.
3904 @end table
3906 @node MicroBlaze Function Attributes
3907 @subsection MicroBlaze Function Attributes
3909 These function attributes are supported on MicroBlaze targets:
3911 @table @code
3912 @item save_volatiles
3913 @cindex @code{save_volatiles} function attribute, MicroBlaze
3914 Use this attribute to indicate that the function is
3915 an interrupt handler.  All volatile registers (in addition to non-volatile
3916 registers) are saved in the function prologue.  If the function is a leaf
3917 function, only volatiles used by the function are saved.  A normal function
3918 return is generated instead of a return from interrupt.
3920 @item break_handler
3921 @cindex @code{break_handler} function attribute, MicroBlaze
3922 @cindex break handler functions
3923 Use this attribute to indicate that
3924 the specified function is a break handler.  The compiler generates function
3925 entry and exit sequences suitable for use in an break handler when this
3926 attribute is present. The return from @code{break_handler} is done through
3927 the @code{rtbd} instead of @code{rtsd}.
3929 @smallexample
3930 void f () __attribute__ ((break_handler));
3931 @end smallexample
3932 @end table
3934 @node Microsoft Windows Function Attributes
3935 @subsection Microsoft Windows Function Attributes
3937 The following attributes are available on Microsoft Windows and Symbian OS
3938 targets.
3940 @table @code
3941 @item dllexport
3942 @cindex @code{dllexport} function attribute
3943 @cindex @code{__declspec(dllexport)}
3944 On Microsoft Windows targets and Symbian OS targets the
3945 @code{dllexport} attribute causes the compiler to provide a global
3946 pointer to a pointer in a DLL, so that it can be referenced with the
3947 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
3948 name is formed by combining @code{_imp__} and the function or variable
3949 name.
3951 You can use @code{__declspec(dllexport)} as a synonym for
3952 @code{__attribute__ ((dllexport))} for compatibility with other
3953 compilers.
3955 On systems that support the @code{visibility} attribute, this
3956 attribute also implies ``default'' visibility.  It is an error to
3957 explicitly specify any other visibility.
3959 GCC's default behavior is to emit all inline functions with the
3960 @code{dllexport} attribute.  Since this can cause object file-size bloat,
3961 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
3962 ignore the attribute for inlined functions unless the 
3963 @option{-fkeep-inline-functions} flag is used instead.
3965 The attribute is ignored for undefined symbols.
3967 When applied to C++ classes, the attribute marks defined non-inlined
3968 member functions and static data members as exports.  Static consts
3969 initialized in-class are not marked unless they are also defined
3970 out-of-class.
3972 For Microsoft Windows targets there are alternative methods for
3973 including the symbol in the DLL's export table such as using a
3974 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
3975 the @option{--export-all} linker flag.
3977 @item dllimport
3978 @cindex @code{dllimport} function attribute
3979 @cindex @code{__declspec(dllimport)}
3980 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
3981 attribute causes the compiler to reference a function or variable via
3982 a global pointer to a pointer that is set up by the DLL exporting the
3983 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
3984 targets, the pointer name is formed by combining @code{_imp__} and the
3985 function or variable name.
3987 You can use @code{__declspec(dllimport)} as a synonym for
3988 @code{__attribute__ ((dllimport))} for compatibility with other
3989 compilers.
3991 On systems that support the @code{visibility} attribute, this
3992 attribute also implies ``default'' visibility.  It is an error to
3993 explicitly specify any other visibility.
3995 Currently, the attribute is ignored for inlined functions.  If the
3996 attribute is applied to a symbol @emph{definition}, an error is reported.
3997 If a symbol previously declared @code{dllimport} is later defined, the
3998 attribute is ignored in subsequent references, and a warning is emitted.
3999 The attribute is also overridden by a subsequent declaration as
4000 @code{dllexport}.
4002 When applied to C++ classes, the attribute marks non-inlined
4003 member functions and static data members as imports.  However, the
4004 attribute is ignored for virtual methods to allow creation of vtables
4005 using thunks.
4007 On the SH Symbian OS target the @code{dllimport} attribute also has
4008 another affect---it can cause the vtable and run-time type information
4009 for a class to be exported.  This happens when the class has a
4010 dllimported constructor or a non-inline, non-pure virtual function
4011 and, for either of those two conditions, the class also has an inline
4012 constructor or destructor and has a key function that is defined in
4013 the current translation unit.
4015 For Microsoft Windows targets the use of the @code{dllimport}
4016 attribute on functions is not necessary, but provides a small
4017 performance benefit by eliminating a thunk in the DLL@.  The use of the
4018 @code{dllimport} attribute on imported variables can be avoided by passing the
4019 @option{--enable-auto-import} switch to the GNU linker.  As with
4020 functions, using the attribute for a variable eliminates a thunk in
4021 the DLL@.
4023 One drawback to using this attribute is that a pointer to a
4024 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4025 address. However, a pointer to a @emph{function} with the
4026 @code{dllimport} attribute can be used as a constant initializer; in
4027 this case, the address of a stub function in the import lib is
4028 referenced.  On Microsoft Windows targets, the attribute can be disabled
4029 for functions by setting the @option{-mnop-fun-dllimport} flag.
4030 @end table
4032 @node MIPS Function Attributes
4033 @subsection MIPS Function Attributes
4035 These function attributes are supported by the MIPS back end:
4037 @table @code
4038 @item interrupt
4039 @cindex @code{interrupt} function attribute, MIPS
4040 Use this attribute to indicate
4041 that the specified function is an interrupt handler.  The compiler generates
4042 function entry and exit sequences suitable for use in an interrupt handler
4043 when this attribute is present.
4045 You can use the following attributes to modify the behavior
4046 of an interrupt handler:
4047 @table @code
4048 @item use_shadow_register_set
4049 @cindex @code{use_shadow_register_set} function attribute, MIPS
4050 Assume that the handler uses a shadow register set, instead of
4051 the main general-purpose registers.
4053 @item keep_interrupts_masked
4054 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4055 Keep interrupts masked for the whole function.  Without this attribute,
4056 GCC tries to reenable interrupts for as much of the function as it can.
4058 @item use_debug_exception_return
4059 @cindex @code{use_debug_exception_return} function attribute, MIPS
4060 Return using the @code{deret} instruction.  Interrupt handlers that don't
4061 have this attribute return using @code{eret} instead.
4062 @end table
4064 You can use any combination of these attributes, as shown below:
4065 @smallexample
4066 void __attribute__ ((interrupt)) v0 ();
4067 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4068 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4069 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4070 void __attribute__ ((interrupt, use_shadow_register_set,
4071                      keep_interrupts_masked)) v4 ();
4072 void __attribute__ ((interrupt, use_shadow_register_set,
4073                      use_debug_exception_return)) v5 ();
4074 void __attribute__ ((interrupt, keep_interrupts_masked,
4075                      use_debug_exception_return)) v6 ();
4076 void __attribute__ ((interrupt, use_shadow_register_set,
4077                      keep_interrupts_masked,
4078                      use_debug_exception_return)) v7 ();
4079 @end smallexample
4081 @item long_call
4082 @itemx near
4083 @itemx far
4084 @cindex indirect calls, MIPS
4085 @cindex @code{long_call} function attribute, MIPS
4086 @cindex @code{near} function attribute, MIPS
4087 @cindex @code{far} function attribute, MIPS
4088 These attributes specify how a particular function is called on MIPS@.
4089 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4090 command-line switch.  The @code{long_call} and @code{far} attributes are
4091 synonyms, and cause the compiler to always call
4092 the function by first loading its address into a register, and then using
4093 the contents of that register.  The @code{near} attribute has the opposite
4094 effect; it specifies that non-PIC calls should be made using the more
4095 efficient @code{jal} instruction.
4097 @item mips16
4098 @itemx nomips16
4099 @cindex @code{mips16} function attribute, MIPS
4100 @cindex @code{nomips16} function attribute, MIPS
4102 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4103 function attributes to locally select or turn off MIPS16 code generation.
4104 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4105 while MIPS16 code generation is disabled for functions with the
4106 @code{nomips16} attribute.  These attributes override the
4107 @option{-mips16} and @option{-mno-mips16} options on the command line
4108 (@pxref{MIPS Options}).
4110 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4111 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4112 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4113 may interact badly with some GCC extensions such as @code{__builtin_apply}
4114 (@pxref{Constructing Calls}).
4116 @item micromips, MIPS
4117 @itemx nomicromips, MIPS
4118 @cindex @code{micromips} function attribute
4119 @cindex @code{nomicromips} function attribute
4121 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4122 function attributes to locally select or turn off microMIPS code generation.
4123 A function with the @code{micromips} attribute is emitted as microMIPS code,
4124 while microMIPS code generation is disabled for functions with the
4125 @code{nomicromips} attribute.  These attributes override the
4126 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4127 (@pxref{MIPS Options}).
4129 When compiling files containing mixed microMIPS and non-microMIPS code, the
4130 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4131 command line,
4132 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4133 may interact badly with some GCC extensions such as @code{__builtin_apply}
4134 (@pxref{Constructing Calls}).
4136 @item nocompression
4137 @cindex @code{nocompression} function attribute, MIPS
4138 On MIPS targets, you can use the @code{nocompression} function attribute
4139 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4140 overrides the @option{-mips16} and @option{-mmicromips} options on the
4141 command line (@pxref{MIPS Options}).
4142 @end table
4144 @node MSP430 Function Attributes
4145 @subsection MSP430 Function Attributes
4147 These function attributes are supported by the MSP430 back end:
4149 @table @code
4150 @item critical
4151 @cindex @code{critical} function attribute, MSP430
4152 Critical functions disable interrupts upon entry and restore the
4153 previous interrupt state upon exit.  Critical functions cannot also
4154 have the @code{naked} or @code{reentrant} attributes.  They can have
4155 the @code{interrupt} attribute.
4157 @item interrupt
4158 @cindex @code{interrupt} function attribute, MSP430
4159 Use this attribute to indicate
4160 that the specified function is an interrupt handler.  The compiler generates
4161 function entry and exit sequences suitable for use in an interrupt handler
4162 when this attribute is present.
4164 You can provide an argument to the interrupt
4165 attribute which specifies a name or number.  If the argument is a
4166 number it indicates the slot in the interrupt vector table (0 - 31) to
4167 which this handler should be assigned.  If the argument is a name it
4168 is treated as a symbolic name for the vector slot.  These names should
4169 match up with appropriate entries in the linker script.  By default
4170 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4171 @code{reset} for vector 31 are recognized.
4173 @item naked
4174 @cindex @code{naked} function attribute, MSP430
4175 This attribute allows the compiler to construct the
4176 requisite function declaration, while allowing the body of the
4177 function to be assembly code. The specified function will not have
4178 prologue/epilogue sequences generated by the compiler. Only basic
4179 @code{asm} statements can safely be included in naked functions
4180 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4181 basic @code{asm} and C code may appear to work, they cannot be
4182 depended upon to work reliably and are not supported.
4184 @item reentrant
4185 @cindex @code{reentrant} function attribute, MSP430
4186 Reentrant functions disable interrupts upon entry and enable them
4187 upon exit.  Reentrant functions cannot also have the @code{naked}
4188 or @code{critical} attributes.  They can have the @code{interrupt}
4189 attribute.
4191 @item wakeup
4192 @cindex @code{wakeup} function attribute, MSP430
4193 This attribute only applies to interrupt functions.  It is silently
4194 ignored if applied to a non-interrupt function.  A wakeup interrupt
4195 function will rouse the processor from any low-power state that it
4196 might be in when the function exits.
4197 @end table
4199 @node NDS32 Function Attributes
4200 @subsection NDS32 Function Attributes
4202 These function attributes are supported by the NDS32 back end:
4204 @table @code
4205 @item exception
4206 @cindex @code{exception} function attribute
4207 @cindex exception handler functions, NDS32
4208 Use this attribute on the NDS32 target to indicate that the specified function
4209 is an exception handler.  The compiler will generate corresponding sections
4210 for use in an exception handler.
4212 @item interrupt
4213 @cindex @code{interrupt} function attribute, NDS32
4214 On NDS32 target, this attribute indicates that the specified function
4215 is an interrupt handler.  The compiler generates corresponding sections
4216 for use in an interrupt handler.  You can use the following attributes
4217 to modify the behavior:
4218 @table @code
4219 @item nested
4220 @cindex @code{nested} function attribute, NDS32
4221 This interrupt service routine is interruptible.
4222 @item not_nested
4223 @cindex @code{not_nested} function attribute, NDS32
4224 This interrupt service routine is not interruptible.
4225 @item nested_ready
4226 @cindex @code{nested_ready} function attribute, NDS32
4227 This interrupt service routine is interruptible after @code{PSW.GIE}
4228 (global interrupt enable) is set.  This allows interrupt service routine to
4229 finish some short critical code before enabling interrupts.
4230 @item save_all
4231 @cindex @code{save_all} function attribute, NDS32
4232 The system will help save all registers into stack before entering
4233 interrupt handler.
4234 @item partial_save
4235 @cindex @code{partial_save} function attribute, NDS32
4236 The system will help save caller registers into stack before entering
4237 interrupt handler.
4238 @end table
4240 @item naked
4241 @cindex @code{naked} function attribute, NDS32
4242 This attribute allows the compiler to construct the
4243 requisite function declaration, while allowing the body of the
4244 function to be assembly code. The specified function will not have
4245 prologue/epilogue sequences generated by the compiler. Only basic
4246 @code{asm} statements can safely be included in naked functions
4247 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4248 basic @code{asm} and C code may appear to work, they cannot be
4249 depended upon to work reliably and are not supported.
4251 @item reset
4252 @cindex @code{reset} function attribute, NDS32
4253 @cindex reset handler functions
4254 Use this attribute on the NDS32 target to indicate that the specified function
4255 is a reset handler.  The compiler will generate corresponding sections
4256 for use in a reset handler.  You can use the following attributes
4257 to provide extra exception handling:
4258 @table @code
4259 @item nmi
4260 @cindex @code{nmi} function attribute, NDS32
4261 Provide a user-defined function to handle NMI exception.
4262 @item warm
4263 @cindex @code{warm} function attribute, NDS32
4264 Provide a user-defined function to handle warm reset exception.
4265 @end table
4266 @end table
4268 @node Nios II Function Attributes
4269 @subsection Nios II Function Attributes
4271 These function attributes are supported by the Nios II back end:
4273 @table @code
4274 @item target (@var{options})
4275 @cindex @code{target} function attribute
4276 As discussed in @ref{Common Function Attributes}, this attribute 
4277 allows specification of target-specific compilation options.
4279 When compiling for Nios II, the following options are allowed:
4281 @table @samp
4282 @item custom-@var{insn}=@var{N}
4283 @itemx no-custom-@var{insn}
4284 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4285 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4286 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4287 custom instruction with encoding @var{N} when generating code that uses 
4288 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4289 the custom instruction @var{insn}.
4290 These target attributes correspond to the
4291 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4292 command-line options, and support the same set of @var{insn} keywords.
4293 @xref{Nios II Options}, for more information.
4295 @item custom-fpu-cfg=@var{name}
4296 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4297 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4298 command-line option, to select a predefined set of custom instructions
4299 named @var{name}.
4300 @xref{Nios II Options}, for more information.
4301 @end table
4302 @end table
4304 @node PowerPC Function Attributes
4305 @subsection PowerPC Function Attributes
4307 These function attributes are supported by the PowerPC back end:
4309 @table @code
4310 @item longcall
4311 @itemx shortcall
4312 @cindex indirect calls, PowerPC
4313 @cindex @code{longcall} function attribute, PowerPC
4314 @cindex @code{shortcall} function attribute, PowerPC
4315 The @code{longcall} attribute
4316 indicates that the function might be far away from the call site and
4317 require a different (more expensive) calling sequence.  The
4318 @code{shortcall} attribute indicates that the function is always close
4319 enough for the shorter calling sequence to be used.  These attributes
4320 override both the @option{-mlongcall} switch and
4321 the @code{#pragma longcall} setting.
4323 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4324 calls are necessary.
4326 @item target (@var{options})
4327 @cindex @code{target} function attribute
4328 As discussed in @ref{Common Function Attributes}, this attribute 
4329 allows specification of target-specific compilation options.
4331 On the PowerPC, the following options are allowed:
4333 @table @samp
4334 @item altivec
4335 @itemx no-altivec
4336 @cindex @code{target("altivec")} function attribute, PowerPC
4337 Generate code that uses (does not use) AltiVec instructions.  In
4338 32-bit code, you cannot enable AltiVec instructions unless
4339 @option{-mabi=altivec} is used on the command line.
4341 @item cmpb
4342 @itemx no-cmpb
4343 @cindex @code{target("cmpb")} function attribute, PowerPC
4344 Generate code that uses (does not use) the compare bytes instruction
4345 implemented on the POWER6 processor and other processors that support
4346 the PowerPC V2.05 architecture.
4348 @item dlmzb
4349 @itemx no-dlmzb
4350 @cindex @code{target("dlmzb")} function attribute, PowerPC
4351 Generate code that uses (does not use) the string-search @samp{dlmzb}
4352 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4353 generated by default when targeting those processors.
4355 @item fprnd
4356 @itemx no-fprnd
4357 @cindex @code{target("fprnd")} function attribute, PowerPC
4358 Generate code that uses (does not use) the FP round to integer
4359 instructions implemented on the POWER5+ processor and other processors
4360 that support the PowerPC V2.03 architecture.
4362 @item hard-dfp
4363 @itemx no-hard-dfp
4364 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4365 Generate code that uses (does not use) the decimal floating-point
4366 instructions implemented on some POWER processors.
4368 @item isel
4369 @itemx no-isel
4370 @cindex @code{target("isel")} function attribute, PowerPC
4371 Generate code that uses (does not use) ISEL instruction.
4373 @item mfcrf
4374 @itemx no-mfcrf
4375 @cindex @code{target("mfcrf")} function attribute, PowerPC
4376 Generate code that uses (does not use) the move from condition
4377 register field instruction implemented on the POWER4 processor and
4378 other processors that support the PowerPC V2.01 architecture.
4380 @item mfpgpr
4381 @itemx no-mfpgpr
4382 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4383 Generate code that uses (does not use) the FP move to/from general
4384 purpose register instructions implemented on the POWER6X processor and
4385 other processors that support the extended PowerPC V2.05 architecture.
4387 @item mulhw
4388 @itemx no-mulhw
4389 @cindex @code{target("mulhw")} function attribute, PowerPC
4390 Generate code that uses (does not use) the half-word multiply and
4391 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4392 These instructions are generated by default when targeting those
4393 processors.
4395 @item multiple
4396 @itemx no-multiple
4397 @cindex @code{target("multiple")} function attribute, PowerPC
4398 Generate code that uses (does not use) the load multiple word
4399 instructions and the store multiple word instructions.
4401 @item update
4402 @itemx no-update
4403 @cindex @code{target("update")} function attribute, PowerPC
4404 Generate code that uses (does not use) the load or store instructions
4405 that update the base register to the address of the calculated memory
4406 location.
4408 @item popcntb
4409 @itemx no-popcntb
4410 @cindex @code{target("popcntb")} function attribute, PowerPC
4411 Generate code that uses (does not use) the popcount and double-precision
4412 FP reciprocal estimate instruction implemented on the POWER5
4413 processor and other processors that support the PowerPC V2.02
4414 architecture.
4416 @item popcntd
4417 @itemx no-popcntd
4418 @cindex @code{target("popcntd")} function attribute, PowerPC
4419 Generate code that uses (does not use) the popcount instruction
4420 implemented on the POWER7 processor and other processors that support
4421 the PowerPC V2.06 architecture.
4423 @item powerpc-gfxopt
4424 @itemx no-powerpc-gfxopt
4425 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4426 Generate code that uses (does not use) the optional PowerPC
4427 architecture instructions in the Graphics group, including
4428 floating-point select.
4430 @item powerpc-gpopt
4431 @itemx no-powerpc-gpopt
4432 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4433 Generate code that uses (does not use) the optional PowerPC
4434 architecture instructions in the General Purpose group, including
4435 floating-point square root.
4437 @item recip-precision
4438 @itemx no-recip-precision
4439 @cindex @code{target("recip-precision")} function attribute, PowerPC
4440 Assume (do not assume) that the reciprocal estimate instructions
4441 provide higher-precision estimates than is mandated by the PowerPC
4442 ABI.
4444 @item string
4445 @itemx no-string
4446 @cindex @code{target("string")} function attribute, PowerPC
4447 Generate code that uses (does not use) the load string instructions
4448 and the store string word instructions to save multiple registers and
4449 do small block moves.
4451 @item vsx
4452 @itemx no-vsx
4453 @cindex @code{target("vsx")} function attribute, PowerPC
4454 Generate code that uses (does not use) vector/scalar (VSX)
4455 instructions, and also enable the use of built-in functions that allow
4456 more direct access to the VSX instruction set.  In 32-bit code, you
4457 cannot enable VSX or AltiVec instructions unless
4458 @option{-mabi=altivec} is used on the command line.
4460 @item friz
4461 @itemx no-friz
4462 @cindex @code{target("friz")} function attribute, PowerPC
4463 Generate (do not generate) the @code{friz} instruction when the
4464 @option{-funsafe-math-optimizations} option is used to optimize
4465 rounding a floating-point value to 64-bit integer and back to floating
4466 point.  The @code{friz} instruction does not return the same value if
4467 the floating-point number is too large to fit in an integer.
4469 @item avoid-indexed-addresses
4470 @itemx no-avoid-indexed-addresses
4471 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4472 Generate code that tries to avoid (not avoid) the use of indexed load
4473 or store instructions.
4475 @item paired
4476 @itemx no-paired
4477 @cindex @code{target("paired")} function attribute, PowerPC
4478 Generate code that uses (does not use) the generation of PAIRED simd
4479 instructions.
4481 @item longcall
4482 @itemx no-longcall
4483 @cindex @code{target("longcall")} function attribute, PowerPC
4484 Generate code that assumes (does not assume) that all calls are far
4485 away so that a longer more expensive calling sequence is required.
4487 @item cpu=@var{CPU}
4488 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4489 Specify the architecture to generate code for when compiling the
4490 function.  If you select the @code{target("cpu=power7")} attribute when
4491 generating 32-bit code, VSX and AltiVec instructions are not generated
4492 unless you use the @option{-mabi=altivec} option on the command line.
4494 @item tune=@var{TUNE}
4495 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4496 Specify the architecture to tune for when compiling the function.  If
4497 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4498 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4499 compilation tunes for the @var{CPU} architecture, and not the
4500 default tuning specified on the command line.
4501 @end table
4503 On the PowerPC, the inliner does not inline a
4504 function that has different target options than the caller, unless the
4505 callee has a subset of the target options of the caller.
4506 @end table
4508 @node RL78 Function Attributes
4509 @subsection RL78 Function Attributes
4511 These function attributes are supported by the RL78 back end:
4513 @table @code
4514 @item interrupt
4515 @itemx brk_interrupt
4516 @cindex @code{interrupt} function attribute, RL78
4517 @cindex @code{brk_interrupt} function attribute, RL78
4518 These attributes indicate
4519 that the specified function is an interrupt handler.  The compiler generates
4520 function entry and exit sequences suitable for use in an interrupt handler
4521 when this attribute is present.
4523 Use @code{brk_interrupt} instead of @code{interrupt} for
4524 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4525 that must end with @code{RETB} instead of @code{RETI}).
4527 @item naked
4528 @cindex @code{naked} function attribute, RL78
4529 This attribute allows the compiler to construct the
4530 requisite function declaration, while allowing the body of the
4531 function to be assembly code. The specified function will not have
4532 prologue/epilogue sequences generated by the compiler. Only basic
4533 @code{asm} statements can safely be included in naked functions
4534 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4535 basic @code{asm} and C code may appear to work, they cannot be
4536 depended upon to work reliably and are not supported.
4537 @end table
4539 @node RX Function Attributes
4540 @subsection RX Function Attributes
4542 These function attributes are supported by the RX back end:
4544 @table @code
4545 @item fast_interrupt
4546 @cindex @code{fast_interrupt} function attribute, RX
4547 Use this attribute on the RX port to indicate that the specified
4548 function is a fast interrupt handler.  This is just like the
4549 @code{interrupt} attribute, except that @code{freit} is used to return
4550 instead of @code{reit}.
4552 @item interrupt
4553 @cindex @code{interrupt} function attribute, RX
4554 Use this attribute to indicate
4555 that the specified function is an interrupt handler.  The compiler generates
4556 function entry and exit sequences suitable for use in an interrupt handler
4557 when this attribute is present.
4559 On RX targets, you may specify one or more vector numbers as arguments
4560 to the attribute, as well as naming an alternate table name.
4561 Parameters are handled sequentially, so one handler can be assigned to
4562 multiple entries in multiple tables.  One may also pass the magic
4563 string @code{"$default"} which causes the function to be used for any
4564 unfilled slots in the current table.
4566 This example shows a simple assignment of a function to one vector in
4567 the default table (note that preprocessor macros may be used for
4568 chip-specific symbolic vector names):
4569 @smallexample
4570 void __attribute__ ((interrupt (5))) txd1_handler ();
4571 @end smallexample
4573 This example assigns a function to two slots in the default table
4574 (using preprocessor macros defined elsewhere) and makes it the default
4575 for the @code{dct} table:
4576 @smallexample
4577 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4578         txd1_handler ();
4579 @end smallexample
4581 @item naked
4582 @cindex @code{naked} function attribute, RX
4583 This attribute allows the compiler to construct the
4584 requisite function declaration, while allowing the body of the
4585 function to be assembly code. The specified function will not have
4586 prologue/epilogue sequences generated by the compiler. Only basic
4587 @code{asm} statements can safely be included in naked functions
4588 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4589 basic @code{asm} and C code may appear to work, they cannot be
4590 depended upon to work reliably and are not supported.
4592 @item vector
4593 @cindex @code{vector} function attribute, RX
4594 This RX attribute is similar to the @code{interrupt} attribute, including its
4595 parameters, but does not make the function an interrupt-handler type
4596 function (i.e. it retains the normal C function calling ABI).  See the
4597 @code{interrupt} attribute for a description of its arguments.
4598 @end table
4600 @node S/390 Function Attributes
4601 @subsection S/390 Function Attributes
4603 These function attributes are supported on the S/390:
4605 @table @code
4606 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4607 @cindex @code{hotpatch} function attribute, S/390
4609 On S/390 System z targets, you can use this function attribute to
4610 make GCC generate a ``hot-patching'' function prologue.  If the
4611 @option{-mhotpatch=} command-line option is used at the same time,
4612 the @code{hotpatch} attribute takes precedence.  The first of the
4613 two arguments specifies the number of halfwords to be added before
4614 the function label.  A second argument can be used to specify the
4615 number of halfwords to be added after the function label.  For
4616 both arguments the maximum allowed value is 1000000.
4618 If both arguments are zero, hotpatching is disabled.
4619 @end table
4621 @node SH Function Attributes
4622 @subsection SH Function Attributes
4624 These function attributes are supported on the SH family of processors:
4626 @table @code
4627 @item function_vector
4628 @cindex @code{function_vector} function attribute, SH
4629 @cindex calling functions through the function vector on SH2A
4630 On SH2A targets, this attribute declares a function to be called using the
4631 TBR relative addressing mode.  The argument to this attribute is the entry
4632 number of the same function in a vector table containing all the TBR
4633 relative addressable functions.  For correct operation the TBR must be setup
4634 accordingly to point to the start of the vector table before any functions with
4635 this attribute are invoked.  Usually a good place to do the initialization is
4636 the startup routine.  The TBR relative vector table can have at max 256 function
4637 entries.  The jumps to these functions are generated using a SH2A specific,
4638 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
4639 from GNU binutils version 2.7 or later for this attribute to work correctly.
4641 In an application, for a function being called once, this attribute
4642 saves at least 8 bytes of code; and if other successive calls are being
4643 made to the same function, it saves 2 bytes of code per each of these
4644 calls.
4646 @item interrupt_handler
4647 @cindex @code{interrupt_handler} function attribute, SH
4648 Use this attribute to
4649 indicate that the specified function is an interrupt handler.  The compiler
4650 generates function entry and exit sequences suitable for use in an
4651 interrupt handler when this attribute is present.
4653 @item nosave_low_regs
4654 @cindex @code{nosave_low_regs} function attribute, SH
4655 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
4656 function should not save and restore registers R0..R7.  This can be used on SH3*
4657 and SH4* targets that have a second R0..R7 register bank for non-reentrant
4658 interrupt handlers.
4660 @item renesas
4661 @cindex @code{renesas} function attribute, SH
4662 On SH targets this attribute specifies that the function or struct follows the
4663 Renesas ABI.
4665 @item resbank
4666 @cindex @code{resbank} function attribute, SH
4667 On the SH2A target, this attribute enables the high-speed register
4668 saving and restoration using a register bank for @code{interrupt_handler}
4669 routines.  Saving to the bank is performed automatically after the CPU
4670 accepts an interrupt that uses a register bank.
4672 The nineteen 32-bit registers comprising general register R0 to R14,
4673 control register GBR, and system registers MACH, MACL, and PR and the
4674 vector table address offset are saved into a register bank.  Register
4675 banks are stacked in first-in last-out (FILO) sequence.  Restoration
4676 from the bank is executed by issuing a RESBANK instruction.
4678 @item sp_switch
4679 @cindex @code{sp_switch} function attribute, SH
4680 Use this attribute on the SH to indicate an @code{interrupt_handler}
4681 function should switch to an alternate stack.  It expects a string
4682 argument that names a global variable holding the address of the
4683 alternate stack.
4685 @smallexample
4686 void *alt_stack;
4687 void f () __attribute__ ((interrupt_handler,
4688                           sp_switch ("alt_stack")));
4689 @end smallexample
4691 @item trap_exit
4692 @cindex @code{trap_exit} function attribute, SH
4693 Use this attribute on the SH for an @code{interrupt_handler} to return using
4694 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4695 argument specifying the trap number to be used.
4697 @item trapa_handler
4698 @cindex @code{trapa_handler} function attribute, SH
4699 On SH targets this function attribute is similar to @code{interrupt_handler}
4700 but it does not save and restore all registers.
4701 @end table
4703 @node SPU Function Attributes
4704 @subsection SPU Function Attributes
4706 These function attributes are supported by the SPU back end:
4708 @table @code
4709 @item naked
4710 @cindex @code{naked} function attribute, SPU
4711 This attribute allows the compiler to construct the
4712 requisite function declaration, while allowing the body of the
4713 function to be assembly code. The specified function will not have
4714 prologue/epilogue sequences generated by the compiler. Only basic
4715 @code{asm} statements can safely be included in naked functions
4716 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4717 basic @code{asm} and C code may appear to work, they cannot be
4718 depended upon to work reliably and are not supported.
4719 @end table
4721 @node Symbian OS Function Attributes
4722 @subsection Symbian OS Function Attributes
4724 @xref{Microsoft Windows Function Attributes}, for discussion of the
4725 @code{dllexport} and @code{dllimport} attributes.
4727 @node Visium Function Attributes
4728 @subsection Visium Function Attributes
4730 These function attributes are supported by the Visium back end:
4732 @table @code
4733 @item interrupt
4734 @cindex @code{interrupt} function attribute, Visium
4735 Use this attribute to indicate
4736 that the specified function is an interrupt handler.  The compiler generates
4737 function entry and exit sequences suitable for use in an interrupt handler
4738 when this attribute is present.
4739 @end table
4741 @node x86 Function Attributes
4742 @subsection x86 Function Attributes
4744 These function attributes are supported by the x86 back end:
4746 @table @code
4747 @item cdecl
4748 @cindex @code{cdecl} function attribute, x86-32
4749 @cindex functions that pop the argument stack on x86-32
4750 @opindex mrtd
4751 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
4752 assume that the calling function pops off the stack space used to
4753 pass arguments.  This is
4754 useful to override the effects of the @option{-mrtd} switch.
4756 @item fastcall
4757 @cindex @code{fastcall} function attribute, x86-32
4758 @cindex functions that pop the argument stack on x86-32
4759 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
4760 pass the first argument (if of integral type) in the register ECX and
4761 the second argument (if of integral type) in the register EDX@.  Subsequent
4762 and other typed arguments are passed on the stack.  The called function
4763 pops the arguments off the stack.  If the number of arguments is variable all
4764 arguments are pushed on the stack.
4766 @item thiscall
4767 @cindex @code{thiscall} function attribute, x86-32
4768 @cindex functions that pop the argument stack on x86-32
4769 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
4770 pass the first argument (if of integral type) in the register ECX.
4771 Subsequent and other typed arguments are passed on the stack. The called
4772 function pops the arguments off the stack.
4773 If the number of arguments is variable all arguments are pushed on the
4774 stack.
4775 The @code{thiscall} attribute is intended for C++ non-static member functions.
4776 As a GCC extension, this calling convention can be used for C functions
4777 and for static member methods.
4779 @item ms_abi
4780 @itemx sysv_abi
4781 @cindex @code{ms_abi} function attribute, x86
4782 @cindex @code{sysv_abi} function attribute, x86
4784 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
4785 to indicate which calling convention should be used for a function.  The
4786 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
4787 while the @code{sysv_abi} attribute tells the compiler to use the ABI
4788 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
4789 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
4791 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
4792 requires the @option{-maccumulate-outgoing-args} option.
4794 @item callee_pop_aggregate_return (@var{number})
4795 @cindex @code{callee_pop_aggregate_return} function attribute, x86
4797 On x86-32 targets, you can use this attribute to control how
4798 aggregates are returned in memory.  If the caller is responsible for
4799 popping the hidden pointer together with the rest of the arguments, specify
4800 @var{number} equal to zero.  If callee is responsible for popping the
4801 hidden pointer, specify @var{number} equal to one.  
4803 The default x86-32 ABI assumes that the callee pops the
4804 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
4805 the compiler assumes that the
4806 caller pops the stack for hidden pointer.
4808 @item ms_hook_prologue
4809 @cindex @code{ms_hook_prologue} function attribute, x86
4811 On 32-bit and 64-bit x86 targets, you can use
4812 this function attribute to make GCC generate the ``hot-patching'' function
4813 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
4814 and newer.
4816 @item regparm (@var{number})
4817 @cindex @code{regparm} function attribute, x86
4818 @cindex functions that are passed arguments in registers on x86-32
4819 On x86-32 targets, the @code{regparm} attribute causes the compiler to
4820 pass arguments number one to @var{number} if they are of integral type
4821 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
4822 take a variable number of arguments continue to be passed all of their
4823 arguments on the stack.
4825 Beware that on some ELF systems this attribute is unsuitable for
4826 global functions in shared libraries with lazy binding (which is the
4827 default).  Lazy binding sends the first call via resolving code in
4828 the loader, which might assume EAX, EDX and ECX can be clobbered, as
4829 per the standard calling conventions.  Solaris 8 is affected by this.
4830 Systems with the GNU C Library version 2.1 or higher
4831 and FreeBSD are believed to be
4832 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
4833 disabled with the linker or the loader if desired, to avoid the
4834 problem.)
4836 @item sseregparm
4837 @cindex @code{sseregparm} function attribute, x86
4838 On x86-32 targets with SSE support, the @code{sseregparm} attribute
4839 causes the compiler to pass up to 3 floating-point arguments in
4840 SSE registers instead of on the stack.  Functions that take a
4841 variable number of arguments continue to pass all of their
4842 floating-point arguments on the stack.
4844 @item force_align_arg_pointer
4845 @cindex @code{force_align_arg_pointer} function attribute, x86
4846 On x86 targets, the @code{force_align_arg_pointer} attribute may be
4847 applied to individual function definitions, generating an alternate
4848 prologue and epilogue that realigns the run-time stack if necessary.
4849 This supports mixing legacy codes that run with a 4-byte aligned stack
4850 with modern codes that keep a 16-byte stack for SSE compatibility.
4852 @item stdcall
4853 @cindex @code{stdcall} function attribute, x86-32
4854 @cindex functions that pop the argument stack on x86-32
4855 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
4856 assume that the called function pops off the stack space used to
4857 pass arguments, unless it takes a variable number of arguments.
4859 @item target (@var{options})
4860 @cindex @code{target} function attribute
4861 As discussed in @ref{Common Function Attributes}, this attribute 
4862 allows specification of target-specific compilation options.
4864 On the x86, the following options are allowed:
4865 @table @samp
4866 @item abm
4867 @itemx no-abm
4868 @cindex @code{target("abm")} function attribute, x86
4869 Enable/disable the generation of the advanced bit instructions.
4871 @item aes
4872 @itemx no-aes
4873 @cindex @code{target("aes")} function attribute, x86
4874 Enable/disable the generation of the AES instructions.
4876 @item default
4877 @cindex @code{target("default")} function attribute, x86
4878 @xref{Function Multiversioning}, where it is used to specify the
4879 default function version.
4881 @item mmx
4882 @itemx no-mmx
4883 @cindex @code{target("mmx")} function attribute, x86
4884 Enable/disable the generation of the MMX instructions.
4886 @item pclmul
4887 @itemx no-pclmul
4888 @cindex @code{target("pclmul")} function attribute, x86
4889 Enable/disable the generation of the PCLMUL instructions.
4891 @item popcnt
4892 @itemx no-popcnt
4893 @cindex @code{target("popcnt")} function attribute, x86
4894 Enable/disable the generation of the POPCNT instruction.
4896 @item sse
4897 @itemx no-sse
4898 @cindex @code{target("sse")} function attribute, x86
4899 Enable/disable the generation of the SSE instructions.
4901 @item sse2
4902 @itemx no-sse2
4903 @cindex @code{target("sse2")} function attribute, x86
4904 Enable/disable the generation of the SSE2 instructions.
4906 @item sse3
4907 @itemx no-sse3
4908 @cindex @code{target("sse3")} function attribute, x86
4909 Enable/disable the generation of the SSE3 instructions.
4911 @item sse4
4912 @itemx no-sse4
4913 @cindex @code{target("sse4")} function attribute, x86
4914 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4915 and SSE4.2).
4917 @item sse4.1
4918 @itemx no-sse4.1
4919 @cindex @code{target("sse4.1")} function attribute, x86
4920 Enable/disable the generation of the sse4.1 instructions.
4922 @item sse4.2
4923 @itemx no-sse4.2
4924 @cindex @code{target("sse4.2")} function attribute, x86
4925 Enable/disable the generation of the sse4.2 instructions.
4927 @item sse4a
4928 @itemx no-sse4a
4929 @cindex @code{target("sse4a")} function attribute, x86
4930 Enable/disable the generation of the SSE4A instructions.
4932 @item fma4
4933 @itemx no-fma4
4934 @cindex @code{target("fma4")} function attribute, x86
4935 Enable/disable the generation of the FMA4 instructions.
4937 @item xop
4938 @itemx no-xop
4939 @cindex @code{target("xop")} function attribute, x86
4940 Enable/disable the generation of the XOP instructions.
4942 @item lwp
4943 @itemx no-lwp
4944 @cindex @code{target("lwp")} function attribute, x86
4945 Enable/disable the generation of the LWP instructions.
4947 @item ssse3
4948 @itemx no-ssse3
4949 @cindex @code{target("ssse3")} function attribute, x86
4950 Enable/disable the generation of the SSSE3 instructions.
4952 @item cld
4953 @itemx no-cld
4954 @cindex @code{target("cld")} function attribute, x86
4955 Enable/disable the generation of the CLD before string moves.
4957 @item fancy-math-387
4958 @itemx no-fancy-math-387
4959 @cindex @code{target("fancy-math-387")} function attribute, x86
4960 Enable/disable the generation of the @code{sin}, @code{cos}, and
4961 @code{sqrt} instructions on the 387 floating-point unit.
4963 @item fused-madd
4964 @itemx no-fused-madd
4965 @cindex @code{target("fused-madd")} function attribute, x86
4966 Enable/disable the generation of the fused multiply/add instructions.
4968 @item ieee-fp
4969 @itemx no-ieee-fp
4970 @cindex @code{target("ieee-fp")} function attribute, x86
4971 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4973 @item inline-all-stringops
4974 @itemx no-inline-all-stringops
4975 @cindex @code{target("inline-all-stringops")} function attribute, x86
4976 Enable/disable inlining of string operations.
4978 @item inline-stringops-dynamically
4979 @itemx no-inline-stringops-dynamically
4980 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
4981 Enable/disable the generation of the inline code to do small string
4982 operations and calling the library routines for large operations.
4984 @item align-stringops
4985 @itemx no-align-stringops
4986 @cindex @code{target("align-stringops")} function attribute, x86
4987 Do/do not align destination of inlined string operations.
4989 @item recip
4990 @itemx no-recip
4991 @cindex @code{target("recip")} function attribute, x86
4992 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4993 instructions followed an additional Newton-Raphson step instead of
4994 doing a floating-point division.
4996 @item arch=@var{ARCH}
4997 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
4998 Specify the architecture to generate code for in compiling the function.
5000 @item tune=@var{TUNE}
5001 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5002 Specify the architecture to tune for in compiling the function.
5004 @item fpmath=@var{FPMATH}
5005 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5006 Specify which floating-point unit to use.  You must specify the
5007 @code{target("fpmath=sse,387")} option as
5008 @code{target("fpmath=sse+387")} because the comma would separate
5009 different options.
5010 @end table
5012 On the x86, the inliner does not inline a
5013 function that has different target options than the caller, unless the
5014 callee has a subset of the target options of the caller.  For example
5015 a function declared with @code{target("sse3")} can inline a function
5016 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5017 @end table
5019 @node Xstormy16 Function Attributes
5020 @subsection Xstormy16 Function Attributes
5022 These function attributes are supported by the Xstormy16 back end:
5024 @table @code
5025 @item interrupt
5026 @cindex @code{interrupt} function attribute, Xstormy16
5027 Use this attribute to indicate
5028 that the specified function is an interrupt handler.  The compiler generates
5029 function entry and exit sequences suitable for use in an interrupt handler
5030 when this attribute is present.
5031 @end table
5033 @node Variable Attributes
5034 @section Specifying Attributes of Variables
5035 @cindex attribute of variables
5036 @cindex variable attributes
5038 The keyword @code{__attribute__} allows you to specify special
5039 attributes of variables or structure fields.  This keyword is followed
5040 by an attribute specification inside double parentheses.  Some
5041 attributes are currently defined generically for variables.
5042 Other attributes are defined for variables on particular target
5043 systems.  Other attributes are available for functions
5044 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
5045 types (@pxref{Type Attributes}).
5046 Other front ends might define more attributes
5047 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5049 @xref{Attribute Syntax}, for details of the exact syntax for using
5050 attributes.
5052 @menu
5053 * Common Variable Attributes::
5054 * AVR Variable Attributes::
5055 * Blackfin Variable Attributes::
5056 * H8/300 Variable Attributes::
5057 * IA-64 Variable Attributes::
5058 * M32R/D Variable Attributes::
5059 * MeP Variable Attributes::
5060 * Microsoft Windows Variable Attributes::
5061 * PowerPC Variable Attributes::
5062 * SPU Variable Attributes::
5063 * x86 Variable Attributes::
5064 * Xstormy16 Variable Attributes::
5065 @end menu
5067 @node Common Variable Attributes
5068 @subsection Common Variable Attributes
5070 The following attributes are supported on most targets.
5072 @table @code
5073 @cindex @code{aligned} variable attribute
5074 @item aligned (@var{alignment})
5075 This attribute specifies a minimum alignment for the variable or
5076 structure field, measured in bytes.  For example, the declaration:
5078 @smallexample
5079 int x __attribute__ ((aligned (16))) = 0;
5080 @end smallexample
5082 @noindent
5083 causes the compiler to allocate the global variable @code{x} on a
5084 16-byte boundary.  On a 68040, this could be used in conjunction with
5085 an @code{asm} expression to access the @code{move16} instruction which
5086 requires 16-byte aligned operands.
5088 You can also specify the alignment of structure fields.  For example, to
5089 create a double-word aligned @code{int} pair, you could write:
5091 @smallexample
5092 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5093 @end smallexample
5095 @noindent
5096 This is an alternative to creating a union with a @code{double} member,
5097 which forces the union to be double-word aligned.
5099 As in the preceding examples, you can explicitly specify the alignment
5100 (in bytes) that you wish the compiler to use for a given variable or
5101 structure field.  Alternatively, you can leave out the alignment factor
5102 and just ask the compiler to align a variable or field to the
5103 default alignment for the target architecture you are compiling for.
5104 The default alignment is sufficient for all scalar types, but may not be
5105 enough for all vector types on a target that supports vector operations.
5106 The default alignment is fixed for a particular target ABI.
5108 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5109 which is the largest alignment ever used for any data type on the
5110 target machine you are compiling for.  For example, you could write:
5112 @smallexample
5113 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5114 @end smallexample
5116 The compiler automatically sets the alignment for the declared
5117 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5118 often make copy operations more efficient, because the compiler can
5119 use whatever instructions copy the biggest chunks of memory when
5120 performing copies to or from the variables or fields that you have
5121 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5122 may change depending on command-line options.
5124 When used on a struct, or struct member, the @code{aligned} attribute can
5125 only increase the alignment; in order to decrease it, the @code{packed}
5126 attribute must be specified as well.  When used as part of a typedef, the
5127 @code{aligned} attribute can both increase and decrease alignment, and
5128 specifying the @code{packed} attribute generates a warning.
5130 Note that the effectiveness of @code{aligned} attributes may be limited
5131 by inherent limitations in your linker.  On many systems, the linker is
5132 only able to arrange for variables to be aligned up to a certain maximum
5133 alignment.  (For some linkers, the maximum supported alignment may
5134 be very very small.)  If your linker is only able to align variables
5135 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5136 in an @code{__attribute__} still only provides you with 8-byte
5137 alignment.  See your linker documentation for further information.
5139 The @code{aligned} attribute can also be used for functions
5140 (@pxref{Common Function Attributes}.)
5142 @item cleanup (@var{cleanup_function})
5143 @cindex @code{cleanup} variable attribute
5144 The @code{cleanup} attribute runs a function when the variable goes
5145 out of scope.  This attribute can only be applied to auto function
5146 scope variables; it may not be applied to parameters or variables
5147 with static storage duration.  The function must take one parameter,
5148 a pointer to a type compatible with the variable.  The return value
5149 of the function (if any) is ignored.
5151 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5152 is run during the stack unwinding that happens during the
5153 processing of the exception.  Note that the @code{cleanup} attribute
5154 does not allow the exception to be caught, only to perform an action.
5155 It is undefined what happens if @var{cleanup_function} does not
5156 return normally.
5158 @item common
5159 @itemx nocommon
5160 @cindex @code{common} variable attribute
5161 @cindex @code{nocommon} variable attribute
5162 @opindex fcommon
5163 @opindex fno-common
5164 The @code{common} attribute requests GCC to place a variable in
5165 ``common'' storage.  The @code{nocommon} attribute requests the
5166 opposite---to allocate space for it directly.
5168 These attributes override the default chosen by the
5169 @option{-fno-common} and @option{-fcommon} flags respectively.
5171 @item deprecated
5172 @itemx deprecated (@var{msg})
5173 @cindex @code{deprecated} variable attribute
5174 The @code{deprecated} attribute results in a warning if the variable
5175 is used anywhere in the source file.  This is useful when identifying
5176 variables that are expected to be removed in a future version of a
5177 program.  The warning also includes the location of the declaration
5178 of the deprecated variable, to enable users to easily find further
5179 information about why the variable is deprecated, or what they should
5180 do instead.  Note that the warning only occurs for uses:
5182 @smallexample
5183 extern int old_var __attribute__ ((deprecated));
5184 extern int old_var;
5185 int new_fn () @{ return old_var; @}
5186 @end smallexample
5188 @noindent
5189 results in a warning on line 3 but not line 2.  The optional @var{msg}
5190 argument, which must be a string, is printed in the warning if
5191 present.
5193 The @code{deprecated} attribute can also be used for functions and
5194 types (@pxref{Common Function Attributes},
5195 @pxref{Common Type Attributes}).
5197 @item mode (@var{mode})
5198 @cindex @code{mode} variable attribute
5199 This attribute specifies the data type for the declaration---whichever
5200 type corresponds to the mode @var{mode}.  This in effect lets you
5201 request an integer or floating-point type according to its width.
5203 You may also specify a mode of @code{byte} or @code{__byte__} to
5204 indicate the mode corresponding to a one-byte integer, @code{word} or
5205 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5206 or @code{__pointer__} for the mode used to represent pointers.
5208 @item packed
5209 @cindex @code{packed} variable attribute
5210 The @code{packed} attribute specifies that a variable or structure field
5211 should have the smallest possible alignment---one byte for a variable,
5212 and one bit for a field, unless you specify a larger value with the
5213 @code{aligned} attribute.
5215 Here is a structure in which the field @code{x} is packed, so that it
5216 immediately follows @code{a}:
5218 @smallexample
5219 struct foo
5221   char a;
5222   int x[2] __attribute__ ((packed));
5224 @end smallexample
5226 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5227 @code{packed} attribute on bit-fields of type @code{char}.  This has
5228 been fixed in GCC 4.4 but the change can lead to differences in the
5229 structure layout.  See the documentation of
5230 @option{-Wpacked-bitfield-compat} for more information.
5232 @item section ("@var{section-name}")
5233 @cindex @code{section} variable attribute
5234 Normally, the compiler places the objects it generates in sections like
5235 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5236 or you need certain particular variables to appear in special sections,
5237 for example to map to special hardware.  The @code{section}
5238 attribute specifies that a variable (or function) lives in a particular
5239 section.  For example, this small program uses several specific section names:
5241 @smallexample
5242 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5243 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5244 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5245 int init_data __attribute__ ((section ("INITDATA")));
5247 main()
5249   /* @r{Initialize stack pointer} */
5250   init_sp (stack + sizeof (stack));
5252   /* @r{Initialize initialized data} */
5253   memcpy (&init_data, &data, &edata - &data);
5255   /* @r{Turn on the serial ports} */
5256   init_duart (&a);
5257   init_duart (&b);
5259 @end smallexample
5261 @noindent
5262 Use the @code{section} attribute with
5263 @emph{global} variables and not @emph{local} variables,
5264 as shown in the example.
5266 You may use the @code{section} attribute with initialized or
5267 uninitialized global variables but the linker requires
5268 each object be defined once, with the exception that uninitialized
5269 variables tentatively go in the @code{common} (or @code{bss}) section
5270 and can be multiply ``defined''.  Using the @code{section} attribute
5271 changes what section the variable goes into and may cause the
5272 linker to issue an error if an uninitialized variable has multiple
5273 definitions.  You can force a variable to be initialized with the
5274 @option{-fno-common} flag or the @code{nocommon} attribute.
5276 Some file formats do not support arbitrary sections so the @code{section}
5277 attribute is not available on all platforms.
5278 If you need to map the entire contents of a module to a particular
5279 section, consider using the facilities of the linker instead.
5281 @item tls_model ("@var{tls_model}")
5282 @cindex @code{tls_model} variable attribute
5283 The @code{tls_model} attribute sets thread-local storage model
5284 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5285 overriding @option{-ftls-model=} command-line switch on a per-variable
5286 basis.
5287 The @var{tls_model} argument should be one of @code{global-dynamic},
5288 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5290 Not all targets support this attribute.
5292 @item unused
5293 @cindex @code{unused} variable attribute
5294 This attribute, attached to a variable, means that the variable is meant
5295 to be possibly unused.  GCC does not produce a warning for this
5296 variable.
5298 @item used
5299 @cindex @code{used} variable attribute
5300 This attribute, attached to a variable with static storage, means that
5301 the variable must be emitted even if it appears that the variable is not
5302 referenced.
5304 When applied to a static data member of a C++ class template, the
5305 attribute also means that the member is instantiated if the
5306 class itself is instantiated.
5308 @item vector_size (@var{bytes})
5309 @cindex @code{vector_size} variable attribute
5310 This attribute specifies the vector size for the variable, measured in
5311 bytes.  For example, the declaration:
5313 @smallexample
5314 int foo __attribute__ ((vector_size (16)));
5315 @end smallexample
5317 @noindent
5318 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5319 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5320 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5322 This attribute is only applicable to integral and float scalars,
5323 although arrays, pointers, and function return values are allowed in
5324 conjunction with this construct.
5326 Aggregates with this attribute are invalid, even if they are of the same
5327 size as a corresponding scalar.  For example, the declaration:
5329 @smallexample
5330 struct S @{ int a; @};
5331 struct S  __attribute__ ((vector_size (16))) foo;
5332 @end smallexample
5334 @noindent
5335 is invalid even if the size of the structure is the same as the size of
5336 the @code{int}.
5338 @item weak
5339 @cindex @code{weak} variable attribute
5340 The @code{weak} attribute is described in
5341 @ref{Common Function Attributes}.
5343 @end table
5345 @node AVR Variable Attributes
5346 @subsection AVR Variable Attributes
5348 @table @code
5349 @item progmem
5350 @cindex @code{progmem} variable attribute, AVR
5351 The @code{progmem} attribute is used on the AVR to place read-only
5352 data in the non-volatile program memory (flash). The @code{progmem}
5353 attribute accomplishes this by putting respective variables into a
5354 section whose name starts with @code{.progmem}.
5356 This attribute works similar to the @code{section} attribute
5357 but adds additional checking. Notice that just like the
5358 @code{section} attribute, @code{progmem} affects the location
5359 of the data but not how this data is accessed.
5361 In order to read data located with the @code{progmem} attribute
5362 (inline) assembler must be used.
5363 @smallexample
5364 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5365 #include <avr/pgmspace.h> 
5367 /* Locate var in flash memory */
5368 const int var[2] PROGMEM = @{ 1, 2 @};
5370 int read_var (int i)
5372     /* Access var[] by accessor macro from avr/pgmspace.h */
5373     return (int) pgm_read_word (& var[i]);
5375 @end smallexample
5377 AVR is a Harvard architecture processor and data and read-only data
5378 normally resides in the data memory (RAM).
5380 See also the @ref{AVR Named Address Spaces} section for
5381 an alternate way to locate and access data in flash memory.
5383 @item io
5384 @itemx io (@var{addr})
5385 @cindex @code{io} variable attribute, AVR
5386 Variables with the @code{io} attribute are used to address
5387 memory-mapped peripherals in the io address range.
5388 If an address is specified, the variable
5389 is assigned that address, and the value is interpreted as an
5390 address in the data address space.
5391 Example:
5393 @smallexample
5394 volatile int porta __attribute__((io (0x22)));
5395 @end smallexample
5397 The address specified in the address in the data address range.
5399 Otherwise, the variable it is not assigned an address, but the
5400 compiler will still use in/out instructions where applicable,
5401 assuming some other module assigns an address in the io address range.
5402 Example:
5404 @smallexample
5405 extern volatile int porta __attribute__((io));
5406 @end smallexample
5408 @item io_low
5409 @itemx io_low (@var{addr})
5410 @cindex @code{io_low} variable attribute, AVR
5411 This is like the @code{io} attribute, but additionally it informs the
5412 compiler that the object lies in the lower half of the I/O area,
5413 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5414 instructions.
5416 @item address
5417 @itemx address (@var{addr})
5418 @cindex @code{address} variable attribute, AVR
5419 Variables with the @code{address} attribute are used to address
5420 memory-mapped peripherals that may lie outside the io address range.
5422 @smallexample
5423 volatile int porta __attribute__((address (0x600)));
5424 @end smallexample
5426 @end table
5428 @node Blackfin Variable Attributes
5429 @subsection Blackfin Variable Attributes
5431 Three attributes are currently defined for the Blackfin.
5433 @table @code
5434 @item l1_data
5435 @itemx l1_data_A
5436 @itemx l1_data_B
5437 @cindex @code{l1_data} variable attribute, Blackfin
5438 @cindex @code{l1_data_A} variable attribute, Blackfin
5439 @cindex @code{l1_data_B} variable attribute, Blackfin
5440 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5441 Variables with @code{l1_data} attribute are put into the specific section
5442 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5443 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5444 attribute are put into the specific section named @code{.l1.data.B}.
5446 @item l2
5447 @cindex @code{l2} variable attribute, Blackfin
5448 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5449 Variables with @code{l2} attribute are put into the specific section
5450 named @code{.l2.data}.
5451 @end table
5453 @node H8/300 Variable Attributes
5454 @subsection H8/300 Variable Attributes
5456 These variable attributes are available for H8/300 targets:
5458 @table @code
5459 @item eightbit_data
5460 @cindex @code{eightbit_data} variable attribute, H8/300
5461 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5462 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5463 variable should be placed into the eight-bit data section.
5464 The compiler generates more efficient code for certain operations
5465 on data in the eight-bit data area.  Note the eight-bit data area is limited to
5466 256 bytes of data.
5468 You must use GAS and GLD from GNU binutils version 2.7 or later for
5469 this attribute to work correctly.
5471 @item tiny_data
5472 @cindex @code{tiny_data} variable attribute, H8/300
5473 @cindex tiny data section on the H8/300H and H8S
5474 Use this attribute on the H8/300H and H8S to indicate that the specified
5475 variable should be placed into the tiny data section.
5476 The compiler generates more efficient code for loads and stores
5477 on data in the tiny data section.  Note the tiny data area is limited to
5478 slightly under 32KB of data.
5480 @end table
5482 @node IA-64 Variable Attributes
5483 @subsection IA-64 Variable Attributes
5485 The IA-64 back end supports the following variable attribute:
5487 @table @code
5488 @item model (@var{model-name})
5489 @cindex @code{model} variable attribute, IA-64
5491 On IA-64, use this attribute to set the addressability of an object.
5492 At present, the only supported identifier for @var{model-name} is
5493 @code{small}, indicating addressability via ``small'' (22-bit)
5494 addresses (so that their addresses can be loaded with the @code{addl}
5495 instruction).  Caveat: such addressing is by definition not position
5496 independent and hence this attribute must not be used for objects
5497 defined by shared libraries.
5499 @end table
5501 @node M32R/D Variable Attributes
5502 @subsection M32R/D Variable Attributes
5504 One attribute is currently defined for the M32R/D@.
5506 @table @code
5507 @item model (@var{model-name})
5508 @cindex @code{model-name} variable attribute, M32R/D
5509 @cindex variable addressability on the M32R/D
5510 Use this attribute on the M32R/D to set the addressability of an object.
5511 The identifier @var{model-name} is one of @code{small}, @code{medium},
5512 or @code{large}, representing each of the code models.
5514 Small model objects live in the lower 16MB of memory (so that their
5515 addresses can be loaded with the @code{ld24} instruction).
5517 Medium and large model objects may live anywhere in the 32-bit address space
5518 (the compiler generates @code{seth/add3} instructions to load their
5519 addresses).
5520 @end table
5522 @node MeP Variable Attributes
5523 @subsection MeP Variable Attributes
5525 The MeP target has a number of addressing modes and busses.  The
5526 @code{near} space spans the standard memory space's first 16 megabytes
5527 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5528 The @code{based} space is a 128-byte region in the memory space that
5529 is addressed relative to the @code{$tp} register.  The @code{tiny}
5530 space is a 65536-byte region relative to the @code{$gp} register.  In
5531 addition to these memory regions, the MeP target has a separate 16-bit
5532 control bus which is specified with @code{cb} attributes.
5534 @table @code
5536 @item based
5537 @cindex @code{based} variable attribute, MeP
5538 Any variable with the @code{based} attribute is assigned to the
5539 @code{.based} section, and is accessed with relative to the
5540 @code{$tp} register.
5542 @item tiny
5543 @cindex @code{tiny} variable attribute, MeP
5544 Likewise, the @code{tiny} attribute assigned variables to the
5545 @code{.tiny} section, relative to the @code{$gp} register.
5547 @item near
5548 @cindex @code{near} variable attribute, MeP
5549 Variables with the @code{near} attribute are assumed to have addresses
5550 that fit in a 24-bit addressing mode.  This is the default for large
5551 variables (@code{-mtiny=4} is the default) but this attribute can
5552 override @code{-mtiny=} for small variables, or override @code{-ml}.
5554 @item far
5555 @cindex @code{far} variable attribute, MeP
5556 Variables with the @code{far} attribute are addressed using a full
5557 32-bit address.  Since this covers the entire memory space, this
5558 allows modules to make no assumptions about where variables might be
5559 stored.
5561 @item io
5562 @cindex @code{io} variable attribute, MeP
5563 @itemx io (@var{addr})
5564 Variables with the @code{io} attribute are used to address
5565 memory-mapped peripherals.  If an address is specified, the variable
5566 is assigned that address, else it is not assigned an address (it is
5567 assumed some other module assigns an address).  Example:
5569 @smallexample
5570 int timer_count __attribute__((io(0x123)));
5571 @end smallexample
5573 @item cb
5574 @itemx cb (@var{addr})
5575 @cindex @code{cb} variable attribute, MeP
5576 Variables with the @code{cb} attribute are used to access the control
5577 bus, using special instructions.  @code{addr} indicates the control bus
5578 address.  Example:
5580 @smallexample
5581 int cpu_clock __attribute__((cb(0x123)));
5582 @end smallexample
5584 @end table
5586 @node Microsoft Windows Variable Attributes
5587 @subsection Microsoft Windows Variable Attributes
5589 You can use these attributes on Microsoft Windows targets.
5590 @ref{x86 Variable Attributes} for additional Windows compatibility
5591 attributes available on all x86 targets.
5593 @table @code
5594 @item dllimport
5595 @itemx dllexport
5596 @cindex @code{dllimport} variable attribute
5597 @cindex @code{dllexport} variable attribute
5598 The @code{dllimport} and @code{dllexport} attributes are described in
5599 @ref{Microsoft Windows Function Attributes}.
5601 @item selectany
5602 @cindex @code{selectany} variable attribute
5603 The @code{selectany} attribute causes an initialized global variable to
5604 have link-once semantics.  When multiple definitions of the variable are
5605 encountered by the linker, the first is selected and the remainder are
5606 discarded.  Following usage by the Microsoft compiler, the linker is told
5607 @emph{not} to warn about size or content differences of the multiple
5608 definitions.
5610 Although the primary usage of this attribute is for POD types, the
5611 attribute can also be applied to global C++ objects that are initialized
5612 by a constructor.  In this case, the static initialization and destruction
5613 code for the object is emitted in each translation defining the object,
5614 but the calls to the constructor and destructor are protected by a
5615 link-once guard variable.
5617 The @code{selectany} attribute is only available on Microsoft Windows
5618 targets.  You can use @code{__declspec (selectany)} as a synonym for
5619 @code{__attribute__ ((selectany))} for compatibility with other
5620 compilers.
5622 @item shared
5623 @cindex @code{shared} variable attribute
5624 On Microsoft Windows, in addition to putting variable definitions in a named
5625 section, the section can also be shared among all running copies of an
5626 executable or DLL@.  For example, this small program defines shared data
5627 by putting it in a named section @code{shared} and marking the section
5628 shareable:
5630 @smallexample
5631 int foo __attribute__((section ("shared"), shared)) = 0;
5634 main()
5636   /* @r{Read and write foo.  All running
5637      copies see the same value.}  */
5638   return 0;
5640 @end smallexample
5642 @noindent
5643 You may only use the @code{shared} attribute along with @code{section}
5644 attribute with a fully-initialized global definition because of the way
5645 linkers work.  See @code{section} attribute for more information.
5647 The @code{shared} attribute is only available on Microsoft Windows@.
5649 @end table
5651 @node PowerPC Variable Attributes
5652 @subsection PowerPC Variable Attributes
5654 Three attributes currently are defined for PowerPC configurations:
5655 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5657 @cindex @code{ms_struct} variable attribute, PowerPC
5658 @cindex @code{gcc_struct} variable attribute, PowerPC
5659 For full documentation of the struct attributes please see the
5660 documentation in @ref{x86 Variable Attributes}.
5662 @cindex @code{altivec} variable attribute, PowerPC
5663 For documentation of @code{altivec} attribute please see the
5664 documentation in @ref{PowerPC Type Attributes}.
5666 @node SPU Variable Attributes
5667 @subsection SPU Variable Attributes
5669 @cindex @code{spu_vector} variable attribute, SPU
5670 The SPU supports the @code{spu_vector} attribute for variables.  For
5671 documentation of this attribute please see the documentation in
5672 @ref{SPU Type Attributes}.
5674 @node x86 Variable Attributes
5675 @subsection x86 Variable Attributes
5677 Two attributes are currently defined for x86 configurations:
5678 @code{ms_struct} and @code{gcc_struct}.
5680 @table @code
5681 @item ms_struct
5682 @itemx gcc_struct
5683 @cindex @code{ms_struct} variable attribute, x86
5684 @cindex @code{gcc_struct} variable attribute, x86
5686 If @code{packed} is used on a structure, or if bit-fields are used,
5687 it may be that the Microsoft ABI lays out the structure differently
5688 than the way GCC normally does.  Particularly when moving packed
5689 data between functions compiled with GCC and the native Microsoft compiler
5690 (either via function call or as data in a file), it may be necessary to access
5691 either format.
5693 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
5694 compilers to match the native Microsoft compiler.
5696 The Microsoft structure layout algorithm is fairly simple with the exception
5697 of the bit-field packing.  
5698 The padding and alignment of members of structures and whether a bit-field 
5699 can straddle a storage-unit boundary are determine by these rules:
5701 @enumerate
5702 @item Structure members are stored sequentially in the order in which they are
5703 declared: the first member has the lowest memory address and the last member
5704 the highest.
5706 @item Every data object has an alignment requirement.  The alignment requirement
5707 for all data except structures, unions, and arrays is either the size of the
5708 object or the current packing size (specified with either the
5709 @code{aligned} attribute or the @code{pack} pragma),
5710 whichever is less.  For structures, unions, and arrays,
5711 the alignment requirement is the largest alignment requirement of its members.
5712 Every object is allocated an offset so that:
5714 @smallexample
5715 offset % alignment_requirement == 0
5716 @end smallexample
5718 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5719 unit if the integral types are the same size and if the next bit-field fits
5720 into the current allocation unit without crossing the boundary imposed by the
5721 common alignment requirements of the bit-fields.
5722 @end enumerate
5724 MSVC interprets zero-length bit-fields in the following ways:
5726 @enumerate
5727 @item If a zero-length bit-field is inserted between two bit-fields that
5728 are normally coalesced, the bit-fields are not coalesced.
5730 For example:
5732 @smallexample
5733 struct
5734  @{
5735    unsigned long bf_1 : 12;
5736    unsigned long : 0;
5737    unsigned long bf_2 : 12;
5738  @} t1;
5739 @end smallexample
5741 @noindent
5742 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5743 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5745 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5746 alignment of the zero-length bit-field is greater than the member that follows it,
5747 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5749 For example:
5751 @smallexample
5752 struct
5753  @{
5754    char foo : 4;
5755    short : 0;
5756    char bar;
5757  @} t2;
5759 struct
5760  @{
5761    char foo : 4;
5762    short : 0;
5763    double bar;
5764  @} t3;
5765 @end smallexample
5767 @noindent
5768 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5769 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5770 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5771 of the structure.
5773 Taking this into account, it is important to note the following:
5775 @enumerate
5776 @item If a zero-length bit-field follows a normal bit-field, the type of the
5777 zero-length bit-field may affect the alignment of the structure as whole. For
5778 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5779 normal bit-field, and is of type short.
5781 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5782 still affect the alignment of the structure:
5784 @smallexample
5785 struct
5786  @{
5787    char foo : 6;
5788    long : 0;
5789  @} t4;
5790 @end smallexample
5792 @noindent
5793 Here, @code{t4} takes up 4 bytes.
5794 @end enumerate
5796 @item Zero-length bit-fields following non-bit-field members are ignored:
5798 @smallexample
5799 struct
5800  @{
5801    char foo;
5802    long : 0;
5803    char bar;
5804  @} t5;
5805 @end smallexample
5807 @noindent
5808 Here, @code{t5} takes up 2 bytes.
5809 @end enumerate
5810 @end table
5812 @node Xstormy16 Variable Attributes
5813 @subsection Xstormy16 Variable Attributes
5815 One attribute is currently defined for xstormy16 configurations:
5816 @code{below100}.
5818 @table @code
5819 @item below100
5820 @cindex @code{below100} variable attribute, Xstormy16
5822 If a variable has the @code{below100} attribute (@code{BELOW100} is
5823 allowed also), GCC places the variable in the first 0x100 bytes of
5824 memory and use special opcodes to access it.  Such variables are
5825 placed in either the @code{.bss_below100} section or the
5826 @code{.data_below100} section.
5828 @end table
5830 @node Type Attributes
5831 @section Specifying Attributes of Types
5832 @cindex attribute of types
5833 @cindex type attributes
5835 The keyword @code{__attribute__} allows you to specify special
5836 attributes of types.  Some type attributes apply only to @code{struct}
5837 and @code{union} types, while others can apply to any type defined
5838 via a @code{typedef} declaration.  Other attributes are defined for
5839 functions (@pxref{Function Attributes}), labels (@pxref{Label 
5840 Attributes}) and for variables (@pxref{Variable Attributes}).
5842 The @code{__attribute__} keyword is followed by an attribute specification
5843 inside double parentheses.  
5845 You may specify type attributes in an enum, struct or union type
5846 declaration or definition by placing them immediately after the
5847 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
5848 syntax is to place them just past the closing curly brace of the
5849 definition.
5851 You can also include type attributes in a @code{typedef} declaration.
5852 @xref{Attribute Syntax}, for details of the exact syntax for using
5853 attributes.
5855 @menu
5856 * Common Type Attributes::
5857 * ARM Type Attributes::
5858 * MeP Type Attributes::
5859 * PowerPC Type Attributes::
5860 * SPU Type Attributes::
5861 * x86 Type Attributes::
5862 @end menu
5864 @node Common Type Attributes
5865 @subsection Common Type Attributes
5867 The following type attributes are supported on most targets.
5869 @table @code
5870 @cindex @code{aligned} type attribute
5871 @item aligned (@var{alignment})
5872 This attribute specifies a minimum alignment (in bytes) for variables
5873 of the specified type.  For example, the declarations:
5875 @smallexample
5876 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5877 typedef int more_aligned_int __attribute__ ((aligned (8)));
5878 @end smallexample
5880 @noindent
5881 force the compiler to ensure (as far as it can) that each variable whose
5882 type is @code{struct S} or @code{more_aligned_int} is allocated and
5883 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5884 variables of type @code{struct S} aligned to 8-byte boundaries allows
5885 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5886 store) instructions when copying one variable of type @code{struct S} to
5887 another, thus improving run-time efficiency.
5889 Note that the alignment of any given @code{struct} or @code{union} type
5890 is required by the ISO C standard to be at least a perfect multiple of
5891 the lowest common multiple of the alignments of all of the members of
5892 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5893 effectively adjust the alignment of a @code{struct} or @code{union}
5894 type by attaching an @code{aligned} attribute to any one of the members
5895 of such a type, but the notation illustrated in the example above is a
5896 more obvious, intuitive, and readable way to request the compiler to
5897 adjust the alignment of an entire @code{struct} or @code{union} type.
5899 As in the preceding example, you can explicitly specify the alignment
5900 (in bytes) that you wish the compiler to use for a given @code{struct}
5901 or @code{union} type.  Alternatively, you can leave out the alignment factor
5902 and just ask the compiler to align a type to the maximum
5903 useful alignment for the target machine you are compiling for.  For
5904 example, you could write:
5906 @smallexample
5907 struct S @{ short f[3]; @} __attribute__ ((aligned));
5908 @end smallexample
5910 Whenever you leave out the alignment factor in an @code{aligned}
5911 attribute specification, the compiler automatically sets the alignment
5912 for the type to the largest alignment that is ever used for any data
5913 type on the target machine you are compiling for.  Doing this can often
5914 make copy operations more efficient, because the compiler can use
5915 whatever instructions copy the biggest chunks of memory when performing
5916 copies to or from the variables that have types that you have aligned
5917 this way.
5919 In the example above, if the size of each @code{short} is 2 bytes, then
5920 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5921 power of two that is greater than or equal to that is 8, so the
5922 compiler sets the alignment for the entire @code{struct S} type to 8
5923 bytes.
5925 Note that although you can ask the compiler to select a time-efficient
5926 alignment for a given type and then declare only individual stand-alone
5927 objects of that type, the compiler's ability to select a time-efficient
5928 alignment is primarily useful only when you plan to create arrays of
5929 variables having the relevant (efficiently aligned) type.  If you
5930 declare or use arrays of variables of an efficiently-aligned type, then
5931 it is likely that your program also does pointer arithmetic (or
5932 subscripting, which amounts to the same thing) on pointers to the
5933 relevant type, and the code that the compiler generates for these
5934 pointer arithmetic operations is often more efficient for
5935 efficiently-aligned types than for other types.
5937 The @code{aligned} attribute can only increase the alignment; but you
5938 can decrease it by specifying @code{packed} as well.  See below.
5940 Note that the effectiveness of @code{aligned} attributes may be limited
5941 by inherent limitations in your linker.  On many systems, the linker is
5942 only able to arrange for variables to be aligned up to a certain maximum
5943 alignment.  (For some linkers, the maximum supported alignment may
5944 be very very small.)  If your linker is only able to align variables
5945 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5946 in an @code{__attribute__} still only provides you with 8-byte
5947 alignment.  See your linker documentation for further information.
5949 @opindex fshort-enums
5950 Specifying this attribute for @code{struct} and @code{union} types is
5951 equivalent to specifying the @code{packed} attribute on each of the
5952 structure or union members.  Specifying the @option{-fshort-enums}
5953 flag on the line is equivalent to specifying the @code{packed}
5954 attribute on all @code{enum} definitions.
5956 In the following example @code{struct my_packed_struct}'s members are
5957 packed closely together, but the internal layout of its @code{s} member
5958 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5959 be packed too.
5961 @smallexample
5962 struct my_unpacked_struct
5963  @{
5964     char c;
5965     int i;
5966  @};
5968 struct __attribute__ ((__packed__)) my_packed_struct
5969   @{
5970      char c;
5971      int  i;
5972      struct my_unpacked_struct s;
5973   @};
5974 @end smallexample
5976 You may only specify this attribute on the definition of an @code{enum},
5977 @code{struct} or @code{union}, not on a @code{typedef} that does not
5978 also define the enumerated type, structure or union.
5980 @item bnd_variable_size
5981 @cindex @code{bnd_variable_size} type attribute
5982 @cindex Pointer Bounds Checker attributes
5983 When applied to a structure field, this attribute tells Pointer
5984 Bounds Checker that the size of this field should not be computed
5985 using static type information.  It may be used to mark variably-sized
5986 static array fields placed at the end of a structure.
5988 @smallexample
5989 struct S
5991   int size;
5992   char data[1];
5994 S *p = (S *)malloc (sizeof(S) + 100);
5995 p->data[10] = 0; //Bounds violation
5996 @end smallexample
5998 @noindent
5999 By using an attribute for the field we may avoid unwanted bound
6000 violation checks:
6002 @smallexample
6003 struct S
6005   int size;
6006   char data[1] __attribute__((bnd_variable_size));
6008 S *p = (S *)malloc (sizeof(S) + 100);
6009 p->data[10] = 0; //OK
6010 @end smallexample
6012 @item deprecated
6013 @itemx deprecated (@var{msg})
6014 @cindex @code{deprecated} type attribute
6015 The @code{deprecated} attribute results in a warning if the type
6016 is used anywhere in the source file.  This is useful when identifying
6017 types that are expected to be removed in a future version of a program.
6018 If possible, the warning also includes the location of the declaration
6019 of the deprecated type, to enable users to easily find further
6020 information about why the type is deprecated, or what they should do
6021 instead.  Note that the warnings only occur for uses and then only
6022 if the type is being applied to an identifier that itself is not being
6023 declared as deprecated.
6025 @smallexample
6026 typedef int T1 __attribute__ ((deprecated));
6027 T1 x;
6028 typedef T1 T2;
6029 T2 y;
6030 typedef T1 T3 __attribute__ ((deprecated));
6031 T3 z __attribute__ ((deprecated));
6032 @end smallexample
6034 @noindent
6035 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
6036 warning is issued for line 4 because T2 is not explicitly
6037 deprecated.  Line 5 has no warning because T3 is explicitly
6038 deprecated.  Similarly for line 6.  The optional @var{msg}
6039 argument, which must be a string, is printed in the warning if
6040 present.
6042 The @code{deprecated} attribute can also be used for functions and
6043 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6045 @item designated_init
6046 @cindex @code{designated_init} type attribute
6047 This attribute may only be applied to structure types.  It indicates
6048 that any initialization of an object of this type must use designated
6049 initializers rather than positional initializers.  The intent of this
6050 attribute is to allow the programmer to indicate that a structure's
6051 layout may change, and that therefore relying on positional
6052 initialization will result in future breakage.
6054 GCC emits warnings based on this attribute by default; use
6055 @option{-Wno-designated-init} to suppress them.
6057 @item may_alias
6058 @cindex @code{may_alias} type attribute
6059 Accesses through pointers to types with this attribute are not subject
6060 to type-based alias analysis, but are instead assumed to be able to alias
6061 any other type of objects.
6062 In the context of section 6.5 paragraph 7 of the C99 standard,
6063 an lvalue expression
6064 dereferencing such a pointer is treated like having a character type.
6065 See @option{-fstrict-aliasing} for more information on aliasing issues.
6066 This extension exists to support some vector APIs, in which pointers to
6067 one vector type are permitted to alias pointers to a different vector type.
6069 Note that an object of a type with this attribute does not have any
6070 special semantics.
6072 Example of use:
6074 @smallexample
6075 typedef short __attribute__((__may_alias__)) short_a;
6078 main (void)
6080   int a = 0x12345678;
6081   short_a *b = (short_a *) &a;
6083   b[1] = 0;
6085   if (a == 0x12345678)
6086     abort();
6088   exit(0);
6090 @end smallexample
6092 @noindent
6093 If you replaced @code{short_a} with @code{short} in the variable
6094 declaration, the above program would abort when compiled with
6095 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6096 above.
6098 @item packed
6099 @cindex @code{packed} type attribute
6100 This attribute, attached to @code{struct} or @code{union} type
6101 definition, specifies that each member (other than zero-width bit-fields)
6102 of the structure or union is placed to minimize the memory required.  When
6103 attached to an @code{enum} definition, it indicates that the smallest
6104 integral type should be used.
6106 @item transparent_union
6107 @cindex @code{transparent_union} type attribute
6109 This attribute, attached to a @code{union} type definition, indicates
6110 that any function parameter having that union type causes calls to that
6111 function to be treated in a special way.
6113 First, the argument corresponding to a transparent union type can be of
6114 any type in the union; no cast is required.  Also, if the union contains
6115 a pointer type, the corresponding argument can be a null pointer
6116 constant or a void pointer expression; and if the union contains a void
6117 pointer type, the corresponding argument can be any pointer expression.
6118 If the union member type is a pointer, qualifiers like @code{const} on
6119 the referenced type must be respected, just as with normal pointer
6120 conversions.
6122 Second, the argument is passed to the function using the calling
6123 conventions of the first member of the transparent union, not the calling
6124 conventions of the union itself.  All members of the union must have the
6125 same machine representation; this is necessary for this argument passing
6126 to work properly.
6128 Transparent unions are designed for library functions that have multiple
6129 interfaces for compatibility reasons.  For example, suppose the
6130 @code{wait} function must accept either a value of type @code{int *} to
6131 comply with POSIX, or a value of type @code{union wait *} to comply with
6132 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
6133 @code{wait} would accept both kinds of arguments, but it would also
6134 accept any other pointer type and this would make argument type checking
6135 less useful.  Instead, @code{<sys/wait.h>} might define the interface
6136 as follows:
6138 @smallexample
6139 typedef union __attribute__ ((__transparent_union__))
6140   @{
6141     int *__ip;
6142     union wait *__up;
6143   @} wait_status_ptr_t;
6145 pid_t wait (wait_status_ptr_t);
6146 @end smallexample
6148 @noindent
6149 This interface allows either @code{int *} or @code{union wait *}
6150 arguments to be passed, using the @code{int *} calling convention.
6151 The program can call @code{wait} with arguments of either type:
6153 @smallexample
6154 int w1 () @{ int w; return wait (&w); @}
6155 int w2 () @{ union wait w; return wait (&w); @}
6156 @end smallexample
6158 @noindent
6159 With this interface, @code{wait}'s implementation might look like this:
6161 @smallexample
6162 pid_t wait (wait_status_ptr_t p)
6164   return waitpid (-1, p.__ip, 0);
6166 @end smallexample
6168 @item unused
6169 @cindex @code{unused} type attribute
6170 When attached to a type (including a @code{union} or a @code{struct}),
6171 this attribute means that variables of that type are meant to appear
6172 possibly unused.  GCC does not produce a warning for any variables of
6173 that type, even if the variable appears to do nothing.  This is often
6174 the case with lock or thread classes, which are usually defined and then
6175 not referenced, but contain constructors and destructors that have
6176 nontrivial bookkeeping functions.
6178 @item visibility
6179 @cindex @code{visibility} type attribute
6180 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6181 applied to class, struct, union and enum types.  Unlike other type
6182 attributes, the attribute must appear between the initial keyword and
6183 the name of the type; it cannot appear after the body of the type.
6185 Note that the type visibility is applied to vague linkage entities
6186 associated with the class (vtable, typeinfo node, etc.).  In
6187 particular, if a class is thrown as an exception in one shared object
6188 and caught in another, the class must have default visibility.
6189 Otherwise the two shared objects are unable to use the same
6190 typeinfo node and exception handling will break.
6192 @end table
6194 To specify multiple attributes, separate them by commas within the
6195 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6196 packed))}.
6198 @node ARM Type Attributes
6199 @subsection ARM Type Attributes
6201 @cindex @code{notshared} type attribute, ARM
6202 On those ARM targets that support @code{dllimport} (such as Symbian
6203 OS), you can use the @code{notshared} attribute to indicate that the
6204 virtual table and other similar data for a class should not be
6205 exported from a DLL@.  For example:
6207 @smallexample
6208 class __declspec(notshared) C @{
6209 public:
6210   __declspec(dllimport) C();
6211   virtual void f();
6214 __declspec(dllexport)
6215 C::C() @{@}
6216 @end smallexample
6218 @noindent
6219 In this code, @code{C::C} is exported from the current DLL, but the
6220 virtual table for @code{C} is not exported.  (You can use
6221 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6222 most Symbian OS code uses @code{__declspec}.)
6224 @node MeP Type Attributes
6225 @subsection MeP Type Attributes
6227 @cindex @code{based} type attribute, MeP
6228 @cindex @code{tiny} type attribute, MeP
6229 @cindex @code{near} type attribute, MeP
6230 @cindex @code{far} type attribute, MeP
6231 Many of the MeP variable attributes may be applied to types as well.
6232 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6233 @code{far} attributes may be applied to either.  The @code{io} and
6234 @code{cb} attributes may not be applied to types.
6236 @node PowerPC Type Attributes
6237 @subsection PowerPC Type Attributes
6239 Three attributes currently are defined for PowerPC configurations:
6240 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6242 @cindex @code{ms_struct} type attribute, PowerPC
6243 @cindex @code{gcc_struct} type attribute, PowerPC
6244 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6245 attributes please see the documentation in @ref{x86 Type Attributes}.
6247 @cindex @code{altivec} type attribute, PowerPC
6248 The @code{altivec} attribute allows one to declare AltiVec vector data
6249 types supported by the AltiVec Programming Interface Manual.  The
6250 attribute requires an argument to specify one of three vector types:
6251 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6252 and @code{bool__} (always followed by unsigned).
6254 @smallexample
6255 __attribute__((altivec(vector__)))
6256 __attribute__((altivec(pixel__))) unsigned short
6257 __attribute__((altivec(bool__))) unsigned
6258 @end smallexample
6260 These attributes mainly are intended to support the @code{__vector},
6261 @code{__pixel}, and @code{__bool} AltiVec keywords.
6263 @node SPU Type Attributes
6264 @subsection SPU Type Attributes
6266 @cindex @code{spu_vector} type attribute, SPU
6267 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6268 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6269 Language Extensions Specification.  It is intended to support the
6270 @code{__vector} keyword.
6272 @node x86 Type Attributes
6273 @subsection x86 Type Attributes
6275 Two attributes are currently defined for x86 configurations:
6276 @code{ms_struct} and @code{gcc_struct}.
6278 @table @code
6280 @item ms_struct
6281 @itemx gcc_struct
6282 @cindex @code{ms_struct} type attribute, x86
6283 @cindex @code{gcc_struct} type attribute, x86
6285 If @code{packed} is used on a structure, or if bit-fields are used
6286 it may be that the Microsoft ABI packs them differently
6287 than GCC normally packs them.  Particularly when moving packed
6288 data between functions compiled with GCC and the native Microsoft compiler
6289 (either via function call or as data in a file), it may be necessary to access
6290 either format.
6292 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6293 compilers to match the native Microsoft compiler.
6294 @end table
6296 @node Label Attributes
6297 @section Label Attributes
6298 @cindex Label Attributes
6300 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
6301 details of the exact syntax for using attributes.  Other attributes are 
6302 available for functions (@pxref{Function Attributes}), variables 
6303 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
6305 This example uses the @code{cold} label attribute to indicate the 
6306 @code{ErrorHandling} branch is unlikely to be taken and that the
6307 @code{ErrorHandling} label is unused:
6309 @smallexample
6311    asm goto ("some asm" : : : : NoError);
6313 /* This branch (the fall-through from the asm) is less commonly used */
6314 ErrorHandling: 
6315    __attribute__((cold, unused)); /* Semi-colon is required here */
6316    printf("error\n");
6317    return 0;
6319 NoError:
6320    printf("no error\n");
6321    return 1;
6322 @end smallexample
6324 @table @code
6325 @item unused
6326 @cindex @code{unused} label attribute
6327 This feature is intended for program-generated code that may contain 
6328 unused labels, but which is compiled with @option{-Wall}.  It is
6329 not normally appropriate to use in it human-written code, though it
6330 could be useful in cases where the code that jumps to the label is
6331 contained within an @code{#ifdef} conditional.
6333 @item hot
6334 @cindex @code{hot} label attribute
6335 The @code{hot} attribute on a label is used to inform the compiler that
6336 the path following the label is more likely than paths that are not so
6337 annotated.  This attribute is used in cases where @code{__builtin_expect}
6338 cannot be used, for instance with computed goto or @code{asm goto}.
6340 @item cold
6341 @cindex @code{cold} label attribute
6342 The @code{cold} attribute on labels is used to inform the compiler that
6343 the path following the label is unlikely to be executed.  This attribute
6344 is used in cases where @code{__builtin_expect} cannot be used, for instance
6345 with computed goto or @code{asm goto}.
6347 @end table
6349 @node Attribute Syntax
6350 @section Attribute Syntax
6351 @cindex attribute syntax
6353 This section describes the syntax with which @code{__attribute__} may be
6354 used, and the constructs to which attribute specifiers bind, for the C
6355 language.  Some details may vary for C++ and Objective-C@.  Because of
6356 infelicities in the grammar for attributes, some forms described here
6357 may not be successfully parsed in all cases.
6359 There are some problems with the semantics of attributes in C++.  For
6360 example, there are no manglings for attributes, although they may affect
6361 code generation, so problems may arise when attributed types are used in
6362 conjunction with templates or overloading.  Similarly, @code{typeid}
6363 does not distinguish between types with different attributes.  Support
6364 for attributes in C++ may be restricted in future to attributes on
6365 declarations only, but not on nested declarators.
6367 @xref{Function Attributes}, for details of the semantics of attributes
6368 applying to functions.  @xref{Variable Attributes}, for details of the
6369 semantics of attributes applying to variables.  @xref{Type Attributes},
6370 for details of the semantics of attributes applying to structure, union
6371 and enumerated types.
6372 @xref{Label Attributes}, for details of the semantics of attributes 
6373 applying to labels.
6375 An @dfn{attribute specifier} is of the form
6376 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
6377 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6378 each attribute is one of the following:
6380 @itemize @bullet
6381 @item
6382 Empty.  Empty attributes are ignored.
6384 @item
6385 An attribute name
6386 (which may be an identifier such as @code{unused}, or a reserved
6387 word such as @code{const}).
6389 @item
6390 An attribute name followed by a parenthesized list of
6391 parameters for the attribute.
6392 These parameters take one of the following forms:
6394 @itemize @bullet
6395 @item
6396 An identifier.  For example, @code{mode} attributes use this form.
6398 @item
6399 An identifier followed by a comma and a non-empty comma-separated list
6400 of expressions.  For example, @code{format} attributes use this form.
6402 @item
6403 A possibly empty comma-separated list of expressions.  For example,
6404 @code{format_arg} attributes use this form with the list being a single
6405 integer constant expression, and @code{alias} attributes use this form
6406 with the list being a single string constant.
6407 @end itemize
6408 @end itemize
6410 An @dfn{attribute specifier list} is a sequence of one or more attribute
6411 specifiers, not separated by any other tokens.
6413 You may optionally specify attribute names with @samp{__}
6414 preceding and following the name.
6415 This allows you to use them in header files without
6416 being concerned about a possible macro of the same name.  For example,
6417 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6420 @subsubheading Label Attributes
6422 In GNU C, an attribute specifier list may appear after the colon following a
6423 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
6424 attributes on labels if the attribute specifier is immediately
6425 followed by a semicolon (i.e., the label applies to an empty
6426 statement).  If the semicolon is missing, C++ label attributes are
6427 ambiguous, as it is permissible for a declaration, which could begin
6428 with an attribute list, to be labelled in C++.  Declarations cannot be
6429 labelled in C90 or C99, so the ambiguity does not arise there.
6431 @subsubheading Type Attributes
6433 An attribute specifier list may appear as part of a @code{struct},
6434 @code{union} or @code{enum} specifier.  It may go either immediately
6435 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6436 the closing brace.  The former syntax is preferred.
6437 Where attribute specifiers follow the closing brace, they are considered
6438 to relate to the structure, union or enumerated type defined, not to any
6439 enclosing declaration the type specifier appears in, and the type
6440 defined is not complete until after the attribute specifiers.
6441 @c Otherwise, there would be the following problems: a shift/reduce
6442 @c conflict between attributes binding the struct/union/enum and
6443 @c binding to the list of specifiers/qualifiers; and "aligned"
6444 @c attributes could use sizeof for the structure, but the size could be
6445 @c changed later by "packed" attributes.
6448 @subsubheading All other attributes
6450 Otherwise, an attribute specifier appears as part of a declaration,
6451 counting declarations of unnamed parameters and type names, and relates
6452 to that declaration (which may be nested in another declaration, for
6453 example in the case of a parameter declaration), or to a particular declarator
6454 within a declaration.  Where an
6455 attribute specifier is applied to a parameter declared as a function or
6456 an array, it should apply to the function or array rather than the
6457 pointer to which the parameter is implicitly converted, but this is not
6458 yet correctly implemented.
6460 Any list of specifiers and qualifiers at the start of a declaration may
6461 contain attribute specifiers, whether or not such a list may in that
6462 context contain storage class specifiers.  (Some attributes, however,
6463 are essentially in the nature of storage class specifiers, and only make
6464 sense where storage class specifiers may be used; for example,
6465 @code{section}.)  There is one necessary limitation to this syntax: the
6466 first old-style parameter declaration in a function definition cannot
6467 begin with an attribute specifier, because such an attribute applies to
6468 the function instead by syntax described below (which, however, is not
6469 yet implemented in this case).  In some other cases, attribute
6470 specifiers are permitted by this grammar but not yet supported by the
6471 compiler.  All attribute specifiers in this place relate to the
6472 declaration as a whole.  In the obsolescent usage where a type of
6473 @code{int} is implied by the absence of type specifiers, such a list of
6474 specifiers and qualifiers may be an attribute specifier list with no
6475 other specifiers or qualifiers.
6477 At present, the first parameter in a function prototype must have some
6478 type specifier that is not an attribute specifier; this resolves an
6479 ambiguity in the interpretation of @code{void f(int
6480 (__attribute__((foo)) x))}, but is subject to change.  At present, if
6481 the parentheses of a function declarator contain only attributes then
6482 those attributes are ignored, rather than yielding an error or warning
6483 or implying a single parameter of type int, but this is subject to
6484 change.
6486 An attribute specifier list may appear immediately before a declarator
6487 (other than the first) in a comma-separated list of declarators in a
6488 declaration of more than one identifier using a single list of
6489 specifiers and qualifiers.  Such attribute specifiers apply
6490 only to the identifier before whose declarator they appear.  For
6491 example, in
6493 @smallexample
6494 __attribute__((noreturn)) void d0 (void),
6495     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6496      d2 (void);
6497 @end smallexample
6499 @noindent
6500 the @code{noreturn} attribute applies to all the functions
6501 declared; the @code{format} attribute only applies to @code{d1}.
6503 An attribute specifier list may appear immediately before the comma,
6504 @code{=} or semicolon terminating the declaration of an identifier other
6505 than a function definition.  Such attribute specifiers apply
6506 to the declared object or function.  Where an
6507 assembler name for an object or function is specified (@pxref{Asm
6508 Labels}), the attribute must follow the @code{asm}
6509 specification.
6511 An attribute specifier list may, in future, be permitted to appear after
6512 the declarator in a function definition (before any old-style parameter
6513 declarations or the function body).
6515 Attribute specifiers may be mixed with type qualifiers appearing inside
6516 the @code{[]} of a parameter array declarator, in the C99 construct by
6517 which such qualifiers are applied to the pointer to which the array is
6518 implicitly converted.  Such attribute specifiers apply to the pointer,
6519 not to the array, but at present this is not implemented and they are
6520 ignored.
6522 An attribute specifier list may appear at the start of a nested
6523 declarator.  At present, there are some limitations in this usage: the
6524 attributes correctly apply to the declarator, but for most individual
6525 attributes the semantics this implies are not implemented.
6526 When attribute specifiers follow the @code{*} of a pointer
6527 declarator, they may be mixed with any type qualifiers present.
6528 The following describes the formal semantics of this syntax.  It makes the
6529 most sense if you are familiar with the formal specification of
6530 declarators in the ISO C standard.
6532 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
6533 D1}, where @code{T} contains declaration specifiers that specify a type
6534 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
6535 contains an identifier @var{ident}.  The type specified for @var{ident}
6536 for derived declarators whose type does not include an attribute
6537 specifier is as in the ISO C standard.
6539 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
6540 and the declaration @code{T D} specifies the type
6541 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6542 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6543 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
6545 If @code{D1} has the form @code{*
6546 @var{type-qualifier-and-attribute-specifier-list} D}, and the
6547 declaration @code{T D} specifies the type
6548 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6549 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6550 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
6551 @var{ident}.
6553 For example,
6555 @smallexample
6556 void (__attribute__((noreturn)) ****f) (void);
6557 @end smallexample
6559 @noindent
6560 specifies the type ``pointer to pointer to pointer to pointer to
6561 non-returning function returning @code{void}''.  As another example,
6563 @smallexample
6564 char *__attribute__((aligned(8))) *f;
6565 @end smallexample
6567 @noindent
6568 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
6569 Note again that this does not work with most attributes; for example,
6570 the usage of @samp{aligned} and @samp{noreturn} attributes given above
6571 is not yet supported.
6573 For compatibility with existing code written for compiler versions that
6574 did not implement attributes on nested declarators, some laxity is
6575 allowed in the placing of attributes.  If an attribute that only applies
6576 to types is applied to a declaration, it is treated as applying to
6577 the type of that declaration.  If an attribute that only applies to
6578 declarations is applied to the type of a declaration, it is treated
6579 as applying to that declaration; and, for compatibility with code
6580 placing the attributes immediately before the identifier declared, such
6581 an attribute applied to a function return type is treated as
6582 applying to the function type, and such an attribute applied to an array
6583 element type is treated as applying to the array type.  If an
6584 attribute that only applies to function types is applied to a
6585 pointer-to-function type, it is treated as applying to the pointer
6586 target type; if such an attribute is applied to a function return type
6587 that is not a pointer-to-function type, it is treated as applying
6588 to the function type.
6590 @node Function Prototypes
6591 @section Prototypes and Old-Style Function Definitions
6592 @cindex function prototype declarations
6593 @cindex old-style function definitions
6594 @cindex promotion of formal parameters
6596 GNU C extends ISO C to allow a function prototype to override a later
6597 old-style non-prototype definition.  Consider the following example:
6599 @smallexample
6600 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
6601 #ifdef __STDC__
6602 #define P(x) x
6603 #else
6604 #define P(x) ()
6605 #endif
6607 /* @r{Prototype function declaration.}  */
6608 int isroot P((uid_t));
6610 /* @r{Old-style function definition.}  */
6612 isroot (x)   /* @r{??? lossage here ???} */
6613      uid_t x;
6615   return x == 0;
6617 @end smallexample
6619 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
6620 not allow this example, because subword arguments in old-style
6621 non-prototype definitions are promoted.  Therefore in this example the
6622 function definition's argument is really an @code{int}, which does not
6623 match the prototype argument type of @code{short}.
6625 This restriction of ISO C makes it hard to write code that is portable
6626 to traditional C compilers, because the programmer does not know
6627 whether the @code{uid_t} type is @code{short}, @code{int}, or
6628 @code{long}.  Therefore, in cases like these GNU C allows a prototype
6629 to override a later old-style definition.  More precisely, in GNU C, a
6630 function prototype argument type overrides the argument type specified
6631 by a later old-style definition if the former type is the same as the
6632 latter type before promotion.  Thus in GNU C the above example is
6633 equivalent to the following:
6635 @smallexample
6636 int isroot (uid_t);
6639 isroot (uid_t x)
6641   return x == 0;
6643 @end smallexample
6645 @noindent
6646 GNU C++ does not support old-style function definitions, so this
6647 extension is irrelevant.
6649 @node C++ Comments
6650 @section C++ Style Comments
6651 @cindex @code{//}
6652 @cindex C++ comments
6653 @cindex comments, C++ style
6655 In GNU C, you may use C++ style comments, which start with @samp{//} and
6656 continue until the end of the line.  Many other C implementations allow
6657 such comments, and they are included in the 1999 C standard.  However,
6658 C++ style comments are not recognized if you specify an @option{-std}
6659 option specifying a version of ISO C before C99, or @option{-ansi}
6660 (equivalent to @option{-std=c90}).
6662 @node Dollar Signs
6663 @section Dollar Signs in Identifier Names
6664 @cindex $
6665 @cindex dollar signs in identifier names
6666 @cindex identifier names, dollar signs in
6668 In GNU C, you may normally use dollar signs in identifier names.
6669 This is because many traditional C implementations allow such identifiers.
6670 However, dollar signs in identifiers are not supported on a few target
6671 machines, typically because the target assembler does not allow them.
6673 @node Character Escapes
6674 @section The Character @key{ESC} in Constants
6676 You can use the sequence @samp{\e} in a string or character constant to
6677 stand for the ASCII character @key{ESC}.
6679 @node Alignment
6680 @section Inquiring on Alignment of Types or Variables
6681 @cindex alignment
6682 @cindex type alignment
6683 @cindex variable alignment
6685 The keyword @code{__alignof__} allows you to inquire about how an object
6686 is aligned, or the minimum alignment usually required by a type.  Its
6687 syntax is just like @code{sizeof}.
6689 For example, if the target machine requires a @code{double} value to be
6690 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6691 This is true on many RISC machines.  On more traditional machine
6692 designs, @code{__alignof__ (double)} is 4 or even 2.
6694 Some machines never actually require alignment; they allow reference to any
6695 data type even at an odd address.  For these machines, @code{__alignof__}
6696 reports the smallest alignment that GCC gives the data type, usually as
6697 mandated by the target ABI.
6699 If the operand of @code{__alignof__} is an lvalue rather than a type,
6700 its value is the required alignment for its type, taking into account
6701 any minimum alignment specified with GCC's @code{__attribute__}
6702 extension (@pxref{Variable Attributes}).  For example, after this
6703 declaration:
6705 @smallexample
6706 struct foo @{ int x; char y; @} foo1;
6707 @end smallexample
6709 @noindent
6710 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6711 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6713 It is an error to ask for the alignment of an incomplete type.
6716 @node Inline
6717 @section An Inline Function is As Fast As a Macro
6718 @cindex inline functions
6719 @cindex integrating function code
6720 @cindex open coding
6721 @cindex macros, inline alternative
6723 By declaring a function inline, you can direct GCC to make
6724 calls to that function faster.  One way GCC can achieve this is to
6725 integrate that function's code into the code for its callers.  This
6726 makes execution faster by eliminating the function-call overhead; in
6727 addition, if any of the actual argument values are constant, their
6728 known values may permit simplifications at compile time so that not
6729 all of the inline function's code needs to be included.  The effect on
6730 code size is less predictable; object code may be larger or smaller
6731 with function inlining, depending on the particular case.  You can
6732 also direct GCC to try to integrate all ``simple enough'' functions
6733 into their callers with the option @option{-finline-functions}.
6735 GCC implements three different semantics of declaring a function
6736 inline.  One is available with @option{-std=gnu89} or
6737 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6738 on all inline declarations, another when
6739 @option{-std=c99}, @option{-std=c11},
6740 @option{-std=gnu99} or @option{-std=gnu11}
6741 (without @option{-fgnu89-inline}), and the third
6742 is used when compiling C++.
6744 To declare a function inline, use the @code{inline} keyword in its
6745 declaration, like this:
6747 @smallexample
6748 static inline int
6749 inc (int *a)
6751   return (*a)++;
6753 @end smallexample
6755 If you are writing a header file to be included in ISO C90 programs, write
6756 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6758 The three types of inlining behave similarly in two important cases:
6759 when the @code{inline} keyword is used on a @code{static} function,
6760 like the example above, and when a function is first declared without
6761 using the @code{inline} keyword and then is defined with
6762 @code{inline}, like this:
6764 @smallexample
6765 extern int inc (int *a);
6766 inline int
6767 inc (int *a)
6769   return (*a)++;
6771 @end smallexample
6773 In both of these common cases, the program behaves the same as if you
6774 had not used the @code{inline} keyword, except for its speed.
6776 @cindex inline functions, omission of
6777 @opindex fkeep-inline-functions
6778 When a function is both inline and @code{static}, if all calls to the
6779 function are integrated into the caller, and the function's address is
6780 never used, then the function's own assembler code is never referenced.
6781 In this case, GCC does not actually output assembler code for the
6782 function, unless you specify the option @option{-fkeep-inline-functions}.
6783 Some calls cannot be integrated for various reasons (in particular,
6784 calls that precede the function's definition cannot be integrated, and
6785 neither can recursive calls within the definition).  If there is a
6786 nonintegrated call, then the function is compiled to assembler code as
6787 usual.  The function must also be compiled as usual if the program
6788 refers to its address, because that can't be inlined.
6790 @opindex Winline
6791 Note that certain usages in a function definition can make it unsuitable
6792 for inline substitution.  Among these usages are: variadic functions, use of
6793 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6794 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6795 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6796 warns when a function marked @code{inline} could not be substituted,
6797 and gives the reason for the failure.
6799 @cindex automatic @code{inline} for C++ member fns
6800 @cindex @code{inline} automatic for C++ member fns
6801 @cindex member fns, automatically @code{inline}
6802 @cindex C++ member fns, automatically @code{inline}
6803 @opindex fno-default-inline
6804 As required by ISO C++, GCC considers member functions defined within
6805 the body of a class to be marked inline even if they are
6806 not explicitly declared with the @code{inline} keyword.  You can
6807 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6808 Options,,Options Controlling C++ Dialect}.
6810 GCC does not inline any functions when not optimizing unless you specify
6811 the @samp{always_inline} attribute for the function, like this:
6813 @smallexample
6814 /* @r{Prototype.}  */
6815 inline void foo (const char) __attribute__((always_inline));
6816 @end smallexample
6818 The remainder of this section is specific to GNU C90 inlining.
6820 @cindex non-static inline function
6821 When an inline function is not @code{static}, then the compiler must assume
6822 that there may be calls from other source files; since a global symbol can
6823 be defined only once in any program, the function must not be defined in
6824 the other source files, so the calls therein cannot be integrated.
6825 Therefore, a non-@code{static} inline function is always compiled on its
6826 own in the usual fashion.
6828 If you specify both @code{inline} and @code{extern} in the function
6829 definition, then the definition is used only for inlining.  In no case
6830 is the function compiled on its own, not even if you refer to its
6831 address explicitly.  Such an address becomes an external reference, as
6832 if you had only declared the function, and had not defined it.
6834 This combination of @code{inline} and @code{extern} has almost the
6835 effect of a macro.  The way to use it is to put a function definition in
6836 a header file with these keywords, and put another copy of the
6837 definition (lacking @code{inline} and @code{extern}) in a library file.
6838 The definition in the header file causes most calls to the function
6839 to be inlined.  If any uses of the function remain, they refer to
6840 the single copy in the library.
6842 @node Volatiles
6843 @section When is a Volatile Object Accessed?
6844 @cindex accessing volatiles
6845 @cindex volatile read
6846 @cindex volatile write
6847 @cindex volatile access
6849 C has the concept of volatile objects.  These are normally accessed by
6850 pointers and used for accessing hardware or inter-thread
6851 communication.  The standard encourages compilers to refrain from
6852 optimizations concerning accesses to volatile objects, but leaves it
6853 implementation defined as to what constitutes a volatile access.  The
6854 minimum requirement is that at a sequence point all previous accesses
6855 to volatile objects have stabilized and no subsequent accesses have
6856 occurred.  Thus an implementation is free to reorder and combine
6857 volatile accesses that occur between sequence points, but cannot do
6858 so for accesses across a sequence point.  The use of volatile does
6859 not allow you to violate the restriction on updating objects multiple
6860 times between two sequence points.
6862 Accesses to non-volatile objects are not ordered with respect to
6863 volatile accesses.  You cannot use a volatile object as a memory
6864 barrier to order a sequence of writes to non-volatile memory.  For
6865 instance:
6867 @smallexample
6868 int *ptr = @var{something};
6869 volatile int vobj;
6870 *ptr = @var{something};
6871 vobj = 1;
6872 @end smallexample
6874 @noindent
6875 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6876 that the write to @var{*ptr} occurs by the time the update
6877 of @var{vobj} happens.  If you need this guarantee, you must use
6878 a stronger memory barrier such as:
6880 @smallexample
6881 int *ptr = @var{something};
6882 volatile int vobj;
6883 *ptr = @var{something};
6884 asm volatile ("" : : : "memory");
6885 vobj = 1;
6886 @end smallexample
6888 A scalar volatile object is read when it is accessed in a void context:
6890 @smallexample
6891 volatile int *src = @var{somevalue};
6892 *src;
6893 @end smallexample
6895 Such expressions are rvalues, and GCC implements this as a
6896 read of the volatile object being pointed to.
6898 Assignments are also expressions and have an rvalue.  However when
6899 assigning to a scalar volatile, the volatile object is not reread,
6900 regardless of whether the assignment expression's rvalue is used or
6901 not.  If the assignment's rvalue is used, the value is that assigned
6902 to the volatile object.  For instance, there is no read of @var{vobj}
6903 in all the following cases:
6905 @smallexample
6906 int obj;
6907 volatile int vobj;
6908 vobj = @var{something};
6909 obj = vobj = @var{something};
6910 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6911 obj = (@var{something}, vobj = @var{anotherthing});
6912 @end smallexample
6914 If you need to read the volatile object after an assignment has
6915 occurred, you must use a separate expression with an intervening
6916 sequence point.
6918 As bit-fields are not individually addressable, volatile bit-fields may
6919 be implicitly read when written to, or when adjacent bit-fields are
6920 accessed.  Bit-field operations may be optimized such that adjacent
6921 bit-fields are only partially accessed, if they straddle a storage unit
6922 boundary.  For these reasons it is unwise to use volatile bit-fields to
6923 access hardware.
6925 @node Using Assembly Language with C
6926 @section How to Use Inline Assembly Language in C Code
6927 @cindex @code{asm} keyword
6928 @cindex assembly language in C
6929 @cindex inline assembly language
6930 @cindex mixing assembly language and C
6932 The @code{asm} keyword allows you to embed assembler instructions
6933 within C code.  GCC provides two forms of inline @code{asm}
6934 statements.  A @dfn{basic @code{asm}} statement is one with no
6935 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
6936 statement (@pxref{Extended Asm}) includes one or more operands.  
6937 The extended form is preferred for mixing C and assembly language
6938 within a function, but to include assembly language at
6939 top level you must use basic @code{asm}.
6941 You can also use the @code{asm} keyword to override the assembler name
6942 for a C symbol, or to place a C variable in a specific register.
6944 @menu
6945 * Basic Asm::          Inline assembler without operands.
6946 * Extended Asm::       Inline assembler with operands.
6947 * Constraints::        Constraints for @code{asm} operands
6948 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6949 * Explicit Reg Vars::  Defining variables residing in specified registers.
6950 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6951 @end menu
6953 @node Basic Asm
6954 @subsection Basic Asm --- Assembler Instructions Without Operands
6955 @cindex basic @code{asm}
6956 @cindex assembly language in C, basic
6958 A basic @code{asm} statement has the following syntax:
6960 @example
6961 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
6962 @end example
6964 The @code{asm} keyword is a GNU extension.
6965 When writing code that can be compiled with @option{-ansi} and the
6966 various @option{-std} options, use @code{__asm__} instead of 
6967 @code{asm} (@pxref{Alternate Keywords}).
6969 @subsubheading Qualifiers
6970 @table @code
6971 @item volatile
6972 The optional @code{volatile} qualifier has no effect. 
6973 All basic @code{asm} blocks are implicitly volatile.
6974 @end table
6976 @subsubheading Parameters
6977 @table @var
6979 @item AssemblerInstructions
6980 This is a literal string that specifies the assembler code. The string can 
6981 contain any instructions recognized by the assembler, including directives. 
6982 GCC does not parse the assembler instructions themselves and 
6983 does not know what they mean or even whether they are valid assembler input. 
6985 You may place multiple assembler instructions together in a single @code{asm} 
6986 string, separated by the characters normally used in assembly code for the 
6987 system. A combination that works in most places is a newline to break the 
6988 line, plus a tab character (written as @samp{\n\t}).
6989 Some assemblers allow semicolons as a line separator. However, 
6990 note that some assembler dialects use semicolons to start a comment. 
6991 @end table
6993 @subsubheading Remarks
6994 Using extended @code{asm} typically produces smaller, safer, and more
6995 efficient code, and in most cases it is a better solution than basic
6996 @code{asm}.  However, there are two situations where only basic @code{asm}
6997 can be used:
6999 @itemize @bullet
7000 @item
7001 Extended @code{asm} statements have to be inside a C
7002 function, so to write inline assembly language at file scope (``top-level''),
7003 outside of C functions, you must use basic @code{asm}.
7004 You can use this technique to emit assembler directives,
7005 define assembly language macros that can be invoked elsewhere in the file,
7006 or write entire functions in assembly language.
7008 @item
7009 Functions declared
7010 with the @code{naked} attribute also require basic @code{asm}
7011 (@pxref{Function Attributes}).
7012 @end itemize
7014 Safely accessing C data and calling functions from basic @code{asm} is more 
7015 complex than it may appear. To access C data, it is better to use extended 
7016 @code{asm}.
7018 Do not expect a sequence of @code{asm} statements to remain perfectly 
7019 consecutive after compilation. If certain instructions need to remain 
7020 consecutive in the output, put them in a single multi-instruction @code{asm}
7021 statement. Note that GCC's optimizers can move @code{asm} statements 
7022 relative to other code, including across jumps.
7024 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7025 GCC does not know about these jumps, and therefore cannot take 
7026 account of them when deciding how to optimize. Jumps from @code{asm} to C 
7027 labels are only supported in extended @code{asm}.
7029 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7030 assembly code when optimizing. This can lead to unexpected duplicate 
7031 symbol errors during compilation if your assembly code defines symbols or 
7032 labels.
7034 Since GCC does not parse the @var{AssemblerInstructions}, it has no 
7035 visibility of any symbols it references. This may result in GCC discarding 
7036 those symbols as unreferenced.
7038 The compiler copies the assembler instructions in a basic @code{asm} 
7039 verbatim to the assembly language output file, without 
7040 processing dialects or any of the @samp{%} operators that are available with
7041 extended @code{asm}. This results in minor differences between basic 
7042 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
7043 registers you might use @samp{%eax} in basic @code{asm} and
7044 @samp{%%eax} in extended @code{asm}.
7046 On targets such as x86 that support multiple assembler dialects,
7047 all basic @code{asm} blocks use the assembler dialect specified by the 
7048 @option{-masm} command-line option (@pxref{x86 Options}).  
7049 Basic @code{asm} provides no
7050 mechanism to provide different assembler strings for different dialects.
7052 Here is an example of basic @code{asm} for i386:
7054 @example
7055 /* Note that this code will not compile with -masm=intel */
7056 #define DebugBreak() asm("int $3")
7057 @end example
7059 @node Extended Asm
7060 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7061 @cindex extended @code{asm}
7062 @cindex assembly language in C, extended
7064 With extended @code{asm} you can read and write C variables from 
7065 assembler and perform jumps from assembler code to C labels.  
7066 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7067 the operand parameters after the assembler template:
7069 @example
7070 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
7071                  : @var{OutputOperands} 
7072                  @r{[} : @var{InputOperands}
7073                  @r{[} : @var{Clobbers} @r{]} @r{]})
7075 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
7076                       : 
7077                       : @var{InputOperands}
7078                       : @var{Clobbers}
7079                       : @var{GotoLabels})
7080 @end example
7082 The @code{asm} keyword is a GNU extension.
7083 When writing code that can be compiled with @option{-ansi} and the
7084 various @option{-std} options, use @code{__asm__} instead of 
7085 @code{asm} (@pxref{Alternate Keywords}).
7087 @subsubheading Qualifiers
7088 @table @code
7090 @item volatile
7091 The typical use of extended @code{asm} statements is to manipulate input 
7092 values to produce output values. However, your @code{asm} statements may 
7093 also produce side effects. If so, you may need to use the @code{volatile} 
7094 qualifier to disable certain optimizations. @xref{Volatile}.
7096 @item goto
7097 This qualifier informs the compiler that the @code{asm} statement may 
7098 perform a jump to one of the labels listed in the @var{GotoLabels}.
7099 @xref{GotoLabels}.
7100 @end table
7102 @subsubheading Parameters
7103 @table @var
7104 @item AssemblerTemplate
7105 This is a literal string that is the template for the assembler code. It is a 
7106 combination of fixed text and tokens that refer to the input, output, 
7107 and goto parameters. @xref{AssemblerTemplate}.
7109 @item OutputOperands
7110 A comma-separated list of the C variables modified by the instructions in the 
7111 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
7113 @item InputOperands
7114 A comma-separated list of C expressions read by the instructions in the 
7115 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
7117 @item Clobbers
7118 A comma-separated list of registers or other values changed by the 
7119 @var{AssemblerTemplate}, beyond those listed as outputs.
7120 An empty list is permitted.  @xref{Clobbers}.
7122 @item GotoLabels
7123 When you are using the @code{goto} form of @code{asm}, this section contains 
7124 the list of all C labels to which the code in the 
7125 @var{AssemblerTemplate} may jump. 
7126 @xref{GotoLabels}.
7128 @code{asm} statements may not perform jumps into other @code{asm} statements,
7129 only to the listed @var{GotoLabels}.
7130 GCC's optimizers do not know about other jumps; therefore they cannot take 
7131 account of them when deciding how to optimize.
7132 @end table
7134 The total number of input + output + goto operands is limited to 30.
7136 @subsubheading Remarks
7137 The @code{asm} statement allows you to include assembly instructions directly 
7138 within C code. This may help you to maximize performance in time-sensitive 
7139 code or to access assembly instructions that are not readily available to C 
7140 programs.
7142 Note that extended @code{asm} statements must be inside a function. Only 
7143 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7144 Functions declared with the @code{naked} attribute also require basic 
7145 @code{asm} (@pxref{Function Attributes}).
7147 While the uses of @code{asm} are many and varied, it may help to think of an 
7148 @code{asm} statement as a series of low-level instructions that convert input 
7149 parameters to output parameters. So a simple (if not particularly useful) 
7150 example for i386 using @code{asm} might look like this:
7152 @example
7153 int src = 1;
7154 int dst;   
7156 asm ("mov %1, %0\n\t"
7157     "add $1, %0"
7158     : "=r" (dst) 
7159     : "r" (src));
7161 printf("%d\n", dst);
7162 @end example
7164 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7166 @anchor{Volatile}
7167 @subsubsection Volatile
7168 @cindex volatile @code{asm}
7169 @cindex @code{asm} volatile
7171 GCC's optimizers sometimes discard @code{asm} statements if they determine 
7172 there is no need for the output variables. Also, the optimizers may move 
7173 code out of loops if they believe that the code will always return the same 
7174 result (i.e. none of its input values change between calls). Using the 
7175 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
7176 that have no output operands, including @code{asm goto} statements, 
7177 are implicitly volatile.
7179 This i386 code demonstrates a case that does not use (or require) the 
7180 @code{volatile} qualifier. If it is performing assertion checking, this code 
7181 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
7182 unreferenced by any code. As a result, the optimizers can discard the 
7183 @code{asm} statement, which in turn removes the need for the entire 
7184 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
7185 isn't needed you allow the optimizers to produce the most efficient code 
7186 possible.
7188 @example
7189 void DoCheck(uint32_t dwSomeValue)
7191    uint32_t dwRes;
7193    // Assumes dwSomeValue is not zero.
7194    asm ("bsfl %1,%0"
7195      : "=r" (dwRes)
7196      : "r" (dwSomeValue)
7197      : "cc");
7199    assert(dwRes > 3);
7201 @end example
7203 The next example shows a case where the optimizers can recognize that the input 
7204 (@code{dwSomeValue}) never changes during the execution of the function and can 
7205 therefore move the @code{asm} outside the loop to produce more efficient code. 
7206 Again, using @code{volatile} disables this type of optimization.
7208 @example
7209 void do_print(uint32_t dwSomeValue)
7211    uint32_t dwRes;
7213    for (uint32_t x=0; x < 5; x++)
7214    @{
7215       // Assumes dwSomeValue is not zero.
7216       asm ("bsfl %1,%0"
7217         : "=r" (dwRes)
7218         : "r" (dwSomeValue)
7219         : "cc");
7221       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7222    @}
7224 @end example
7226 The following example demonstrates a case where you need to use the 
7227 @code{volatile} qualifier. 
7228 It uses the x86 @code{rdtsc} instruction, which reads 
7229 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
7230 the optimizers might assume that the @code{asm} block will always return the 
7231 same value and therefore optimize away the second call.
7233 @example
7234 uint64_t msr;
7236 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7237         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7238         "or %%rdx, %0"        // 'Or' in the lower bits.
7239         : "=a" (msr)
7240         : 
7241         : "rdx");
7243 printf("msr: %llx\n", msr);
7245 // Do other work...
7247 // Reprint the timestamp
7248 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7249         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7250         "or %%rdx, %0"        // 'Or' in the lower bits.
7251         : "=a" (msr)
7252         : 
7253         : "rdx");
7255 printf("msr: %llx\n", msr);
7256 @end example
7258 GCC's optimizers do not treat this code like the non-volatile code in the 
7259 earlier examples. They do not move it out of loops or omit it on the 
7260 assumption that the result from a previous call is still valid.
7262 Note that the compiler can move even volatile @code{asm} instructions relative 
7263 to other code, including across jump instructions. For example, on many 
7264 targets there is a system register that controls the rounding mode of 
7265 floating-point operations. Setting it with a volatile @code{asm}, as in the 
7266 following PowerPC example, does not work reliably.
7268 @example
7269 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7270 sum = x + y;
7271 @end example
7273 The compiler may move the addition back before the volatile @code{asm}. To 
7274 make it work as expected, add an artificial dependency to the @code{asm} by 
7275 referencing a variable in the subsequent code, for example: 
7277 @example
7278 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7279 sum = x + y;
7280 @end example
7282 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7283 assembly code when optimizing. This can lead to unexpected duplicate symbol 
7284 errors during compilation if your asm code defines symbols or labels. 
7285 Using @samp{%=} 
7286 (@pxref{AssemblerTemplate}) may help resolve this problem.
7288 @anchor{AssemblerTemplate}
7289 @subsubsection Assembler Template
7290 @cindex @code{asm} assembler template
7292 An assembler template is a literal string containing assembler instructions.
7293 The compiler replaces tokens in the template that refer 
7294 to inputs, outputs, and goto labels,
7295 and then outputs the resulting string to the assembler. The 
7296 string can contain any instructions recognized by the assembler, including 
7297 directives. GCC does not parse the assembler instructions 
7298 themselves and does not know what they mean or even whether they are valid 
7299 assembler input. However, it does count the statements 
7300 (@pxref{Size of an asm}).
7302 You may place multiple assembler instructions together in a single @code{asm} 
7303 string, separated by the characters normally used in assembly code for the 
7304 system. A combination that works in most places is a newline to break the 
7305 line, plus a tab character to move to the instruction field (written as 
7306 @samp{\n\t}). 
7307 Some assemblers allow semicolons as a line separator. However, note 
7308 that some assembler dialects use semicolons to start a comment. 
7310 Do not expect a sequence of @code{asm} statements to remain perfectly 
7311 consecutive after compilation, even when you are using the @code{volatile} 
7312 qualifier. If certain instructions need to remain consecutive in the output, 
7313 put them in a single multi-instruction asm statement.
7315 Accessing data from C programs without using input/output operands (such as 
7316 by using global symbols directly from the assembler template) may not work as 
7317 expected. Similarly, calling functions directly from an assembler template 
7318 requires a detailed understanding of the target assembler and ABI.
7320 Since GCC does not parse the assembler template,
7321 it has no visibility of any 
7322 symbols it references. This may result in GCC discarding those symbols as 
7323 unreferenced unless they are also listed as input, output, or goto operands.
7325 @subsubheading Special format strings
7327 In addition to the tokens described by the input, output, and goto operands, 
7328 these tokens have special meanings in the assembler template:
7330 @table @samp
7331 @item %% 
7332 Outputs a single @samp{%} into the assembler code.
7334 @item %= 
7335 Outputs a number that is unique to each instance of the @code{asm} 
7336 statement in the entire compilation. This option is useful when creating local 
7337 labels and referring to them multiple times in a single template that 
7338 generates multiple assembler instructions. 
7340 @item %@{
7341 @itemx %|
7342 @itemx %@}
7343 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7344 into the assembler code.  When unescaped, these characters have special
7345 meaning to indicate multiple assembler dialects, as described below.
7346 @end table
7348 @subsubheading Multiple assembler dialects in @code{asm} templates
7350 On targets such as x86, GCC supports multiple assembler dialects.
7351 The @option{-masm} option controls which dialect GCC uses as its 
7352 default for inline assembler. The target-specific documentation for the 
7353 @option{-masm} option contains the list of supported dialects, as well as the 
7354 default dialect if the option is not specified. This information may be 
7355 important to understand, since assembler code that works correctly when 
7356 compiled using one dialect will likely fail if compiled using another.
7357 @xref{x86 Options}.
7359 If your code needs to support multiple assembler dialects (for example, if 
7360 you are writing public headers that need to support a variety of compilation 
7361 options), use constructs of this form:
7363 @example
7364 @{ dialect0 | dialect1 | dialect2... @}
7365 @end example
7367 This construct outputs @code{dialect0} 
7368 when using dialect #0 to compile the code, 
7369 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
7370 braces than the number of dialects the compiler supports, the construct 
7371 outputs nothing.
7373 For example, if an x86 compiler supports two dialects
7374 (@samp{att}, @samp{intel}), an 
7375 assembler template such as this:
7377 @example
7378 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7379 @end example
7381 @noindent
7382 is equivalent to one of
7384 @example
7385 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
7386 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
7387 @end example
7389 Using that same compiler, this code:
7391 @example
7392 "xchg@{l@}\t@{%%@}ebx, %1"
7393 @end example
7395 @noindent
7396 corresponds to either
7398 @example
7399 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
7400 "xchg\tebx, %1"                    @r{/* intel dialect */}
7401 @end example
7403 There is no support for nesting dialect alternatives.
7405 @anchor{OutputOperands}
7406 @subsubsection Output Operands
7407 @cindex @code{asm} output operands
7409 An @code{asm} statement has zero or more output operands indicating the names
7410 of C variables modified by the assembler code.
7412 In this i386 example, @code{old} (referred to in the template string as 
7413 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
7414 (@code{%2}) is an input:
7416 @example
7417 bool old;
7419 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7420          "sbb %0,%0"      // Use the CF to calculate old.
7421    : "=r" (old), "+rm" (*Base)
7422    : "Ir" (Offset)
7423    : "cc");
7425 return old;
7426 @end example
7428 Operands are separated by commas.  Each operand has this format:
7430 @example
7431 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7432 @end example
7434 @table @var
7435 @item asmSymbolicName
7436 Specifies a symbolic name for the operand.
7437 Reference the name in the assembler template 
7438 by enclosing it in square brackets 
7439 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
7440 that contains the definition. Any valid C variable name is acceptable, 
7441 including names already defined in the surrounding code. No two operands 
7442 within the same @code{asm} statement can use the same symbolic name.
7444 When not using an @var{asmSymbolicName}, use the (zero-based) position
7445 of the operand 
7446 in the list of operands in the assembler template. For example if there are 
7447 three output operands, use @samp{%0} in the template to refer to the first, 
7448 @samp{%1} for the second, and @samp{%2} for the third. 
7450 @item constraint
7451 A string constant specifying constraints on the placement of the operand; 
7452 @xref{Constraints}, for details.
7454 Output constraints must begin with either @samp{=} (a variable overwriting an 
7455 existing value) or @samp{+} (when reading and writing). When using 
7456 @samp{=}, do not assume the location contains the existing value
7457 on entry to the @code{asm}, except 
7458 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7460 After the prefix, there must be one or more additional constraints 
7461 (@pxref{Constraints}) that describe where the value resides. Common 
7462 constraints include @samp{r} for register and @samp{m} for memory. 
7463 When you list more than one possible location (for example, @code{"=rm"}),
7464 the compiler chooses the most efficient one based on the current context. 
7465 If you list as many alternates as the @code{asm} statement allows, you permit 
7466 the optimizers to produce the best possible code. 
7467 If you must use a specific register, but your Machine Constraints do not
7468 provide sufficient control to select the specific register you want, 
7469 local register variables may provide a solution (@pxref{Local Reg Vars}).
7471 @item cvariablename
7472 Specifies a C lvalue expression to hold the output, typically a variable name.
7473 The enclosing parentheses are a required part of the syntax.
7475 @end table
7477 When the compiler selects the registers to use to 
7478 represent the output operands, it does not use any of the clobbered registers 
7479 (@pxref{Clobbers}).
7481 Output operand expressions must be lvalues. The compiler cannot check whether 
7482 the operands have data types that are reasonable for the instruction being 
7483 executed. For output expressions that are not directly addressable (for 
7484 example a bit-field), the constraint must allow a register. In that case, GCC 
7485 uses the register as the output of the @code{asm}, and then stores that 
7486 register into the output. 
7488 Operands using the @samp{+} constraint modifier count as two operands 
7489 (that is, both as input and output) towards the total maximum of 30 operands
7490 per @code{asm} statement.
7492 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7493 operands that must not overlap an input.  Otherwise, 
7494 GCC may allocate the output operand in the same register as an unrelated 
7495 input operand, on the assumption that the assembler code consumes its 
7496 inputs before producing outputs. This assumption may be false if the assembler 
7497 code actually consists of more than one instruction.
7499 The same problem can occur if one output parameter (@var{a}) allows a register 
7500 constraint and another output parameter (@var{b}) allows a memory constraint.
7501 The code generated by GCC to access the memory address in @var{b} can contain
7502 registers which @emph{might} be shared by @var{a}, and GCC considers those 
7503 registers to be inputs to the asm. As above, GCC assumes that such input
7504 registers are consumed before any outputs are written. This assumption may 
7505 result in incorrect behavior if the asm writes to @var{a} before using 
7506 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7507 ensures that modifying @var{a} does not affect the address referenced by 
7508 @var{b}. Otherwise, the location of @var{b} 
7509 is undefined if @var{a} is modified before using @var{b}.
7511 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7512 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7513 dependent. The list of supported modifiers for x86 is found at 
7514 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7516 If the C code that follows the @code{asm} makes no use of any of the output 
7517 operands, use @code{volatile} for the @code{asm} statement to prevent the 
7518 optimizers from discarding the @code{asm} statement as unneeded 
7519 (see @ref{Volatile}).
7521 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
7522 references the first output operand as @code{%0} (were there a second, it 
7523 would be @code{%1}, etc). The number of the first input operand is one greater 
7524 than that of the last output operand. In this i386 example, that makes 
7525 @code{Mask} referenced as @code{%1}:
7527 @example
7528 uint32_t Mask = 1234;
7529 uint32_t Index;
7531   asm ("bsfl %1, %0"
7532      : "=r" (Index)
7533      : "r" (Mask)
7534      : "cc");
7535 @end example
7537 That code overwrites the variable @code{Index} (@samp{=}),
7538 placing the value in a register (@samp{r}).
7539 Using the generic @samp{r} constraint instead of a constraint for a specific 
7540 register allows the compiler to pick the register to use, which can result 
7541 in more efficient code. This may not be possible if an assembler instruction 
7542 requires a specific register.
7544 The following i386 example uses the @var{asmSymbolicName} syntax.
7545 It produces the 
7546 same result as the code above, but some may consider it more readable or more 
7547 maintainable since reordering index numbers is not necessary when adding or 
7548 removing operands. The names @code{aIndex} and @code{aMask}
7549 are only used in this example to emphasize which 
7550 names get used where.
7551 It is acceptable to reuse the names @code{Index} and @code{Mask}.
7553 @example
7554 uint32_t Mask = 1234;
7555 uint32_t Index;
7557   asm ("bsfl %[aMask], %[aIndex]"
7558      : [aIndex] "=r" (Index)
7559      : [aMask] "r" (Mask)
7560      : "cc");
7561 @end example
7563 Here are some more examples of output operands.
7565 @example
7566 uint32_t c = 1;
7567 uint32_t d;
7568 uint32_t *e = &c;
7570 asm ("mov %[e], %[d]"
7571    : [d] "=rm" (d)
7572    : [e] "rm" (*e));
7573 @end example
7575 Here, @code{d} may either be in a register or in memory. Since the compiler 
7576 might already have the current value of the @code{uint32_t} location
7577 pointed to by @code{e}
7578 in a register, you can enable it to choose the best location
7579 for @code{d} by specifying both constraints.
7581 @anchor{InputOperands}
7582 @subsubsection Input Operands
7583 @cindex @code{asm} input operands
7584 @cindex @code{asm} expressions
7586 Input operands make values from C variables and expressions available to the 
7587 assembly code.
7589 Operands are separated by commas.  Each operand has this format:
7591 @example
7592 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
7593 @end example
7595 @table @var
7596 @item asmSymbolicName
7597 Specifies a symbolic name for the operand.
7598 Reference the name in the assembler template 
7599 by enclosing it in square brackets 
7600 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
7601 that contains the definition. Any valid C variable name is acceptable, 
7602 including names already defined in the surrounding code. No two operands 
7603 within the same @code{asm} statement can use the same symbolic name.
7605 When not using an @var{asmSymbolicName}, use the (zero-based) position
7606 of the operand 
7607 in the list of operands in the assembler template. For example if there are
7608 two output operands and three inputs,
7609 use @samp{%2} in the template to refer to the first input operand,
7610 @samp{%3} for the second, and @samp{%4} for the third. 
7612 @item constraint
7613 A string constant specifying constraints on the placement of the operand; 
7614 @xref{Constraints}, for details.
7616 Input constraint strings may not begin with either @samp{=} or @samp{+}.
7617 When you list more than one possible location (for example, @samp{"irm"}), 
7618 the compiler chooses the most efficient one based on the current context.
7619 If you must use a specific register, but your Machine Constraints do not
7620 provide sufficient control to select the specific register you want, 
7621 local register variables may provide a solution (@pxref{Local Reg Vars}).
7623 Input constraints can also be digits (for example, @code{"0"}). This indicates 
7624 that the specified input must be in the same place as the output constraint 
7625 at the (zero-based) index in the output constraint list. 
7626 When using @var{asmSymbolicName} syntax for the output operands,
7627 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
7629 @item cexpression
7630 This is the C variable or expression being passed to the @code{asm} statement 
7631 as input.  The enclosing parentheses are a required part of the syntax.
7633 @end table
7635 When the compiler selects the registers to use to represent the input 
7636 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
7638 If there are no output operands but there are input operands, place two 
7639 consecutive colons where the output operands would go:
7641 @example
7642 __asm__ ("some instructions"
7643    : /* No outputs. */
7644    : "r" (Offset / 8));
7645 @end example
7647 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7648 (except for inputs tied to outputs). The compiler assumes that on exit from 
7649 the @code{asm} statement these operands contain the same values as they 
7650 had before executing the statement. 
7651 It is @emph{not} possible to use clobbers
7652 to inform the compiler that the values in these inputs are changing. One 
7653 common work-around is to tie the changing input variable to an output variable 
7654 that never gets used. Note, however, that if the code that follows the 
7655 @code{asm} statement makes no use of any of the output operands, the GCC 
7656 optimizers may discard the @code{asm} statement as unneeded 
7657 (see @ref{Volatile}).
7659 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7660 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7661 dependent. The list of supported modifiers for x86 is found at 
7662 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7664 In this example using the fictitious @code{combine} instruction, the 
7665 constraint @code{"0"} for input operand 1 says that it must occupy the same 
7666 location as output operand 0. Only input operands may use numbers in 
7667 constraints, and they must each refer to an output operand. Only a number (or 
7668 the symbolic assembler name) in the constraint can guarantee that one operand 
7669 is in the same place as another. The mere fact that @code{foo} is the value of 
7670 both operands is not enough to guarantee that they are in the same place in 
7671 the generated assembler code.
7673 @example
7674 asm ("combine %2, %0" 
7675    : "=r" (foo) 
7676    : "0" (foo), "g" (bar));
7677 @end example
7679 Here is an example using symbolic names.
7681 @example
7682 asm ("cmoveq %1, %2, %[result]" 
7683    : [result] "=r"(result) 
7684    : "r" (test), "r" (new), "[result]" (old));
7685 @end example
7687 @anchor{Clobbers}
7688 @subsubsection Clobbers
7689 @cindex @code{asm} clobbers
7691 While the compiler is aware of changes to entries listed in the output 
7692 operands, the inline @code{asm} code may modify more than just the outputs. For 
7693 example, calculations may require additional registers, or the processor may 
7694 overwrite a register as a side effect of a particular assembler instruction. 
7695 In order to inform the compiler of these changes, list them in the clobber 
7696 list. Clobber list items are either register names or the special clobbers 
7697 (listed below). Each clobber list item is a string constant 
7698 enclosed in double quotes and separated by commas.
7700 Clobber descriptions may not in any way overlap with an input or output 
7701 operand. For example, you may not have an operand describing a register class 
7702 with one member when listing that register in the clobber list. Variables 
7703 declared to live in specific registers (@pxref{Explicit Reg Vars}) and used 
7704 as @code{asm} input or output operands must have no part mentioned in the 
7705 clobber description. In particular, there is no way to specify that input 
7706 operands get modified without also specifying them as output operands.
7708 When the compiler selects which registers to use to represent input and output 
7709 operands, it does not use any of the clobbered registers. As a result, 
7710 clobbered registers are available for any use in the assembler code.
7712 Here is a realistic example for the VAX showing the use of clobbered 
7713 registers: 
7715 @example
7716 asm volatile ("movc3 %0, %1, %2"
7717                    : /* No outputs. */
7718                    : "g" (from), "g" (to), "g" (count)
7719                    : "r0", "r1", "r2", "r3", "r4", "r5");
7720 @end example
7722 Also, there are two special clobber arguments:
7724 @table @code
7725 @item "cc"
7726 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7727 register. On some machines, GCC represents the condition codes as a specific 
7728 hardware register; @code{"cc"} serves to name this register.
7729 On other machines, condition code handling is different, 
7730 and specifying @code{"cc"} has no effect. But 
7731 it is valid no matter what the target.
7733 @item "memory"
7734 The @code{"memory"} clobber tells the compiler that the assembly code
7735 performs memory 
7736 reads or writes to items other than those listed in the input and output 
7737 operands (for example, accessing the memory pointed to by one of the input 
7738 parameters). To ensure memory contains correct values, GCC may need to flush 
7739 specific register values to memory before executing the @code{asm}. Further, 
7740 the compiler does not assume that any values read from memory before an 
7741 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
7742 needed.  
7743 Using the @code{"memory"} clobber effectively forms a read/write
7744 memory barrier for the compiler.
7746 Note that this clobber does not prevent the @emph{processor} from doing 
7747 speculative reads past the @code{asm} statement. To prevent that, you need 
7748 processor-specific fence instructions.
7750 Flushing registers to memory has performance implications and may be an issue 
7751 for time-sensitive code.  You can use a trick to avoid this if the size of 
7752 the memory being accessed is known at compile time. For example, if accessing 
7753 ten bytes of a string, use a memory input like: 
7755 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7757 @end table
7759 @anchor{GotoLabels}
7760 @subsubsection Goto Labels
7761 @cindex @code{asm} goto labels
7763 @code{asm goto} allows assembly code to jump to one or more C labels.  The
7764 @var{GotoLabels} section in an @code{asm goto} statement contains 
7765 a comma-separated 
7766 list of all C labels to which the assembler code may jump. GCC assumes that 
7767 @code{asm} execution falls through to the next statement (if this is not the 
7768 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7769 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7770 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7771 Attributes}).
7773 An @code{asm goto} statement cannot have outputs.
7774 This is due to an internal restriction of 
7775 the compiler: control transfer instructions cannot have outputs. 
7776 If the assembler code does modify anything, use the @code{"memory"} clobber 
7777 to force the 
7778 optimizers to flush all register values to memory and reload them if 
7779 necessary after the @code{asm} statement.
7781 Also note that an @code{asm goto} statement is always implicitly
7782 considered volatile.
7784 To reference a label in the assembler template,
7785 prefix it with @samp{%l} (lowercase @samp{L}) followed 
7786 by its (zero-based) position in @var{GotoLabels} plus the number of input 
7787 operands.  For example, if the @code{asm} has three inputs and references two 
7788 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
7790 Alternately, you can reference labels using the actual C label name enclosed
7791 in brackets.  For example, to reference a label named @code{carry}, you can
7792 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
7793 section when using this approach.
7795 Here is an example of @code{asm goto} for i386:
7797 @example
7798 asm goto (
7799     "btl %1, %0\n\t"
7800     "jc %l2"
7801     : /* No outputs. */
7802     : "r" (p1), "r" (p2) 
7803     : "cc" 
7804     : carry);
7806 return 0;
7808 carry:
7809 return 1;
7810 @end example
7812 The following example shows an @code{asm goto} that uses a memory clobber.
7814 @example
7815 int frob(int x)
7817   int y;
7818   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7819             : /* No outputs. */
7820             : "r"(x), "r"(&y)
7821             : "r5", "memory" 
7822             : error);
7823   return y;
7824 error:
7825   return -1;
7827 @end example
7829 @anchor{x86Operandmodifiers}
7830 @subsubsection x86 Operand Modifiers
7832 References to input, output, and goto operands in the assembler template
7833 of extended @code{asm} statements can use 
7834 modifiers to affect the way the operands are formatted in 
7835 the code output to the assembler. For example, the 
7836 following code uses the @samp{h} and @samp{b} modifiers for x86:
7838 @example
7839 uint16_t  num;
7840 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7841 @end example
7843 @noindent
7844 These modifiers generate this assembler code:
7846 @example
7847 xchg %ah, %al
7848 @end example
7850 The rest of this discussion uses the following code for illustrative purposes.
7852 @example
7853 int main()
7855    int iInt = 1;
7857 top:
7859    asm volatile goto ("some assembler instructions here"
7860    : /* No outputs. */
7861    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7862    : /* No clobbers. */
7863    : top);
7865 @end example
7867 With no modifiers, this is what the output from the operands would be for the 
7868 @samp{att} and @samp{intel} dialects of assembler:
7870 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7871 @headitem Operand @tab masm=att @tab masm=intel
7872 @item @code{%0}
7873 @tab @code{%eax}
7874 @tab @code{eax}
7875 @item @code{%1}
7876 @tab @code{$2}
7877 @tab @code{2}
7878 @item @code{%2}
7879 @tab @code{$.L2}
7880 @tab @code{OFFSET FLAT:.L2}
7881 @end multitable
7883 The table below shows the list of supported modifiers and their effects.
7885 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7886 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7887 @item @code{z}
7888 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7889 @tab @code{%z0}
7890 @tab @code{l}
7891 @tab 
7892 @item @code{b}
7893 @tab Print the QImode name of the register.
7894 @tab @code{%b0}
7895 @tab @code{%al}
7896 @tab @code{al}
7897 @item @code{h}
7898 @tab Print the QImode name for a ``high'' register.
7899 @tab @code{%h0}
7900 @tab @code{%ah}
7901 @tab @code{ah}
7902 @item @code{w}
7903 @tab Print the HImode name of the register.
7904 @tab @code{%w0}
7905 @tab @code{%ax}
7906 @tab @code{ax}
7907 @item @code{k}
7908 @tab Print the SImode name of the register.
7909 @tab @code{%k0}
7910 @tab @code{%eax}
7911 @tab @code{eax}
7912 @item @code{q}
7913 @tab Print the DImode name of the register.
7914 @tab @code{%q0}
7915 @tab @code{%rax}
7916 @tab @code{rax}
7917 @item @code{l}
7918 @tab Print the label name with no punctuation.
7919 @tab @code{%l2}
7920 @tab @code{.L2}
7921 @tab @code{.L2}
7922 @item @code{c}
7923 @tab Require a constant operand and print the constant expression with no punctuation.
7924 @tab @code{%c1}
7925 @tab @code{2}
7926 @tab @code{2}
7927 @end multitable
7929 @anchor{x86floatingpointasmoperands}
7930 @subsubsection x86 Floating-Point @code{asm} Operands
7932 On x86 targets, there are several rules on the usage of stack-like registers
7933 in the operands of an @code{asm}.  These rules apply only to the operands
7934 that are stack-like registers:
7936 @enumerate
7937 @item
7938 Given a set of input registers that die in an @code{asm}, it is
7939 necessary to know which are implicitly popped by the @code{asm}, and
7940 which must be explicitly popped by GCC@.
7942 An input register that is implicitly popped by the @code{asm} must be
7943 explicitly clobbered, unless it is constrained to match an
7944 output operand.
7946 @item
7947 For any input register that is implicitly popped by an @code{asm}, it is
7948 necessary to know how to adjust the stack to compensate for the pop.
7949 If any non-popped input is closer to the top of the reg-stack than
7950 the implicitly popped register, it would not be possible to know what the
7951 stack looked like---it's not clear how the rest of the stack ``slides
7952 up''.
7954 All implicitly popped input registers must be closer to the top of
7955 the reg-stack than any input that is not implicitly popped.
7957 It is possible that if an input dies in an @code{asm}, the compiler might
7958 use the input register for an output reload.  Consider this example:
7960 @smallexample
7961 asm ("foo" : "=t" (a) : "f" (b));
7962 @end smallexample
7964 @noindent
7965 This code says that input @code{b} is not popped by the @code{asm}, and that
7966 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7967 deeper after the @code{asm} than it was before.  But, it is possible that
7968 reload may think that it can use the same register for both the input and
7969 the output.
7971 To prevent this from happening,
7972 if any input operand uses the @samp{f} constraint, all output register
7973 constraints must use the @samp{&} early-clobber modifier.
7975 The example above is correctly written as:
7977 @smallexample
7978 asm ("foo" : "=&t" (a) : "f" (b));
7979 @end smallexample
7981 @item
7982 Some operands need to be in particular places on the stack.  All
7983 output operands fall in this category---GCC has no other way to
7984 know which registers the outputs appear in unless you indicate
7985 this in the constraints.
7987 Output operands must specifically indicate which register an output
7988 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
7989 constraints must select a class with a single register.
7991 @item
7992 Output operands may not be ``inserted'' between existing stack registers.
7993 Since no 387 opcode uses a read/write operand, all output operands
7994 are dead before the @code{asm}, and are pushed by the @code{asm}.
7995 It makes no sense to push anywhere but the top of the reg-stack.
7997 Output operands must start at the top of the reg-stack: output
7998 operands may not ``skip'' a register.
8000 @item
8001 Some @code{asm} statements may need extra stack space for internal
8002 calculations.  This can be guaranteed by clobbering stack registers
8003 unrelated to the inputs and outputs.
8005 @end enumerate
8007 This @code{asm}
8008 takes one input, which is internally popped, and produces two outputs.
8010 @smallexample
8011 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8012 @end smallexample
8014 @noindent
8015 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8016 and replaces them with one output.  The @code{st(1)} clobber is necessary 
8017 for the compiler to know that @code{fyl2xp1} pops both inputs.
8019 @smallexample
8020 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8021 @end smallexample
8023 @lowersections
8024 @include md.texi
8025 @raisesections
8027 @node Asm Labels
8028 @subsection Controlling Names Used in Assembler Code
8029 @cindex assembler names for identifiers
8030 @cindex names used in assembler code
8031 @cindex identifiers, names in assembler code
8033 You can specify the name to be used in the assembler code for a C
8034 function or variable by writing the @code{asm} (or @code{__asm__})
8035 keyword after the declarator as follows:
8037 @smallexample
8038 int foo asm ("myfoo") = 2;
8039 @end smallexample
8041 @noindent
8042 This specifies that the name to be used for the variable @code{foo} in
8043 the assembler code should be @samp{myfoo} rather than the usual
8044 @samp{_foo}.
8046 On systems where an underscore is normally prepended to the name of a C
8047 function or variable, this feature allows you to define names for the
8048 linker that do not start with an underscore.
8050 It does not make sense to use this feature with a non-static local
8051 variable since such variables do not have assembler names.  If you are
8052 trying to put the variable in a particular register, see @ref{Explicit
8053 Reg Vars}.  GCC presently accepts such code with a warning, but will
8054 probably be changed to issue an error, rather than a warning, in the
8055 future.
8057 You cannot use @code{asm} in this way in a function @emph{definition}; but
8058 you can get the same effect by writing a declaration for the function
8059 before its definition and putting @code{asm} there, like this:
8061 @smallexample
8062 extern func () asm ("FUNC");
8064 func (x, y)
8065      int x, y;
8066 /* @r{@dots{}} */
8067 @end smallexample
8069 It is up to you to make sure that the assembler names you choose do not
8070 conflict with any other assembler symbols.  Also, you must not use a
8071 register name; that would produce completely invalid assembler code.  GCC
8072 does not as yet have the ability to store static variables in registers.
8073 Perhaps that will be added.
8075 @node Explicit Reg Vars
8076 @subsection Variables in Specified Registers
8077 @cindex explicit register variables
8078 @cindex variables in specified registers
8079 @cindex specified registers
8080 @cindex registers, global allocation
8082 GNU C allows you to put a few global variables into specified hardware
8083 registers.  You can also specify the register in which an ordinary
8084 register variable should be allocated.
8086 @itemize @bullet
8087 @item
8088 Global register variables reserve registers throughout the program.
8089 This may be useful in programs such as programming language
8090 interpreters that have a couple of global variables that are accessed
8091 very often.
8093 @item
8094 Local register variables in specific registers do not reserve the
8095 registers, except at the point where they are used as input or output
8096 operands in an @code{asm} statement and the @code{asm} statement itself is
8097 not deleted.  The compiler's data flow analysis is capable of determining
8098 where the specified registers contain live values, and where they are
8099 available for other uses.  Stores into local register variables may be deleted
8100 when they appear to be dead according to dataflow analysis.  References
8101 to local register variables may be deleted or moved or simplified.
8103 These local variables are sometimes convenient for use with the extended
8104 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
8105 output of the assembler instruction directly into a particular register.
8106 (This works provided the register you specify fits the constraints
8107 specified for that operand in the @code{asm}.)
8108 @end itemize
8110 @menu
8111 * Global Reg Vars::
8112 * Local Reg Vars::
8113 @end menu
8115 @node Global Reg Vars
8116 @subsubsection Defining Global Register Variables
8117 @cindex global register variables
8118 @cindex registers, global variables in
8120 You can define a global register variable in GNU C like this:
8122 @smallexample
8123 register int *foo asm ("a5");
8124 @end smallexample
8126 @noindent
8127 Here @code{a5} is the name of the register that should be used.  Choose a
8128 register that is normally saved and restored by function calls on your
8129 machine, so that library routines will not clobber it.
8131 Naturally the register name is CPU-dependent, so you need to
8132 conditionalize your program according to CPU type.  The register
8133 @code{a5} is a good choice on a 68000 for a variable of pointer
8134 type.  On machines with register windows, be sure to choose a ``global''
8135 register that is not affected magically by the function call mechanism.
8137 In addition, different operating systems on the same CPU may differ in how they
8138 name the registers; then you need additional conditionals.  For
8139 example, some 68000 operating systems call this register @code{%a5}.
8141 Eventually there may be a way of asking the compiler to choose a register
8142 automatically, but first we need to figure out how it should choose and
8143 how to enable you to guide the choice.  No solution is evident.
8145 Defining a global register variable in a certain register reserves that
8146 register entirely for this use, at least within the current compilation.
8147 The register is not allocated for any other purpose in the functions
8148 in the current compilation, and is not saved and restored by
8149 these functions.  Stores into this register are never deleted even if they
8150 appear to be dead, but references may be deleted or moved or
8151 simplified.
8153 It is not safe to access the global register variables from signal
8154 handlers, or from more than one thread of control, because the system
8155 library routines may temporarily use the register for other things (unless
8156 you recompile them specially for the task at hand).
8158 @cindex @code{qsort}, and global register variables
8159 It is not safe for one function that uses a global register variable to
8160 call another such function @code{foo} by way of a third function
8161 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
8162 different source file in which the variable isn't declared).  This is
8163 because @code{lose} might save the register and put some other value there.
8164 For example, you can't expect a global register variable to be available in
8165 the comparison-function that you pass to @code{qsort}, since @code{qsort}
8166 might have put something else in that register.  (If you are prepared to
8167 recompile @code{qsort} with the same global register variable, you can
8168 solve this problem.)
8170 If you want to recompile @code{qsort} or other source files that do not
8171 actually use your global register variable, so that they do not use that
8172 register for any other purpose, then it suffices to specify the compiler
8173 option @option{-ffixed-@var{reg}}.  You need not actually add a global
8174 register declaration to their source code.
8176 A function that can alter the value of a global register variable cannot
8177 safely be called from a function compiled without this variable, because it
8178 could clobber the value the caller expects to find there on return.
8179 Therefore, the function that is the entry point into the part of the
8180 program that uses the global register variable must explicitly save and
8181 restore the value that belongs to its caller.
8183 @cindex register variable after @code{longjmp}
8184 @cindex global register after @code{longjmp}
8185 @cindex value after @code{longjmp}
8186 @findex longjmp
8187 @findex setjmp
8188 On most machines, @code{longjmp} restores to each global register
8189 variable the value it had at the time of the @code{setjmp}.  On some
8190 machines, however, @code{longjmp} does not change the value of global
8191 register variables.  To be portable, the function that called @code{setjmp}
8192 should make other arrangements to save the values of the global register
8193 variables, and to restore them in a @code{longjmp}.  This way, the same
8194 thing happens regardless of what @code{longjmp} does.
8196 All global register variable declarations must precede all function
8197 definitions.  If such a declaration could appear after function
8198 definitions, the declaration would be too late to prevent the register from
8199 being used for other purposes in the preceding functions.
8201 Global register variables may not have initial values, because an
8202 executable file has no means to supply initial contents for a register.
8204 On the SPARC, there are reports that g3 @dots{} g7 are suitable
8205 registers, but certain library functions, such as @code{getwd}, as well
8206 as the subroutines for division and remainder, modify g3 and g4.  g1 and
8207 g2 are local temporaries.
8209 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
8210 Of course, it does not do to use more than a few of those.
8212 @node Local Reg Vars
8213 @subsubsection Specifying Registers for Local Variables
8214 @cindex local variables, specifying registers
8215 @cindex specifying registers for local variables
8216 @cindex registers for local variables
8218 You can define a local register variable with a specified register
8219 like this:
8221 @smallexample
8222 register int *foo asm ("a5");
8223 @end smallexample
8225 @noindent
8226 Here @code{a5} is the name of the register that should be used.  Note
8227 that this is the same syntax used for defining global register
8228 variables, but for a local variable it appears within a function.
8230 Naturally the register name is CPU-dependent, but this is not a
8231 problem, since specific registers are most often useful with explicit
8232 assembler instructions (@pxref{Extended Asm}).  Both of these things
8233 generally require that you conditionalize your program according to
8234 CPU type.
8236 In addition, operating systems on one type of CPU may differ in how they
8237 name the registers; then you need additional conditionals.  For
8238 example, some 68000 operating systems call this register @code{%a5}.
8240 Defining such a register variable does not reserve the register; it
8241 remains available for other uses in places where flow control determines
8242 the variable's value is not live.
8244 This option does not guarantee that GCC generates code that has
8245 this variable in the register you specify at all times.  You may not
8246 code an explicit reference to this register in the assembler
8247 instruction template part of an @code{asm} statement and assume it
8248 always refers to this variable.
8249 However, using the variable as an input or output operand to the @code{asm}
8250 guarantees that the specified register is used for that operand.  
8251 @xref{Extended Asm}, for more information.
8253 Stores into local register variables may be deleted when they appear to be dead
8254 according to dataflow analysis.  References to local register variables may
8255 be deleted or moved or simplified.
8257 As with global register variables, it is recommended that you choose a
8258 register that is normally saved and restored by function calls on
8259 your machine, so that library routines will not clobber it.  
8261 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
8262 specific register, but there's no matching constraint letter for that 
8263 register. To force the operand into that register, create a local variable 
8264 and specify the register in the variable's declaration. Then use the local 
8265 variable for the asm operand and specify any constraint letter that matches 
8266 the register:
8268 @smallexample
8269 register int *p1 asm ("r0") = @dots{};
8270 register int *p2 asm ("r1") = @dots{};
8271 register int *result asm ("r0");
8272 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8273 @end smallexample
8275 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
8276 call-clobbered by subsequent code, including function calls and library calls 
8277 for arithmetic operators on other variables (for example the initialization 
8278 of p2). In this case, use temporary variables for expressions between the 
8279 register assignments:
8281 @smallexample
8282 int t1 = @dots{};
8283 register int *p1 asm ("r0") = @dots{};
8284 register int *p2 asm ("r1") = t1;
8285 register int *result asm ("r0");
8286 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8287 @end smallexample
8289 @node Size of an asm
8290 @subsection Size of an @code{asm}
8292 Some targets require that GCC track the size of each instruction used
8293 in order to generate correct code.  Because the final length of the
8294 code produced by an @code{asm} statement is only known by the
8295 assembler, GCC must make an estimate as to how big it will be.  It
8296 does this by counting the number of instructions in the pattern of the
8297 @code{asm} and multiplying that by the length of the longest
8298 instruction supported by that processor.  (When working out the number
8299 of instructions, it assumes that any occurrence of a newline or of
8300 whatever statement separator character is supported by the assembler --
8301 typically @samp{;} --- indicates the end of an instruction.)
8303 Normally, GCC's estimate is adequate to ensure that correct
8304 code is generated, but it is possible to confuse the compiler if you use
8305 pseudo instructions or assembler macros that expand into multiple real
8306 instructions, or if you use assembler directives that expand to more
8307 space in the object file than is needed for a single instruction.
8308 If this happens then the assembler may produce a diagnostic saying that
8309 a label is unreachable.
8311 @node Alternate Keywords
8312 @section Alternate Keywords
8313 @cindex alternate keywords
8314 @cindex keywords, alternate
8316 @option{-ansi} and the various @option{-std} options disable certain
8317 keywords.  This causes trouble when you want to use GNU C extensions, or
8318 a general-purpose header file that should be usable by all programs,
8319 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
8320 @code{inline} are not available in programs compiled with
8321 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8322 program compiled with @option{-std=c99} or @option{-std=c11}).  The
8323 ISO C99 keyword
8324 @code{restrict} is only available when @option{-std=gnu99} (which will
8325 eventually be the default) or @option{-std=c99} (or the equivalent
8326 @option{-std=iso9899:1999}), or an option for a later standard
8327 version, is used.
8329 The way to solve these problems is to put @samp{__} at the beginning and
8330 end of each problematical keyword.  For example, use @code{__asm__}
8331 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8333 Other C compilers won't accept these alternative keywords; if you want to
8334 compile with another compiler, you can define the alternate keywords as
8335 macros to replace them with the customary keywords.  It looks like this:
8337 @smallexample
8338 #ifndef __GNUC__
8339 #define __asm__ asm
8340 #endif
8341 @end smallexample
8343 @findex __extension__
8344 @opindex pedantic
8345 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8346 You can
8347 prevent such warnings within one expression by writing
8348 @code{__extension__} before the expression.  @code{__extension__} has no
8349 effect aside from this.
8351 @node Incomplete Enums
8352 @section Incomplete @code{enum} Types
8354 You can define an @code{enum} tag without specifying its possible values.
8355 This results in an incomplete type, much like what you get if you write
8356 @code{struct foo} without describing the elements.  A later declaration
8357 that does specify the possible values completes the type.
8359 You can't allocate variables or storage using the type while it is
8360 incomplete.  However, you can work with pointers to that type.
8362 This extension may not be very useful, but it makes the handling of
8363 @code{enum} more consistent with the way @code{struct} and @code{union}
8364 are handled.
8366 This extension is not supported by GNU C++.
8368 @node Function Names
8369 @section Function Names as Strings
8370 @cindex @code{__func__} identifier
8371 @cindex @code{__FUNCTION__} identifier
8372 @cindex @code{__PRETTY_FUNCTION__} identifier
8374 GCC provides three magic variables that hold the name of the current
8375 function, as a string.  The first of these is @code{__func__}, which
8376 is part of the C99 standard:
8378 The identifier @code{__func__} is implicitly declared by the translator
8379 as if, immediately following the opening brace of each function
8380 definition, the declaration
8382 @smallexample
8383 static const char __func__[] = "function-name";
8384 @end smallexample
8386 @noindent
8387 appeared, where function-name is the name of the lexically-enclosing
8388 function.  This name is the unadorned name of the function.
8390 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8391 backward compatibility with old versions of GCC.
8393 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8394 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
8395 the type signature of the function as well as its bare name.  For
8396 example, this program:
8398 @smallexample
8399 extern "C" @{
8400 extern int printf (char *, ...);
8403 class a @{
8404  public:
8405   void sub (int i)
8406     @{
8407       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8408       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8409     @}
8413 main (void)
8415   a ax;
8416   ax.sub (0);
8417   return 0;
8419 @end smallexample
8421 @noindent
8422 gives this output:
8424 @smallexample
8425 __FUNCTION__ = sub
8426 __PRETTY_FUNCTION__ = void a::sub(int)
8427 @end smallexample
8429 These identifiers are variables, not preprocessor macros, and may not
8430 be used to initialize @code{char} arrays or be concatenated with other string
8431 literals.
8433 @node Return Address
8434 @section Getting the Return or Frame Address of a Function
8436 These functions may be used to get information about the callers of a
8437 function.
8439 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8440 This function returns the return address of the current function, or of
8441 one of its callers.  The @var{level} argument is number of frames to
8442 scan up the call stack.  A value of @code{0} yields the return address
8443 of the current function, a value of @code{1} yields the return address
8444 of the caller of the current function, and so forth.  When inlining
8445 the expected behavior is that the function returns the address of
8446 the function that is returned to.  To work around this behavior use
8447 the @code{noinline} function attribute.
8449 The @var{level} argument must be a constant integer.
8451 On some machines it may be impossible to determine the return address of
8452 any function other than the current one; in such cases, or when the top
8453 of the stack has been reached, this function returns @code{0} or a
8454 random value.  In addition, @code{__builtin_frame_address} may be used
8455 to determine if the top of the stack has been reached.
8457 Additional post-processing of the returned value may be needed, see
8458 @code{__builtin_extract_return_addr}.
8460 This function should only be used with a nonzero argument for debugging
8461 purposes.
8462 @end deftypefn
8464 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
8465 The address as returned by @code{__builtin_return_address} may have to be fed
8466 through this function to get the actual encoded address.  For example, on the
8467 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
8468 platforms an offset has to be added for the true next instruction to be
8469 executed.
8471 If no fixup is needed, this function simply passes through @var{addr}.
8472 @end deftypefn
8474 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
8475 This function does the reverse of @code{__builtin_extract_return_addr}.
8476 @end deftypefn
8478 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
8479 This function is similar to @code{__builtin_return_address}, but it
8480 returns the address of the function frame rather than the return address
8481 of the function.  Calling @code{__builtin_frame_address} with a value of
8482 @code{0} yields the frame address of the current function, a value of
8483 @code{1} yields the frame address of the caller of the current function,
8484 and so forth.
8486 The frame is the area on the stack that holds local variables and saved
8487 registers.  The frame address is normally the address of the first word
8488 pushed on to the stack by the function.  However, the exact definition
8489 depends upon the processor and the calling convention.  If the processor
8490 has a dedicated frame pointer register, and the function has a frame,
8491 then @code{__builtin_frame_address} returns the value of the frame
8492 pointer register.
8494 On some machines it may be impossible to determine the frame address of
8495 any function other than the current one; in such cases, or when the top
8496 of the stack has been reached, this function returns @code{0} if
8497 the first frame pointer is properly initialized by the startup code.
8499 This function should only be used with a nonzero argument for debugging
8500 purposes.
8501 @end deftypefn
8503 @node Vector Extensions
8504 @section Using Vector Instructions through Built-in Functions
8506 On some targets, the instruction set contains SIMD vector instructions which
8507 operate on multiple values contained in one large register at the same time.
8508 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
8509 this way.
8511 The first step in using these extensions is to provide the necessary data
8512 types.  This should be done using an appropriate @code{typedef}:
8514 @smallexample
8515 typedef int v4si __attribute__ ((vector_size (16)));
8516 @end smallexample
8518 @noindent
8519 The @code{int} type specifies the base type, while the attribute specifies
8520 the vector size for the variable, measured in bytes.  For example, the
8521 declaration above causes the compiler to set the mode for the @code{v4si}
8522 type to be 16 bytes wide and divided into @code{int} sized units.  For
8523 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
8524 corresponding mode of @code{foo} is @acronym{V4SI}.
8526 The @code{vector_size} attribute is only applicable to integral and
8527 float scalars, although arrays, pointers, and function return values
8528 are allowed in conjunction with this construct. Only sizes that are
8529 a power of two are currently allowed.
8531 All the basic integer types can be used as base types, both as signed
8532 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
8533 @code{long long}.  In addition, @code{float} and @code{double} can be
8534 used to build floating-point vector types.
8536 Specifying a combination that is not valid for the current architecture
8537 causes GCC to synthesize the instructions using a narrower mode.
8538 For example, if you specify a variable of type @code{V4SI} and your
8539 architecture does not allow for this specific SIMD type, GCC
8540 produces code that uses 4 @code{SIs}.
8542 The types defined in this manner can be used with a subset of normal C
8543 operations.  Currently, GCC allows using the following operators
8544 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
8546 The operations behave like C++ @code{valarrays}.  Addition is defined as
8547 the addition of the corresponding elements of the operands.  For
8548 example, in the code below, each of the 4 elements in @var{a} is
8549 added to the corresponding 4 elements in @var{b} and the resulting
8550 vector is stored in @var{c}.
8552 @smallexample
8553 typedef int v4si __attribute__ ((vector_size (16)));
8555 v4si a, b, c;
8557 c = a + b;
8558 @end smallexample
8560 Subtraction, multiplication, division, and the logical operations
8561 operate in a similar manner.  Likewise, the result of using the unary
8562 minus or complement operators on a vector type is a vector whose
8563 elements are the negative or complemented values of the corresponding
8564 elements in the operand.
8566 It is possible to use shifting operators @code{<<}, @code{>>} on
8567 integer-type vectors. The operation is defined as following: @code{@{a0,
8568 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
8569 @dots{}, an >> bn@}}@. Vector operands must have the same number of
8570 elements. 
8572 For convenience, it is allowed to use a binary vector operation
8573 where one operand is a scalar. In that case the compiler transforms
8574 the scalar operand into a vector where each element is the scalar from
8575 the operation. The transformation happens only if the scalar could be
8576 safely converted to the vector-element type.
8577 Consider the following code.
8579 @smallexample
8580 typedef int v4si __attribute__ ((vector_size (16)));
8582 v4si a, b, c;
8583 long l;
8585 a = b + 1;    /* a = b + @{1,1,1,1@}; */
8586 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
8588 a = l + a;    /* Error, cannot convert long to int. */
8589 @end smallexample
8591 Vectors can be subscripted as if the vector were an array with
8592 the same number of elements and base type.  Out of bound accesses
8593 invoke undefined behavior at run time.  Warnings for out of bound
8594 accesses for vector subscription can be enabled with
8595 @option{-Warray-bounds}.
8597 Vector comparison is supported with standard comparison
8598 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
8599 vector expressions of integer-type or real-type. Comparison between
8600 integer-type vectors and real-type vectors are not supported.  The
8601 result of the comparison is a vector of the same width and number of
8602 elements as the comparison operands with a signed integral element
8603 type.
8605 Vectors are compared element-wise producing 0 when comparison is false
8606 and -1 (constant of the appropriate type where all bits are set)
8607 otherwise. Consider the following example.
8609 @smallexample
8610 typedef int v4si __attribute__ ((vector_size (16)));
8612 v4si a = @{1,2,3,4@};
8613 v4si b = @{3,2,1,4@};
8614 v4si c;
8616 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
8617 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
8618 @end smallexample
8620 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8621 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8622 integer vector with the same number of elements of the same size as @code{b}
8623 and @code{c}, computes all three arguments and creates a vector
8624 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
8625 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8626 As in the case of binary operations, this syntax is also accepted when
8627 one of @code{b} or @code{c} is a scalar that is then transformed into a
8628 vector. If both @code{b} and @code{c} are scalars and the type of
8629 @code{true?b:c} has the same size as the element type of @code{a}, then
8630 @code{b} and @code{c} are converted to a vector type whose elements have
8631 this type and with the same number of elements as @code{a}.
8633 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8634 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8635 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8636 For mixed operations between a scalar @code{s} and a vector @code{v},
8637 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8638 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8640 Vector shuffling is available using functions
8641 @code{__builtin_shuffle (vec, mask)} and
8642 @code{__builtin_shuffle (vec0, vec1, mask)}.
8643 Both functions construct a permutation of elements from one or two
8644 vectors and return a vector of the same type as the input vector(s).
8645 The @var{mask} is an integral vector with the same width (@var{W})
8646 and element count (@var{N}) as the output vector.
8648 The elements of the input vectors are numbered in memory ordering of
8649 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8650 elements of @var{mask} are considered modulo @var{N} in the single-operand
8651 case and modulo @math{2*@var{N}} in the two-operand case.
8653 Consider the following example,
8655 @smallexample
8656 typedef int v4si __attribute__ ((vector_size (16)));
8658 v4si a = @{1,2,3,4@};
8659 v4si b = @{5,6,7,8@};
8660 v4si mask1 = @{0,1,1,3@};
8661 v4si mask2 = @{0,4,2,5@};
8662 v4si res;
8664 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
8665 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
8666 @end smallexample
8668 Note that @code{__builtin_shuffle} is intentionally semantically
8669 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8671 You can declare variables and use them in function calls and returns, as
8672 well as in assignments and some casts.  You can specify a vector type as
8673 a return type for a function.  Vector types can also be used as function
8674 arguments.  It is possible to cast from one vector type to another,
8675 provided they are of the same size (in fact, you can also cast vectors
8676 to and from other datatypes of the same size).
8678 You cannot operate between vectors of different lengths or different
8679 signedness without a cast.
8681 @node Offsetof
8682 @section Support for @code{offsetof}
8683 @findex __builtin_offsetof
8685 GCC implements for both C and C++ a syntactic extension to implement
8686 the @code{offsetof} macro.
8688 @smallexample
8689 primary:
8690         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8692 offsetof_member_designator:
8693           @code{identifier}
8694         | offsetof_member_designator "." @code{identifier}
8695         | offsetof_member_designator "[" @code{expr} "]"
8696 @end smallexample
8698 This extension is sufficient such that
8700 @smallexample
8701 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8702 @end smallexample
8704 @noindent
8705 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8706 may be dependent.  In either case, @var{member} may consist of a single
8707 identifier, or a sequence of member accesses and array references.
8709 @node __sync Builtins
8710 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
8712 The following built-in functions
8713 are intended to be compatible with those described
8714 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8715 section 7.4.  As such, they depart from normal GCC practice by not using
8716 the @samp{__builtin_} prefix and also by being overloaded so that they
8717 work on multiple types.
8719 The definition given in the Intel documentation allows only for the use of
8720 the types @code{int}, @code{long}, @code{long long} or their unsigned
8721 counterparts.  GCC allows any integral scalar or pointer type that is
8722 1, 2, 4 or 8 bytes in length.
8724 These functions are implemented in terms of the @samp{__atomic}
8725 builtins (@pxref{__atomic Builtins}).  They should not be used for new
8726 code which should use the @samp{__atomic} builtins instead.
8728 Not all operations are supported by all target processors.  If a particular
8729 operation cannot be implemented on the target processor, a warning is
8730 generated and a call to an external function is generated.  The external
8731 function carries the same name as the built-in version,
8732 with an additional suffix
8733 @samp{_@var{n}} where @var{n} is the size of the data type.
8735 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8736 @c useful for implementing the operation under the control of an external
8737 @c mutex.
8739 In most cases, these built-in functions are considered a @dfn{full barrier}.
8740 That is,
8741 no memory operand is moved across the operation, either forward or
8742 backward.  Further, instructions are issued as necessary to prevent the
8743 processor from speculating loads across the operation and from queuing stores
8744 after the operation.
8746 All of the routines are described in the Intel documentation to take
8747 ``an optional list of variables protected by the memory barrier''.  It's
8748 not clear what is meant by that; it could mean that @emph{only} the
8749 listed variables are protected, or it could mean a list of additional
8750 variables to be protected.  The list is ignored by GCC which treats it as
8751 empty.  GCC interprets an empty list as meaning that all globally
8752 accessible variables should be protected.
8754 @table @code
8755 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8756 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8757 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8758 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8759 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8760 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8761 @findex __sync_fetch_and_add
8762 @findex __sync_fetch_and_sub
8763 @findex __sync_fetch_and_or
8764 @findex __sync_fetch_and_and
8765 @findex __sync_fetch_and_xor
8766 @findex __sync_fetch_and_nand
8767 These built-in functions perform the operation suggested by the name, and
8768 returns the value that had previously been in memory.  That is,
8770 @smallexample
8771 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8772 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8773 @end smallexample
8775 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8776 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8778 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8779 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8780 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8781 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8782 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8783 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8784 @findex __sync_add_and_fetch
8785 @findex __sync_sub_and_fetch
8786 @findex __sync_or_and_fetch
8787 @findex __sync_and_and_fetch
8788 @findex __sync_xor_and_fetch
8789 @findex __sync_nand_and_fetch
8790 These built-in functions perform the operation suggested by the name, and
8791 return the new value.  That is,
8793 @smallexample
8794 @{ *ptr @var{op}= value; return *ptr; @}
8795 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8796 @end smallexample
8798 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8799 as @code{*ptr = ~(*ptr & value)} instead of
8800 @code{*ptr = ~*ptr & value}.
8802 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8803 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8804 @findex __sync_bool_compare_and_swap
8805 @findex __sync_val_compare_and_swap
8806 These built-in functions perform an atomic compare and swap.
8807 That is, if the current
8808 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8809 @code{*@var{ptr}}.
8811 The ``bool'' version returns true if the comparison is successful and
8812 @var{newval} is written.  The ``val'' version returns the contents
8813 of @code{*@var{ptr}} before the operation.
8815 @item __sync_synchronize (...)
8816 @findex __sync_synchronize
8817 This built-in function issues a full memory barrier.
8819 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8820 @findex __sync_lock_test_and_set
8821 This built-in function, as described by Intel, is not a traditional test-and-set
8822 operation, but rather an atomic exchange operation.  It writes @var{value}
8823 into @code{*@var{ptr}}, and returns the previous contents of
8824 @code{*@var{ptr}}.
8826 Many targets have only minimal support for such locks, and do not support
8827 a full exchange operation.  In this case, a target may support reduced
8828 functionality here by which the @emph{only} valid value to store is the
8829 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8830 is implementation defined.
8832 This built-in function is not a full barrier,
8833 but rather an @dfn{acquire barrier}.
8834 This means that references after the operation cannot move to (or be
8835 speculated to) before the operation, but previous memory stores may not
8836 be globally visible yet, and previous memory loads may not yet be
8837 satisfied.
8839 @item void __sync_lock_release (@var{type} *ptr, ...)
8840 @findex __sync_lock_release
8841 This built-in function releases the lock acquired by
8842 @code{__sync_lock_test_and_set}.
8843 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8845 This built-in function is not a full barrier,
8846 but rather a @dfn{release barrier}.
8847 This means that all previous memory stores are globally visible, and all
8848 previous memory loads have been satisfied, but following memory reads
8849 are not prevented from being speculated to before the barrier.
8850 @end table
8852 @node __atomic Builtins
8853 @section Built-in Functions for Memory Model Aware Atomic Operations
8855 The following built-in functions approximately match the requirements
8856 for C++11 concurrency and memory models.  They are all
8857 identified by being prefixed with @samp{__atomic} and most are
8858 overloaded so that they work with multiple types.
8860 These functions are intended to replace the legacy @samp{__sync}
8861 builtins.  The main difference is that the memory model to be used is a
8862 parameter to the functions.  New code should always use the
8863 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
8865 Note that the @samp{__atomic} builtins assume that programs will
8866 conform to the C++11 model for concurrency.  In particular, they assume
8867 that programs are free of data races.  See the C++11 standard for
8868 detailed definitions.
8870 The @samp{__atomic} builtins can be used with any integral scalar or
8871 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
8872 types are also allowed if @samp{__int128} (@pxref{__int128}) is
8873 supported by the architecture.
8875 The four non-arithmetic functions (load, store, exchange, and 
8876 compare_exchange) all have a generic version as well.  This generic
8877 version works on any data type.  If the data type size maps to one
8878 of the integral sizes that may have lock free support, the generic
8879 version uses the lock free built-in function.  Otherwise an
8880 external call is left to be resolved at run time.  This external call is
8881 the same format with the addition of a @samp{size_t} parameter inserted
8882 as the first parameter indicating the size of the object being pointed to.
8883 All objects must be the same size.
8885 There are 6 different memory models that can be specified.  These map
8886 to the C++11 memory models with the same names, see the C++11 standard
8887 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
8888 on atomic synchronization} for detailed definitions.  Individual
8889 targets may also support additional memory models for use on specific
8890 architectures.  Refer to the target documentation for details of
8891 these.
8893 The memory models integrate both barriers to code motion as well as
8894 synchronization requirements with other threads.  They are listed here
8895 in approximately ascending order of strength.
8897 @table  @code
8898 @item __ATOMIC_RELAXED
8899 No barriers or synchronization.
8900 @item __ATOMIC_CONSUME
8901 Data dependency only for both barrier and synchronization with another
8902 thread.
8903 @item __ATOMIC_ACQUIRE
8904 Barrier to hoisting of code and synchronizes with release (or stronger)
8905 semantic stores from another thread.
8906 @item __ATOMIC_RELEASE
8907 Barrier to sinking of code and synchronizes with acquire (or stronger)
8908 semantic loads from another thread.
8909 @item __ATOMIC_ACQ_REL
8910 Barrier in both directions and synchronizes with acquire loads and
8911 release stores in another thread.
8912 @item __ATOMIC_SEQ_CST
8913 Barrier in both directions and synchronizes with acquire loads and
8914 release stores in all threads.
8915 @end table
8917 Note that the scope of a C++11 memory model depends on whether or not
8918 the function being called is a @emph{fence} (such as
8919 @samp{__atomic_thread_fence}).  In a fence, all memory accesses are
8920 subject to the restrictions of the memory model.  When the function is
8921 an operation on a location, the restrictions apply only to those
8922 memory accesses that could affect or that could depend on the
8923 location.
8925 Target architectures are encouraged to provide their own patterns for
8926 each of these built-in functions.  If no target is provided, the original
8927 non-memory model set of @samp{__sync} atomic built-in functions are
8928 used, along with any required synchronization fences surrounding it in
8929 order to achieve the proper behavior.  Execution in this case is subject
8930 to the same restrictions as those built-in functions.
8932 If there is no pattern or mechanism to provide a lock free instruction
8933 sequence, a call is made to an external routine with the same parameters
8934 to be resolved at run time.
8936 When implementing patterns for these built-in functions, the memory model
8937 parameter can be ignored as long as the pattern implements the most
8938 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8939 execute correctly with this memory model but they may not execute as
8940 efficiently as they could with a more appropriate implementation of the
8941 relaxed requirements.
8943 Note that the C++11 standard allows for the memory model parameter to be
8944 determined at run time rather than at compile time.  These built-in
8945 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8946 than invoke a runtime library call or inline a switch statement.  This is
8947 standard compliant, safe, and the simplest approach for now.
8949 The memory model parameter is a signed int, but only the lower 8 bits are
8950 reserved for the memory model.  The remainder of the signed int is reserved
8951 for future use and should be 0.  Use of the predefined atomic values
8952 ensures proper usage.
8954 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8955 This built-in function implements an atomic load operation.  It returns the
8956 contents of @code{*@var{ptr}}.
8958 The valid memory model variants are
8959 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8960 and @code{__ATOMIC_CONSUME}.
8962 @end deftypefn
8964 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8965 This is the generic version of an atomic load.  It returns the
8966 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8968 @end deftypefn
8970 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8971 This built-in function implements an atomic store operation.  It writes 
8972 @code{@var{val}} into @code{*@var{ptr}}.  
8974 The valid memory model variants are
8975 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8977 @end deftypefn
8979 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8980 This is the generic version of an atomic store.  It stores the value
8981 of @code{*@var{val}} into @code{*@var{ptr}}.
8983 @end deftypefn
8985 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8986 This built-in function implements an atomic exchange operation.  It writes
8987 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8988 @code{*@var{ptr}}.
8990 The valid memory model variants are
8991 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8992 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8994 @end deftypefn
8996 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8997 This is the generic version of an atomic exchange.  It stores the
8998 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8999 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9001 @end deftypefn
9003 @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)
9004 This built-in function implements an atomic compare and exchange operation.
9005 This compares the contents of @code{*@var{ptr}} with the contents of
9006 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9007 which writes @var{desired} into @code{*@var{ptr}}.  If they are not
9008 equal, the operation is a @emph{read} and the current contents of
9009 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
9010 for weak compare_exchange, and false for the strong variation.  Many targets 
9011 only offer the strong variation and ignore the parameter.  When in doubt, use
9012 the strong variation.
9014 True is returned if @var{desired} is written into
9015 @code{*@var{ptr}} and the operation is considered to conform to the
9016 memory model specified by @var{success_memmodel}.  There are no
9017 restrictions on what memory model can be used here.
9019 False is returned otherwise, and the operation is considered to conform
9020 to @var{failure_memmodel}. This memory model cannot be
9021 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
9022 stronger model than that specified by @var{success_memmodel}.
9024 @end deftypefn
9026 @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)
9027 This built-in function implements the generic version of
9028 @code{__atomic_compare_exchange}.  The function is virtually identical to
9029 @code{__atomic_compare_exchange_n}, except the desired value is also a
9030 pointer.
9032 @end deftypefn
9034 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
9035 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
9036 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
9037 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
9038 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
9039 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
9040 These built-in functions perform the operation suggested by the name, and
9041 return the result of the operation. That is,
9043 @smallexample
9044 @{ *ptr @var{op}= val; return *ptr; @}
9045 @end smallexample
9047 All memory models are valid.
9049 @end deftypefn
9051 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
9052 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
9053 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
9054 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
9055 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
9056 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
9057 These built-in functions perform the operation suggested by the name, and
9058 return the value that had previously been in @code{*@var{ptr}}.  That is,
9060 @smallexample
9061 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9062 @end smallexample
9064 All memory models are valid.
9066 @end deftypefn
9068 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
9070 This built-in function performs an atomic test-and-set operation on
9071 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
9072 defined nonzero ``set'' value and the return value is @code{true} if and only
9073 if the previous contents were ``set''.
9074 It should be only used for operands of type @code{bool} or @code{char}. For 
9075 other types only part of the value may be set.
9077 All memory models are valid.
9079 @end deftypefn
9081 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
9083 This built-in function performs an atomic clear operation on
9084 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
9085 It should be only used for operands of type @code{bool} or @code{char} and 
9086 in conjunction with @code{__atomic_test_and_set}.
9087 For other types it may only clear partially. If the type is not @code{bool}
9088 prefer using @code{__atomic_store}.
9090 The valid memory model variants are
9091 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9092 @code{__ATOMIC_RELEASE}.
9094 @end deftypefn
9096 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
9098 This built-in function acts as a synchronization fence between threads
9099 based on the specified memory model.
9101 All memory orders are valid.
9103 @end deftypefn
9105 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
9107 This built-in function acts as a synchronization fence between a thread
9108 and signal handlers based in the same thread.
9110 All memory orders are valid.
9112 @end deftypefn
9114 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
9116 This built-in function returns true if objects of @var{size} bytes always
9117 generate lock free atomic instructions for the target architecture.  
9118 @var{size} must resolve to a compile-time constant and the result also
9119 resolves to a compile-time constant.
9121 @var{ptr} is an optional pointer to the object that may be used to determine
9122 alignment.  A value of 0 indicates typical alignment should be used.  The 
9123 compiler may also ignore this parameter.
9125 @smallexample
9126 if (_atomic_always_lock_free (sizeof (long long), 0))
9127 @end smallexample
9129 @end deftypefn
9131 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9133 This built-in function returns true if objects of @var{size} bytes always
9134 generate lock free atomic instructions for the target architecture.  If
9135 it is not known to be lock free a call is made to a runtime routine named
9136 @code{__atomic_is_lock_free}.
9138 @var{ptr} is an optional pointer to the object that may be used to determine
9139 alignment.  A value of 0 indicates typical alignment should be used.  The 
9140 compiler may also ignore this parameter.
9141 @end deftypefn
9143 @node Integer Overflow Builtins
9144 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9146 The following built-in functions allow performing simple arithmetic operations
9147 together with checking whether the operations overflowed.
9149 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9150 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9151 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9152 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9153 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9154 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9155 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9157 These built-in functions promote the first two operands into infinite precision signed
9158 type and perform addition on those promoted operands.  The result is then
9159 cast to the type the third pointer argument points to and stored there.
9160 If the stored result is equal to the infinite precision result, the built-in
9161 functions return false, otherwise they return true.  As the addition is
9162 performed in infinite signed precision, these built-in functions have fully defined
9163 behavior for all argument values.
9165 The first built-in function allows arbitrary integral types for operands and
9166 the result type must be pointer to some integer type, the rest of the built-in
9167 functions have explicit integer types.
9169 The compiler will attempt to use hardware instructions to implement
9170 these built-in functions where possible, like conditional jump on overflow
9171 after addition, conditional jump on carry etc.
9173 @end deftypefn
9175 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9176 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9177 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9178 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9179 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9180 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9181 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9183 These built-in functions are similar to the add overflow checking built-in
9184 functions above, except they perform subtraction, subtract the second argument
9185 from the first one, instead of addition.
9187 @end deftypefn
9189 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9190 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9191 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9192 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9193 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9194 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9195 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9197 These built-in functions are similar to the add overflow checking built-in
9198 functions above, except they perform multiplication, instead of addition.
9200 @end deftypefn
9202 @node x86 specific memory model extensions for transactional memory
9203 @section x86-Specific Memory Model Extensions for Transactional Memory
9205 The x86 architecture supports additional memory ordering flags
9206 to mark lock critical sections for hardware lock elision. 
9207 These must be specified in addition to an existing memory model to 
9208 atomic intrinsics.
9210 @table @code
9211 @item __ATOMIC_HLE_ACQUIRE
9212 Start lock elision on a lock variable.
9213 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
9214 @item __ATOMIC_HLE_RELEASE
9215 End lock elision on a lock variable.
9216 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
9217 @end table
9219 When a lock acquire fails it is required for good performance to abort
9220 the transaction quickly. This can be done with a @code{_mm_pause}
9222 @smallexample
9223 #include <immintrin.h> // For _mm_pause
9225 int lockvar;
9227 /* Acquire lock with lock elision */
9228 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9229     _mm_pause(); /* Abort failed transaction */
9231 /* Free lock with lock elision */
9232 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9233 @end smallexample
9235 @node Object Size Checking
9236 @section Object Size Checking Built-in Functions
9237 @findex __builtin_object_size
9238 @findex __builtin___memcpy_chk
9239 @findex __builtin___mempcpy_chk
9240 @findex __builtin___memmove_chk
9241 @findex __builtin___memset_chk
9242 @findex __builtin___strcpy_chk
9243 @findex __builtin___stpcpy_chk
9244 @findex __builtin___strncpy_chk
9245 @findex __builtin___strcat_chk
9246 @findex __builtin___strncat_chk
9247 @findex __builtin___sprintf_chk
9248 @findex __builtin___snprintf_chk
9249 @findex __builtin___vsprintf_chk
9250 @findex __builtin___vsnprintf_chk
9251 @findex __builtin___printf_chk
9252 @findex __builtin___vprintf_chk
9253 @findex __builtin___fprintf_chk
9254 @findex __builtin___vfprintf_chk
9256 GCC implements a limited buffer overflow protection mechanism
9257 that can prevent some buffer overflow attacks.
9259 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9260 is a built-in construct that returns a constant number of bytes from
9261 @var{ptr} to the end of the object @var{ptr} pointer points to
9262 (if known at compile time).  @code{__builtin_object_size} never evaluates
9263 its arguments for side-effects.  If there are any side-effects in them, it
9264 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9265 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
9266 point to and all of them are known at compile time, the returned number
9267 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9268 0 and minimum if nonzero.  If it is not possible to determine which objects
9269 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9270 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9271 for @var{type} 2 or 3.
9273 @var{type} is an integer constant from 0 to 3.  If the least significant
9274 bit is clear, objects are whole variables, if it is set, a closest
9275 surrounding subobject is considered the object a pointer points to.
9276 The second bit determines if maximum or minimum of remaining bytes
9277 is computed.
9279 @smallexample
9280 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9281 char *p = &var.buf1[1], *q = &var.b;
9283 /* Here the object p points to is var.  */
9284 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9285 /* The subobject p points to is var.buf1.  */
9286 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9287 /* The object q points to is var.  */
9288 assert (__builtin_object_size (q, 0)
9289         == (char *) (&var + 1) - (char *) &var.b);
9290 /* The subobject q points to is var.b.  */
9291 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9292 @end smallexample
9293 @end deftypefn
9295 There are built-in functions added for many common string operation
9296 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9297 built-in is provided.  This built-in has an additional last argument,
9298 which is the number of bytes remaining in object the @var{dest}
9299 argument points to or @code{(size_t) -1} if the size is not known.
9301 The built-in functions are optimized into the normal string functions
9302 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9303 it is known at compile time that the destination object will not
9304 be overflown.  If the compiler can determine at compile time the
9305 object will be always overflown, it issues a warning.
9307 The intended use can be e.g.@:
9309 @smallexample
9310 #undef memcpy
9311 #define bos0(dest) __builtin_object_size (dest, 0)
9312 #define memcpy(dest, src, n) \
9313   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9315 char *volatile p;
9316 char buf[10];
9317 /* It is unknown what object p points to, so this is optimized
9318    into plain memcpy - no checking is possible.  */
9319 memcpy (p, "abcde", n);
9320 /* Destination is known and length too.  It is known at compile
9321    time there will be no overflow.  */
9322 memcpy (&buf[5], "abcde", 5);
9323 /* Destination is known, but the length is not known at compile time.
9324    This will result in __memcpy_chk call that can check for overflow
9325    at run time.  */
9326 memcpy (&buf[5], "abcde", n);
9327 /* Destination is known and it is known at compile time there will
9328    be overflow.  There will be a warning and __memcpy_chk call that
9329    will abort the program at run time.  */
9330 memcpy (&buf[6], "abcde", 5);
9331 @end smallexample
9333 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9334 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9335 @code{strcat} and @code{strncat}.
9337 There are also checking built-in functions for formatted output functions.
9338 @smallexample
9339 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9340 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9341                               const char *fmt, ...);
9342 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9343                               va_list ap);
9344 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9345                                const char *fmt, va_list ap);
9346 @end smallexample
9348 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9349 etc.@: functions and can contain implementation specific flags on what
9350 additional security measures the checking function might take, such as
9351 handling @code{%n} differently.
9353 The @var{os} argument is the object size @var{s} points to, like in the
9354 other built-in functions.  There is a small difference in the behavior
9355 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9356 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9357 the checking function is called with @var{os} argument set to
9358 @code{(size_t) -1}.
9360 In addition to this, there are checking built-in functions
9361 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9362 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9363 These have just one additional argument, @var{flag}, right before
9364 format string @var{fmt}.  If the compiler is able to optimize them to
9365 @code{fputc} etc.@: functions, it does, otherwise the checking function
9366 is called and the @var{flag} argument passed to it.
9368 @node Pointer Bounds Checker builtins
9369 @section Pointer Bounds Checker Built-in Functions
9370 @cindex Pointer Bounds Checker builtins
9371 @findex __builtin___bnd_set_ptr_bounds
9372 @findex __builtin___bnd_narrow_ptr_bounds
9373 @findex __builtin___bnd_copy_ptr_bounds
9374 @findex __builtin___bnd_init_ptr_bounds
9375 @findex __builtin___bnd_null_ptr_bounds
9376 @findex __builtin___bnd_store_ptr_bounds
9377 @findex __builtin___bnd_chk_ptr_lbounds
9378 @findex __builtin___bnd_chk_ptr_ubounds
9379 @findex __builtin___bnd_chk_ptr_bounds
9380 @findex __builtin___bnd_get_ptr_lbound
9381 @findex __builtin___bnd_get_ptr_ubound
9383 GCC provides a set of built-in functions to control Pointer Bounds Checker
9384 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
9385 even if you compile with Pointer Bounds Checker off
9386 (@option{-fno-check-pointer-bounds}).
9387 The behavior may differ in such case as documented below.
9389 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9391 This built-in function returns a new pointer with the value of @var{q}, and
9392 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
9393 Bounds Checker off, the built-in function just returns the first argument.
9395 @smallexample
9396 extern void *__wrap_malloc (size_t n)
9398   void *p = (void *)__real_malloc (n);
9399   if (!p) return __builtin___bnd_null_ptr_bounds (p);
9400   return __builtin___bnd_set_ptr_bounds (p, n);
9402 @end smallexample
9404 @end deftypefn
9406 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
9408 This built-in function returns a new pointer with the value of @var{p}
9409 and associates it with the narrowed bounds formed by the intersection
9410 of bounds associated with @var{q} and the bounds
9411 [@var{p}, @var{p} + @var{size} - 1].
9412 With Pointer Bounds Checker off, the built-in function just returns the first
9413 argument.
9415 @smallexample
9416 void init_objects (object *objs, size_t size)
9418   size_t i;
9419   /* Initialize objects one-by-one passing pointers with bounds of 
9420      an object, not the full array of objects.  */
9421   for (i = 0; i < size; i++)
9422     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
9423                                                     sizeof(object)));
9425 @end smallexample
9427 @end deftypefn
9429 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
9431 This built-in function returns a new pointer with the value of @var{q},
9432 and associates it with the bounds already associated with pointer @var{r}.
9433 With Pointer Bounds Checker off, the built-in function just returns the first
9434 argument.
9436 @smallexample
9437 /* Here is a way to get pointer to object's field but
9438    still with the full object's bounds.  */
9439 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
9440                                                   objptr);
9441 @end smallexample
9443 @end deftypefn
9445 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
9447 This built-in function returns a new pointer with the value of @var{q}, and
9448 associates it with INIT (allowing full memory access) bounds. With Pointer
9449 Bounds Checker off, the built-in function just returns the first argument.
9451 @end deftypefn
9453 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
9455 This built-in function returns a new pointer with the value of @var{q}, and
9456 associates it with NULL (allowing no memory access) bounds. With Pointer
9457 Bounds Checker off, the built-in function just returns the first argument.
9459 @end deftypefn
9461 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
9463 This built-in function stores the bounds associated with pointer @var{ptr_val}
9464 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
9465 bounds from legacy code without touching the associated pointer's memory when
9466 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
9467 function call is ignored.
9469 @end deftypefn
9471 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
9473 This built-in function checks if the pointer @var{q} is within the lower
9474 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
9475 function call is ignored.
9477 @smallexample
9478 extern void *__wrap_memset (void *dst, int c, size_t len)
9480   if (len > 0)
9481     @{
9482       __builtin___bnd_chk_ptr_lbounds (dst);
9483       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
9484       __real_memset (dst, c, len);
9485     @}
9486   return dst;
9488 @end smallexample
9490 @end deftypefn
9492 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
9494 This built-in function checks if the pointer @var{q} is within the upper
9495 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
9496 function call is ignored.
9498 @end deftypefn
9500 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
9502 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
9503 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
9504 off, the built-in function call is ignored.
9506 @smallexample
9507 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
9509   if (n > 0)
9510     @{
9511       __bnd_chk_ptr_bounds (dst, n);
9512       __bnd_chk_ptr_bounds (src, n);
9513       __real_memcpy (dst, src, n);
9514     @}
9515   return dst;
9517 @end smallexample
9519 @end deftypefn
9521 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
9523 This built-in function returns the lower bound associated
9524 with the pointer @var{q}, as a pointer value.  
9525 This is useful for debugging using @code{printf}.
9526 With Pointer Bounds Checker off, the built-in function returns 0.
9528 @smallexample
9529 void *lb = __builtin___bnd_get_ptr_lbound (q);
9530 void *ub = __builtin___bnd_get_ptr_ubound (q);
9531 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
9532 @end smallexample
9534 @end deftypefn
9536 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
9538 This built-in function returns the upper bound (which is a pointer) associated
9539 with the pointer @var{q}.  With Pointer Bounds Checker off,
9540 the built-in function returns -1.
9542 @end deftypefn
9544 @node Cilk Plus Builtins
9545 @section Cilk Plus C/C++ Language Extension Built-in Functions
9547 GCC provides support for the following built-in reduction functions if Cilk Plus
9548 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
9550 @itemize @bullet
9551 @item @code{__sec_implicit_index}
9552 @item @code{__sec_reduce}
9553 @item @code{__sec_reduce_add}
9554 @item @code{__sec_reduce_all_nonzero}
9555 @item @code{__sec_reduce_all_zero}
9556 @item @code{__sec_reduce_any_nonzero}
9557 @item @code{__sec_reduce_any_zero}
9558 @item @code{__sec_reduce_max}
9559 @item @code{__sec_reduce_min}
9560 @item @code{__sec_reduce_max_ind}
9561 @item @code{__sec_reduce_min_ind}
9562 @item @code{__sec_reduce_mul}
9563 @item @code{__sec_reduce_mutating}
9564 @end itemize
9566 Further details and examples about these built-in functions are described 
9567 in the Cilk Plus language manual which can be found at 
9568 @uref{http://www.cilkplus.org}.
9570 @node Other Builtins
9571 @section Other Built-in Functions Provided by GCC
9572 @cindex built-in functions
9573 @findex __builtin_call_with_static_chain
9574 @findex __builtin_fpclassify
9575 @findex __builtin_isfinite
9576 @findex __builtin_isnormal
9577 @findex __builtin_isgreater
9578 @findex __builtin_isgreaterequal
9579 @findex __builtin_isinf_sign
9580 @findex __builtin_isless
9581 @findex __builtin_islessequal
9582 @findex __builtin_islessgreater
9583 @findex __builtin_isunordered
9584 @findex __builtin_powi
9585 @findex __builtin_powif
9586 @findex __builtin_powil
9587 @findex _Exit
9588 @findex _exit
9589 @findex abort
9590 @findex abs
9591 @findex acos
9592 @findex acosf
9593 @findex acosh
9594 @findex acoshf
9595 @findex acoshl
9596 @findex acosl
9597 @findex alloca
9598 @findex asin
9599 @findex asinf
9600 @findex asinh
9601 @findex asinhf
9602 @findex asinhl
9603 @findex asinl
9604 @findex atan
9605 @findex atan2
9606 @findex atan2f
9607 @findex atan2l
9608 @findex atanf
9609 @findex atanh
9610 @findex atanhf
9611 @findex atanhl
9612 @findex atanl
9613 @findex bcmp
9614 @findex bzero
9615 @findex cabs
9616 @findex cabsf
9617 @findex cabsl
9618 @findex cacos
9619 @findex cacosf
9620 @findex cacosh
9621 @findex cacoshf
9622 @findex cacoshl
9623 @findex cacosl
9624 @findex calloc
9625 @findex carg
9626 @findex cargf
9627 @findex cargl
9628 @findex casin
9629 @findex casinf
9630 @findex casinh
9631 @findex casinhf
9632 @findex casinhl
9633 @findex casinl
9634 @findex catan
9635 @findex catanf
9636 @findex catanh
9637 @findex catanhf
9638 @findex catanhl
9639 @findex catanl
9640 @findex cbrt
9641 @findex cbrtf
9642 @findex cbrtl
9643 @findex ccos
9644 @findex ccosf
9645 @findex ccosh
9646 @findex ccoshf
9647 @findex ccoshl
9648 @findex ccosl
9649 @findex ceil
9650 @findex ceilf
9651 @findex ceill
9652 @findex cexp
9653 @findex cexpf
9654 @findex cexpl
9655 @findex cimag
9656 @findex cimagf
9657 @findex cimagl
9658 @findex clog
9659 @findex clogf
9660 @findex clogl
9661 @findex conj
9662 @findex conjf
9663 @findex conjl
9664 @findex copysign
9665 @findex copysignf
9666 @findex copysignl
9667 @findex cos
9668 @findex cosf
9669 @findex cosh
9670 @findex coshf
9671 @findex coshl
9672 @findex cosl
9673 @findex cpow
9674 @findex cpowf
9675 @findex cpowl
9676 @findex cproj
9677 @findex cprojf
9678 @findex cprojl
9679 @findex creal
9680 @findex crealf
9681 @findex creall
9682 @findex csin
9683 @findex csinf
9684 @findex csinh
9685 @findex csinhf
9686 @findex csinhl
9687 @findex csinl
9688 @findex csqrt
9689 @findex csqrtf
9690 @findex csqrtl
9691 @findex ctan
9692 @findex ctanf
9693 @findex ctanh
9694 @findex ctanhf
9695 @findex ctanhl
9696 @findex ctanl
9697 @findex dcgettext
9698 @findex dgettext
9699 @findex drem
9700 @findex dremf
9701 @findex dreml
9702 @findex erf
9703 @findex erfc
9704 @findex erfcf
9705 @findex erfcl
9706 @findex erff
9707 @findex erfl
9708 @findex exit
9709 @findex exp
9710 @findex exp10
9711 @findex exp10f
9712 @findex exp10l
9713 @findex exp2
9714 @findex exp2f
9715 @findex exp2l
9716 @findex expf
9717 @findex expl
9718 @findex expm1
9719 @findex expm1f
9720 @findex expm1l
9721 @findex fabs
9722 @findex fabsf
9723 @findex fabsl
9724 @findex fdim
9725 @findex fdimf
9726 @findex fdiml
9727 @findex ffs
9728 @findex floor
9729 @findex floorf
9730 @findex floorl
9731 @findex fma
9732 @findex fmaf
9733 @findex fmal
9734 @findex fmax
9735 @findex fmaxf
9736 @findex fmaxl
9737 @findex fmin
9738 @findex fminf
9739 @findex fminl
9740 @findex fmod
9741 @findex fmodf
9742 @findex fmodl
9743 @findex fprintf
9744 @findex fprintf_unlocked
9745 @findex fputs
9746 @findex fputs_unlocked
9747 @findex frexp
9748 @findex frexpf
9749 @findex frexpl
9750 @findex fscanf
9751 @findex gamma
9752 @findex gammaf
9753 @findex gammal
9754 @findex gamma_r
9755 @findex gammaf_r
9756 @findex gammal_r
9757 @findex gettext
9758 @findex hypot
9759 @findex hypotf
9760 @findex hypotl
9761 @findex ilogb
9762 @findex ilogbf
9763 @findex ilogbl
9764 @findex imaxabs
9765 @findex index
9766 @findex isalnum
9767 @findex isalpha
9768 @findex isascii
9769 @findex isblank
9770 @findex iscntrl
9771 @findex isdigit
9772 @findex isgraph
9773 @findex islower
9774 @findex isprint
9775 @findex ispunct
9776 @findex isspace
9777 @findex isupper
9778 @findex iswalnum
9779 @findex iswalpha
9780 @findex iswblank
9781 @findex iswcntrl
9782 @findex iswdigit
9783 @findex iswgraph
9784 @findex iswlower
9785 @findex iswprint
9786 @findex iswpunct
9787 @findex iswspace
9788 @findex iswupper
9789 @findex iswxdigit
9790 @findex isxdigit
9791 @findex j0
9792 @findex j0f
9793 @findex j0l
9794 @findex j1
9795 @findex j1f
9796 @findex j1l
9797 @findex jn
9798 @findex jnf
9799 @findex jnl
9800 @findex labs
9801 @findex ldexp
9802 @findex ldexpf
9803 @findex ldexpl
9804 @findex lgamma
9805 @findex lgammaf
9806 @findex lgammal
9807 @findex lgamma_r
9808 @findex lgammaf_r
9809 @findex lgammal_r
9810 @findex llabs
9811 @findex llrint
9812 @findex llrintf
9813 @findex llrintl
9814 @findex llround
9815 @findex llroundf
9816 @findex llroundl
9817 @findex log
9818 @findex log10
9819 @findex log10f
9820 @findex log10l
9821 @findex log1p
9822 @findex log1pf
9823 @findex log1pl
9824 @findex log2
9825 @findex log2f
9826 @findex log2l
9827 @findex logb
9828 @findex logbf
9829 @findex logbl
9830 @findex logf
9831 @findex logl
9832 @findex lrint
9833 @findex lrintf
9834 @findex lrintl
9835 @findex lround
9836 @findex lroundf
9837 @findex lroundl
9838 @findex malloc
9839 @findex memchr
9840 @findex memcmp
9841 @findex memcpy
9842 @findex mempcpy
9843 @findex memset
9844 @findex modf
9845 @findex modff
9846 @findex modfl
9847 @findex nearbyint
9848 @findex nearbyintf
9849 @findex nearbyintl
9850 @findex nextafter
9851 @findex nextafterf
9852 @findex nextafterl
9853 @findex nexttoward
9854 @findex nexttowardf
9855 @findex nexttowardl
9856 @findex pow
9857 @findex pow10
9858 @findex pow10f
9859 @findex pow10l
9860 @findex powf
9861 @findex powl
9862 @findex printf
9863 @findex printf_unlocked
9864 @findex putchar
9865 @findex puts
9866 @findex remainder
9867 @findex remainderf
9868 @findex remainderl
9869 @findex remquo
9870 @findex remquof
9871 @findex remquol
9872 @findex rindex
9873 @findex rint
9874 @findex rintf
9875 @findex rintl
9876 @findex round
9877 @findex roundf
9878 @findex roundl
9879 @findex scalb
9880 @findex scalbf
9881 @findex scalbl
9882 @findex scalbln
9883 @findex scalblnf
9884 @findex scalblnf
9885 @findex scalbn
9886 @findex scalbnf
9887 @findex scanfnl
9888 @findex signbit
9889 @findex signbitf
9890 @findex signbitl
9891 @findex signbitd32
9892 @findex signbitd64
9893 @findex signbitd128
9894 @findex significand
9895 @findex significandf
9896 @findex significandl
9897 @findex sin
9898 @findex sincos
9899 @findex sincosf
9900 @findex sincosl
9901 @findex sinf
9902 @findex sinh
9903 @findex sinhf
9904 @findex sinhl
9905 @findex sinl
9906 @findex snprintf
9907 @findex sprintf
9908 @findex sqrt
9909 @findex sqrtf
9910 @findex sqrtl
9911 @findex sscanf
9912 @findex stpcpy
9913 @findex stpncpy
9914 @findex strcasecmp
9915 @findex strcat
9916 @findex strchr
9917 @findex strcmp
9918 @findex strcpy
9919 @findex strcspn
9920 @findex strdup
9921 @findex strfmon
9922 @findex strftime
9923 @findex strlen
9924 @findex strncasecmp
9925 @findex strncat
9926 @findex strncmp
9927 @findex strncpy
9928 @findex strndup
9929 @findex strpbrk
9930 @findex strrchr
9931 @findex strspn
9932 @findex strstr
9933 @findex tan
9934 @findex tanf
9935 @findex tanh
9936 @findex tanhf
9937 @findex tanhl
9938 @findex tanl
9939 @findex tgamma
9940 @findex tgammaf
9941 @findex tgammal
9942 @findex toascii
9943 @findex tolower
9944 @findex toupper
9945 @findex towlower
9946 @findex towupper
9947 @findex trunc
9948 @findex truncf
9949 @findex truncl
9950 @findex vfprintf
9951 @findex vfscanf
9952 @findex vprintf
9953 @findex vscanf
9954 @findex vsnprintf
9955 @findex vsprintf
9956 @findex vsscanf
9957 @findex y0
9958 @findex y0f
9959 @findex y0l
9960 @findex y1
9961 @findex y1f
9962 @findex y1l
9963 @findex yn
9964 @findex ynf
9965 @findex ynl
9967 GCC provides a large number of built-in functions other than the ones
9968 mentioned above.  Some of these are for internal use in the processing
9969 of exceptions or variable-length argument lists and are not
9970 documented here because they may change from time to time; we do not
9971 recommend general use of these functions.
9973 The remaining functions are provided for optimization purposes.
9975 @opindex fno-builtin
9976 GCC includes built-in versions of many of the functions in the standard
9977 C library.  The versions prefixed with @code{__builtin_} are always
9978 treated as having the same meaning as the C library function even if you
9979 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
9980 Many of these functions are only optimized in certain cases; if they are
9981 not optimized in a particular case, a call to the library function is
9982 emitted.
9984 @opindex ansi
9985 @opindex std
9986 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9987 @option{-std=c99} or @option{-std=c11}), the functions
9988 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9989 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9990 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9991 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9992 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9993 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9994 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9995 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9996 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9997 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9998 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9999 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10000 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10001 @code{significandl}, @code{significand}, @code{sincosf},
10002 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10003 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10004 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10005 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10006 @code{yn}
10007 may be handled as built-in functions.
10008 All these functions have corresponding versions
10009 prefixed with @code{__builtin_}, which may be used even in strict C90
10010 mode.
10012 The ISO C99 functions
10013 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10014 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10015 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10016 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10017 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10018 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10019 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10020 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10021 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10022 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10023 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10024 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10025 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10026 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10027 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10028 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10029 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10030 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10031 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10032 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10033 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10034 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10035 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10036 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10037 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10038 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10039 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10040 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10041 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10042 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10043 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10044 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10045 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10046 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10047 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10048 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10049 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10050 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10051 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10052 are handled as built-in functions
10053 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10055 There are also built-in versions of the ISO C99 functions
10056 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10057 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10058 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10059 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10060 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10061 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10062 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10063 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10064 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10065 that are recognized in any mode since ISO C90 reserves these names for
10066 the purpose to which ISO C99 puts them.  All these functions have
10067 corresponding versions prefixed with @code{__builtin_}.
10069 The ISO C94 functions
10070 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10071 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10072 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10073 @code{towupper}
10074 are handled as built-in functions
10075 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10077 The ISO C90 functions
10078 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10079 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10080 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10081 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10082 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10083 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10084 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10085 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10086 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10087 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10088 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10089 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10090 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10091 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10092 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10093 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10094 are all recognized as built-in functions unless
10095 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10096 is specified for an individual function).  All of these functions have
10097 corresponding versions prefixed with @code{__builtin_}.
10099 GCC provides built-in versions of the ISO C99 floating-point comparison
10100 macros that avoid raising exceptions for unordered operands.  They have
10101 the same names as the standard macros ( @code{isgreater},
10102 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10103 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10104 prefixed.  We intend for a library implementor to be able to simply
10105 @code{#define} each standard macro to its built-in equivalent.
10106 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10107 @code{isinf_sign} and @code{isnormal} built-ins used with
10108 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
10109 built-in functions appear both with and without the @code{__builtin_} prefix.
10111 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10113 You can use the built-in function @code{__builtin_types_compatible_p} to
10114 determine whether two types are the same.
10116 This built-in function returns 1 if the unqualified versions of the
10117 types @var{type1} and @var{type2} (which are types, not expressions) are
10118 compatible, 0 otherwise.  The result of this built-in function can be
10119 used in integer constant expressions.
10121 This built-in function ignores top level qualifiers (e.g., @code{const},
10122 @code{volatile}).  For example, @code{int} is equivalent to @code{const
10123 int}.
10125 The type @code{int[]} and @code{int[5]} are compatible.  On the other
10126 hand, @code{int} and @code{char *} are not compatible, even if the size
10127 of their types, on the particular architecture are the same.  Also, the
10128 amount of pointer indirection is taken into account when determining
10129 similarity.  Consequently, @code{short *} is not similar to
10130 @code{short **}.  Furthermore, two types that are typedefed are
10131 considered compatible if their underlying types are compatible.
10133 An @code{enum} type is not considered to be compatible with another
10134 @code{enum} type even if both are compatible with the same integer
10135 type; this is what the C standard specifies.
10136 For example, @code{enum @{foo, bar@}} is not similar to
10137 @code{enum @{hot, dog@}}.
10139 You typically use this function in code whose execution varies
10140 depending on the arguments' types.  For example:
10142 @smallexample
10143 #define foo(x)                                                  \
10144   (@{                                                           \
10145     typeof (x) tmp = (x);                                       \
10146     if (__builtin_types_compatible_p (typeof (x), long double)) \
10147       tmp = foo_long_double (tmp);                              \
10148     else if (__builtin_types_compatible_p (typeof (x), double)) \
10149       tmp = foo_double (tmp);                                   \
10150     else if (__builtin_types_compatible_p (typeof (x), float))  \
10151       tmp = foo_float (tmp);                                    \
10152     else                                                        \
10153       abort ();                                                 \
10154     tmp;                                                        \
10155   @})
10156 @end smallexample
10158 @emph{Note:} This construct is only available for C@.
10160 @end deftypefn
10162 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10164 The @var{call_exp} expression must be a function call, and the
10165 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
10166 is passed to the function call in the target's static chain location.
10167 The result of builtin is the result of the function call.
10169 @emph{Note:} This builtin is only available for C@.
10170 This builtin can be used to call Go closures from C.
10172 @end deftypefn
10174 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10176 You can use the built-in function @code{__builtin_choose_expr} to
10177 evaluate code depending on the value of a constant expression.  This
10178 built-in function returns @var{exp1} if @var{const_exp}, which is an
10179 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
10181 This built-in function is analogous to the @samp{? :} operator in C,
10182 except that the expression returned has its type unaltered by promotion
10183 rules.  Also, the built-in function does not evaluate the expression
10184 that is not chosen.  For example, if @var{const_exp} evaluates to true,
10185 @var{exp2} is not evaluated even if it has side-effects.
10187 This built-in function can return an lvalue if the chosen argument is an
10188 lvalue.
10190 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10191 type.  Similarly, if @var{exp2} is returned, its return type is the same
10192 as @var{exp2}.
10194 Example:
10196 @smallexample
10197 #define foo(x)                                                    \
10198   __builtin_choose_expr (                                         \
10199     __builtin_types_compatible_p (typeof (x), double),            \
10200     foo_double (x),                                               \
10201     __builtin_choose_expr (                                       \
10202       __builtin_types_compatible_p (typeof (x), float),           \
10203       foo_float (x),                                              \
10204       /* @r{The void expression results in a compile-time error}  \
10205          @r{when assigning the result to something.}  */          \
10206       (void)0))
10207 @end smallexample
10209 @emph{Note:} This construct is only available for C@.  Furthermore, the
10210 unused expression (@var{exp1} or @var{exp2} depending on the value of
10211 @var{const_exp}) may still generate syntax errors.  This may change in
10212 future revisions.
10214 @end deftypefn
10216 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10218 The built-in function @code{__builtin_complex} is provided for use in
10219 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10220 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
10221 real binary floating-point type, and the result has the corresponding
10222 complex type with real and imaginary parts @var{real} and @var{imag}.
10223 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10224 infinities, NaNs and negative zeros are involved.
10226 @end deftypefn
10228 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10229 You can use the built-in function @code{__builtin_constant_p} to
10230 determine if a value is known to be constant at compile time and hence
10231 that GCC can perform constant-folding on expressions involving that
10232 value.  The argument of the function is the value to test.  The function
10233 returns the integer 1 if the argument is known to be a compile-time
10234 constant and 0 if it is not known to be a compile-time constant.  A
10235 return of 0 does not indicate that the value is @emph{not} a constant,
10236 but merely that GCC cannot prove it is a constant with the specified
10237 value of the @option{-O} option.
10239 You typically use this function in an embedded application where
10240 memory is a critical resource.  If you have some complex calculation,
10241 you may want it to be folded if it involves constants, but need to call
10242 a function if it does not.  For example:
10244 @smallexample
10245 #define Scale_Value(X)      \
10246   (__builtin_constant_p (X) \
10247   ? ((X) * SCALE + OFFSET) : Scale (X))
10248 @end smallexample
10250 You may use this built-in function in either a macro or an inline
10251 function.  However, if you use it in an inlined function and pass an
10252 argument of the function as the argument to the built-in, GCC 
10253 never returns 1 when you call the inline function with a string constant
10254 or compound literal (@pxref{Compound Literals}) and does not return 1
10255 when you pass a constant numeric value to the inline function unless you
10256 specify the @option{-O} option.
10258 You may also use @code{__builtin_constant_p} in initializers for static
10259 data.  For instance, you can write
10261 @smallexample
10262 static const int table[] = @{
10263    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10264    /* @r{@dots{}} */
10266 @end smallexample
10268 @noindent
10269 This is an acceptable initializer even if @var{EXPRESSION} is not a
10270 constant expression, including the case where
10271 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10272 folded to a constant but @var{EXPRESSION} contains operands that are
10273 not otherwise permitted in a static initializer (for example,
10274 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
10275 built-in in this case, because it has no opportunity to perform
10276 optimization.
10277 @end deftypefn
10279 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10280 @opindex fprofile-arcs
10281 You may use @code{__builtin_expect} to provide the compiler with
10282 branch prediction information.  In general, you should prefer to
10283 use actual profile feedback for this (@option{-fprofile-arcs}), as
10284 programmers are notoriously bad at predicting how their programs
10285 actually perform.  However, there are applications in which this
10286 data is hard to collect.
10288 The return value is the value of @var{exp}, which should be an integral
10289 expression.  The semantics of the built-in are that it is expected that
10290 @var{exp} == @var{c}.  For example:
10292 @smallexample
10293 if (__builtin_expect (x, 0))
10294   foo ();
10295 @end smallexample
10297 @noindent
10298 indicates that we do not expect to call @code{foo}, since
10299 we expect @code{x} to be zero.  Since you are limited to integral
10300 expressions for @var{exp}, you should use constructions such as
10302 @smallexample
10303 if (__builtin_expect (ptr != NULL, 1))
10304   foo (*ptr);
10305 @end smallexample
10307 @noindent
10308 when testing pointer or floating-point values.
10309 @end deftypefn
10311 @deftypefn {Built-in Function} void __builtin_trap (void)
10312 This function causes the program to exit abnormally.  GCC implements
10313 this function by using a target-dependent mechanism (such as
10314 intentionally executing an illegal instruction) or by calling
10315 @code{abort}.  The mechanism used may vary from release to release so
10316 you should not rely on any particular implementation.
10317 @end deftypefn
10319 @deftypefn {Built-in Function} void __builtin_unreachable (void)
10320 If control flow reaches the point of the @code{__builtin_unreachable},
10321 the program is undefined.  It is useful in situations where the
10322 compiler cannot deduce the unreachability of the code.
10324 One such case is immediately following an @code{asm} statement that
10325 either never terminates, or one that transfers control elsewhere
10326 and never returns.  In this example, without the
10327 @code{__builtin_unreachable}, GCC issues a warning that control
10328 reaches the end of a non-void function.  It also generates code
10329 to return after the @code{asm}.
10331 @smallexample
10332 int f (int c, int v)
10334   if (c)
10335     @{
10336       return v;
10337     @}
10338   else
10339     @{
10340       asm("jmp error_handler");
10341       __builtin_unreachable ();
10342     @}
10344 @end smallexample
10346 @noindent
10347 Because the @code{asm} statement unconditionally transfers control out
10348 of the function, control never reaches the end of the function
10349 body.  The @code{__builtin_unreachable} is in fact unreachable and
10350 communicates this fact to the compiler.
10352 Another use for @code{__builtin_unreachable} is following a call a
10353 function that never returns but that is not declared
10354 @code{__attribute__((noreturn))}, as in this example:
10356 @smallexample
10357 void function_that_never_returns (void);
10359 int g (int c)
10361   if (c)
10362     @{
10363       return 1;
10364     @}
10365   else
10366     @{
10367       function_that_never_returns ();
10368       __builtin_unreachable ();
10369     @}
10371 @end smallexample
10373 @end deftypefn
10375 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
10376 This function returns its first argument, and allows the compiler
10377 to assume that the returned pointer is at least @var{align} bytes
10378 aligned.  This built-in can have either two or three arguments,
10379 if it has three, the third argument should have integer type, and
10380 if it is nonzero means misalignment offset.  For example:
10382 @smallexample
10383 void *x = __builtin_assume_aligned (arg, 16);
10384 @end smallexample
10386 @noindent
10387 means that the compiler can assume @code{x}, set to @code{arg}, is at least
10388 16-byte aligned, while:
10390 @smallexample
10391 void *x = __builtin_assume_aligned (arg, 32, 8);
10392 @end smallexample
10394 @noindent
10395 means that the compiler can assume for @code{x}, set to @code{arg}, that
10396 @code{(char *) x - 8} is 32-byte aligned.
10397 @end deftypefn
10399 @deftypefn {Built-in Function} int __builtin_LINE ()
10400 This function is the equivalent to the preprocessor @code{__LINE__}
10401 macro and returns the line number of the invocation of the built-in.
10402 In a C++ default argument for a function @var{F}, it gets the line number of
10403 the call to @var{F}.
10404 @end deftypefn
10406 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
10407 This function is the equivalent to the preprocessor @code{__FUNCTION__}
10408 macro and returns the function name the invocation of the built-in is in.
10409 @end deftypefn
10411 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
10412 This function is the equivalent to the preprocessor @code{__FILE__}
10413 macro and returns the file name the invocation of the built-in is in.
10414 In a C++ default argument for a function @var{F}, it gets the file name of
10415 the call to @var{F}.
10416 @end deftypefn
10418 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
10419 This function is used to flush the processor's instruction cache for
10420 the region of memory between @var{begin} inclusive and @var{end}
10421 exclusive.  Some targets require that the instruction cache be
10422 flushed, after modifying memory containing code, in order to obtain
10423 deterministic behavior.
10425 If the target does not require instruction cache flushes,
10426 @code{__builtin___clear_cache} has no effect.  Otherwise either
10427 instructions are emitted in-line to clear the instruction cache or a
10428 call to the @code{__clear_cache} function in libgcc is made.
10429 @end deftypefn
10431 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
10432 This function is used to minimize cache-miss latency by moving data into
10433 a cache before it is accessed.
10434 You can insert calls to @code{__builtin_prefetch} into code for which
10435 you know addresses of data in memory that is likely to be accessed soon.
10436 If the target supports them, data prefetch instructions are generated.
10437 If the prefetch is done early enough before the access then the data will
10438 be in the cache by the time it is accessed.
10440 The value of @var{addr} is the address of the memory to prefetch.
10441 There are two optional arguments, @var{rw} and @var{locality}.
10442 The value of @var{rw} is a compile-time constant one or zero; one
10443 means that the prefetch is preparing for a write to the memory address
10444 and zero, the default, means that the prefetch is preparing for a read.
10445 The value @var{locality} must be a compile-time constant integer between
10446 zero and three.  A value of zero means that the data has no temporal
10447 locality, so it need not be left in the cache after the access.  A value
10448 of three means that the data has a high degree of temporal locality and
10449 should be left in all levels of cache possible.  Values of one and two
10450 mean, respectively, a low or moderate degree of temporal locality.  The
10451 default is three.
10453 @smallexample
10454 for (i = 0; i < n; i++)
10455   @{
10456     a[i] = a[i] + b[i];
10457     __builtin_prefetch (&a[i+j], 1, 1);
10458     __builtin_prefetch (&b[i+j], 0, 1);
10459     /* @r{@dots{}} */
10460   @}
10461 @end smallexample
10463 Data prefetch does not generate faults if @var{addr} is invalid, but
10464 the address expression itself must be valid.  For example, a prefetch
10465 of @code{p->next} does not fault if @code{p->next} is not a valid
10466 address, but evaluation faults if @code{p} is not a valid address.
10468 If the target does not support data prefetch, the address expression
10469 is evaluated if it includes side effects but no other code is generated
10470 and GCC does not issue a warning.
10471 @end deftypefn
10473 @deftypefn {Built-in Function} double __builtin_huge_val (void)
10474 Returns a positive infinity, if supported by the floating-point format,
10475 else @code{DBL_MAX}.  This function is suitable for implementing the
10476 ISO C macro @code{HUGE_VAL}.
10477 @end deftypefn
10479 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
10480 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
10481 @end deftypefn
10483 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
10484 Similar to @code{__builtin_huge_val}, except the return
10485 type is @code{long double}.
10486 @end deftypefn
10488 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
10489 This built-in implements the C99 fpclassify functionality.  The first
10490 five int arguments should be the target library's notion of the
10491 possible FP classes and are used for return values.  They must be
10492 constant values and they must appear in this order: @code{FP_NAN},
10493 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
10494 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
10495 to classify.  GCC treats the last argument as type-generic, which
10496 means it does not do default promotion from float to double.
10497 @end deftypefn
10499 @deftypefn {Built-in Function} double __builtin_inf (void)
10500 Similar to @code{__builtin_huge_val}, except a warning is generated
10501 if the target floating-point format does not support infinities.
10502 @end deftypefn
10504 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
10505 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
10506 @end deftypefn
10508 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
10509 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
10510 @end deftypefn
10512 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
10513 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
10514 @end deftypefn
10516 @deftypefn {Built-in Function} float __builtin_inff (void)
10517 Similar to @code{__builtin_inf}, except the return type is @code{float}.
10518 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
10519 @end deftypefn
10521 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
10522 Similar to @code{__builtin_inf}, except the return
10523 type is @code{long double}.
10524 @end deftypefn
10526 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
10527 Similar to @code{isinf}, except the return value is -1 for
10528 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
10529 Note while the parameter list is an
10530 ellipsis, this function only accepts exactly one floating-point
10531 argument.  GCC treats this parameter as type-generic, which means it
10532 does not do default promotion from float to double.
10533 @end deftypefn
10535 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
10536 This is an implementation of the ISO C99 function @code{nan}.
10538 Since ISO C99 defines this function in terms of @code{strtod}, which we
10539 do not implement, a description of the parsing is in order.  The string
10540 is parsed as by @code{strtol}; that is, the base is recognized by
10541 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
10542 in the significand such that the least significant bit of the number
10543 is at the least significant bit of the significand.  The number is
10544 truncated to fit the significand field provided.  The significand is
10545 forced to be a quiet NaN@.
10547 This function, if given a string literal all of which would have been
10548 consumed by @code{strtol}, is evaluated early enough that it is considered a
10549 compile-time constant.
10550 @end deftypefn
10552 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
10553 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
10554 @end deftypefn
10556 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
10557 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
10558 @end deftypefn
10560 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
10561 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
10562 @end deftypefn
10564 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
10565 Similar to @code{__builtin_nan}, except the return type is @code{float}.
10566 @end deftypefn
10568 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
10569 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
10570 @end deftypefn
10572 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
10573 Similar to @code{__builtin_nan}, except the significand is forced
10574 to be a signaling NaN@.  The @code{nans} function is proposed by
10575 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
10576 @end deftypefn
10578 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
10579 Similar to @code{__builtin_nans}, except the return type is @code{float}.
10580 @end deftypefn
10582 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
10583 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
10584 @end deftypefn
10586 @deftypefn {Built-in Function} int __builtin_ffs (int x)
10587 Returns one plus the index of the least significant 1-bit of @var{x}, or
10588 if @var{x} is zero, returns zero.
10589 @end deftypefn
10591 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
10592 Returns the number of leading 0-bits in @var{x}, starting at the most
10593 significant bit position.  If @var{x} is 0, the result is undefined.
10594 @end deftypefn
10596 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
10597 Returns the number of trailing 0-bits in @var{x}, starting at the least
10598 significant bit position.  If @var{x} is 0, the result is undefined.
10599 @end deftypefn
10601 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
10602 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
10603 number of bits following the most significant bit that are identical
10604 to it.  There are no special cases for 0 or other values. 
10605 @end deftypefn
10607 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
10608 Returns the number of 1-bits in @var{x}.
10609 @end deftypefn
10611 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
10612 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
10613 modulo 2.
10614 @end deftypefn
10616 @deftypefn {Built-in Function} int __builtin_ffsl (long)
10617 Similar to @code{__builtin_ffs}, except the argument type is
10618 @code{long}.
10619 @end deftypefn
10621 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
10622 Similar to @code{__builtin_clz}, except the argument type is
10623 @code{unsigned long}.
10624 @end deftypefn
10626 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
10627 Similar to @code{__builtin_ctz}, except the argument type is
10628 @code{unsigned long}.
10629 @end deftypefn
10631 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
10632 Similar to @code{__builtin_clrsb}, except the argument type is
10633 @code{long}.
10634 @end deftypefn
10636 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
10637 Similar to @code{__builtin_popcount}, except the argument type is
10638 @code{unsigned long}.
10639 @end deftypefn
10641 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
10642 Similar to @code{__builtin_parity}, except the argument type is
10643 @code{unsigned long}.
10644 @end deftypefn
10646 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
10647 Similar to @code{__builtin_ffs}, except the argument type is
10648 @code{long long}.
10649 @end deftypefn
10651 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
10652 Similar to @code{__builtin_clz}, except the argument type is
10653 @code{unsigned long long}.
10654 @end deftypefn
10656 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
10657 Similar to @code{__builtin_ctz}, except the argument type is
10658 @code{unsigned long long}.
10659 @end deftypefn
10661 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
10662 Similar to @code{__builtin_clrsb}, except the argument type is
10663 @code{long long}.
10664 @end deftypefn
10666 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10667 Similar to @code{__builtin_popcount}, except the argument type is
10668 @code{unsigned long long}.
10669 @end deftypefn
10671 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10672 Similar to @code{__builtin_parity}, except the argument type is
10673 @code{unsigned long long}.
10674 @end deftypefn
10676 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10677 Returns the first argument raised to the power of the second.  Unlike the
10678 @code{pow} function no guarantees about precision and rounding are made.
10679 @end deftypefn
10681 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10682 Similar to @code{__builtin_powi}, except the argument and return types
10683 are @code{float}.
10684 @end deftypefn
10686 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10687 Similar to @code{__builtin_powi}, except the argument and return types
10688 are @code{long double}.
10689 @end deftypefn
10691 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10692 Returns @var{x} with the order of the bytes reversed; for example,
10693 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
10694 exactly 8 bits.
10695 @end deftypefn
10697 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10698 Similar to @code{__builtin_bswap16}, except the argument and return types
10699 are 32 bit.
10700 @end deftypefn
10702 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10703 Similar to @code{__builtin_bswap32}, except the argument and return types
10704 are 64 bit.
10705 @end deftypefn
10707 @node Target Builtins
10708 @section Built-in Functions Specific to Particular Target Machines
10710 On some target machines, GCC supports many built-in functions specific
10711 to those machines.  Generally these generate calls to specific machine
10712 instructions, but allow the compiler to schedule those calls.
10714 @menu
10715 * AArch64 Built-in Functions::
10716 * Alpha Built-in Functions::
10717 * Altera Nios II Built-in Functions::
10718 * ARC Built-in Functions::
10719 * ARC SIMD Built-in Functions::
10720 * ARM iWMMXt Built-in Functions::
10721 * ARM C Language Extensions (ACLE)::
10722 * ARM Floating Point Status and Control Intrinsics::
10723 * AVR Built-in Functions::
10724 * Blackfin Built-in Functions::
10725 * FR-V Built-in Functions::
10726 * MIPS DSP Built-in Functions::
10727 * MIPS Paired-Single Support::
10728 * MIPS Loongson Built-in Functions::
10729 * Other MIPS Built-in Functions::
10730 * MSP430 Built-in Functions::
10731 * NDS32 Built-in Functions::
10732 * picoChip Built-in Functions::
10733 * PowerPC Built-in Functions::
10734 * PowerPC AltiVec/VSX Built-in Functions::
10735 * PowerPC Hardware Transactional Memory Built-in Functions::
10736 * RX Built-in Functions::
10737 * S/390 System z Built-in Functions::
10738 * SH Built-in Functions::
10739 * SPARC VIS Built-in Functions::
10740 * SPU Built-in Functions::
10741 * TI C6X Built-in Functions::
10742 * TILE-Gx Built-in Functions::
10743 * TILEPro Built-in Functions::
10744 * x86 Built-in Functions::
10745 * x86 transactional memory intrinsics::
10746 @end menu
10748 @node AArch64 Built-in Functions
10749 @subsection AArch64 Built-in Functions
10751 These built-in functions are available for the AArch64 family of
10752 processors.
10753 @smallexample
10754 unsigned int __builtin_aarch64_get_fpcr ()
10755 void __builtin_aarch64_set_fpcr (unsigned int)
10756 unsigned int __builtin_aarch64_get_fpsr ()
10757 void __builtin_aarch64_set_fpsr (unsigned int)
10758 @end smallexample
10760 @node Alpha Built-in Functions
10761 @subsection Alpha Built-in Functions
10763 These built-in functions are available for the Alpha family of
10764 processors, depending on the command-line switches used.
10766 The following built-in functions are always available.  They
10767 all generate the machine instruction that is part of the name.
10769 @smallexample
10770 long __builtin_alpha_implver (void)
10771 long __builtin_alpha_rpcc (void)
10772 long __builtin_alpha_amask (long)
10773 long __builtin_alpha_cmpbge (long, long)
10774 long __builtin_alpha_extbl (long, long)
10775 long __builtin_alpha_extwl (long, long)
10776 long __builtin_alpha_extll (long, long)
10777 long __builtin_alpha_extql (long, long)
10778 long __builtin_alpha_extwh (long, long)
10779 long __builtin_alpha_extlh (long, long)
10780 long __builtin_alpha_extqh (long, long)
10781 long __builtin_alpha_insbl (long, long)
10782 long __builtin_alpha_inswl (long, long)
10783 long __builtin_alpha_insll (long, long)
10784 long __builtin_alpha_insql (long, long)
10785 long __builtin_alpha_inswh (long, long)
10786 long __builtin_alpha_inslh (long, long)
10787 long __builtin_alpha_insqh (long, long)
10788 long __builtin_alpha_mskbl (long, long)
10789 long __builtin_alpha_mskwl (long, long)
10790 long __builtin_alpha_mskll (long, long)
10791 long __builtin_alpha_mskql (long, long)
10792 long __builtin_alpha_mskwh (long, long)
10793 long __builtin_alpha_msklh (long, long)
10794 long __builtin_alpha_mskqh (long, long)
10795 long __builtin_alpha_umulh (long, long)
10796 long __builtin_alpha_zap (long, long)
10797 long __builtin_alpha_zapnot (long, long)
10798 @end smallexample
10800 The following built-in functions are always with @option{-mmax}
10801 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10802 later.  They all generate the machine instruction that is part
10803 of the name.
10805 @smallexample
10806 long __builtin_alpha_pklb (long)
10807 long __builtin_alpha_pkwb (long)
10808 long __builtin_alpha_unpkbl (long)
10809 long __builtin_alpha_unpkbw (long)
10810 long __builtin_alpha_minub8 (long, long)
10811 long __builtin_alpha_minsb8 (long, long)
10812 long __builtin_alpha_minuw4 (long, long)
10813 long __builtin_alpha_minsw4 (long, long)
10814 long __builtin_alpha_maxub8 (long, long)
10815 long __builtin_alpha_maxsb8 (long, long)
10816 long __builtin_alpha_maxuw4 (long, long)
10817 long __builtin_alpha_maxsw4 (long, long)
10818 long __builtin_alpha_perr (long, long)
10819 @end smallexample
10821 The following built-in functions are always with @option{-mcix}
10822 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10823 later.  They all generate the machine instruction that is part
10824 of the name.
10826 @smallexample
10827 long __builtin_alpha_cttz (long)
10828 long __builtin_alpha_ctlz (long)
10829 long __builtin_alpha_ctpop (long)
10830 @end smallexample
10832 The following built-in functions are available on systems that use the OSF/1
10833 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
10834 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10835 @code{rdval} and @code{wrval}.
10837 @smallexample
10838 void *__builtin_thread_pointer (void)
10839 void __builtin_set_thread_pointer (void *)
10840 @end smallexample
10842 @node Altera Nios II Built-in Functions
10843 @subsection Altera Nios II Built-in Functions
10845 These built-in functions are available for the Altera Nios II
10846 family of processors.
10848 The following built-in functions are always available.  They
10849 all generate the machine instruction that is part of the name.
10851 @example
10852 int __builtin_ldbio (volatile const void *)
10853 int __builtin_ldbuio (volatile const void *)
10854 int __builtin_ldhio (volatile const void *)
10855 int __builtin_ldhuio (volatile const void *)
10856 int __builtin_ldwio (volatile const void *)
10857 void __builtin_stbio (volatile void *, int)
10858 void __builtin_sthio (volatile void *, int)
10859 void __builtin_stwio (volatile void *, int)
10860 void __builtin_sync (void)
10861 int __builtin_rdctl (int) 
10862 void __builtin_wrctl (int, int)
10863 @end example
10865 The following built-in functions are always available.  They
10866 all generate a Nios II Custom Instruction. The name of the
10867 function represents the types that the function takes and
10868 returns. The letter before the @code{n} is the return type
10869 or void if absent. The @code{n} represents the first parameter
10870 to all the custom instructions, the custom instruction number.
10871 The two letters after the @code{n} represent the up to two
10872 parameters to the function.
10874 The letters represent the following data types:
10875 @table @code
10876 @item <no letter>
10877 @code{void} for return type and no parameter for parameter types.
10879 @item i
10880 @code{int} for return type and parameter type
10882 @item f
10883 @code{float} for return type and parameter type
10885 @item p
10886 @code{void *} for return type and parameter type
10888 @end table
10890 And the function names are:
10891 @example
10892 void __builtin_custom_n (void)
10893 void __builtin_custom_ni (int)
10894 void __builtin_custom_nf (float)
10895 void __builtin_custom_np (void *)
10896 void __builtin_custom_nii (int, int)
10897 void __builtin_custom_nif (int, float)
10898 void __builtin_custom_nip (int, void *)
10899 void __builtin_custom_nfi (float, int)
10900 void __builtin_custom_nff (float, float)
10901 void __builtin_custom_nfp (float, void *)
10902 void __builtin_custom_npi (void *, int)
10903 void __builtin_custom_npf (void *, float)
10904 void __builtin_custom_npp (void *, void *)
10905 int __builtin_custom_in (void)
10906 int __builtin_custom_ini (int)
10907 int __builtin_custom_inf (float)
10908 int __builtin_custom_inp (void *)
10909 int __builtin_custom_inii (int, int)
10910 int __builtin_custom_inif (int, float)
10911 int __builtin_custom_inip (int, void *)
10912 int __builtin_custom_infi (float, int)
10913 int __builtin_custom_inff (float, float)
10914 int __builtin_custom_infp (float, void *)
10915 int __builtin_custom_inpi (void *, int)
10916 int __builtin_custom_inpf (void *, float)
10917 int __builtin_custom_inpp (void *, void *)
10918 float __builtin_custom_fn (void)
10919 float __builtin_custom_fni (int)
10920 float __builtin_custom_fnf (float)
10921 float __builtin_custom_fnp (void *)
10922 float __builtin_custom_fnii (int, int)
10923 float __builtin_custom_fnif (int, float)
10924 float __builtin_custom_fnip (int, void *)
10925 float __builtin_custom_fnfi (float, int)
10926 float __builtin_custom_fnff (float, float)
10927 float __builtin_custom_fnfp (float, void *)
10928 float __builtin_custom_fnpi (void *, int)
10929 float __builtin_custom_fnpf (void *, float)
10930 float __builtin_custom_fnpp (void *, void *)
10931 void * __builtin_custom_pn (void)
10932 void * __builtin_custom_pni (int)
10933 void * __builtin_custom_pnf (float)
10934 void * __builtin_custom_pnp (void *)
10935 void * __builtin_custom_pnii (int, int)
10936 void * __builtin_custom_pnif (int, float)
10937 void * __builtin_custom_pnip (int, void *)
10938 void * __builtin_custom_pnfi (float, int)
10939 void * __builtin_custom_pnff (float, float)
10940 void * __builtin_custom_pnfp (float, void *)
10941 void * __builtin_custom_pnpi (void *, int)
10942 void * __builtin_custom_pnpf (void *, float)
10943 void * __builtin_custom_pnpp (void *, void *)
10944 @end example
10946 @node ARC Built-in Functions
10947 @subsection ARC Built-in Functions
10949 The following built-in functions are provided for ARC targets.  The
10950 built-ins generate the corresponding assembly instructions.  In the
10951 examples given below, the generated code often requires an operand or
10952 result to be in a register.  Where necessary further code will be
10953 generated to ensure this is true, but for brevity this is not
10954 described in each case.
10956 @emph{Note:} Using a built-in to generate an instruction not supported
10957 by a target may cause problems. At present the compiler is not
10958 guaranteed to detect such misuse, and as a result an internal compiler
10959 error may be generated.
10961 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10962 Return 1 if @var{val} is known to have the byte alignment given
10963 by @var{alignval}, otherwise return 0.
10964 Note that this is different from
10965 @smallexample
10966 __alignof__(*(char *)@var{val}) >= alignval
10967 @end smallexample
10968 because __alignof__ sees only the type of the dereference, whereas
10969 __builtin_arc_align uses alignment information from the pointer
10970 as well as from the pointed-to type.
10971 The information available will depend on optimization level.
10972 @end deftypefn
10974 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10975 Generates
10976 @example
10978 @end example
10979 @end deftypefn
10981 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10982 The operand is the number of a register to be read.  Generates:
10983 @example
10984 mov  @var{dest}, r@var{regno}
10985 @end example
10986 where the value in @var{dest} will be the result returned from the
10987 built-in.
10988 @end deftypefn
10990 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10991 The first operand is the number of a register to be written, the
10992 second operand is a compile time constant to write into that
10993 register.  Generates:
10994 @example
10995 mov  r@var{regno}, @var{val}
10996 @end example
10997 @end deftypefn
10999 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11000 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11001 Generates:
11002 @example
11003 divaw  @var{dest}, @var{a}, @var{b}
11004 @end example
11005 where the value in @var{dest} will be the result returned from the
11006 built-in.
11007 @end deftypefn
11009 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11010 Generates
11011 @example
11012 flag  @var{a}
11013 @end example
11014 @end deftypefn
11016 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11017 The operand, @var{auxv}, is the address of an auxiliary register and
11018 must be a compile time constant.  Generates:
11019 @example
11020 lr  @var{dest}, [@var{auxr}]
11021 @end example
11022 Where the value in @var{dest} will be the result returned from the
11023 built-in.
11024 @end deftypefn
11026 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11027 Only available with @option{-mmul64}.  Generates:
11028 @example
11029 mul64  @var{a}, @var{b}
11030 @end example
11031 @end deftypefn
11033 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11034 Only available with @option{-mmul64}.  Generates:
11035 @example
11036 mulu64  @var{a}, @var{b}
11037 @end example
11038 @end deftypefn
11040 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11041 Generates:
11042 @example
11044 @end example
11045 @end deftypefn
11047 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11048 Only valid if the @samp{norm} instruction is available through the
11049 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11050 Generates:
11051 @example
11052 norm  @var{dest}, @var{src}
11053 @end example
11054 Where the value in @var{dest} will be the result returned from the
11055 built-in.
11056 @end deftypefn
11058 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
11059 Only valid if the @samp{normw} instruction is available through the
11060 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11061 Generates:
11062 @example
11063 normw  @var{dest}, @var{src}
11064 @end example
11065 Where the value in @var{dest} will be the result returned from the
11066 built-in.
11067 @end deftypefn
11069 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
11070 Generates:
11071 @example
11072 rtie
11073 @end example
11074 @end deftypefn
11076 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
11077 Generates:
11078 @example
11079 sleep  @var{a}
11080 @end example
11081 @end deftypefn
11083 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11084 The first argument, @var{auxv}, is the address of an auxiliary
11085 register, the second argument, @var{val}, is a compile time constant
11086 to be written to the register.  Generates:
11087 @example
11088 sr  @var{auxr}, [@var{val}]
11089 @end example
11090 @end deftypefn
11092 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
11093 Only valid with @option{-mswap}.  Generates:
11094 @example
11095 swap  @var{dest}, @var{src}
11096 @end example
11097 Where the value in @var{dest} will be the result returned from the
11098 built-in.
11099 @end deftypefn
11101 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
11102 Generates:
11103 @example
11105 @end example
11106 @end deftypefn
11108 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
11109 Only available with @option{-mcpu=ARC700}.  Generates:
11110 @example
11111 sync
11112 @end example
11113 @end deftypefn
11115 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
11116 Only available with @option{-mcpu=ARC700}.  Generates:
11117 @example
11118 trap_s  @var{c}
11119 @end example
11120 @end deftypefn
11122 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
11123 Only available with @option{-mcpu=ARC700}.  Generates:
11124 @example
11125 unimp_s
11126 @end example
11127 @end deftypefn
11129 The instructions generated by the following builtins are not
11130 considered as candidates for scheduling.  They are not moved around by
11131 the compiler during scheduling, and thus can be expected to appear
11132 where they are put in the C code:
11133 @example
11134 __builtin_arc_brk()
11135 __builtin_arc_core_read()
11136 __builtin_arc_core_write()
11137 __builtin_arc_flag()
11138 __builtin_arc_lr()
11139 __builtin_arc_sleep()
11140 __builtin_arc_sr()
11141 __builtin_arc_swi()
11142 @end example
11144 @node ARC SIMD Built-in Functions
11145 @subsection ARC SIMD Built-in Functions
11147 SIMD builtins provided by the compiler can be used to generate the
11148 vector instructions.  This section describes the available builtins
11149 and their usage in programs.  With the @option{-msimd} option, the
11150 compiler provides 128-bit vector types, which can be specified using
11151 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
11152 can be included to use the following predefined types:
11153 @example
11154 typedef int __v4si   __attribute__((vector_size(16)));
11155 typedef short __v8hi __attribute__((vector_size(16)));
11156 @end example
11158 These types can be used to define 128-bit variables.  The built-in
11159 functions listed in the following section can be used on these
11160 variables to generate the vector operations.
11162 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11163 @file{arc-simd.h} also provides equivalent macros called
11164 @code{_@var{someinsn}} that can be used for programming ease and
11165 improved readability.  The following macros for DMA control are also
11166 provided:
11167 @example
11168 #define _setup_dma_in_channel_reg _vdiwr
11169 #define _setup_dma_out_channel_reg _vdowr
11170 @end example
11172 The following is a complete list of all the SIMD built-ins provided
11173 for ARC, grouped by calling signature.
11175 The following take two @code{__v8hi} arguments and return a
11176 @code{__v8hi} result:
11177 @example
11178 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11179 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11180 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11181 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11182 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11183 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11184 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11185 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11186 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11187 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11188 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11189 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11190 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11191 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11192 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11193 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11194 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11195 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11196 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11197 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11198 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11199 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11200 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11201 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11202 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11203 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11204 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11205 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11206 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11207 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11208 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11209 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11210 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11211 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11212 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11213 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11214 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11215 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11216 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11217 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11218 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11219 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11220 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11221 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11222 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11223 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11224 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11225 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11226 @end example
11228 The following take one @code{__v8hi} and one @code{int} argument and return a
11229 @code{__v8hi} result:
11231 @example
11232 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11233 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11234 __v8hi __builtin_arc_vbminw (__v8hi, int)
11235 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11236 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11237 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11238 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11239 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11240 @end example
11242 The following take one @code{__v8hi} argument and one @code{int} argument which
11243 must be a 3-bit compile time constant indicating a register number
11244 I0-I7.  They return a @code{__v8hi} result.
11245 @example
11246 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11247 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11248 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11249 @end example
11251 The following take one @code{__v8hi} argument and one @code{int}
11252 argument which must be a 6-bit compile time constant.  They return a
11253 @code{__v8hi} result.
11254 @example
11255 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11256 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11257 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11258 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11259 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11260 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11261 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11262 @end example
11264 The following take one @code{__v8hi} argument and one @code{int} argument which
11265 must be a 8-bit compile time constant.  They return a @code{__v8hi}
11266 result.
11267 @example
11268 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11269 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11270 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11271 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11272 @end example
11274 The following take two @code{int} arguments, the second of which which
11275 must be a 8-bit compile time constant.  They return a @code{__v8hi}
11276 result:
11277 @example
11278 __v8hi __builtin_arc_vmovaw (int, const int)
11279 __v8hi __builtin_arc_vmovw (int, const int)
11280 __v8hi __builtin_arc_vmovzw (int, const int)
11281 @end example
11283 The following take a single @code{__v8hi} argument and return a
11284 @code{__v8hi} result:
11285 @example
11286 __v8hi __builtin_arc_vabsaw (__v8hi)
11287 __v8hi __builtin_arc_vabsw (__v8hi)
11288 __v8hi __builtin_arc_vaddsuw (__v8hi)
11289 __v8hi __builtin_arc_vexch1 (__v8hi)
11290 __v8hi __builtin_arc_vexch2 (__v8hi)
11291 __v8hi __builtin_arc_vexch4 (__v8hi)
11292 __v8hi __builtin_arc_vsignw (__v8hi)
11293 __v8hi __builtin_arc_vupbaw (__v8hi)
11294 __v8hi __builtin_arc_vupbw (__v8hi)
11295 __v8hi __builtin_arc_vupsbaw (__v8hi)
11296 __v8hi __builtin_arc_vupsbw (__v8hi)
11297 @end example
11299 The following take two @code{int} arguments and return no result:
11300 @example
11301 void __builtin_arc_vdirun (int, int)
11302 void __builtin_arc_vdorun (int, int)
11303 @end example
11305 The following take two @code{int} arguments and return no result.  The
11306 first argument must a 3-bit compile time constant indicating one of
11307 the DR0-DR7 DMA setup channels:
11308 @example
11309 void __builtin_arc_vdiwr (const int, int)
11310 void __builtin_arc_vdowr (const int, int)
11311 @end example
11313 The following take an @code{int} argument and return no result:
11314 @example
11315 void __builtin_arc_vendrec (int)
11316 void __builtin_arc_vrec (int)
11317 void __builtin_arc_vrecrun (int)
11318 void __builtin_arc_vrun (int)
11319 @end example
11321 The following take a @code{__v8hi} argument and two @code{int}
11322 arguments and return a @code{__v8hi} result.  The second argument must
11323 be a 3-bit compile time constants, indicating one the registers I0-I7,
11324 and the third argument must be an 8-bit compile time constant.
11326 @emph{Note:} Although the equivalent hardware instructions do not take
11327 an SIMD register as an operand, these builtins overwrite the relevant
11328 bits of the @code{__v8hi} register provided as the first argument with
11329 the value loaded from the @code{[Ib, u8]} location in the SDM.
11331 @example
11332 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
11333 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
11334 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
11335 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
11336 @end example
11338 The following take two @code{int} arguments and return a @code{__v8hi}
11339 result.  The first argument must be a 3-bit compile time constants,
11340 indicating one the registers I0-I7, and the second argument must be an
11341 8-bit compile time constant.
11343 @example
11344 __v8hi __builtin_arc_vld128 (const int, const int)
11345 __v8hi __builtin_arc_vld64w (const int, const int)
11346 @end example
11348 The following take a @code{__v8hi} argument and two @code{int}
11349 arguments and return no result.  The second argument must be a 3-bit
11350 compile time constants, indicating one the registers I0-I7, and the
11351 third argument must be an 8-bit compile time constant.
11353 @example
11354 void __builtin_arc_vst128 (__v8hi, const int, const int)
11355 void __builtin_arc_vst64 (__v8hi, const int, const int)
11356 @end example
11358 The following take a @code{__v8hi} argument and three @code{int}
11359 arguments and return no result.  The second argument must be a 3-bit
11360 compile-time constant, identifying the 16-bit sub-register to be
11361 stored, the third argument must be a 3-bit compile time constants,
11362 indicating one the registers I0-I7, and the fourth argument must be an
11363 8-bit compile time constant.
11365 @example
11366 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
11367 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
11368 @end example
11370 @node ARM iWMMXt Built-in Functions
11371 @subsection ARM iWMMXt Built-in Functions
11373 These built-in functions are available for the ARM family of
11374 processors when the @option{-mcpu=iwmmxt} switch is used:
11376 @smallexample
11377 typedef int v2si __attribute__ ((vector_size (8)));
11378 typedef short v4hi __attribute__ ((vector_size (8)));
11379 typedef char v8qi __attribute__ ((vector_size (8)));
11381 int __builtin_arm_getwcgr0 (void)
11382 void __builtin_arm_setwcgr0 (int)
11383 int __builtin_arm_getwcgr1 (void)
11384 void __builtin_arm_setwcgr1 (int)
11385 int __builtin_arm_getwcgr2 (void)
11386 void __builtin_arm_setwcgr2 (int)
11387 int __builtin_arm_getwcgr3 (void)
11388 void __builtin_arm_setwcgr3 (int)
11389 int __builtin_arm_textrmsb (v8qi, int)
11390 int __builtin_arm_textrmsh (v4hi, int)
11391 int __builtin_arm_textrmsw (v2si, int)
11392 int __builtin_arm_textrmub (v8qi, int)
11393 int __builtin_arm_textrmuh (v4hi, int)
11394 int __builtin_arm_textrmuw (v2si, int)
11395 v8qi __builtin_arm_tinsrb (v8qi, int, int)
11396 v4hi __builtin_arm_tinsrh (v4hi, int, int)
11397 v2si __builtin_arm_tinsrw (v2si, int, int)
11398 long long __builtin_arm_tmia (long long, int, int)
11399 long long __builtin_arm_tmiabb (long long, int, int)
11400 long long __builtin_arm_tmiabt (long long, int, int)
11401 long long __builtin_arm_tmiaph (long long, int, int)
11402 long long __builtin_arm_tmiatb (long long, int, int)
11403 long long __builtin_arm_tmiatt (long long, int, int)
11404 int __builtin_arm_tmovmskb (v8qi)
11405 int __builtin_arm_tmovmskh (v4hi)
11406 int __builtin_arm_tmovmskw (v2si)
11407 long long __builtin_arm_waccb (v8qi)
11408 long long __builtin_arm_wacch (v4hi)
11409 long long __builtin_arm_waccw (v2si)
11410 v8qi __builtin_arm_waddb (v8qi, v8qi)
11411 v8qi __builtin_arm_waddbss (v8qi, v8qi)
11412 v8qi __builtin_arm_waddbus (v8qi, v8qi)
11413 v4hi __builtin_arm_waddh (v4hi, v4hi)
11414 v4hi __builtin_arm_waddhss (v4hi, v4hi)
11415 v4hi __builtin_arm_waddhus (v4hi, v4hi)
11416 v2si __builtin_arm_waddw (v2si, v2si)
11417 v2si __builtin_arm_waddwss (v2si, v2si)
11418 v2si __builtin_arm_waddwus (v2si, v2si)
11419 v8qi __builtin_arm_walign (v8qi, v8qi, int)
11420 long long __builtin_arm_wand(long long, long long)
11421 long long __builtin_arm_wandn (long long, long long)
11422 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
11423 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
11424 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
11425 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
11426 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
11427 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
11428 v2si __builtin_arm_wcmpeqw (v2si, v2si)
11429 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
11430 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
11431 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
11432 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
11433 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
11434 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
11435 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
11436 long long __builtin_arm_wmacsz (v4hi, v4hi)
11437 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
11438 long long __builtin_arm_wmacuz (v4hi, v4hi)
11439 v4hi __builtin_arm_wmadds (v4hi, v4hi)
11440 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
11441 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
11442 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
11443 v2si __builtin_arm_wmaxsw (v2si, v2si)
11444 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
11445 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
11446 v2si __builtin_arm_wmaxuw (v2si, v2si)
11447 v8qi __builtin_arm_wminsb (v8qi, v8qi)
11448 v4hi __builtin_arm_wminsh (v4hi, v4hi)
11449 v2si __builtin_arm_wminsw (v2si, v2si)
11450 v8qi __builtin_arm_wminub (v8qi, v8qi)
11451 v4hi __builtin_arm_wminuh (v4hi, v4hi)
11452 v2si __builtin_arm_wminuw (v2si, v2si)
11453 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
11454 v4hi __builtin_arm_wmulul (v4hi, v4hi)
11455 v4hi __builtin_arm_wmulum (v4hi, v4hi)
11456 long long __builtin_arm_wor (long long, long long)
11457 v2si __builtin_arm_wpackdss (long long, long long)
11458 v2si __builtin_arm_wpackdus (long long, long long)
11459 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
11460 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
11461 v4hi __builtin_arm_wpackwss (v2si, v2si)
11462 v4hi __builtin_arm_wpackwus (v2si, v2si)
11463 long long __builtin_arm_wrord (long long, long long)
11464 long long __builtin_arm_wrordi (long long, int)
11465 v4hi __builtin_arm_wrorh (v4hi, long long)
11466 v4hi __builtin_arm_wrorhi (v4hi, int)
11467 v2si __builtin_arm_wrorw (v2si, long long)
11468 v2si __builtin_arm_wrorwi (v2si, int)
11469 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
11470 v2si __builtin_arm_wsadbz (v8qi, v8qi)
11471 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
11472 v2si __builtin_arm_wsadhz (v4hi, v4hi)
11473 v4hi __builtin_arm_wshufh (v4hi, int)
11474 long long __builtin_arm_wslld (long long, long long)
11475 long long __builtin_arm_wslldi (long long, int)
11476 v4hi __builtin_arm_wsllh (v4hi, long long)
11477 v4hi __builtin_arm_wsllhi (v4hi, int)
11478 v2si __builtin_arm_wsllw (v2si, long long)
11479 v2si __builtin_arm_wsllwi (v2si, int)
11480 long long __builtin_arm_wsrad (long long, long long)
11481 long long __builtin_arm_wsradi (long long, int)
11482 v4hi __builtin_arm_wsrah (v4hi, long long)
11483 v4hi __builtin_arm_wsrahi (v4hi, int)
11484 v2si __builtin_arm_wsraw (v2si, long long)
11485 v2si __builtin_arm_wsrawi (v2si, int)
11486 long long __builtin_arm_wsrld (long long, long long)
11487 long long __builtin_arm_wsrldi (long long, int)
11488 v4hi __builtin_arm_wsrlh (v4hi, long long)
11489 v4hi __builtin_arm_wsrlhi (v4hi, int)
11490 v2si __builtin_arm_wsrlw (v2si, long long)
11491 v2si __builtin_arm_wsrlwi (v2si, int)
11492 v8qi __builtin_arm_wsubb (v8qi, v8qi)
11493 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
11494 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
11495 v4hi __builtin_arm_wsubh (v4hi, v4hi)
11496 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
11497 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
11498 v2si __builtin_arm_wsubw (v2si, v2si)
11499 v2si __builtin_arm_wsubwss (v2si, v2si)
11500 v2si __builtin_arm_wsubwus (v2si, v2si)
11501 v4hi __builtin_arm_wunpckehsb (v8qi)
11502 v2si __builtin_arm_wunpckehsh (v4hi)
11503 long long __builtin_arm_wunpckehsw (v2si)
11504 v4hi __builtin_arm_wunpckehub (v8qi)
11505 v2si __builtin_arm_wunpckehuh (v4hi)
11506 long long __builtin_arm_wunpckehuw (v2si)
11507 v4hi __builtin_arm_wunpckelsb (v8qi)
11508 v2si __builtin_arm_wunpckelsh (v4hi)
11509 long long __builtin_arm_wunpckelsw (v2si)
11510 v4hi __builtin_arm_wunpckelub (v8qi)
11511 v2si __builtin_arm_wunpckeluh (v4hi)
11512 long long __builtin_arm_wunpckeluw (v2si)
11513 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
11514 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
11515 v2si __builtin_arm_wunpckihw (v2si, v2si)
11516 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
11517 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
11518 v2si __builtin_arm_wunpckilw (v2si, v2si)
11519 long long __builtin_arm_wxor (long long, long long)
11520 long long __builtin_arm_wzero ()
11521 @end smallexample
11524 @node ARM C Language Extensions (ACLE)
11525 @subsection ARM C Language Extensions (ACLE)
11527 GCC implements extensions for C as described in the ARM C Language
11528 Extensions (ACLE) specification, which can be found at
11529 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
11531 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
11532 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
11533 intrinsics can be found at
11534 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
11535 The built-in intrinsics for the Advanced SIMD extension are available when
11536 NEON is enabled.
11538 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
11539 back ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM back end's
11540 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
11541 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
11542 intrinsics yet.
11544 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
11545 availability of extensions.
11547 @node ARM Floating Point Status and Control Intrinsics
11548 @subsection ARM Floating Point Status and Control Intrinsics
11550 These built-in functions are available for the ARM family of
11551 processors with floating-point unit.
11553 @smallexample
11554 unsigned int __builtin_arm_get_fpscr ()
11555 void __builtin_arm_set_fpscr (unsigned int)
11556 @end smallexample
11558 @node AVR Built-in Functions
11559 @subsection AVR Built-in Functions
11561 For each built-in function for AVR, there is an equally named,
11562 uppercase built-in macro defined. That way users can easily query if
11563 or if not a specific built-in is implemented or not. For example, if
11564 @code{__builtin_avr_nop} is available the macro
11565 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
11567 The following built-in functions map to the respective machine
11568 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
11569 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
11570 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
11571 as library call if no hardware multiplier is available.
11573 @smallexample
11574 void __builtin_avr_nop (void)
11575 void __builtin_avr_sei (void)
11576 void __builtin_avr_cli (void)
11577 void __builtin_avr_sleep (void)
11578 void __builtin_avr_wdr (void)
11579 unsigned char __builtin_avr_swap (unsigned char)
11580 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
11581 int __builtin_avr_fmuls (char, char)
11582 int __builtin_avr_fmulsu (char, unsigned char)
11583 @end smallexample
11585 In order to delay execution for a specific number of cycles, GCC
11586 implements
11587 @smallexample
11588 void __builtin_avr_delay_cycles (unsigned long ticks)
11589 @end smallexample
11591 @noindent
11592 @code{ticks} is the number of ticks to delay execution. Note that this
11593 built-in does not take into account the effect of interrupts that
11594 might increase delay time. @code{ticks} must be a compile-time
11595 integer constant; delays with a variable number of cycles are not supported.
11597 @smallexample
11598 char __builtin_avr_flash_segment (const __memx void*)
11599 @end smallexample
11601 @noindent
11602 This built-in takes a byte address to the 24-bit
11603 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
11604 the number of the flash segment (the 64 KiB chunk) where the address
11605 points to.  Counting starts at @code{0}.
11606 If the address does not point to flash memory, return @code{-1}.
11608 @smallexample
11609 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
11610 @end smallexample
11612 @noindent
11613 Insert bits from @var{bits} into @var{val} and return the resulting
11614 value. The nibbles of @var{map} determine how the insertion is
11615 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
11616 @enumerate
11617 @item If @var{X} is @code{0xf},
11618 then the @var{n}-th bit of @var{val} is returned unaltered.
11620 @item If X is in the range 0@dots{}7,
11621 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
11623 @item If X is in the range 8@dots{}@code{0xe},
11624 then the @var{n}-th result bit is undefined.
11625 @end enumerate
11627 @noindent
11628 One typical use case for this built-in is adjusting input and
11629 output values to non-contiguous port layouts. Some examples:
11631 @smallexample
11632 // same as val, bits is unused
11633 __builtin_avr_insert_bits (0xffffffff, bits, val)
11634 @end smallexample
11636 @smallexample
11637 // same as bits, val is unused
11638 __builtin_avr_insert_bits (0x76543210, bits, val)
11639 @end smallexample
11641 @smallexample
11642 // same as rotating bits by 4
11643 __builtin_avr_insert_bits (0x32107654, bits, 0)
11644 @end smallexample
11646 @smallexample
11647 // high nibble of result is the high nibble of val
11648 // low nibble of result is the low nibble of bits
11649 __builtin_avr_insert_bits (0xffff3210, bits, val)
11650 @end smallexample
11652 @smallexample
11653 // reverse the bit order of bits
11654 __builtin_avr_insert_bits (0x01234567, bits, 0)
11655 @end smallexample
11657 @node Blackfin Built-in Functions
11658 @subsection Blackfin Built-in Functions
11660 Currently, there are two Blackfin-specific built-in functions.  These are
11661 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
11662 using inline assembly; by using these built-in functions the compiler can
11663 automatically add workarounds for hardware errata involving these
11664 instructions.  These functions are named as follows:
11666 @smallexample
11667 void __builtin_bfin_csync (void)
11668 void __builtin_bfin_ssync (void)
11669 @end smallexample
11671 @node FR-V Built-in Functions
11672 @subsection FR-V Built-in Functions
11674 GCC provides many FR-V-specific built-in functions.  In general,
11675 these functions are intended to be compatible with those described
11676 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11677 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
11678 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11679 pointer rather than by value.
11681 Most of the functions are named after specific FR-V instructions.
11682 Such functions are said to be ``directly mapped'' and are summarized
11683 here in tabular form.
11685 @menu
11686 * Argument Types::
11687 * Directly-mapped Integer Functions::
11688 * Directly-mapped Media Functions::
11689 * Raw read/write Functions::
11690 * Other Built-in Functions::
11691 @end menu
11693 @node Argument Types
11694 @subsubsection Argument Types
11696 The arguments to the built-in functions can be divided into three groups:
11697 register numbers, compile-time constants and run-time values.  In order
11698 to make this classification clear at a glance, the arguments and return
11699 values are given the following pseudo types:
11701 @multitable @columnfractions .20 .30 .15 .35
11702 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11703 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11704 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11705 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11706 @item @code{uw2} @tab @code{unsigned long long} @tab No
11707 @tab an unsigned doubleword
11708 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11709 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11710 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11711 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11712 @end multitable
11714 These pseudo types are not defined by GCC, they are simply a notational
11715 convenience used in this manual.
11717 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11718 and @code{sw2} are evaluated at run time.  They correspond to
11719 register operands in the underlying FR-V instructions.
11721 @code{const} arguments represent immediate operands in the underlying
11722 FR-V instructions.  They must be compile-time constants.
11724 @code{acc} arguments are evaluated at compile time and specify the number
11725 of an accumulator register.  For example, an @code{acc} argument of 2
11726 selects the ACC2 register.
11728 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11729 number of an IACC register.  See @pxref{Other Built-in Functions}
11730 for more details.
11732 @node Directly-mapped Integer Functions
11733 @subsubsection Directly-Mapped Integer Functions
11735 The functions listed below map directly to FR-V I-type instructions.
11737 @multitable @columnfractions .45 .32 .23
11738 @item Function prototype @tab Example usage @tab Assembly output
11739 @item @code{sw1 __ADDSS (sw1, sw1)}
11740 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11741 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11742 @item @code{sw1 __SCAN (sw1, sw1)}
11743 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11744 @tab @code{SCAN @var{a},@var{b},@var{c}}
11745 @item @code{sw1 __SCUTSS (sw1)}
11746 @tab @code{@var{b} = __SCUTSS (@var{a})}
11747 @tab @code{SCUTSS @var{a},@var{b}}
11748 @item @code{sw1 __SLASS (sw1, sw1)}
11749 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11750 @tab @code{SLASS @var{a},@var{b},@var{c}}
11751 @item @code{void __SMASS (sw1, sw1)}
11752 @tab @code{__SMASS (@var{a}, @var{b})}
11753 @tab @code{SMASS @var{a},@var{b}}
11754 @item @code{void __SMSSS (sw1, sw1)}
11755 @tab @code{__SMSSS (@var{a}, @var{b})}
11756 @tab @code{SMSSS @var{a},@var{b}}
11757 @item @code{void __SMU (sw1, sw1)}
11758 @tab @code{__SMU (@var{a}, @var{b})}
11759 @tab @code{SMU @var{a},@var{b}}
11760 @item @code{sw2 __SMUL (sw1, sw1)}
11761 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11762 @tab @code{SMUL @var{a},@var{b},@var{c}}
11763 @item @code{sw1 __SUBSS (sw1, sw1)}
11764 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11765 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11766 @item @code{uw2 __UMUL (uw1, uw1)}
11767 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11768 @tab @code{UMUL @var{a},@var{b},@var{c}}
11769 @end multitable
11771 @node Directly-mapped Media Functions
11772 @subsubsection Directly-Mapped Media Functions
11774 The functions listed below map directly to FR-V M-type instructions.
11776 @multitable @columnfractions .45 .32 .23
11777 @item Function prototype @tab Example usage @tab Assembly output
11778 @item @code{uw1 __MABSHS (sw1)}
11779 @tab @code{@var{b} = __MABSHS (@var{a})}
11780 @tab @code{MABSHS @var{a},@var{b}}
11781 @item @code{void __MADDACCS (acc, acc)}
11782 @tab @code{__MADDACCS (@var{b}, @var{a})}
11783 @tab @code{MADDACCS @var{a},@var{b}}
11784 @item @code{sw1 __MADDHSS (sw1, sw1)}
11785 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11786 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11787 @item @code{uw1 __MADDHUS (uw1, uw1)}
11788 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11789 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11790 @item @code{uw1 __MAND (uw1, uw1)}
11791 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11792 @tab @code{MAND @var{a},@var{b},@var{c}}
11793 @item @code{void __MASACCS (acc, acc)}
11794 @tab @code{__MASACCS (@var{b}, @var{a})}
11795 @tab @code{MASACCS @var{a},@var{b}}
11796 @item @code{uw1 __MAVEH (uw1, uw1)}
11797 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11798 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11799 @item @code{uw2 __MBTOH (uw1)}
11800 @tab @code{@var{b} = __MBTOH (@var{a})}
11801 @tab @code{MBTOH @var{a},@var{b}}
11802 @item @code{void __MBTOHE (uw1 *, uw1)}
11803 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11804 @tab @code{MBTOHE @var{a},@var{b}}
11805 @item @code{void __MCLRACC (acc)}
11806 @tab @code{__MCLRACC (@var{a})}
11807 @tab @code{MCLRACC @var{a}}
11808 @item @code{void __MCLRACCA (void)}
11809 @tab @code{__MCLRACCA ()}
11810 @tab @code{MCLRACCA}
11811 @item @code{uw1 __Mcop1 (uw1, uw1)}
11812 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11813 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11814 @item @code{uw1 __Mcop2 (uw1, uw1)}
11815 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11816 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11817 @item @code{uw1 __MCPLHI (uw2, const)}
11818 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11819 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11820 @item @code{uw1 __MCPLI (uw2, const)}
11821 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11822 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11823 @item @code{void __MCPXIS (acc, sw1, sw1)}
11824 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11825 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11826 @item @code{void __MCPXIU (acc, uw1, uw1)}
11827 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11828 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11829 @item @code{void __MCPXRS (acc, sw1, sw1)}
11830 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11831 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11832 @item @code{void __MCPXRU (acc, uw1, uw1)}
11833 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11834 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11835 @item @code{uw1 __MCUT (acc, uw1)}
11836 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11837 @tab @code{MCUT @var{a},@var{b},@var{c}}
11838 @item @code{uw1 __MCUTSS (acc, sw1)}
11839 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11840 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11841 @item @code{void __MDADDACCS (acc, acc)}
11842 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11843 @tab @code{MDADDACCS @var{a},@var{b}}
11844 @item @code{void __MDASACCS (acc, acc)}
11845 @tab @code{__MDASACCS (@var{b}, @var{a})}
11846 @tab @code{MDASACCS @var{a},@var{b}}
11847 @item @code{uw2 __MDCUTSSI (acc, const)}
11848 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11849 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11850 @item @code{uw2 __MDPACKH (uw2, uw2)}
11851 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11852 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11853 @item @code{uw2 __MDROTLI (uw2, const)}
11854 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11855 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11856 @item @code{void __MDSUBACCS (acc, acc)}
11857 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11858 @tab @code{MDSUBACCS @var{a},@var{b}}
11859 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11860 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11861 @tab @code{MDUNPACKH @var{a},@var{b}}
11862 @item @code{uw2 __MEXPDHD (uw1, const)}
11863 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11864 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11865 @item @code{uw1 __MEXPDHW (uw1, const)}
11866 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11867 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11868 @item @code{uw1 __MHDSETH (uw1, const)}
11869 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11870 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11871 @item @code{sw1 __MHDSETS (const)}
11872 @tab @code{@var{b} = __MHDSETS (@var{a})}
11873 @tab @code{MHDSETS #@var{a},@var{b}}
11874 @item @code{uw1 __MHSETHIH (uw1, const)}
11875 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11876 @tab @code{MHSETHIH #@var{a},@var{b}}
11877 @item @code{sw1 __MHSETHIS (sw1, const)}
11878 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11879 @tab @code{MHSETHIS #@var{a},@var{b}}
11880 @item @code{uw1 __MHSETLOH (uw1, const)}
11881 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11882 @tab @code{MHSETLOH #@var{a},@var{b}}
11883 @item @code{sw1 __MHSETLOS (sw1, const)}
11884 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11885 @tab @code{MHSETLOS #@var{a},@var{b}}
11886 @item @code{uw1 __MHTOB (uw2)}
11887 @tab @code{@var{b} = __MHTOB (@var{a})}
11888 @tab @code{MHTOB @var{a},@var{b}}
11889 @item @code{void __MMACHS (acc, sw1, sw1)}
11890 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11891 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11892 @item @code{void __MMACHU (acc, uw1, uw1)}
11893 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11894 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11895 @item @code{void __MMRDHS (acc, sw1, sw1)}
11896 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11897 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11898 @item @code{void __MMRDHU (acc, uw1, uw1)}
11899 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11900 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11901 @item @code{void __MMULHS (acc, sw1, sw1)}
11902 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11903 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11904 @item @code{void __MMULHU (acc, uw1, uw1)}
11905 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11906 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11907 @item @code{void __MMULXHS (acc, sw1, sw1)}
11908 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11909 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11910 @item @code{void __MMULXHU (acc, uw1, uw1)}
11911 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11912 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11913 @item @code{uw1 __MNOT (uw1)}
11914 @tab @code{@var{b} = __MNOT (@var{a})}
11915 @tab @code{MNOT @var{a},@var{b}}
11916 @item @code{uw1 __MOR (uw1, uw1)}
11917 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11918 @tab @code{MOR @var{a},@var{b},@var{c}}
11919 @item @code{uw1 __MPACKH (uh, uh)}
11920 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11921 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11922 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11923 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11924 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11925 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11926 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11927 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11928 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11929 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11930 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11931 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11932 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11933 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11934 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11935 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11936 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11937 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11938 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11939 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11940 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11941 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11942 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11943 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11944 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11945 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11946 @item @code{void __MQMACHS (acc, sw2, sw2)}
11947 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11948 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11949 @item @code{void __MQMACHU (acc, uw2, uw2)}
11950 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11951 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11952 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11953 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11954 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11955 @item @code{void __MQMULHS (acc, sw2, sw2)}
11956 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11957 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11958 @item @code{void __MQMULHU (acc, uw2, uw2)}
11959 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11960 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11961 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11962 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11963 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11964 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11965 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11966 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11967 @item @code{sw2 __MQSATHS (sw2, sw2)}
11968 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11969 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11970 @item @code{uw2 __MQSLLHI (uw2, int)}
11971 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11972 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11973 @item @code{sw2 __MQSRAHI (sw2, int)}
11974 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11975 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11976 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11977 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11978 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11979 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11980 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11981 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11982 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11983 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11984 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11985 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11986 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11987 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11988 @item @code{uw1 __MRDACC (acc)}
11989 @tab @code{@var{b} = __MRDACC (@var{a})}
11990 @tab @code{MRDACC @var{a},@var{b}}
11991 @item @code{uw1 __MRDACCG (acc)}
11992 @tab @code{@var{b} = __MRDACCG (@var{a})}
11993 @tab @code{MRDACCG @var{a},@var{b}}
11994 @item @code{uw1 __MROTLI (uw1, const)}
11995 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11996 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11997 @item @code{uw1 __MROTRI (uw1, const)}
11998 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11999 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12000 @item @code{sw1 __MSATHS (sw1, sw1)}
12001 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12002 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12003 @item @code{uw1 __MSATHU (uw1, uw1)}
12004 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12005 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12006 @item @code{uw1 __MSLLHI (uw1, const)}
12007 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12008 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12009 @item @code{sw1 __MSRAHI (sw1, const)}
12010 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12011 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12012 @item @code{uw1 __MSRLHI (uw1, const)}
12013 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12014 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12015 @item @code{void __MSUBACCS (acc, acc)}
12016 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12017 @tab @code{MSUBACCS @var{a},@var{b}}
12018 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12019 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12020 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12021 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12022 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12023 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12024 @item @code{void __MTRAP (void)}
12025 @tab @code{__MTRAP ()}
12026 @tab @code{MTRAP}
12027 @item @code{uw2 __MUNPACKH (uw1)}
12028 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12029 @tab @code{MUNPACKH @var{a},@var{b}}
12030 @item @code{uw1 __MWCUT (uw2, uw1)}
12031 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12032 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12033 @item @code{void __MWTACC (acc, uw1)}
12034 @tab @code{__MWTACC (@var{b}, @var{a})}
12035 @tab @code{MWTACC @var{a},@var{b}}
12036 @item @code{void __MWTACCG (acc, uw1)}
12037 @tab @code{__MWTACCG (@var{b}, @var{a})}
12038 @tab @code{MWTACCG @var{a},@var{b}}
12039 @item @code{uw1 __MXOR (uw1, uw1)}
12040 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12041 @tab @code{MXOR @var{a},@var{b},@var{c}}
12042 @end multitable
12044 @node Raw read/write Functions
12045 @subsubsection Raw Read/Write Functions
12047 This sections describes built-in functions related to read and write
12048 instructions to access memory.  These functions generate
12049 @code{membar} instructions to flush the I/O load and stores where
12050 appropriate, as described in Fujitsu's manual described above.
12052 @table @code
12054 @item unsigned char __builtin_read8 (void *@var{data})
12055 @item unsigned short __builtin_read16 (void *@var{data})
12056 @item unsigned long __builtin_read32 (void *@var{data})
12057 @item unsigned long long __builtin_read64 (void *@var{data})
12059 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12060 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12061 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12062 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12063 @end table
12065 @node Other Built-in Functions
12066 @subsubsection Other Built-in Functions
12068 This section describes built-in functions that are not named after
12069 a specific FR-V instruction.
12071 @table @code
12072 @item sw2 __IACCreadll (iacc @var{reg})
12073 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
12074 for future expansion and must be 0.
12076 @item sw1 __IACCreadl (iacc @var{reg})
12077 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12078 Other values of @var{reg} are rejected as invalid.
12080 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12081 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
12082 is reserved for future expansion and must be 0.
12084 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12085 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12086 is 1.  Other values of @var{reg} are rejected as invalid.
12088 @item void __data_prefetch0 (const void *@var{x})
12089 Use the @code{dcpl} instruction to load the contents of address @var{x}
12090 into the data cache.
12092 @item void __data_prefetch (const void *@var{x})
12093 Use the @code{nldub} instruction to load the contents of address @var{x}
12094 into the data cache.  The instruction is issued in slot I1@.
12095 @end table
12097 @node MIPS DSP Built-in Functions
12098 @subsection MIPS DSP Built-in Functions
12100 The MIPS DSP Application-Specific Extension (ASE) includes new
12101 instructions that are designed to improve the performance of DSP and
12102 media applications.  It provides instructions that operate on packed
12103 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12105 GCC supports MIPS DSP operations using both the generic
12106 vector extensions (@pxref{Vector Extensions}) and a collection of
12107 MIPS-specific built-in functions.  Both kinds of support are
12108 enabled by the @option{-mdsp} command-line option.
12110 Revision 2 of the ASE was introduced in the second half of 2006.
12111 This revision adds extra instructions to the original ASE, but is
12112 otherwise backwards-compatible with it.  You can select revision 2
12113 using the command-line option @option{-mdspr2}; this option implies
12114 @option{-mdsp}.
12116 The SCOUNT and POS bits of the DSP control register are global.  The
12117 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12118 POS bits.  During optimization, the compiler does not delete these
12119 instructions and it does not delete calls to functions containing
12120 these instructions.
12122 At present, GCC only provides support for operations on 32-bit
12123 vectors.  The vector type associated with 8-bit integer data is
12124 usually called @code{v4i8}, the vector type associated with Q7
12125 is usually called @code{v4q7}, the vector type associated with 16-bit
12126 integer data is usually called @code{v2i16}, and the vector type
12127 associated with Q15 is usually called @code{v2q15}.  They can be
12128 defined in C as follows:
12130 @smallexample
12131 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12132 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12133 typedef short v2i16 __attribute__ ((vector_size(4)));
12134 typedef short v2q15 __attribute__ ((vector_size(4)));
12135 @end smallexample
12137 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12138 initialized in the same way as aggregates.  For example:
12140 @smallexample
12141 v4i8 a = @{1, 2, 3, 4@};
12142 v4i8 b;
12143 b = (v4i8) @{5, 6, 7, 8@};
12145 v2q15 c = @{0x0fcb, 0x3a75@};
12146 v2q15 d;
12147 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12148 @end smallexample
12150 @emph{Note:} The CPU's endianness determines the order in which values
12151 are packed.  On little-endian targets, the first value is the least
12152 significant and the last value is the most significant.  The opposite
12153 order applies to big-endian targets.  For example, the code above
12154 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12155 and @code{4} on big-endian targets.
12157 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12158 representation.  As shown in this example, the integer representation
12159 of a Q7 value can be obtained by multiplying the fractional value by
12160 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
12161 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
12162 @code{0x1.0p31}.
12164 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12165 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
12166 and @code{c} and @code{d} are @code{v2q15} values.
12168 @multitable @columnfractions .50 .50
12169 @item C code @tab MIPS instruction
12170 @item @code{a + b} @tab @code{addu.qb}
12171 @item @code{c + d} @tab @code{addq.ph}
12172 @item @code{a - b} @tab @code{subu.qb}
12173 @item @code{c - d} @tab @code{subq.ph}
12174 @end multitable
12176 The table below lists the @code{v2i16} operation for which
12177 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
12178 @code{v2i16} values.
12180 @multitable @columnfractions .50 .50
12181 @item C code @tab MIPS instruction
12182 @item @code{e * f} @tab @code{mul.ph}
12183 @end multitable
12185 It is easier to describe the DSP built-in functions if we first define
12186 the following types:
12188 @smallexample
12189 typedef int q31;
12190 typedef int i32;
12191 typedef unsigned int ui32;
12192 typedef long long a64;
12193 @end smallexample
12195 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12196 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12197 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
12198 @code{long long}, but we use @code{a64} to indicate values that are
12199 placed in one of the four DSP accumulators (@code{$ac0},
12200 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12202 Also, some built-in functions prefer or require immediate numbers as
12203 parameters, because the corresponding DSP instructions accept both immediate
12204 numbers and register operands, or accept immediate numbers only.  The
12205 immediate parameters are listed as follows.
12207 @smallexample
12208 imm0_3: 0 to 3.
12209 imm0_7: 0 to 7.
12210 imm0_15: 0 to 15.
12211 imm0_31: 0 to 31.
12212 imm0_63: 0 to 63.
12213 imm0_255: 0 to 255.
12214 imm_n32_31: -32 to 31.
12215 imm_n512_511: -512 to 511.
12216 @end smallexample
12218 The following built-in functions map directly to a particular MIPS DSP
12219 instruction.  Please refer to the architecture specification
12220 for details on what each instruction does.
12222 @smallexample
12223 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12224 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12225 q31 __builtin_mips_addq_s_w (q31, q31)
12226 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12227 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12228 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12229 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12230 q31 __builtin_mips_subq_s_w (q31, q31)
12231 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12232 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12233 i32 __builtin_mips_addsc (i32, i32)
12234 i32 __builtin_mips_addwc (i32, i32)
12235 i32 __builtin_mips_modsub (i32, i32)
12236 i32 __builtin_mips_raddu_w_qb (v4i8)
12237 v2q15 __builtin_mips_absq_s_ph (v2q15)
12238 q31 __builtin_mips_absq_s_w (q31)
12239 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12240 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12241 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12242 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12243 q31 __builtin_mips_preceq_w_phl (v2q15)
12244 q31 __builtin_mips_preceq_w_phr (v2q15)
12245 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12246 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12247 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12248 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12249 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12250 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12251 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12252 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12253 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12254 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12255 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12256 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12257 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12258 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12259 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12260 q31 __builtin_mips_shll_s_w (q31, i32)
12261 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12262 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12263 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12264 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12265 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12266 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12267 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12268 q31 __builtin_mips_shra_r_w (q31, i32)
12269 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12270 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12271 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12272 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12273 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12274 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12275 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12276 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12277 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12278 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12279 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12280 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12281 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12282 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12283 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12284 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12285 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12286 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12287 i32 __builtin_mips_bitrev (i32)
12288 i32 __builtin_mips_insv (i32, i32)
12289 v4i8 __builtin_mips_repl_qb (imm0_255)
12290 v4i8 __builtin_mips_repl_qb (i32)
12291 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12292 v2q15 __builtin_mips_repl_ph (i32)
12293 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12294 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12295 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12296 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12297 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12298 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12299 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12300 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12301 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12302 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12303 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12304 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12305 i32 __builtin_mips_extr_w (a64, imm0_31)
12306 i32 __builtin_mips_extr_w (a64, i32)
12307 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12308 i32 __builtin_mips_extr_s_h (a64, i32)
12309 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12310 i32 __builtin_mips_extr_rs_w (a64, i32)
12311 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12312 i32 __builtin_mips_extr_r_w (a64, i32)
12313 i32 __builtin_mips_extp (a64, imm0_31)
12314 i32 __builtin_mips_extp (a64, i32)
12315 i32 __builtin_mips_extpdp (a64, imm0_31)
12316 i32 __builtin_mips_extpdp (a64, i32)
12317 a64 __builtin_mips_shilo (a64, imm_n32_31)
12318 a64 __builtin_mips_shilo (a64, i32)
12319 a64 __builtin_mips_mthlip (a64, i32)
12320 void __builtin_mips_wrdsp (i32, imm0_63)
12321 i32 __builtin_mips_rddsp (imm0_63)
12322 i32 __builtin_mips_lbux (void *, i32)
12323 i32 __builtin_mips_lhx (void *, i32)
12324 i32 __builtin_mips_lwx (void *, i32)
12325 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12326 i32 __builtin_mips_bposge32 (void)
12327 a64 __builtin_mips_madd (a64, i32, i32);
12328 a64 __builtin_mips_maddu (a64, ui32, ui32);
12329 a64 __builtin_mips_msub (a64, i32, i32);
12330 a64 __builtin_mips_msubu (a64, ui32, ui32);
12331 a64 __builtin_mips_mult (i32, i32);
12332 a64 __builtin_mips_multu (ui32, ui32);
12333 @end smallexample
12335 The following built-in functions map directly to a particular MIPS DSP REV 2
12336 instruction.  Please refer to the architecture specification
12337 for details on what each instruction does.
12339 @smallexample
12340 v4q7 __builtin_mips_absq_s_qb (v4q7);
12341 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12342 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12343 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12344 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12345 i32 __builtin_mips_append (i32, i32, imm0_31);
12346 i32 __builtin_mips_balign (i32, i32, imm0_3);
12347 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12348 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12349 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12350 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12351 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12352 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12353 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12354 q31 __builtin_mips_mulq_rs_w (q31, q31);
12355 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12356 q31 __builtin_mips_mulq_s_w (q31, q31);
12357 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12358 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12359 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12360 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12361 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12362 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12363 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12364 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12365 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12366 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12367 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12368 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12369 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12370 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12371 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12372 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12373 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12374 q31 __builtin_mips_addqh_w (q31, q31);
12375 q31 __builtin_mips_addqh_r_w (q31, q31);
12376 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12377 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12378 q31 __builtin_mips_subqh_w (q31, q31);
12379 q31 __builtin_mips_subqh_r_w (q31, q31);
12380 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12381 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12382 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12383 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12384 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12385 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12386 @end smallexample
12389 @node MIPS Paired-Single Support
12390 @subsection MIPS Paired-Single Support
12392 The MIPS64 architecture includes a number of instructions that
12393 operate on pairs of single-precision floating-point values.
12394 Each pair is packed into a 64-bit floating-point register,
12395 with one element being designated the ``upper half'' and
12396 the other being designated the ``lower half''.
12398 GCC supports paired-single operations using both the generic
12399 vector extensions (@pxref{Vector Extensions}) and a collection of
12400 MIPS-specific built-in functions.  Both kinds of support are
12401 enabled by the @option{-mpaired-single} command-line option.
12403 The vector type associated with paired-single values is usually
12404 called @code{v2sf}.  It can be defined in C as follows:
12406 @smallexample
12407 typedef float v2sf __attribute__ ((vector_size (8)));
12408 @end smallexample
12410 @code{v2sf} values are initialized in the same way as aggregates.
12411 For example:
12413 @smallexample
12414 v2sf a = @{1.5, 9.1@};
12415 v2sf b;
12416 float e, f;
12417 b = (v2sf) @{e, f@};
12418 @end smallexample
12420 @emph{Note:} The CPU's endianness determines which value is stored in
12421 the upper half of a register and which value is stored in the lower half.
12422 On little-endian targets, the first value is the lower one and the second
12423 value is the upper one.  The opposite order applies to big-endian targets.
12424 For example, the code above sets the lower half of @code{a} to
12425 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12427 @node MIPS Loongson Built-in Functions
12428 @subsection MIPS Loongson Built-in Functions
12430 GCC provides intrinsics to access the SIMD instructions provided by the
12431 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
12432 available after inclusion of the @code{loongson.h} header file,
12433 operate on the following 64-bit vector types:
12435 @itemize
12436 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12437 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12438 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12439 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12440 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12441 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12442 @end itemize
12444 The intrinsics provided are listed below; each is named after the
12445 machine instruction to which it corresponds, with suffixes added as
12446 appropriate to distinguish intrinsics that expand to the same machine
12447 instruction yet have different argument types.  Refer to the architecture
12448 documentation for a description of the functionality of each
12449 instruction.
12451 @smallexample
12452 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12453 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12454 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12455 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12456 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12457 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12458 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12459 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12460 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12461 uint64_t paddd_u (uint64_t s, uint64_t t);
12462 int64_t paddd_s (int64_t s, int64_t t);
12463 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12464 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12465 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12466 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12467 uint64_t pandn_ud (uint64_t s, uint64_t t);
12468 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12469 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12470 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12471 int64_t pandn_sd (int64_t s, int64_t t);
12472 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12473 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12474 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12475 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12476 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12477 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12478 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12479 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12480 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12481 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12482 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12483 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12484 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12485 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12486 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12487 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12488 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12489 uint16x4_t pextrh_u (uint16x4_t s, int field);
12490 int16x4_t pextrh_s (int16x4_t s, int field);
12491 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12492 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12493 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12494 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12495 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12496 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12497 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12498 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12499 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12500 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12501 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12502 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12503 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12504 uint8x8_t pmovmskb_u (uint8x8_t s);
12505 int8x8_t pmovmskb_s (int8x8_t s);
12506 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12507 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12508 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12509 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12510 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12511 uint16x4_t biadd (uint8x8_t s);
12512 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12513 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12514 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12515 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12516 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12517 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12518 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12519 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12520 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12521 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12522 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12523 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12524 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12525 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12526 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12527 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12528 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12529 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12530 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12531 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12532 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12533 uint64_t psubd_u (uint64_t s, uint64_t t);
12534 int64_t psubd_s (int64_t s, int64_t t);
12535 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12536 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12537 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12538 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12539 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12540 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12541 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12542 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12543 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12544 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12545 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12546 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12547 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12548 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12549 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12550 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12551 @end smallexample
12553 @menu
12554 * Paired-Single Arithmetic::
12555 * Paired-Single Built-in Functions::
12556 * MIPS-3D Built-in Functions::
12557 @end menu
12559 @node Paired-Single Arithmetic
12560 @subsubsection Paired-Single Arithmetic
12562 The table below lists the @code{v2sf} operations for which hardware
12563 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
12564 values and @code{x} is an integral value.
12566 @multitable @columnfractions .50 .50
12567 @item C code @tab MIPS instruction
12568 @item @code{a + b} @tab @code{add.ps}
12569 @item @code{a - b} @tab @code{sub.ps}
12570 @item @code{-a} @tab @code{neg.ps}
12571 @item @code{a * b} @tab @code{mul.ps}
12572 @item @code{a * b + c} @tab @code{madd.ps}
12573 @item @code{a * b - c} @tab @code{msub.ps}
12574 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
12575 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
12576 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
12577 @end multitable
12579 Note that the multiply-accumulate instructions can be disabled
12580 using the command-line option @code{-mno-fused-madd}.
12582 @node Paired-Single Built-in Functions
12583 @subsubsection Paired-Single Built-in Functions
12585 The following paired-single functions map directly to a particular
12586 MIPS instruction.  Please refer to the architecture specification
12587 for details on what each instruction does.
12589 @table @code
12590 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
12591 Pair lower lower (@code{pll.ps}).
12593 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
12594 Pair upper lower (@code{pul.ps}).
12596 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
12597 Pair lower upper (@code{plu.ps}).
12599 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
12600 Pair upper upper (@code{puu.ps}).
12602 @item v2sf __builtin_mips_cvt_ps_s (float, float)
12603 Convert pair to paired single (@code{cvt.ps.s}).
12605 @item float __builtin_mips_cvt_s_pl (v2sf)
12606 Convert pair lower to single (@code{cvt.s.pl}).
12608 @item float __builtin_mips_cvt_s_pu (v2sf)
12609 Convert pair upper to single (@code{cvt.s.pu}).
12611 @item v2sf __builtin_mips_abs_ps (v2sf)
12612 Absolute value (@code{abs.ps}).
12614 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12615 Align variable (@code{alnv.ps}).
12617 @emph{Note:} The value of the third parameter must be 0 or 4
12618 modulo 8, otherwise the result is unpredictable.  Please read the
12619 instruction description for details.
12620 @end table
12622 The following multi-instruction functions are also available.
12623 In each case, @var{cond} can be any of the 16 floating-point conditions:
12624 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12625 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12626 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12628 @table @code
12629 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12630 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12631 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12632 @code{movt.ps}/@code{movf.ps}).
12634 The @code{movt} functions return the value @var{x} computed by:
12636 @smallexample
12637 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12638 mov.ps @var{x},@var{c}
12639 movt.ps @var{x},@var{d},@var{cc}
12640 @end smallexample
12642 The @code{movf} functions are similar but use @code{movf.ps} instead
12643 of @code{movt.ps}.
12645 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12646 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12647 Comparison of two paired-single values (@code{c.@var{cond}.ps},
12648 @code{bc1t}/@code{bc1f}).
12650 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12651 and return either the upper or lower half of the result.  For example:
12653 @smallexample
12654 v2sf a, b;
12655 if (__builtin_mips_upper_c_eq_ps (a, b))
12656   upper_halves_are_equal ();
12657 else
12658   upper_halves_are_unequal ();
12660 if (__builtin_mips_lower_c_eq_ps (a, b))
12661   lower_halves_are_equal ();
12662 else
12663   lower_halves_are_unequal ();
12664 @end smallexample
12665 @end table
12667 @node MIPS-3D Built-in Functions
12668 @subsubsection MIPS-3D Built-in Functions
12670 The MIPS-3D Application-Specific Extension (ASE) includes additional
12671 paired-single instructions that are designed to improve the performance
12672 of 3D graphics operations.  Support for these instructions is controlled
12673 by the @option{-mips3d} command-line option.
12675 The functions listed below map directly to a particular MIPS-3D
12676 instruction.  Please refer to the architecture specification for
12677 more details on what each instruction does.
12679 @table @code
12680 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
12681 Reduction add (@code{addr.ps}).
12683 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
12684 Reduction multiply (@code{mulr.ps}).
12686 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
12687 Convert paired single to paired word (@code{cvt.pw.ps}).
12689 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
12690 Convert paired word to paired single (@code{cvt.ps.pw}).
12692 @item float __builtin_mips_recip1_s (float)
12693 @itemx double __builtin_mips_recip1_d (double)
12694 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
12695 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
12697 @item float __builtin_mips_recip2_s (float, float)
12698 @itemx double __builtin_mips_recip2_d (double, double)
12699 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
12700 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
12702 @item float __builtin_mips_rsqrt1_s (float)
12703 @itemx double __builtin_mips_rsqrt1_d (double)
12704 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
12705 Reduced-precision reciprocal square root (sequence step 1)
12706 (@code{rsqrt1.@var{fmt}}).
12708 @item float __builtin_mips_rsqrt2_s (float, float)
12709 @itemx double __builtin_mips_rsqrt2_d (double, double)
12710 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
12711 Reduced-precision reciprocal square root (sequence step 2)
12712 (@code{rsqrt2.@var{fmt}}).
12713 @end table
12715 The following multi-instruction functions are also available.
12716 In each case, @var{cond} can be any of the 16 floating-point conditions:
12717 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12718 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
12719 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12721 @table @code
12722 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
12723 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
12724 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
12725 @code{bc1t}/@code{bc1f}).
12727 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
12728 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
12729 For example:
12731 @smallexample
12732 float a, b;
12733 if (__builtin_mips_cabs_eq_s (a, b))
12734   true ();
12735 else
12736   false ();
12737 @end smallexample
12739 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12740 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12741 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
12742 @code{bc1t}/@code{bc1f}).
12744 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
12745 and return either the upper or lower half of the result.  For example:
12747 @smallexample
12748 v2sf a, b;
12749 if (__builtin_mips_upper_cabs_eq_ps (a, b))
12750   upper_halves_are_equal ();
12751 else
12752   upper_halves_are_unequal ();
12754 if (__builtin_mips_lower_cabs_eq_ps (a, b))
12755   lower_halves_are_equal ();
12756 else
12757   lower_halves_are_unequal ();
12758 @end smallexample
12760 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12761 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12762 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
12763 @code{movt.ps}/@code{movf.ps}).
12765 The @code{movt} functions return the value @var{x} computed by:
12767 @smallexample
12768 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
12769 mov.ps @var{x},@var{c}
12770 movt.ps @var{x},@var{d},@var{cc}
12771 @end smallexample
12773 The @code{movf} functions are similar but use @code{movf.ps} instead
12774 of @code{movt.ps}.
12776 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12777 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12778 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12779 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12780 Comparison of two paired-single values
12781 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12782 @code{bc1any2t}/@code{bc1any2f}).
12784 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12785 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
12786 result is true and the @code{all} forms return true if both results are true.
12787 For example:
12789 @smallexample
12790 v2sf a, b;
12791 if (__builtin_mips_any_c_eq_ps (a, b))
12792   one_is_true ();
12793 else
12794   both_are_false ();
12796 if (__builtin_mips_all_c_eq_ps (a, b))
12797   both_are_true ();
12798 else
12799   one_is_false ();
12800 @end smallexample
12802 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12803 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12804 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12805 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12806 Comparison of four paired-single values
12807 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12808 @code{bc1any4t}/@code{bc1any4f}).
12810 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
12811 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
12812 The @code{any} forms return true if any of the four results are true
12813 and the @code{all} forms return true if all four results are true.
12814 For example:
12816 @smallexample
12817 v2sf a, b, c, d;
12818 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
12819   some_are_true ();
12820 else
12821   all_are_false ();
12823 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
12824   all_are_true ();
12825 else
12826   some_are_false ();
12827 @end smallexample
12828 @end table
12830 @node Other MIPS Built-in Functions
12831 @subsection Other MIPS Built-in Functions
12833 GCC provides other MIPS-specific built-in functions:
12835 @table @code
12836 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
12837 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
12838 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
12839 when this function is available.
12841 @item unsigned int __builtin_mips_get_fcsr (void)
12842 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
12843 Get and set the contents of the floating-point control and status register
12844 (FPU control register 31).  These functions are only available in hard-float
12845 code but can be called in both MIPS16 and non-MIPS16 contexts.
12847 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
12848 register except the condition codes, which GCC assumes are preserved.
12849 @end table
12851 @node MSP430 Built-in Functions
12852 @subsection MSP430 Built-in Functions
12854 GCC provides a couple of special builtin functions to aid in the
12855 writing of interrupt handlers in C.
12857 @table @code
12858 @item __bic_SR_register_on_exit (int @var{mask})
12859 This clears the indicated bits in the saved copy of the status register
12860 currently residing on the stack.  This only works inside interrupt
12861 handlers and the changes to the status register will only take affect
12862 once the handler returns.
12864 @item __bis_SR_register_on_exit (int @var{mask})
12865 This sets the indicated bits in the saved copy of the status register
12866 currently residing on the stack.  This only works inside interrupt
12867 handlers and the changes to the status register will only take affect
12868 once the handler returns.
12870 @item __delay_cycles (long long @var{cycles})
12871 This inserts an instruction sequence that takes exactly @var{cycles}
12872 cycles (between 0 and about 17E9) to complete.  The inserted sequence
12873 may use jumps, loops, or no-ops, and does not interfere with any other
12874 instructions.  Note that @var{cycles} must be a compile-time constant
12875 integer - that is, you must pass a number, not a variable that may be
12876 optimized to a constant later.  The number of cycles delayed by this
12877 builtin is exact.
12878 @end table
12880 @node NDS32 Built-in Functions
12881 @subsection NDS32 Built-in Functions
12883 These built-in functions are available for the NDS32 target:
12885 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
12886 Insert an ISYNC instruction into the instruction stream where
12887 @var{addr} is an instruction address for serialization.
12888 @end deftypefn
12890 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
12891 Insert an ISB instruction into the instruction stream.
12892 @end deftypefn
12894 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
12895 Return the content of a system register which is mapped by @var{sr}.
12896 @end deftypefn
12898 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
12899 Return the content of a user space register which is mapped by @var{usr}.
12900 @end deftypefn
12902 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
12903 Move the @var{value} to a system register which is mapped by @var{sr}.
12904 @end deftypefn
12906 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
12907 Move the @var{value} to a user space register which is mapped by @var{usr}.
12908 @end deftypefn
12910 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
12911 Enable global interrupt.
12912 @end deftypefn
12914 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
12915 Disable global interrupt.
12916 @end deftypefn
12918 @node picoChip Built-in Functions
12919 @subsection picoChip Built-in Functions
12921 GCC provides an interface to selected machine instructions from the
12922 picoChip instruction set.
12924 @table @code
12925 @item int __builtin_sbc (int @var{value})
12926 Sign bit count.  Return the number of consecutive bits in @var{value}
12927 that have the same value as the sign bit.  The result is the number of
12928 leading sign bits minus one, giving the number of redundant sign bits in
12929 @var{value}.
12931 @item int __builtin_byteswap (int @var{value})
12932 Byte swap.  Return the result of swapping the upper and lower bytes of
12933 @var{value}.
12935 @item int __builtin_brev (int @var{value})
12936 Bit reversal.  Return the result of reversing the bits in
12937 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
12938 and so on.
12940 @item int __builtin_adds (int @var{x}, int @var{y})
12941 Saturating addition.  Return the result of adding @var{x} and @var{y},
12942 storing the value 32767 if the result overflows.
12944 @item int __builtin_subs (int @var{x}, int @var{y})
12945 Saturating subtraction.  Return the result of subtracting @var{y} from
12946 @var{x}, storing the value @minus{}32768 if the result overflows.
12948 @item void __builtin_halt (void)
12949 Halt.  The processor stops execution.  This built-in is useful for
12950 implementing assertions.
12952 @end table
12954 @node PowerPC Built-in Functions
12955 @subsection PowerPC Built-in Functions
12957 These built-in functions are available for the PowerPC family of
12958 processors:
12959 @smallexample
12960 float __builtin_recipdivf (float, float);
12961 float __builtin_rsqrtf (float);
12962 double __builtin_recipdiv (double, double);
12963 double __builtin_rsqrt (double);
12964 uint64_t __builtin_ppc_get_timebase ();
12965 unsigned long __builtin_ppc_mftb ();
12966 double __builtin_unpack_longdouble (long double, int);
12967 long double __builtin_pack_longdouble (double, double);
12968 @end smallexample
12970 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
12971 @code{__builtin_rsqrtf} functions generate multiple instructions to
12972 implement the reciprocal sqrt functionality using reciprocal sqrt
12973 estimate instructions.
12975 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
12976 functions generate multiple instructions to implement division using
12977 the reciprocal estimate instructions.
12979 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
12980 functions generate instructions to read the Time Base Register.  The
12981 @code{__builtin_ppc_get_timebase} function may generate multiple
12982 instructions and always returns the 64 bits of the Time Base Register.
12983 The @code{__builtin_ppc_mftb} function always generates one instruction and
12984 returns the Time Base Register value as an unsigned long, throwing away
12985 the most significant word on 32-bit environments.
12987 The following built-in functions are available for the PowerPC family
12988 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
12989 or @option{-mpopcntd}):
12990 @smallexample
12991 long __builtin_bpermd (long, long);
12992 int __builtin_divwe (int, int);
12993 int __builtin_divweo (int, int);
12994 unsigned int __builtin_divweu (unsigned int, unsigned int);
12995 unsigned int __builtin_divweuo (unsigned int, unsigned int);
12996 long __builtin_divde (long, long);
12997 long __builtin_divdeo (long, long);
12998 unsigned long __builtin_divdeu (unsigned long, unsigned long);
12999 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13000 unsigned int cdtbcd (unsigned int);
13001 unsigned int cbcdtd (unsigned int);
13002 unsigned int addg6s (unsigned int, unsigned int);
13003 @end smallexample
13005 The @code{__builtin_divde}, @code{__builtin_divdeo},
13006 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13007 64-bit environment support ISA 2.06 or later.
13009 The following built-in functions are available for the PowerPC family
13010 of processors when hardware decimal floating point
13011 (@option{-mhard-dfp}) is available:
13012 @smallexample
13013 _Decimal64 __builtin_dxex (_Decimal64);
13014 _Decimal128 __builtin_dxexq (_Decimal128);
13015 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13016 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13017 _Decimal64 __builtin_denbcd (int, _Decimal64);
13018 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13019 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13020 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13021 _Decimal64 __builtin_dscli (_Decimal64, int);
13022 _Decimal128 __builtin_dscliq (_Decimal128, int);
13023 _Decimal64 __builtin_dscri (_Decimal64, int);
13024 _Decimal128 __builtin_dscriq (_Decimal128, int);
13025 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13026 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13027 @end smallexample
13029 The following built-in functions are available for the PowerPC family
13030 of processors when the Vector Scalar (vsx) instruction set is
13031 available:
13032 @smallexample
13033 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13034 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13035                                                 unsigned long long);
13036 @end smallexample
13038 @node PowerPC AltiVec/VSX Built-in Functions
13039 @subsection PowerPC AltiVec Built-in Functions
13041 GCC provides an interface for the PowerPC family of processors to access
13042 the AltiVec operations described in Motorola's AltiVec Programming
13043 Interface Manual.  The interface is made available by including
13044 @code{<altivec.h>} and using @option{-maltivec} and
13045 @option{-mabi=altivec}.  The interface supports the following vector
13046 types.
13048 @smallexample
13049 vector unsigned char
13050 vector signed char
13051 vector bool char
13053 vector unsigned short
13054 vector signed short
13055 vector bool short
13056 vector pixel
13058 vector unsigned int
13059 vector signed int
13060 vector bool int
13061 vector float
13062 @end smallexample
13064 If @option{-mvsx} is used the following additional vector types are
13065 implemented.
13067 @smallexample
13068 vector unsigned long
13069 vector signed long
13070 vector double
13071 @end smallexample
13073 The long types are only implemented for 64-bit code generation, and
13074 the long type is only used in the floating point/integer conversion
13075 instructions.
13077 GCC's implementation of the high-level language interface available from
13078 C and C++ code differs from Motorola's documentation in several ways.
13080 @itemize @bullet
13082 @item
13083 A vector constant is a list of constant expressions within curly braces.
13085 @item
13086 A vector initializer requires no cast if the vector constant is of the
13087 same type as the variable it is initializing.
13089 @item
13090 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13091 vector type is the default signedness of the base type.  The default
13092 varies depending on the operating system, so a portable program should
13093 always specify the signedness.
13095 @item
13096 Compiling with @option{-maltivec} adds keywords @code{__vector},
13097 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13098 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13099 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13100 disabled.  To use them, you must include @code{<altivec.h>} instead.
13102 @item
13103 GCC allows using a @code{typedef} name as the type specifier for a
13104 vector type.
13106 @item
13107 For C, overloaded functions are implemented with macros so the following
13108 does not work:
13110 @smallexample
13111   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13112 @end smallexample
13114 @noindent
13115 Since @code{vec_add} is a macro, the vector constant in the example
13116 is treated as four separate arguments.  Wrap the entire argument in
13117 parentheses for this to work.
13118 @end itemize
13120 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13121 Internally, GCC uses built-in functions to achieve the functionality in
13122 the aforementioned header file, but they are not supported and are
13123 subject to change without notice.
13125 The following interfaces are supported for the generic and specific
13126 AltiVec operations and the AltiVec predicates.  In cases where there
13127 is a direct mapping between generic and specific operations, only the
13128 generic names are shown here, although the specific operations can also
13129 be used.
13131 Arguments that are documented as @code{const int} require literal
13132 integral values within the range required for that operation.
13134 @smallexample
13135 vector signed char vec_abs (vector signed char);
13136 vector signed short vec_abs (vector signed short);
13137 vector signed int vec_abs (vector signed int);
13138 vector float vec_abs (vector float);
13140 vector signed char vec_abss (vector signed char);
13141 vector signed short vec_abss (vector signed short);
13142 vector signed int vec_abss (vector signed int);
13144 vector signed char vec_add (vector bool char, vector signed char);
13145 vector signed char vec_add (vector signed char, vector bool char);
13146 vector signed char vec_add (vector signed char, vector signed char);
13147 vector unsigned char vec_add (vector bool char, vector unsigned char);
13148 vector unsigned char vec_add (vector unsigned char, vector bool char);
13149 vector unsigned char vec_add (vector unsigned char,
13150                               vector unsigned char);
13151 vector signed short vec_add (vector bool short, vector signed short);
13152 vector signed short vec_add (vector signed short, vector bool short);
13153 vector signed short vec_add (vector signed short, vector signed short);
13154 vector unsigned short vec_add (vector bool short,
13155                                vector unsigned short);
13156 vector unsigned short vec_add (vector unsigned short,
13157                                vector bool short);
13158 vector unsigned short vec_add (vector unsigned short,
13159                                vector unsigned short);
13160 vector signed int vec_add (vector bool int, vector signed int);
13161 vector signed int vec_add (vector signed int, vector bool int);
13162 vector signed int vec_add (vector signed int, vector signed int);
13163 vector unsigned int vec_add (vector bool int, vector unsigned int);
13164 vector unsigned int vec_add (vector unsigned int, vector bool int);
13165 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13166 vector float vec_add (vector float, vector float);
13168 vector float vec_vaddfp (vector float, vector float);
13170 vector signed int vec_vadduwm (vector bool int, vector signed int);
13171 vector signed int vec_vadduwm (vector signed int, vector bool int);
13172 vector signed int vec_vadduwm (vector signed int, vector signed int);
13173 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13174 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13175 vector unsigned int vec_vadduwm (vector unsigned int,
13176                                  vector unsigned int);
13178 vector signed short vec_vadduhm (vector bool short,
13179                                  vector signed short);
13180 vector signed short vec_vadduhm (vector signed short,
13181                                  vector bool short);
13182 vector signed short vec_vadduhm (vector signed short,
13183                                  vector signed short);
13184 vector unsigned short vec_vadduhm (vector bool short,
13185                                    vector unsigned short);
13186 vector unsigned short vec_vadduhm (vector unsigned short,
13187                                    vector bool short);
13188 vector unsigned short vec_vadduhm (vector unsigned short,
13189                                    vector unsigned short);
13191 vector signed char vec_vaddubm (vector bool char, vector signed char);
13192 vector signed char vec_vaddubm (vector signed char, vector bool char);
13193 vector signed char vec_vaddubm (vector signed char, vector signed char);
13194 vector unsigned char vec_vaddubm (vector bool char,
13195                                   vector unsigned char);
13196 vector unsigned char vec_vaddubm (vector unsigned char,
13197                                   vector bool char);
13198 vector unsigned char vec_vaddubm (vector unsigned char,
13199                                   vector unsigned char);
13201 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13203 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13204 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13205 vector unsigned char vec_adds (vector unsigned char,
13206                                vector unsigned char);
13207 vector signed char vec_adds (vector bool char, vector signed char);
13208 vector signed char vec_adds (vector signed char, vector bool char);
13209 vector signed char vec_adds (vector signed char, vector signed char);
13210 vector unsigned short vec_adds (vector bool short,
13211                                 vector unsigned short);
13212 vector unsigned short vec_adds (vector unsigned short,
13213                                 vector bool short);
13214 vector unsigned short vec_adds (vector unsigned short,
13215                                 vector unsigned short);
13216 vector signed short vec_adds (vector bool short, vector signed short);
13217 vector signed short vec_adds (vector signed short, vector bool short);
13218 vector signed short vec_adds (vector signed short, vector signed short);
13219 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13220 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13221 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13222 vector signed int vec_adds (vector bool int, vector signed int);
13223 vector signed int vec_adds (vector signed int, vector bool int);
13224 vector signed int vec_adds (vector signed int, vector signed int);
13226 vector signed int vec_vaddsws (vector bool int, vector signed int);
13227 vector signed int vec_vaddsws (vector signed int, vector bool int);
13228 vector signed int vec_vaddsws (vector signed int, vector signed int);
13230 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13231 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13232 vector unsigned int vec_vadduws (vector unsigned int,
13233                                  vector unsigned int);
13235 vector signed short vec_vaddshs (vector bool short,
13236                                  vector signed short);
13237 vector signed short vec_vaddshs (vector signed short,
13238                                  vector bool short);
13239 vector signed short vec_vaddshs (vector signed short,
13240                                  vector signed short);
13242 vector unsigned short vec_vadduhs (vector bool short,
13243                                    vector unsigned short);
13244 vector unsigned short vec_vadduhs (vector unsigned short,
13245                                    vector bool short);
13246 vector unsigned short vec_vadduhs (vector unsigned short,
13247                                    vector unsigned short);
13249 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13250 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13251 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13253 vector unsigned char vec_vaddubs (vector bool char,
13254                                   vector unsigned char);
13255 vector unsigned char vec_vaddubs (vector unsigned char,
13256                                   vector bool char);
13257 vector unsigned char vec_vaddubs (vector unsigned char,
13258                                   vector unsigned char);
13260 vector float vec_and (vector float, vector float);
13261 vector float vec_and (vector float, vector bool int);
13262 vector float vec_and (vector bool int, vector float);
13263 vector bool int vec_and (vector bool int, vector bool int);
13264 vector signed int vec_and (vector bool int, vector signed int);
13265 vector signed int vec_and (vector signed int, vector bool int);
13266 vector signed int vec_and (vector signed int, vector signed int);
13267 vector unsigned int vec_and (vector bool int, vector unsigned int);
13268 vector unsigned int vec_and (vector unsigned int, vector bool int);
13269 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13270 vector bool short vec_and (vector bool short, vector bool short);
13271 vector signed short vec_and (vector bool short, vector signed short);
13272 vector signed short vec_and (vector signed short, vector bool short);
13273 vector signed short vec_and (vector signed short, vector signed short);
13274 vector unsigned short vec_and (vector bool short,
13275                                vector unsigned short);
13276 vector unsigned short vec_and (vector unsigned short,
13277                                vector bool short);
13278 vector unsigned short vec_and (vector unsigned short,
13279                                vector unsigned short);
13280 vector signed char vec_and (vector bool char, vector signed char);
13281 vector bool char vec_and (vector bool char, vector bool char);
13282 vector signed char vec_and (vector signed char, vector bool char);
13283 vector signed char vec_and (vector signed char, vector signed char);
13284 vector unsigned char vec_and (vector bool char, vector unsigned char);
13285 vector unsigned char vec_and (vector unsigned char, vector bool char);
13286 vector unsigned char vec_and (vector unsigned char,
13287                               vector unsigned char);
13289 vector float vec_andc (vector float, vector float);
13290 vector float vec_andc (vector float, vector bool int);
13291 vector float vec_andc (vector bool int, vector float);
13292 vector bool int vec_andc (vector bool int, vector bool int);
13293 vector signed int vec_andc (vector bool int, vector signed int);
13294 vector signed int vec_andc (vector signed int, vector bool int);
13295 vector signed int vec_andc (vector signed int, vector signed int);
13296 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13297 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13298 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13299 vector bool short vec_andc (vector bool short, vector bool short);
13300 vector signed short vec_andc (vector bool short, vector signed short);
13301 vector signed short vec_andc (vector signed short, vector bool short);
13302 vector signed short vec_andc (vector signed short, vector signed short);
13303 vector unsigned short vec_andc (vector bool short,
13304                                 vector unsigned short);
13305 vector unsigned short vec_andc (vector unsigned short,
13306                                 vector bool short);
13307 vector unsigned short vec_andc (vector unsigned short,
13308                                 vector unsigned short);
13309 vector signed char vec_andc (vector bool char, vector signed char);
13310 vector bool char vec_andc (vector bool char, vector bool char);
13311 vector signed char vec_andc (vector signed char, vector bool char);
13312 vector signed char vec_andc (vector signed char, vector signed char);
13313 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13314 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13315 vector unsigned char vec_andc (vector unsigned char,
13316                                vector unsigned char);
13318 vector unsigned char vec_avg (vector unsigned char,
13319                               vector unsigned char);
13320 vector signed char vec_avg (vector signed char, vector signed char);
13321 vector unsigned short vec_avg (vector unsigned short,
13322                                vector unsigned short);
13323 vector signed short vec_avg (vector signed short, vector signed short);
13324 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13325 vector signed int vec_avg (vector signed int, vector signed int);
13327 vector signed int vec_vavgsw (vector signed int, vector signed int);
13329 vector unsigned int vec_vavguw (vector unsigned int,
13330                                 vector unsigned int);
13332 vector signed short vec_vavgsh (vector signed short,
13333                                 vector signed short);
13335 vector unsigned short vec_vavguh (vector unsigned short,
13336                                   vector unsigned short);
13338 vector signed char vec_vavgsb (vector signed char, vector signed char);
13340 vector unsigned char vec_vavgub (vector unsigned char,
13341                                  vector unsigned char);
13343 vector float vec_copysign (vector float);
13345 vector float vec_ceil (vector float);
13347 vector signed int vec_cmpb (vector float, vector float);
13349 vector bool char vec_cmpeq (vector signed char, vector signed char);
13350 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13351 vector bool short vec_cmpeq (vector signed short, vector signed short);
13352 vector bool short vec_cmpeq (vector unsigned short,
13353                              vector unsigned short);
13354 vector bool int vec_cmpeq (vector signed int, vector signed int);
13355 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13356 vector bool int vec_cmpeq (vector float, vector float);
13358 vector bool int vec_vcmpeqfp (vector float, vector float);
13360 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13361 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13363 vector bool short vec_vcmpequh (vector signed short,
13364                                 vector signed short);
13365 vector bool short vec_vcmpequh (vector unsigned short,
13366                                 vector unsigned short);
13368 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13369 vector bool char vec_vcmpequb (vector unsigned char,
13370                                vector unsigned char);
13372 vector bool int vec_cmpge (vector float, vector float);
13374 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13375 vector bool char vec_cmpgt (vector signed char, vector signed char);
13376 vector bool short vec_cmpgt (vector unsigned short,
13377                              vector unsigned short);
13378 vector bool short vec_cmpgt (vector signed short, vector signed short);
13379 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13380 vector bool int vec_cmpgt (vector signed int, vector signed int);
13381 vector bool int vec_cmpgt (vector float, vector float);
13383 vector bool int vec_vcmpgtfp (vector float, vector float);
13385 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13387 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13389 vector bool short vec_vcmpgtsh (vector signed short,
13390                                 vector signed short);
13392 vector bool short vec_vcmpgtuh (vector unsigned short,
13393                                 vector unsigned short);
13395 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13397 vector bool char vec_vcmpgtub (vector unsigned char,
13398                                vector unsigned char);
13400 vector bool int vec_cmple (vector float, vector float);
13402 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13403 vector bool char vec_cmplt (vector signed char, vector signed char);
13404 vector bool short vec_cmplt (vector unsigned short,
13405                              vector unsigned short);
13406 vector bool short vec_cmplt (vector signed short, vector signed short);
13407 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13408 vector bool int vec_cmplt (vector signed int, vector signed int);
13409 vector bool int vec_cmplt (vector float, vector float);
13411 vector float vec_cpsgn (vector float, vector float);
13413 vector float vec_ctf (vector unsigned int, const int);
13414 vector float vec_ctf (vector signed int, const int);
13415 vector double vec_ctf (vector unsigned long, const int);
13416 vector double vec_ctf (vector signed long, const int);
13418 vector float vec_vcfsx (vector signed int, const int);
13420 vector float vec_vcfux (vector unsigned int, const int);
13422 vector signed int vec_cts (vector float, const int);
13423 vector signed long vec_cts (vector double, const int);
13425 vector unsigned int vec_ctu (vector float, const int);
13426 vector unsigned long vec_ctu (vector double, const int);
13428 void vec_dss (const int);
13430 void vec_dssall (void);
13432 void vec_dst (const vector unsigned char *, int, const int);
13433 void vec_dst (const vector signed char *, int, const int);
13434 void vec_dst (const vector bool char *, int, const int);
13435 void vec_dst (const vector unsigned short *, int, const int);
13436 void vec_dst (const vector signed short *, int, const int);
13437 void vec_dst (const vector bool short *, int, const int);
13438 void vec_dst (const vector pixel *, int, const int);
13439 void vec_dst (const vector unsigned int *, int, const int);
13440 void vec_dst (const vector signed int *, int, const int);
13441 void vec_dst (const vector bool int *, int, const int);
13442 void vec_dst (const vector float *, int, const int);
13443 void vec_dst (const unsigned char *, int, const int);
13444 void vec_dst (const signed char *, int, const int);
13445 void vec_dst (const unsigned short *, int, const int);
13446 void vec_dst (const short *, int, const int);
13447 void vec_dst (const unsigned int *, int, const int);
13448 void vec_dst (const int *, int, const int);
13449 void vec_dst (const unsigned long *, int, const int);
13450 void vec_dst (const long *, int, const int);
13451 void vec_dst (const float *, int, const int);
13453 void vec_dstst (const vector unsigned char *, int, const int);
13454 void vec_dstst (const vector signed char *, int, const int);
13455 void vec_dstst (const vector bool char *, int, const int);
13456 void vec_dstst (const vector unsigned short *, int, const int);
13457 void vec_dstst (const vector signed short *, int, const int);
13458 void vec_dstst (const vector bool short *, int, const int);
13459 void vec_dstst (const vector pixel *, int, const int);
13460 void vec_dstst (const vector unsigned int *, int, const int);
13461 void vec_dstst (const vector signed int *, int, const int);
13462 void vec_dstst (const vector bool int *, int, const int);
13463 void vec_dstst (const vector float *, int, const int);
13464 void vec_dstst (const unsigned char *, int, const int);
13465 void vec_dstst (const signed char *, int, const int);
13466 void vec_dstst (const unsigned short *, int, const int);
13467 void vec_dstst (const short *, int, const int);
13468 void vec_dstst (const unsigned int *, int, const int);
13469 void vec_dstst (const int *, int, const int);
13470 void vec_dstst (const unsigned long *, int, const int);
13471 void vec_dstst (const long *, int, const int);
13472 void vec_dstst (const float *, int, const int);
13474 void vec_dststt (const vector unsigned char *, int, const int);
13475 void vec_dststt (const vector signed char *, int, const int);
13476 void vec_dststt (const vector bool char *, int, const int);
13477 void vec_dststt (const vector unsigned short *, int, const int);
13478 void vec_dststt (const vector signed short *, int, const int);
13479 void vec_dststt (const vector bool short *, int, const int);
13480 void vec_dststt (const vector pixel *, int, const int);
13481 void vec_dststt (const vector unsigned int *, int, const int);
13482 void vec_dststt (const vector signed int *, int, const int);
13483 void vec_dststt (const vector bool int *, int, const int);
13484 void vec_dststt (const vector float *, int, const int);
13485 void vec_dststt (const unsigned char *, int, const int);
13486 void vec_dststt (const signed char *, int, const int);
13487 void vec_dststt (const unsigned short *, int, const int);
13488 void vec_dststt (const short *, int, const int);
13489 void vec_dststt (const unsigned int *, int, const int);
13490 void vec_dststt (const int *, int, const int);
13491 void vec_dststt (const unsigned long *, int, const int);
13492 void vec_dststt (const long *, int, const int);
13493 void vec_dststt (const float *, int, const int);
13495 void vec_dstt (const vector unsigned char *, int, const int);
13496 void vec_dstt (const vector signed char *, int, const int);
13497 void vec_dstt (const vector bool char *, int, const int);
13498 void vec_dstt (const vector unsigned short *, int, const int);
13499 void vec_dstt (const vector signed short *, int, const int);
13500 void vec_dstt (const vector bool short *, int, const int);
13501 void vec_dstt (const vector pixel *, int, const int);
13502 void vec_dstt (const vector unsigned int *, int, const int);
13503 void vec_dstt (const vector signed int *, int, const int);
13504 void vec_dstt (const vector bool int *, int, const int);
13505 void vec_dstt (const vector float *, int, const int);
13506 void vec_dstt (const unsigned char *, int, const int);
13507 void vec_dstt (const signed char *, int, const int);
13508 void vec_dstt (const unsigned short *, int, const int);
13509 void vec_dstt (const short *, int, const int);
13510 void vec_dstt (const unsigned int *, int, const int);
13511 void vec_dstt (const int *, int, const int);
13512 void vec_dstt (const unsigned long *, int, const int);
13513 void vec_dstt (const long *, int, const int);
13514 void vec_dstt (const float *, int, const int);
13516 vector float vec_expte (vector float);
13518 vector float vec_floor (vector float);
13520 vector float vec_ld (int, const vector float *);
13521 vector float vec_ld (int, const float *);
13522 vector bool int vec_ld (int, const vector bool int *);
13523 vector signed int vec_ld (int, const vector signed int *);
13524 vector signed int vec_ld (int, const int *);
13525 vector signed int vec_ld (int, const long *);
13526 vector unsigned int vec_ld (int, const vector unsigned int *);
13527 vector unsigned int vec_ld (int, const unsigned int *);
13528 vector unsigned int vec_ld (int, const unsigned long *);
13529 vector bool short vec_ld (int, const vector bool short *);
13530 vector pixel vec_ld (int, const vector pixel *);
13531 vector signed short vec_ld (int, const vector signed short *);
13532 vector signed short vec_ld (int, const short *);
13533 vector unsigned short vec_ld (int, const vector unsigned short *);
13534 vector unsigned short vec_ld (int, const unsigned short *);
13535 vector bool char vec_ld (int, const vector bool char *);
13536 vector signed char vec_ld (int, const vector signed char *);
13537 vector signed char vec_ld (int, const signed char *);
13538 vector unsigned char vec_ld (int, const vector unsigned char *);
13539 vector unsigned char vec_ld (int, const unsigned char *);
13541 vector signed char vec_lde (int, const signed char *);
13542 vector unsigned char vec_lde (int, const unsigned char *);
13543 vector signed short vec_lde (int, const short *);
13544 vector unsigned short vec_lde (int, const unsigned short *);
13545 vector float vec_lde (int, const float *);
13546 vector signed int vec_lde (int, const int *);
13547 vector unsigned int vec_lde (int, const unsigned int *);
13548 vector signed int vec_lde (int, const long *);
13549 vector unsigned int vec_lde (int, const unsigned long *);
13551 vector float vec_lvewx (int, float *);
13552 vector signed int vec_lvewx (int, int *);
13553 vector unsigned int vec_lvewx (int, unsigned int *);
13554 vector signed int vec_lvewx (int, long *);
13555 vector unsigned int vec_lvewx (int, unsigned long *);
13557 vector signed short vec_lvehx (int, short *);
13558 vector unsigned short vec_lvehx (int, unsigned short *);
13560 vector signed char vec_lvebx (int, char *);
13561 vector unsigned char vec_lvebx (int, unsigned char *);
13563 vector float vec_ldl (int, const vector float *);
13564 vector float vec_ldl (int, const float *);
13565 vector bool int vec_ldl (int, const vector bool int *);
13566 vector signed int vec_ldl (int, const vector signed int *);
13567 vector signed int vec_ldl (int, const int *);
13568 vector signed int vec_ldl (int, const long *);
13569 vector unsigned int vec_ldl (int, const vector unsigned int *);
13570 vector unsigned int vec_ldl (int, const unsigned int *);
13571 vector unsigned int vec_ldl (int, const unsigned long *);
13572 vector bool short vec_ldl (int, const vector bool short *);
13573 vector pixel vec_ldl (int, const vector pixel *);
13574 vector signed short vec_ldl (int, const vector signed short *);
13575 vector signed short vec_ldl (int, const short *);
13576 vector unsigned short vec_ldl (int, const vector unsigned short *);
13577 vector unsigned short vec_ldl (int, const unsigned short *);
13578 vector bool char vec_ldl (int, const vector bool char *);
13579 vector signed char vec_ldl (int, const vector signed char *);
13580 vector signed char vec_ldl (int, const signed char *);
13581 vector unsigned char vec_ldl (int, const vector unsigned char *);
13582 vector unsigned char vec_ldl (int, const unsigned char *);
13584 vector float vec_loge (vector float);
13586 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
13587 vector unsigned char vec_lvsl (int, const volatile signed char *);
13588 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
13589 vector unsigned char vec_lvsl (int, const volatile short *);
13590 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
13591 vector unsigned char vec_lvsl (int, const volatile int *);
13592 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
13593 vector unsigned char vec_lvsl (int, const volatile long *);
13594 vector unsigned char vec_lvsl (int, const volatile float *);
13596 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
13597 vector unsigned char vec_lvsr (int, const volatile signed char *);
13598 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
13599 vector unsigned char vec_lvsr (int, const volatile short *);
13600 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
13601 vector unsigned char vec_lvsr (int, const volatile int *);
13602 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
13603 vector unsigned char vec_lvsr (int, const volatile long *);
13604 vector unsigned char vec_lvsr (int, const volatile float *);
13606 vector float vec_madd (vector float, vector float, vector float);
13608 vector signed short vec_madds (vector signed short,
13609                                vector signed short,
13610                                vector signed short);
13612 vector unsigned char vec_max (vector bool char, vector unsigned char);
13613 vector unsigned char vec_max (vector unsigned char, vector bool char);
13614 vector unsigned char vec_max (vector unsigned char,
13615                               vector unsigned char);
13616 vector signed char vec_max (vector bool char, vector signed char);
13617 vector signed char vec_max (vector signed char, vector bool char);
13618 vector signed char vec_max (vector signed char, vector signed char);
13619 vector unsigned short vec_max (vector bool short,
13620                                vector unsigned short);
13621 vector unsigned short vec_max (vector unsigned short,
13622                                vector bool short);
13623 vector unsigned short vec_max (vector unsigned short,
13624                                vector unsigned short);
13625 vector signed short vec_max (vector bool short, vector signed short);
13626 vector signed short vec_max (vector signed short, vector bool short);
13627 vector signed short vec_max (vector signed short, vector signed short);
13628 vector unsigned int vec_max (vector bool int, vector unsigned int);
13629 vector unsigned int vec_max (vector unsigned int, vector bool int);
13630 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13631 vector signed int vec_max (vector bool int, vector signed int);
13632 vector signed int vec_max (vector signed int, vector bool int);
13633 vector signed int vec_max (vector signed int, vector signed int);
13634 vector float vec_max (vector float, vector float);
13636 vector float vec_vmaxfp (vector float, vector float);
13638 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13639 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13640 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13642 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13643 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13644 vector unsigned int vec_vmaxuw (vector unsigned int,
13645                                 vector unsigned int);
13647 vector signed short vec_vmaxsh (vector bool short, vector signed short);
13648 vector signed short vec_vmaxsh (vector signed short, vector bool short);
13649 vector signed short vec_vmaxsh (vector signed short,
13650                                 vector signed short);
13652 vector unsigned short vec_vmaxuh (vector bool short,
13653                                   vector unsigned short);
13654 vector unsigned short vec_vmaxuh (vector unsigned short,
13655                                   vector bool short);
13656 vector unsigned short vec_vmaxuh (vector unsigned short,
13657                                   vector unsigned short);
13659 vector signed char vec_vmaxsb (vector bool char, vector signed char);
13660 vector signed char vec_vmaxsb (vector signed char, vector bool char);
13661 vector signed char vec_vmaxsb (vector signed char, vector signed char);
13663 vector unsigned char vec_vmaxub (vector bool char,
13664                                  vector unsigned char);
13665 vector unsigned char vec_vmaxub (vector unsigned char,
13666                                  vector bool char);
13667 vector unsigned char vec_vmaxub (vector unsigned char,
13668                                  vector unsigned char);
13670 vector bool char vec_mergeh (vector bool char, vector bool char);
13671 vector signed char vec_mergeh (vector signed char, vector signed char);
13672 vector unsigned char vec_mergeh (vector unsigned char,
13673                                  vector unsigned char);
13674 vector bool short vec_mergeh (vector bool short, vector bool short);
13675 vector pixel vec_mergeh (vector pixel, vector pixel);
13676 vector signed short vec_mergeh (vector signed short,
13677                                 vector signed short);
13678 vector unsigned short vec_mergeh (vector unsigned short,
13679                                   vector unsigned short);
13680 vector float vec_mergeh (vector float, vector float);
13681 vector bool int vec_mergeh (vector bool int, vector bool int);
13682 vector signed int vec_mergeh (vector signed int, vector signed int);
13683 vector unsigned int vec_mergeh (vector unsigned int,
13684                                 vector unsigned int);
13686 vector float vec_vmrghw (vector float, vector float);
13687 vector bool int vec_vmrghw (vector bool int, vector bool int);
13688 vector signed int vec_vmrghw (vector signed int, vector signed int);
13689 vector unsigned int vec_vmrghw (vector unsigned int,
13690                                 vector unsigned int);
13692 vector bool short vec_vmrghh (vector bool short, vector bool short);
13693 vector signed short vec_vmrghh (vector signed short,
13694                                 vector signed short);
13695 vector unsigned short vec_vmrghh (vector unsigned short,
13696                                   vector unsigned short);
13697 vector pixel vec_vmrghh (vector pixel, vector pixel);
13699 vector bool char vec_vmrghb (vector bool char, vector bool char);
13700 vector signed char vec_vmrghb (vector signed char, vector signed char);
13701 vector unsigned char vec_vmrghb (vector unsigned char,
13702                                  vector unsigned char);
13704 vector bool char vec_mergel (vector bool char, vector bool char);
13705 vector signed char vec_mergel (vector signed char, vector signed char);
13706 vector unsigned char vec_mergel (vector unsigned char,
13707                                  vector unsigned char);
13708 vector bool short vec_mergel (vector bool short, vector bool short);
13709 vector pixel vec_mergel (vector pixel, vector pixel);
13710 vector signed short vec_mergel (vector signed short,
13711                                 vector signed short);
13712 vector unsigned short vec_mergel (vector unsigned short,
13713                                   vector unsigned short);
13714 vector float vec_mergel (vector float, vector float);
13715 vector bool int vec_mergel (vector bool int, vector bool int);
13716 vector signed int vec_mergel (vector signed int, vector signed int);
13717 vector unsigned int vec_mergel (vector unsigned int,
13718                                 vector unsigned int);
13720 vector float vec_vmrglw (vector float, vector float);
13721 vector signed int vec_vmrglw (vector signed int, vector signed int);
13722 vector unsigned int vec_vmrglw (vector unsigned int,
13723                                 vector unsigned int);
13724 vector bool int vec_vmrglw (vector bool int, vector bool int);
13726 vector bool short vec_vmrglh (vector bool short, vector bool short);
13727 vector signed short vec_vmrglh (vector signed short,
13728                                 vector signed short);
13729 vector unsigned short vec_vmrglh (vector unsigned short,
13730                                   vector unsigned short);
13731 vector pixel vec_vmrglh (vector pixel, vector pixel);
13733 vector bool char vec_vmrglb (vector bool char, vector bool char);
13734 vector signed char vec_vmrglb (vector signed char, vector signed char);
13735 vector unsigned char vec_vmrglb (vector unsigned char,
13736                                  vector unsigned char);
13738 vector unsigned short vec_mfvscr (void);
13740 vector unsigned char vec_min (vector bool char, vector unsigned char);
13741 vector unsigned char vec_min (vector unsigned char, vector bool char);
13742 vector unsigned char vec_min (vector unsigned char,
13743                               vector unsigned char);
13744 vector signed char vec_min (vector bool char, vector signed char);
13745 vector signed char vec_min (vector signed char, vector bool char);
13746 vector signed char vec_min (vector signed char, vector signed char);
13747 vector unsigned short vec_min (vector bool short,
13748                                vector unsigned short);
13749 vector unsigned short vec_min (vector unsigned short,
13750                                vector bool short);
13751 vector unsigned short vec_min (vector unsigned short,
13752                                vector unsigned short);
13753 vector signed short vec_min (vector bool short, vector signed short);
13754 vector signed short vec_min (vector signed short, vector bool short);
13755 vector signed short vec_min (vector signed short, vector signed short);
13756 vector unsigned int vec_min (vector bool int, vector unsigned int);
13757 vector unsigned int vec_min (vector unsigned int, vector bool int);
13758 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
13759 vector signed int vec_min (vector bool int, vector signed int);
13760 vector signed int vec_min (vector signed int, vector bool int);
13761 vector signed int vec_min (vector signed int, vector signed int);
13762 vector float vec_min (vector float, vector float);
13764 vector float vec_vminfp (vector float, vector float);
13766 vector signed int vec_vminsw (vector bool int, vector signed int);
13767 vector signed int vec_vminsw (vector signed int, vector bool int);
13768 vector signed int vec_vminsw (vector signed int, vector signed int);
13770 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
13771 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
13772 vector unsigned int vec_vminuw (vector unsigned int,
13773                                 vector unsigned int);
13775 vector signed short vec_vminsh (vector bool short, vector signed short);
13776 vector signed short vec_vminsh (vector signed short, vector bool short);
13777 vector signed short vec_vminsh (vector signed short,
13778                                 vector signed short);
13780 vector unsigned short vec_vminuh (vector bool short,
13781                                   vector unsigned short);
13782 vector unsigned short vec_vminuh (vector unsigned short,
13783                                   vector bool short);
13784 vector unsigned short vec_vminuh (vector unsigned short,
13785                                   vector unsigned short);
13787 vector signed char vec_vminsb (vector bool char, vector signed char);
13788 vector signed char vec_vminsb (vector signed char, vector bool char);
13789 vector signed char vec_vminsb (vector signed char, vector signed char);
13791 vector unsigned char vec_vminub (vector bool char,
13792                                  vector unsigned char);
13793 vector unsigned char vec_vminub (vector unsigned char,
13794                                  vector bool char);
13795 vector unsigned char vec_vminub (vector unsigned char,
13796                                  vector unsigned char);
13798 vector signed short vec_mladd (vector signed short,
13799                                vector signed short,
13800                                vector signed short);
13801 vector signed short vec_mladd (vector signed short,
13802                                vector unsigned short,
13803                                vector unsigned short);
13804 vector signed short vec_mladd (vector unsigned short,
13805                                vector signed short,
13806                                vector signed short);
13807 vector unsigned short vec_mladd (vector unsigned short,
13808                                  vector unsigned short,
13809                                  vector unsigned short);
13811 vector signed short vec_mradds (vector signed short,
13812                                 vector signed short,
13813                                 vector signed short);
13815 vector unsigned int vec_msum (vector unsigned char,
13816                               vector unsigned char,
13817                               vector unsigned int);
13818 vector signed int vec_msum (vector signed char,
13819                             vector unsigned char,
13820                             vector signed int);
13821 vector unsigned int vec_msum (vector unsigned short,
13822                               vector unsigned short,
13823                               vector unsigned int);
13824 vector signed int vec_msum (vector signed short,
13825                             vector signed short,
13826                             vector signed int);
13828 vector signed int vec_vmsumshm (vector signed short,
13829                                 vector signed short,
13830                                 vector signed int);
13832 vector unsigned int vec_vmsumuhm (vector unsigned short,
13833                                   vector unsigned short,
13834                                   vector unsigned int);
13836 vector signed int vec_vmsummbm (vector signed char,
13837                                 vector unsigned char,
13838                                 vector signed int);
13840 vector unsigned int vec_vmsumubm (vector unsigned char,
13841                                   vector unsigned char,
13842                                   vector unsigned int);
13844 vector unsigned int vec_msums (vector unsigned short,
13845                                vector unsigned short,
13846                                vector unsigned int);
13847 vector signed int vec_msums (vector signed short,
13848                              vector signed short,
13849                              vector signed int);
13851 vector signed int vec_vmsumshs (vector signed short,
13852                                 vector signed short,
13853                                 vector signed int);
13855 vector unsigned int vec_vmsumuhs (vector unsigned short,
13856                                   vector unsigned short,
13857                                   vector unsigned int);
13859 void vec_mtvscr (vector signed int);
13860 void vec_mtvscr (vector unsigned int);
13861 void vec_mtvscr (vector bool int);
13862 void vec_mtvscr (vector signed short);
13863 void vec_mtvscr (vector unsigned short);
13864 void vec_mtvscr (vector bool short);
13865 void vec_mtvscr (vector pixel);
13866 void vec_mtvscr (vector signed char);
13867 void vec_mtvscr (vector unsigned char);
13868 void vec_mtvscr (vector bool char);
13870 vector unsigned short vec_mule (vector unsigned char,
13871                                 vector unsigned char);
13872 vector signed short vec_mule (vector signed char,
13873                               vector signed char);
13874 vector unsigned int vec_mule (vector unsigned short,
13875                               vector unsigned short);
13876 vector signed int vec_mule (vector signed short, vector signed short);
13878 vector signed int vec_vmulesh (vector signed short,
13879                                vector signed short);
13881 vector unsigned int vec_vmuleuh (vector unsigned short,
13882                                  vector unsigned short);
13884 vector signed short vec_vmulesb (vector signed char,
13885                                  vector signed char);
13887 vector unsigned short vec_vmuleub (vector unsigned char,
13888                                   vector unsigned char);
13890 vector unsigned short vec_mulo (vector unsigned char,
13891                                 vector unsigned char);
13892 vector signed short vec_mulo (vector signed char, vector signed char);
13893 vector unsigned int vec_mulo (vector unsigned short,
13894                               vector unsigned short);
13895 vector signed int vec_mulo (vector signed short, vector signed short);
13897 vector signed int vec_vmulosh (vector signed short,
13898                                vector signed short);
13900 vector unsigned int vec_vmulouh (vector unsigned short,
13901                                  vector unsigned short);
13903 vector signed short vec_vmulosb (vector signed char,
13904                                  vector signed char);
13906 vector unsigned short vec_vmuloub (vector unsigned char,
13907                                    vector unsigned char);
13909 vector float vec_nmsub (vector float, vector float, vector float);
13911 vector float vec_nor (vector float, vector float);
13912 vector signed int vec_nor (vector signed int, vector signed int);
13913 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
13914 vector bool int vec_nor (vector bool int, vector bool int);
13915 vector signed short vec_nor (vector signed short, vector signed short);
13916 vector unsigned short vec_nor (vector unsigned short,
13917                                vector unsigned short);
13918 vector bool short vec_nor (vector bool short, vector bool short);
13919 vector signed char vec_nor (vector signed char, vector signed char);
13920 vector unsigned char vec_nor (vector unsigned char,
13921                               vector unsigned char);
13922 vector bool char vec_nor (vector bool char, vector bool char);
13924 vector float vec_or (vector float, vector float);
13925 vector float vec_or (vector float, vector bool int);
13926 vector float vec_or (vector bool int, vector float);
13927 vector bool int vec_or (vector bool int, vector bool int);
13928 vector signed int vec_or (vector bool int, vector signed int);
13929 vector signed int vec_or (vector signed int, vector bool int);
13930 vector signed int vec_or (vector signed int, vector signed int);
13931 vector unsigned int vec_or (vector bool int, vector unsigned int);
13932 vector unsigned int vec_or (vector unsigned int, vector bool int);
13933 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
13934 vector bool short vec_or (vector bool short, vector bool short);
13935 vector signed short vec_or (vector bool short, vector signed short);
13936 vector signed short vec_or (vector signed short, vector bool short);
13937 vector signed short vec_or (vector signed short, vector signed short);
13938 vector unsigned short vec_or (vector bool short, vector unsigned short);
13939 vector unsigned short vec_or (vector unsigned short, vector bool short);
13940 vector unsigned short vec_or (vector unsigned short,
13941                               vector unsigned short);
13942 vector signed char vec_or (vector bool char, vector signed char);
13943 vector bool char vec_or (vector bool char, vector bool char);
13944 vector signed char vec_or (vector signed char, vector bool char);
13945 vector signed char vec_or (vector signed char, vector signed char);
13946 vector unsigned char vec_or (vector bool char, vector unsigned char);
13947 vector unsigned char vec_or (vector unsigned char, vector bool char);
13948 vector unsigned char vec_or (vector unsigned char,
13949                              vector unsigned char);
13951 vector signed char vec_pack (vector signed short, vector signed short);
13952 vector unsigned char vec_pack (vector unsigned short,
13953                                vector unsigned short);
13954 vector bool char vec_pack (vector bool short, vector bool short);
13955 vector signed short vec_pack (vector signed int, vector signed int);
13956 vector unsigned short vec_pack (vector unsigned int,
13957                                 vector unsigned int);
13958 vector bool short vec_pack (vector bool int, vector bool int);
13960 vector bool short vec_vpkuwum (vector bool int, vector bool int);
13961 vector signed short vec_vpkuwum (vector signed int, vector signed int);
13962 vector unsigned short vec_vpkuwum (vector unsigned int,
13963                                    vector unsigned int);
13965 vector bool char vec_vpkuhum (vector bool short, vector bool short);
13966 vector signed char vec_vpkuhum (vector signed short,
13967                                 vector signed short);
13968 vector unsigned char vec_vpkuhum (vector unsigned short,
13969                                   vector unsigned short);
13971 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
13973 vector unsigned char vec_packs (vector unsigned short,
13974                                 vector unsigned short);
13975 vector signed char vec_packs (vector signed short, vector signed short);
13976 vector unsigned short vec_packs (vector unsigned int,
13977                                  vector unsigned int);
13978 vector signed short vec_packs (vector signed int, vector signed int);
13980 vector signed short vec_vpkswss (vector signed int, vector signed int);
13982 vector unsigned short vec_vpkuwus (vector unsigned int,
13983                                    vector unsigned int);
13985 vector signed char vec_vpkshss (vector signed short,
13986                                 vector signed short);
13988 vector unsigned char vec_vpkuhus (vector unsigned short,
13989                                   vector unsigned short);
13991 vector unsigned char vec_packsu (vector unsigned short,
13992                                  vector unsigned short);
13993 vector unsigned char vec_packsu (vector signed short,
13994                                  vector signed short);
13995 vector unsigned short vec_packsu (vector unsigned int,
13996                                   vector unsigned int);
13997 vector unsigned short vec_packsu (vector signed int, vector signed int);
13999 vector unsigned short vec_vpkswus (vector signed int,
14000                                    vector signed int);
14002 vector unsigned char vec_vpkshus (vector signed short,
14003                                   vector signed short);
14005 vector float vec_perm (vector float,
14006                        vector float,
14007                        vector unsigned char);
14008 vector signed int vec_perm (vector signed int,
14009                             vector signed int,
14010                             vector unsigned char);
14011 vector unsigned int vec_perm (vector unsigned int,
14012                               vector unsigned int,
14013                               vector unsigned char);
14014 vector bool int vec_perm (vector bool int,
14015                           vector bool int,
14016                           vector unsigned char);
14017 vector signed short vec_perm (vector signed short,
14018                               vector signed short,
14019                               vector unsigned char);
14020 vector unsigned short vec_perm (vector unsigned short,
14021                                 vector unsigned short,
14022                                 vector unsigned char);
14023 vector bool short vec_perm (vector bool short,
14024                             vector bool short,
14025                             vector unsigned char);
14026 vector pixel vec_perm (vector pixel,
14027                        vector pixel,
14028                        vector unsigned char);
14029 vector signed char vec_perm (vector signed char,
14030                              vector signed char,
14031                              vector unsigned char);
14032 vector unsigned char vec_perm (vector unsigned char,
14033                                vector unsigned char,
14034                                vector unsigned char);
14035 vector bool char vec_perm (vector bool char,
14036                            vector bool char,
14037                            vector unsigned char);
14039 vector float vec_re (vector float);
14041 vector signed char vec_rl (vector signed char,
14042                            vector unsigned char);
14043 vector unsigned char vec_rl (vector unsigned char,
14044                              vector unsigned char);
14045 vector signed short vec_rl (vector signed short, vector unsigned short);
14046 vector unsigned short vec_rl (vector unsigned short,
14047                               vector unsigned short);
14048 vector signed int vec_rl (vector signed int, vector unsigned int);
14049 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14051 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14052 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14054 vector signed short vec_vrlh (vector signed short,
14055                               vector unsigned short);
14056 vector unsigned short vec_vrlh (vector unsigned short,
14057                                 vector unsigned short);
14059 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14060 vector unsigned char vec_vrlb (vector unsigned char,
14061                                vector unsigned char);
14063 vector float vec_round (vector float);
14065 vector float vec_recip (vector float, vector float);
14067 vector float vec_rsqrt (vector float);
14069 vector float vec_rsqrte (vector float);
14071 vector float vec_sel (vector float, vector float, vector bool int);
14072 vector float vec_sel (vector float, vector float, vector unsigned int);
14073 vector signed int vec_sel (vector signed int,
14074                            vector signed int,
14075                            vector bool int);
14076 vector signed int vec_sel (vector signed int,
14077                            vector signed int,
14078                            vector unsigned int);
14079 vector unsigned int vec_sel (vector unsigned int,
14080                              vector unsigned int,
14081                              vector bool int);
14082 vector unsigned int vec_sel (vector unsigned int,
14083                              vector unsigned int,
14084                              vector unsigned int);
14085 vector bool int vec_sel (vector bool int,
14086                          vector bool int,
14087                          vector bool int);
14088 vector bool int vec_sel (vector bool int,
14089                          vector bool int,
14090                          vector unsigned int);
14091 vector signed short vec_sel (vector signed short,
14092                              vector signed short,
14093                              vector bool short);
14094 vector signed short vec_sel (vector signed short,
14095                              vector signed short,
14096                              vector unsigned short);
14097 vector unsigned short vec_sel (vector unsigned short,
14098                                vector unsigned short,
14099                                vector bool short);
14100 vector unsigned short vec_sel (vector unsigned short,
14101                                vector unsigned short,
14102                                vector unsigned short);
14103 vector bool short vec_sel (vector bool short,
14104                            vector bool short,
14105                            vector bool short);
14106 vector bool short vec_sel (vector bool short,
14107                            vector bool short,
14108                            vector unsigned short);
14109 vector signed char vec_sel (vector signed char,
14110                             vector signed char,
14111                             vector bool char);
14112 vector signed char vec_sel (vector signed char,
14113                             vector signed char,
14114                             vector unsigned char);
14115 vector unsigned char vec_sel (vector unsigned char,
14116                               vector unsigned char,
14117                               vector bool char);
14118 vector unsigned char vec_sel (vector unsigned char,
14119                               vector unsigned char,
14120                               vector unsigned char);
14121 vector bool char vec_sel (vector bool char,
14122                           vector bool char,
14123                           vector bool char);
14124 vector bool char vec_sel (vector bool char,
14125                           vector bool char,
14126                           vector unsigned char);
14128 vector signed char vec_sl (vector signed char,
14129                            vector unsigned char);
14130 vector unsigned char vec_sl (vector unsigned char,
14131                              vector unsigned char);
14132 vector signed short vec_sl (vector signed short, vector unsigned short);
14133 vector unsigned short vec_sl (vector unsigned short,
14134                               vector unsigned short);
14135 vector signed int vec_sl (vector signed int, vector unsigned int);
14136 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14138 vector signed int vec_vslw (vector signed int, vector unsigned int);
14139 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14141 vector signed short vec_vslh (vector signed short,
14142                               vector unsigned short);
14143 vector unsigned short vec_vslh (vector unsigned short,
14144                                 vector unsigned short);
14146 vector signed char vec_vslb (vector signed char, vector unsigned char);
14147 vector unsigned char vec_vslb (vector unsigned char,
14148                                vector unsigned char);
14150 vector float vec_sld (vector float, vector float, const int);
14151 vector signed int vec_sld (vector signed int,
14152                            vector signed int,
14153                            const int);
14154 vector unsigned int vec_sld (vector unsigned int,
14155                              vector unsigned int,
14156                              const int);
14157 vector bool int vec_sld (vector bool int,
14158                          vector bool int,
14159                          const int);
14160 vector signed short vec_sld (vector signed short,
14161                              vector signed short,
14162                              const int);
14163 vector unsigned short vec_sld (vector unsigned short,
14164                                vector unsigned short,
14165                                const int);
14166 vector bool short vec_sld (vector bool short,
14167                            vector bool short,
14168                            const int);
14169 vector pixel vec_sld (vector pixel,
14170                       vector pixel,
14171                       const int);
14172 vector signed char vec_sld (vector signed char,
14173                             vector signed char,
14174                             const int);
14175 vector unsigned char vec_sld (vector unsigned char,
14176                               vector unsigned char,
14177                               const int);
14178 vector bool char vec_sld (vector bool char,
14179                           vector bool char,
14180                           const int);
14182 vector signed int vec_sll (vector signed int,
14183                            vector unsigned int);
14184 vector signed int vec_sll (vector signed int,
14185                            vector unsigned short);
14186 vector signed int vec_sll (vector signed int,
14187                            vector unsigned char);
14188 vector unsigned int vec_sll (vector unsigned int,
14189                              vector unsigned int);
14190 vector unsigned int vec_sll (vector unsigned int,
14191                              vector unsigned short);
14192 vector unsigned int vec_sll (vector unsigned int,
14193                              vector unsigned char);
14194 vector bool int vec_sll (vector bool int,
14195                          vector unsigned int);
14196 vector bool int vec_sll (vector bool int,
14197                          vector unsigned short);
14198 vector bool int vec_sll (vector bool int,
14199                          vector unsigned char);
14200 vector signed short vec_sll (vector signed short,
14201                              vector unsigned int);
14202 vector signed short vec_sll (vector signed short,
14203                              vector unsigned short);
14204 vector signed short vec_sll (vector signed short,
14205                              vector unsigned char);
14206 vector unsigned short vec_sll (vector unsigned short,
14207                                vector unsigned int);
14208 vector unsigned short vec_sll (vector unsigned short,
14209                                vector unsigned short);
14210 vector unsigned short vec_sll (vector unsigned short,
14211                                vector unsigned char);
14212 vector bool short vec_sll (vector bool short, vector unsigned int);
14213 vector bool short vec_sll (vector bool short, vector unsigned short);
14214 vector bool short vec_sll (vector bool short, vector unsigned char);
14215 vector pixel vec_sll (vector pixel, vector unsigned int);
14216 vector pixel vec_sll (vector pixel, vector unsigned short);
14217 vector pixel vec_sll (vector pixel, vector unsigned char);
14218 vector signed char vec_sll (vector signed char, vector unsigned int);
14219 vector signed char vec_sll (vector signed char, vector unsigned short);
14220 vector signed char vec_sll (vector signed char, vector unsigned char);
14221 vector unsigned char vec_sll (vector unsigned char,
14222                               vector unsigned int);
14223 vector unsigned char vec_sll (vector unsigned char,
14224                               vector unsigned short);
14225 vector unsigned char vec_sll (vector unsigned char,
14226                               vector unsigned char);
14227 vector bool char vec_sll (vector bool char, vector unsigned int);
14228 vector bool char vec_sll (vector bool char, vector unsigned short);
14229 vector bool char vec_sll (vector bool char, vector unsigned char);
14231 vector float vec_slo (vector float, vector signed char);
14232 vector float vec_slo (vector float, vector unsigned char);
14233 vector signed int vec_slo (vector signed int, vector signed char);
14234 vector signed int vec_slo (vector signed int, vector unsigned char);
14235 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14236 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14237 vector signed short vec_slo (vector signed short, vector signed char);
14238 vector signed short vec_slo (vector signed short, vector unsigned char);
14239 vector unsigned short vec_slo (vector unsigned short,
14240                                vector signed char);
14241 vector unsigned short vec_slo (vector unsigned short,
14242                                vector unsigned char);
14243 vector pixel vec_slo (vector pixel, vector signed char);
14244 vector pixel vec_slo (vector pixel, vector unsigned char);
14245 vector signed char vec_slo (vector signed char, vector signed char);
14246 vector signed char vec_slo (vector signed char, vector unsigned char);
14247 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14248 vector unsigned char vec_slo (vector unsigned char,
14249                               vector unsigned char);
14251 vector signed char vec_splat (vector signed char, const int);
14252 vector unsigned char vec_splat (vector unsigned char, const int);
14253 vector bool char vec_splat (vector bool char, const int);
14254 vector signed short vec_splat (vector signed short, const int);
14255 vector unsigned short vec_splat (vector unsigned short, const int);
14256 vector bool short vec_splat (vector bool short, const int);
14257 vector pixel vec_splat (vector pixel, const int);
14258 vector float vec_splat (vector float, const int);
14259 vector signed int vec_splat (vector signed int, const int);
14260 vector unsigned int vec_splat (vector unsigned int, const int);
14261 vector bool int vec_splat (vector bool int, const int);
14262 vector signed long vec_splat (vector signed long, const int);
14263 vector unsigned long vec_splat (vector unsigned long, const int);
14265 vector signed char vec_splats (signed char);
14266 vector unsigned char vec_splats (unsigned char);
14267 vector signed short vec_splats (signed short);
14268 vector unsigned short vec_splats (unsigned short);
14269 vector signed int vec_splats (signed int);
14270 vector unsigned int vec_splats (unsigned int);
14271 vector float vec_splats (float);
14273 vector float vec_vspltw (vector float, const int);
14274 vector signed int vec_vspltw (vector signed int, const int);
14275 vector unsigned int vec_vspltw (vector unsigned int, const int);
14276 vector bool int vec_vspltw (vector bool int, const int);
14278 vector bool short vec_vsplth (vector bool short, const int);
14279 vector signed short vec_vsplth (vector signed short, const int);
14280 vector unsigned short vec_vsplth (vector unsigned short, const int);
14281 vector pixel vec_vsplth (vector pixel, const int);
14283 vector signed char vec_vspltb (vector signed char, const int);
14284 vector unsigned char vec_vspltb (vector unsigned char, const int);
14285 vector bool char vec_vspltb (vector bool char, const int);
14287 vector signed char vec_splat_s8 (const int);
14289 vector signed short vec_splat_s16 (const int);
14291 vector signed int vec_splat_s32 (const int);
14293 vector unsigned char vec_splat_u8 (const int);
14295 vector unsigned short vec_splat_u16 (const int);
14297 vector unsigned int vec_splat_u32 (const int);
14299 vector signed char vec_sr (vector signed char, vector unsigned char);
14300 vector unsigned char vec_sr (vector unsigned char,
14301                              vector unsigned char);
14302 vector signed short vec_sr (vector signed short,
14303                             vector unsigned short);
14304 vector unsigned short vec_sr (vector unsigned short,
14305                               vector unsigned short);
14306 vector signed int vec_sr (vector signed int, vector unsigned int);
14307 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14309 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14310 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14312 vector signed short vec_vsrh (vector signed short,
14313                               vector unsigned short);
14314 vector unsigned short vec_vsrh (vector unsigned short,
14315                                 vector unsigned short);
14317 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14318 vector unsigned char vec_vsrb (vector unsigned char,
14319                                vector unsigned char);
14321 vector signed char vec_sra (vector signed char, vector unsigned char);
14322 vector unsigned char vec_sra (vector unsigned char,
14323                               vector unsigned char);
14324 vector signed short vec_sra (vector signed short,
14325                              vector unsigned short);
14326 vector unsigned short vec_sra (vector unsigned short,
14327                                vector unsigned short);
14328 vector signed int vec_sra (vector signed int, vector unsigned int);
14329 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14331 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14332 vector unsigned int vec_vsraw (vector unsigned int,
14333                                vector unsigned int);
14335 vector signed short vec_vsrah (vector signed short,
14336                                vector unsigned short);
14337 vector unsigned short vec_vsrah (vector unsigned short,
14338                                  vector unsigned short);
14340 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14341 vector unsigned char vec_vsrab (vector unsigned char,
14342                                 vector unsigned char);
14344 vector signed int vec_srl (vector signed int, vector unsigned int);
14345 vector signed int vec_srl (vector signed int, vector unsigned short);
14346 vector signed int vec_srl (vector signed int, vector unsigned char);
14347 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14348 vector unsigned int vec_srl (vector unsigned int,
14349                              vector unsigned short);
14350 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14351 vector bool int vec_srl (vector bool int, vector unsigned int);
14352 vector bool int vec_srl (vector bool int, vector unsigned short);
14353 vector bool int vec_srl (vector bool int, vector unsigned char);
14354 vector signed short vec_srl (vector signed short, vector unsigned int);
14355 vector signed short vec_srl (vector signed short,
14356                              vector unsigned short);
14357 vector signed short vec_srl (vector signed short, vector unsigned char);
14358 vector unsigned short vec_srl (vector unsigned short,
14359                                vector unsigned int);
14360 vector unsigned short vec_srl (vector unsigned short,
14361                                vector unsigned short);
14362 vector unsigned short vec_srl (vector unsigned short,
14363                                vector unsigned char);
14364 vector bool short vec_srl (vector bool short, vector unsigned int);
14365 vector bool short vec_srl (vector bool short, vector unsigned short);
14366 vector bool short vec_srl (vector bool short, vector unsigned char);
14367 vector pixel vec_srl (vector pixel, vector unsigned int);
14368 vector pixel vec_srl (vector pixel, vector unsigned short);
14369 vector pixel vec_srl (vector pixel, vector unsigned char);
14370 vector signed char vec_srl (vector signed char, vector unsigned int);
14371 vector signed char vec_srl (vector signed char, vector unsigned short);
14372 vector signed char vec_srl (vector signed char, vector unsigned char);
14373 vector unsigned char vec_srl (vector unsigned char,
14374                               vector unsigned int);
14375 vector unsigned char vec_srl (vector unsigned char,
14376                               vector unsigned short);
14377 vector unsigned char vec_srl (vector unsigned char,
14378                               vector unsigned char);
14379 vector bool char vec_srl (vector bool char, vector unsigned int);
14380 vector bool char vec_srl (vector bool char, vector unsigned short);
14381 vector bool char vec_srl (vector bool char, vector unsigned char);
14383 vector float vec_sro (vector float, vector signed char);
14384 vector float vec_sro (vector float, vector unsigned char);
14385 vector signed int vec_sro (vector signed int, vector signed char);
14386 vector signed int vec_sro (vector signed int, vector unsigned char);
14387 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14388 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14389 vector signed short vec_sro (vector signed short, vector signed char);
14390 vector signed short vec_sro (vector signed short, vector unsigned char);
14391 vector unsigned short vec_sro (vector unsigned short,
14392                                vector signed char);
14393 vector unsigned short vec_sro (vector unsigned short,
14394                                vector unsigned char);
14395 vector pixel vec_sro (vector pixel, vector signed char);
14396 vector pixel vec_sro (vector pixel, vector unsigned char);
14397 vector signed char vec_sro (vector signed char, vector signed char);
14398 vector signed char vec_sro (vector signed char, vector unsigned char);
14399 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14400 vector unsigned char vec_sro (vector unsigned char,
14401                               vector unsigned char);
14403 void vec_st (vector float, int, vector float *);
14404 void vec_st (vector float, int, float *);
14405 void vec_st (vector signed int, int, vector signed int *);
14406 void vec_st (vector signed int, int, int *);
14407 void vec_st (vector unsigned int, int, vector unsigned int *);
14408 void vec_st (vector unsigned int, int, unsigned int *);
14409 void vec_st (vector bool int, int, vector bool int *);
14410 void vec_st (vector bool int, int, unsigned int *);
14411 void vec_st (vector bool int, int, int *);
14412 void vec_st (vector signed short, int, vector signed short *);
14413 void vec_st (vector signed short, int, short *);
14414 void vec_st (vector unsigned short, int, vector unsigned short *);
14415 void vec_st (vector unsigned short, int, unsigned short *);
14416 void vec_st (vector bool short, int, vector bool short *);
14417 void vec_st (vector bool short, int, unsigned short *);
14418 void vec_st (vector pixel, int, vector pixel *);
14419 void vec_st (vector pixel, int, unsigned short *);
14420 void vec_st (vector pixel, int, short *);
14421 void vec_st (vector bool short, int, short *);
14422 void vec_st (vector signed char, int, vector signed char *);
14423 void vec_st (vector signed char, int, signed char *);
14424 void vec_st (vector unsigned char, int, vector unsigned char *);
14425 void vec_st (vector unsigned char, int, unsigned char *);
14426 void vec_st (vector bool char, int, vector bool char *);
14427 void vec_st (vector bool char, int, unsigned char *);
14428 void vec_st (vector bool char, int, signed char *);
14430 void vec_ste (vector signed char, int, signed char *);
14431 void vec_ste (vector unsigned char, int, unsigned char *);
14432 void vec_ste (vector bool char, int, signed char *);
14433 void vec_ste (vector bool char, int, unsigned char *);
14434 void vec_ste (vector signed short, int, short *);
14435 void vec_ste (vector unsigned short, int, unsigned short *);
14436 void vec_ste (vector bool short, int, short *);
14437 void vec_ste (vector bool short, int, unsigned short *);
14438 void vec_ste (vector pixel, int, short *);
14439 void vec_ste (vector pixel, int, unsigned short *);
14440 void vec_ste (vector float, int, float *);
14441 void vec_ste (vector signed int, int, int *);
14442 void vec_ste (vector unsigned int, int, unsigned int *);
14443 void vec_ste (vector bool int, int, int *);
14444 void vec_ste (vector bool int, int, unsigned int *);
14446 void vec_stvewx (vector float, int, float *);
14447 void vec_stvewx (vector signed int, int, int *);
14448 void vec_stvewx (vector unsigned int, int, unsigned int *);
14449 void vec_stvewx (vector bool int, int, int *);
14450 void vec_stvewx (vector bool int, int, unsigned int *);
14452 void vec_stvehx (vector signed short, int, short *);
14453 void vec_stvehx (vector unsigned short, int, unsigned short *);
14454 void vec_stvehx (vector bool short, int, short *);
14455 void vec_stvehx (vector bool short, int, unsigned short *);
14456 void vec_stvehx (vector pixel, int, short *);
14457 void vec_stvehx (vector pixel, int, unsigned short *);
14459 void vec_stvebx (vector signed char, int, signed char *);
14460 void vec_stvebx (vector unsigned char, int, unsigned char *);
14461 void vec_stvebx (vector bool char, int, signed char *);
14462 void vec_stvebx (vector bool char, int, unsigned char *);
14464 void vec_stl (vector float, int, vector float *);
14465 void vec_stl (vector float, int, float *);
14466 void vec_stl (vector signed int, int, vector signed int *);
14467 void vec_stl (vector signed int, int, int *);
14468 void vec_stl (vector unsigned int, int, vector unsigned int *);
14469 void vec_stl (vector unsigned int, int, unsigned int *);
14470 void vec_stl (vector bool int, int, vector bool int *);
14471 void vec_stl (vector bool int, int, unsigned int *);
14472 void vec_stl (vector bool int, int, int *);
14473 void vec_stl (vector signed short, int, vector signed short *);
14474 void vec_stl (vector signed short, int, short *);
14475 void vec_stl (vector unsigned short, int, vector unsigned short *);
14476 void vec_stl (vector unsigned short, int, unsigned short *);
14477 void vec_stl (vector bool short, int, vector bool short *);
14478 void vec_stl (vector bool short, int, unsigned short *);
14479 void vec_stl (vector bool short, int, short *);
14480 void vec_stl (vector pixel, int, vector pixel *);
14481 void vec_stl (vector pixel, int, unsigned short *);
14482 void vec_stl (vector pixel, int, short *);
14483 void vec_stl (vector signed char, int, vector signed char *);
14484 void vec_stl (vector signed char, int, signed char *);
14485 void vec_stl (vector unsigned char, int, vector unsigned char *);
14486 void vec_stl (vector unsigned char, int, unsigned char *);
14487 void vec_stl (vector bool char, int, vector bool char *);
14488 void vec_stl (vector bool char, int, unsigned char *);
14489 void vec_stl (vector bool char, int, signed char *);
14491 vector signed char vec_sub (vector bool char, vector signed char);
14492 vector signed char vec_sub (vector signed char, vector bool char);
14493 vector signed char vec_sub (vector signed char, vector signed char);
14494 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14495 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14496 vector unsigned char vec_sub (vector unsigned char,
14497                               vector unsigned char);
14498 vector signed short vec_sub (vector bool short, vector signed short);
14499 vector signed short vec_sub (vector signed short, vector bool short);
14500 vector signed short vec_sub (vector signed short, vector signed short);
14501 vector unsigned short vec_sub (vector bool short,
14502                                vector unsigned short);
14503 vector unsigned short vec_sub (vector unsigned short,
14504                                vector bool short);
14505 vector unsigned short vec_sub (vector unsigned short,
14506                                vector unsigned short);
14507 vector signed int vec_sub (vector bool int, vector signed int);
14508 vector signed int vec_sub (vector signed int, vector bool int);
14509 vector signed int vec_sub (vector signed int, vector signed int);
14510 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14511 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14512 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14513 vector float vec_sub (vector float, vector float);
14515 vector float vec_vsubfp (vector float, vector float);
14517 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14518 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14519 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14520 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14521 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14522 vector unsigned int vec_vsubuwm (vector unsigned int,
14523                                  vector unsigned int);
14525 vector signed short vec_vsubuhm (vector bool short,
14526                                  vector signed short);
14527 vector signed short vec_vsubuhm (vector signed short,
14528                                  vector bool short);
14529 vector signed short vec_vsubuhm (vector signed short,
14530                                  vector signed short);
14531 vector unsigned short vec_vsubuhm (vector bool short,
14532                                    vector unsigned short);
14533 vector unsigned short vec_vsubuhm (vector unsigned short,
14534                                    vector bool short);
14535 vector unsigned short vec_vsubuhm (vector unsigned short,
14536                                    vector unsigned short);
14538 vector signed char vec_vsububm (vector bool char, vector signed char);
14539 vector signed char vec_vsububm (vector signed char, vector bool char);
14540 vector signed char vec_vsububm (vector signed char, vector signed char);
14541 vector unsigned char vec_vsububm (vector bool char,
14542                                   vector unsigned char);
14543 vector unsigned char vec_vsububm (vector unsigned char,
14544                                   vector bool char);
14545 vector unsigned char vec_vsububm (vector unsigned char,
14546                                   vector unsigned char);
14548 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14550 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14551 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14552 vector unsigned char vec_subs (vector unsigned char,
14553                                vector unsigned char);
14554 vector signed char vec_subs (vector bool char, vector signed char);
14555 vector signed char vec_subs (vector signed char, vector bool char);
14556 vector signed char vec_subs (vector signed char, vector signed char);
14557 vector unsigned short vec_subs (vector bool short,
14558                                 vector unsigned short);
14559 vector unsigned short vec_subs (vector unsigned short,
14560                                 vector bool short);
14561 vector unsigned short vec_subs (vector unsigned short,
14562                                 vector unsigned short);
14563 vector signed short vec_subs (vector bool short, vector signed short);
14564 vector signed short vec_subs (vector signed short, vector bool short);
14565 vector signed short vec_subs (vector signed short, vector signed short);
14566 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14567 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14568 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14569 vector signed int vec_subs (vector bool int, vector signed int);
14570 vector signed int vec_subs (vector signed int, vector bool int);
14571 vector signed int vec_subs (vector signed int, vector signed int);
14573 vector signed int vec_vsubsws (vector bool int, vector signed int);
14574 vector signed int vec_vsubsws (vector signed int, vector bool int);
14575 vector signed int vec_vsubsws (vector signed int, vector signed int);
14577 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14578 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
14579 vector unsigned int vec_vsubuws (vector unsigned int,
14580                                  vector unsigned int);
14582 vector signed short vec_vsubshs (vector bool short,
14583                                  vector signed short);
14584 vector signed short vec_vsubshs (vector signed short,
14585                                  vector bool short);
14586 vector signed short vec_vsubshs (vector signed short,
14587                                  vector signed short);
14589 vector unsigned short vec_vsubuhs (vector bool short,
14590                                    vector unsigned short);
14591 vector unsigned short vec_vsubuhs (vector unsigned short,
14592                                    vector bool short);
14593 vector unsigned short vec_vsubuhs (vector unsigned short,
14594                                    vector unsigned short);
14596 vector signed char vec_vsubsbs (vector bool char, vector signed char);
14597 vector signed char vec_vsubsbs (vector signed char, vector bool char);
14598 vector signed char vec_vsubsbs (vector signed char, vector signed char);
14600 vector unsigned char vec_vsububs (vector bool char,
14601                                   vector unsigned char);
14602 vector unsigned char vec_vsububs (vector unsigned char,
14603                                   vector bool char);
14604 vector unsigned char vec_vsububs (vector unsigned char,
14605                                   vector unsigned char);
14607 vector unsigned int vec_sum4s (vector unsigned char,
14608                                vector unsigned int);
14609 vector signed int vec_sum4s (vector signed char, vector signed int);
14610 vector signed int vec_sum4s (vector signed short, vector signed int);
14612 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14614 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14616 vector unsigned int vec_vsum4ubs (vector unsigned char,
14617                                   vector unsigned int);
14619 vector signed int vec_sum2s (vector signed int, vector signed int);
14621 vector signed int vec_sums (vector signed int, vector signed int);
14623 vector float vec_trunc (vector float);
14625 vector signed short vec_unpackh (vector signed char);
14626 vector bool short vec_unpackh (vector bool char);
14627 vector signed int vec_unpackh (vector signed short);
14628 vector bool int vec_unpackh (vector bool short);
14629 vector unsigned int vec_unpackh (vector pixel);
14631 vector bool int vec_vupkhsh (vector bool short);
14632 vector signed int vec_vupkhsh (vector signed short);
14634 vector unsigned int vec_vupkhpx (vector pixel);
14636 vector bool short vec_vupkhsb (vector bool char);
14637 vector signed short vec_vupkhsb (vector signed char);
14639 vector signed short vec_unpackl (vector signed char);
14640 vector bool short vec_unpackl (vector bool char);
14641 vector unsigned int vec_unpackl (vector pixel);
14642 vector signed int vec_unpackl (vector signed short);
14643 vector bool int vec_unpackl (vector bool short);
14645 vector unsigned int vec_vupklpx (vector pixel);
14647 vector bool int vec_vupklsh (vector bool short);
14648 vector signed int vec_vupklsh (vector signed short);
14650 vector bool short vec_vupklsb (vector bool char);
14651 vector signed short vec_vupklsb (vector signed char);
14653 vector float vec_xor (vector float, vector float);
14654 vector float vec_xor (vector float, vector bool int);
14655 vector float vec_xor (vector bool int, vector float);
14656 vector bool int vec_xor (vector bool int, vector bool int);
14657 vector signed int vec_xor (vector bool int, vector signed int);
14658 vector signed int vec_xor (vector signed int, vector bool int);
14659 vector signed int vec_xor (vector signed int, vector signed int);
14660 vector unsigned int vec_xor (vector bool int, vector unsigned int);
14661 vector unsigned int vec_xor (vector unsigned int, vector bool int);
14662 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
14663 vector bool short vec_xor (vector bool short, vector bool short);
14664 vector signed short vec_xor (vector bool short, vector signed short);
14665 vector signed short vec_xor (vector signed short, vector bool short);
14666 vector signed short vec_xor (vector signed short, vector signed short);
14667 vector unsigned short vec_xor (vector bool short,
14668                                vector unsigned short);
14669 vector unsigned short vec_xor (vector unsigned short,
14670                                vector bool short);
14671 vector unsigned short vec_xor (vector unsigned short,
14672                                vector unsigned short);
14673 vector signed char vec_xor (vector bool char, vector signed char);
14674 vector bool char vec_xor (vector bool char, vector bool char);
14675 vector signed char vec_xor (vector signed char, vector bool char);
14676 vector signed char vec_xor (vector signed char, vector signed char);
14677 vector unsigned char vec_xor (vector bool char, vector unsigned char);
14678 vector unsigned char vec_xor (vector unsigned char, vector bool char);
14679 vector unsigned char vec_xor (vector unsigned char,
14680                               vector unsigned char);
14682 int vec_all_eq (vector signed char, vector bool char);
14683 int vec_all_eq (vector signed char, vector signed char);
14684 int vec_all_eq (vector unsigned char, vector bool char);
14685 int vec_all_eq (vector unsigned char, vector unsigned char);
14686 int vec_all_eq (vector bool char, vector bool char);
14687 int vec_all_eq (vector bool char, vector unsigned char);
14688 int vec_all_eq (vector bool char, vector signed char);
14689 int vec_all_eq (vector signed short, vector bool short);
14690 int vec_all_eq (vector signed short, vector signed short);
14691 int vec_all_eq (vector unsigned short, vector bool short);
14692 int vec_all_eq (vector unsigned short, vector unsigned short);
14693 int vec_all_eq (vector bool short, vector bool short);
14694 int vec_all_eq (vector bool short, vector unsigned short);
14695 int vec_all_eq (vector bool short, vector signed short);
14696 int vec_all_eq (vector pixel, vector pixel);
14697 int vec_all_eq (vector signed int, vector bool int);
14698 int vec_all_eq (vector signed int, vector signed int);
14699 int vec_all_eq (vector unsigned int, vector bool int);
14700 int vec_all_eq (vector unsigned int, vector unsigned int);
14701 int vec_all_eq (vector bool int, vector bool int);
14702 int vec_all_eq (vector bool int, vector unsigned int);
14703 int vec_all_eq (vector bool int, vector signed int);
14704 int vec_all_eq (vector float, vector float);
14706 int vec_all_ge (vector bool char, vector unsigned char);
14707 int vec_all_ge (vector unsigned char, vector bool char);
14708 int vec_all_ge (vector unsigned char, vector unsigned char);
14709 int vec_all_ge (vector bool char, vector signed char);
14710 int vec_all_ge (vector signed char, vector bool char);
14711 int vec_all_ge (vector signed char, vector signed char);
14712 int vec_all_ge (vector bool short, vector unsigned short);
14713 int vec_all_ge (vector unsigned short, vector bool short);
14714 int vec_all_ge (vector unsigned short, vector unsigned short);
14715 int vec_all_ge (vector signed short, vector signed short);
14716 int vec_all_ge (vector bool short, vector signed short);
14717 int vec_all_ge (vector signed short, vector bool short);
14718 int vec_all_ge (vector bool int, vector unsigned int);
14719 int vec_all_ge (vector unsigned int, vector bool int);
14720 int vec_all_ge (vector unsigned int, vector unsigned int);
14721 int vec_all_ge (vector bool int, vector signed int);
14722 int vec_all_ge (vector signed int, vector bool int);
14723 int vec_all_ge (vector signed int, vector signed int);
14724 int vec_all_ge (vector float, vector float);
14726 int vec_all_gt (vector bool char, vector unsigned char);
14727 int vec_all_gt (vector unsigned char, vector bool char);
14728 int vec_all_gt (vector unsigned char, vector unsigned char);
14729 int vec_all_gt (vector bool char, vector signed char);
14730 int vec_all_gt (vector signed char, vector bool char);
14731 int vec_all_gt (vector signed char, vector signed char);
14732 int vec_all_gt (vector bool short, vector unsigned short);
14733 int vec_all_gt (vector unsigned short, vector bool short);
14734 int vec_all_gt (vector unsigned short, vector unsigned short);
14735 int vec_all_gt (vector bool short, vector signed short);
14736 int vec_all_gt (vector signed short, vector bool short);
14737 int vec_all_gt (vector signed short, vector signed short);
14738 int vec_all_gt (vector bool int, vector unsigned int);
14739 int vec_all_gt (vector unsigned int, vector bool int);
14740 int vec_all_gt (vector unsigned int, vector unsigned int);
14741 int vec_all_gt (vector bool int, vector signed int);
14742 int vec_all_gt (vector signed int, vector bool int);
14743 int vec_all_gt (vector signed int, vector signed int);
14744 int vec_all_gt (vector float, vector float);
14746 int vec_all_in (vector float, vector float);
14748 int vec_all_le (vector bool char, vector unsigned char);
14749 int vec_all_le (vector unsigned char, vector bool char);
14750 int vec_all_le (vector unsigned char, vector unsigned char);
14751 int vec_all_le (vector bool char, vector signed char);
14752 int vec_all_le (vector signed char, vector bool char);
14753 int vec_all_le (vector signed char, vector signed char);
14754 int vec_all_le (vector bool short, vector unsigned short);
14755 int vec_all_le (vector unsigned short, vector bool short);
14756 int vec_all_le (vector unsigned short, vector unsigned short);
14757 int vec_all_le (vector bool short, vector signed short);
14758 int vec_all_le (vector signed short, vector bool short);
14759 int vec_all_le (vector signed short, vector signed short);
14760 int vec_all_le (vector bool int, vector unsigned int);
14761 int vec_all_le (vector unsigned int, vector bool int);
14762 int vec_all_le (vector unsigned int, vector unsigned int);
14763 int vec_all_le (vector bool int, vector signed int);
14764 int vec_all_le (vector signed int, vector bool int);
14765 int vec_all_le (vector signed int, vector signed int);
14766 int vec_all_le (vector float, vector float);
14768 int vec_all_lt (vector bool char, vector unsigned char);
14769 int vec_all_lt (vector unsigned char, vector bool char);
14770 int vec_all_lt (vector unsigned char, vector unsigned char);
14771 int vec_all_lt (vector bool char, vector signed char);
14772 int vec_all_lt (vector signed char, vector bool char);
14773 int vec_all_lt (vector signed char, vector signed char);
14774 int vec_all_lt (vector bool short, vector unsigned short);
14775 int vec_all_lt (vector unsigned short, vector bool short);
14776 int vec_all_lt (vector unsigned short, vector unsigned short);
14777 int vec_all_lt (vector bool short, vector signed short);
14778 int vec_all_lt (vector signed short, vector bool short);
14779 int vec_all_lt (vector signed short, vector signed short);
14780 int vec_all_lt (vector bool int, vector unsigned int);
14781 int vec_all_lt (vector unsigned int, vector bool int);
14782 int vec_all_lt (vector unsigned int, vector unsigned int);
14783 int vec_all_lt (vector bool int, vector signed int);
14784 int vec_all_lt (vector signed int, vector bool int);
14785 int vec_all_lt (vector signed int, vector signed int);
14786 int vec_all_lt (vector float, vector float);
14788 int vec_all_nan (vector float);
14790 int vec_all_ne (vector signed char, vector bool char);
14791 int vec_all_ne (vector signed char, vector signed char);
14792 int vec_all_ne (vector unsigned char, vector bool char);
14793 int vec_all_ne (vector unsigned char, vector unsigned char);
14794 int vec_all_ne (vector bool char, vector bool char);
14795 int vec_all_ne (vector bool char, vector unsigned char);
14796 int vec_all_ne (vector bool char, vector signed char);
14797 int vec_all_ne (vector signed short, vector bool short);
14798 int vec_all_ne (vector signed short, vector signed short);
14799 int vec_all_ne (vector unsigned short, vector bool short);
14800 int vec_all_ne (vector unsigned short, vector unsigned short);
14801 int vec_all_ne (vector bool short, vector bool short);
14802 int vec_all_ne (vector bool short, vector unsigned short);
14803 int vec_all_ne (vector bool short, vector signed short);
14804 int vec_all_ne (vector pixel, vector pixel);
14805 int vec_all_ne (vector signed int, vector bool int);
14806 int vec_all_ne (vector signed int, vector signed int);
14807 int vec_all_ne (vector unsigned int, vector bool int);
14808 int vec_all_ne (vector unsigned int, vector unsigned int);
14809 int vec_all_ne (vector bool int, vector bool int);
14810 int vec_all_ne (vector bool int, vector unsigned int);
14811 int vec_all_ne (vector bool int, vector signed int);
14812 int vec_all_ne (vector float, vector float);
14814 int vec_all_nge (vector float, vector float);
14816 int vec_all_ngt (vector float, vector float);
14818 int vec_all_nle (vector float, vector float);
14820 int vec_all_nlt (vector float, vector float);
14822 int vec_all_numeric (vector float);
14824 int vec_any_eq (vector signed char, vector bool char);
14825 int vec_any_eq (vector signed char, vector signed char);
14826 int vec_any_eq (vector unsigned char, vector bool char);
14827 int vec_any_eq (vector unsigned char, vector unsigned char);
14828 int vec_any_eq (vector bool char, vector bool char);
14829 int vec_any_eq (vector bool char, vector unsigned char);
14830 int vec_any_eq (vector bool char, vector signed char);
14831 int vec_any_eq (vector signed short, vector bool short);
14832 int vec_any_eq (vector signed short, vector signed short);
14833 int vec_any_eq (vector unsigned short, vector bool short);
14834 int vec_any_eq (vector unsigned short, vector unsigned short);
14835 int vec_any_eq (vector bool short, vector bool short);
14836 int vec_any_eq (vector bool short, vector unsigned short);
14837 int vec_any_eq (vector bool short, vector signed short);
14838 int vec_any_eq (vector pixel, vector pixel);
14839 int vec_any_eq (vector signed int, vector bool int);
14840 int vec_any_eq (vector signed int, vector signed int);
14841 int vec_any_eq (vector unsigned int, vector bool int);
14842 int vec_any_eq (vector unsigned int, vector unsigned int);
14843 int vec_any_eq (vector bool int, vector bool int);
14844 int vec_any_eq (vector bool int, vector unsigned int);
14845 int vec_any_eq (vector bool int, vector signed int);
14846 int vec_any_eq (vector float, vector float);
14848 int vec_any_ge (vector signed char, vector bool char);
14849 int vec_any_ge (vector unsigned char, vector bool char);
14850 int vec_any_ge (vector unsigned char, vector unsigned char);
14851 int vec_any_ge (vector signed char, vector signed char);
14852 int vec_any_ge (vector bool char, vector unsigned char);
14853 int vec_any_ge (vector bool char, vector signed char);
14854 int vec_any_ge (vector unsigned short, vector bool short);
14855 int vec_any_ge (vector unsigned short, vector unsigned short);
14856 int vec_any_ge (vector signed short, vector signed short);
14857 int vec_any_ge (vector signed short, vector bool short);
14858 int vec_any_ge (vector bool short, vector unsigned short);
14859 int vec_any_ge (vector bool short, vector signed short);
14860 int vec_any_ge (vector signed int, vector bool int);
14861 int vec_any_ge (vector unsigned int, vector bool int);
14862 int vec_any_ge (vector unsigned int, vector unsigned int);
14863 int vec_any_ge (vector signed int, vector signed int);
14864 int vec_any_ge (vector bool int, vector unsigned int);
14865 int vec_any_ge (vector bool int, vector signed int);
14866 int vec_any_ge (vector float, vector float);
14868 int vec_any_gt (vector bool char, vector unsigned char);
14869 int vec_any_gt (vector unsigned char, vector bool char);
14870 int vec_any_gt (vector unsigned char, vector unsigned char);
14871 int vec_any_gt (vector bool char, vector signed char);
14872 int vec_any_gt (vector signed char, vector bool char);
14873 int vec_any_gt (vector signed char, vector signed char);
14874 int vec_any_gt (vector bool short, vector unsigned short);
14875 int vec_any_gt (vector unsigned short, vector bool short);
14876 int vec_any_gt (vector unsigned short, vector unsigned short);
14877 int vec_any_gt (vector bool short, vector signed short);
14878 int vec_any_gt (vector signed short, vector bool short);
14879 int vec_any_gt (vector signed short, vector signed short);
14880 int vec_any_gt (vector bool int, vector unsigned int);
14881 int vec_any_gt (vector unsigned int, vector bool int);
14882 int vec_any_gt (vector unsigned int, vector unsigned int);
14883 int vec_any_gt (vector bool int, vector signed int);
14884 int vec_any_gt (vector signed int, vector bool int);
14885 int vec_any_gt (vector signed int, vector signed int);
14886 int vec_any_gt (vector float, vector float);
14888 int vec_any_le (vector bool char, vector unsigned char);
14889 int vec_any_le (vector unsigned char, vector bool char);
14890 int vec_any_le (vector unsigned char, vector unsigned char);
14891 int vec_any_le (vector bool char, vector signed char);
14892 int vec_any_le (vector signed char, vector bool char);
14893 int vec_any_le (vector signed char, vector signed char);
14894 int vec_any_le (vector bool short, vector unsigned short);
14895 int vec_any_le (vector unsigned short, vector bool short);
14896 int vec_any_le (vector unsigned short, vector unsigned short);
14897 int vec_any_le (vector bool short, vector signed short);
14898 int vec_any_le (vector signed short, vector bool short);
14899 int vec_any_le (vector signed short, vector signed short);
14900 int vec_any_le (vector bool int, vector unsigned int);
14901 int vec_any_le (vector unsigned int, vector bool int);
14902 int vec_any_le (vector unsigned int, vector unsigned int);
14903 int vec_any_le (vector bool int, vector signed int);
14904 int vec_any_le (vector signed int, vector bool int);
14905 int vec_any_le (vector signed int, vector signed int);
14906 int vec_any_le (vector float, vector float);
14908 int vec_any_lt (vector bool char, vector unsigned char);
14909 int vec_any_lt (vector unsigned char, vector bool char);
14910 int vec_any_lt (vector unsigned char, vector unsigned char);
14911 int vec_any_lt (vector bool char, vector signed char);
14912 int vec_any_lt (vector signed char, vector bool char);
14913 int vec_any_lt (vector signed char, vector signed char);
14914 int vec_any_lt (vector bool short, vector unsigned short);
14915 int vec_any_lt (vector unsigned short, vector bool short);
14916 int vec_any_lt (vector unsigned short, vector unsigned short);
14917 int vec_any_lt (vector bool short, vector signed short);
14918 int vec_any_lt (vector signed short, vector bool short);
14919 int vec_any_lt (vector signed short, vector signed short);
14920 int vec_any_lt (vector bool int, vector unsigned int);
14921 int vec_any_lt (vector unsigned int, vector bool int);
14922 int vec_any_lt (vector unsigned int, vector unsigned int);
14923 int vec_any_lt (vector bool int, vector signed int);
14924 int vec_any_lt (vector signed int, vector bool int);
14925 int vec_any_lt (vector signed int, vector signed int);
14926 int vec_any_lt (vector float, vector float);
14928 int vec_any_nan (vector float);
14930 int vec_any_ne (vector signed char, vector bool char);
14931 int vec_any_ne (vector signed char, vector signed char);
14932 int vec_any_ne (vector unsigned char, vector bool char);
14933 int vec_any_ne (vector unsigned char, vector unsigned char);
14934 int vec_any_ne (vector bool char, vector bool char);
14935 int vec_any_ne (vector bool char, vector unsigned char);
14936 int vec_any_ne (vector bool char, vector signed char);
14937 int vec_any_ne (vector signed short, vector bool short);
14938 int vec_any_ne (vector signed short, vector signed short);
14939 int vec_any_ne (vector unsigned short, vector bool short);
14940 int vec_any_ne (vector unsigned short, vector unsigned short);
14941 int vec_any_ne (vector bool short, vector bool short);
14942 int vec_any_ne (vector bool short, vector unsigned short);
14943 int vec_any_ne (vector bool short, vector signed short);
14944 int vec_any_ne (vector pixel, vector pixel);
14945 int vec_any_ne (vector signed int, vector bool int);
14946 int vec_any_ne (vector signed int, vector signed int);
14947 int vec_any_ne (vector unsigned int, vector bool int);
14948 int vec_any_ne (vector unsigned int, vector unsigned int);
14949 int vec_any_ne (vector bool int, vector bool int);
14950 int vec_any_ne (vector bool int, vector unsigned int);
14951 int vec_any_ne (vector bool int, vector signed int);
14952 int vec_any_ne (vector float, vector float);
14954 int vec_any_nge (vector float, vector float);
14956 int vec_any_ngt (vector float, vector float);
14958 int vec_any_nle (vector float, vector float);
14960 int vec_any_nlt (vector float, vector float);
14962 int vec_any_numeric (vector float);
14964 int vec_any_out (vector float, vector float);
14965 @end smallexample
14967 If the vector/scalar (VSX) instruction set is available, the following
14968 additional functions are available:
14970 @smallexample
14971 vector double vec_abs (vector double);
14972 vector double vec_add (vector double, vector double);
14973 vector double vec_and (vector double, vector double);
14974 vector double vec_and (vector double, vector bool long);
14975 vector double vec_and (vector bool long, vector double);
14976 vector long vec_and (vector long, vector long);
14977 vector long vec_and (vector long, vector bool long);
14978 vector long vec_and (vector bool long, vector long);
14979 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
14980 vector unsigned long vec_and (vector unsigned long, vector bool long);
14981 vector unsigned long vec_and (vector bool long, vector unsigned long);
14982 vector double vec_andc (vector double, vector double);
14983 vector double vec_andc (vector double, vector bool long);
14984 vector double vec_andc (vector bool long, vector double);
14985 vector long vec_andc (vector long, vector long);
14986 vector long vec_andc (vector long, vector bool long);
14987 vector long vec_andc (vector bool long, vector long);
14988 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
14989 vector unsigned long vec_andc (vector unsigned long, vector bool long);
14990 vector unsigned long vec_andc (vector bool long, vector unsigned long);
14991 vector double vec_ceil (vector double);
14992 vector bool long vec_cmpeq (vector double, vector double);
14993 vector bool long vec_cmpge (vector double, vector double);
14994 vector bool long vec_cmpgt (vector double, vector double);
14995 vector bool long vec_cmple (vector double, vector double);
14996 vector bool long vec_cmplt (vector double, vector double);
14997 vector double vec_cpsgn (vector double, vector double);
14998 vector float vec_div (vector float, vector float);
14999 vector double vec_div (vector double, vector double);
15000 vector long vec_div (vector long, vector long);
15001 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15002 vector double vec_floor (vector double);
15003 vector double vec_ld (int, const vector double *);
15004 vector double vec_ld (int, const double *);
15005 vector double vec_ldl (int, const vector double *);
15006 vector double vec_ldl (int, const double *);
15007 vector unsigned char vec_lvsl (int, const volatile double *);
15008 vector unsigned char vec_lvsr (int, const volatile double *);
15009 vector double vec_madd (vector double, vector double, vector double);
15010 vector double vec_max (vector double, vector double);
15011 vector signed long vec_mergeh (vector signed long, vector signed long);
15012 vector signed long vec_mergeh (vector signed long, vector bool long);
15013 vector signed long vec_mergeh (vector bool long, vector signed long);
15014 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15015 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15016 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15017 vector signed long vec_mergel (vector signed long, vector signed long);
15018 vector signed long vec_mergel (vector signed long, vector bool long);
15019 vector signed long vec_mergel (vector bool long, vector signed long);
15020 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15021 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15022 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15023 vector double vec_min (vector double, vector double);
15024 vector float vec_msub (vector float, vector float, vector float);
15025 vector double vec_msub (vector double, vector double, vector double);
15026 vector float vec_mul (vector float, vector float);
15027 vector double vec_mul (vector double, vector double);
15028 vector long vec_mul (vector long, vector long);
15029 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15030 vector float vec_nearbyint (vector float);
15031 vector double vec_nearbyint (vector double);
15032 vector float vec_nmadd (vector float, vector float, vector float);
15033 vector double vec_nmadd (vector double, vector double, vector double);
15034 vector double vec_nmsub (vector double, vector double, vector double);
15035 vector double vec_nor (vector double, vector double);
15036 vector long vec_nor (vector long, vector long);
15037 vector long vec_nor (vector long, vector bool long);
15038 vector long vec_nor (vector bool long, vector long);
15039 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15040 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15041 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15042 vector double vec_or (vector double, vector double);
15043 vector double vec_or (vector double, vector bool long);
15044 vector double vec_or (vector bool long, vector double);
15045 vector long vec_or (vector long, vector long);
15046 vector long vec_or (vector long, vector bool long);
15047 vector long vec_or (vector bool long, vector long);
15048 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15049 vector unsigned long vec_or (vector unsigned long, vector bool long);
15050 vector unsigned long vec_or (vector bool long, vector unsigned long);
15051 vector double vec_perm (vector double, vector double, vector unsigned char);
15052 vector long vec_perm (vector long, vector long, vector unsigned char);
15053 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15054                                vector unsigned char);
15055 vector double vec_rint (vector double);
15056 vector double vec_recip (vector double, vector double);
15057 vector double vec_rsqrt (vector double);
15058 vector double vec_rsqrte (vector double);
15059 vector double vec_sel (vector double, vector double, vector bool long);
15060 vector double vec_sel (vector double, vector double, vector unsigned long);
15061 vector long vec_sel (vector long, vector long, vector long);
15062 vector long vec_sel (vector long, vector long, vector unsigned long);
15063 vector long vec_sel (vector long, vector long, vector bool long);
15064 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15065                               vector long);
15066 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15067                               vector unsigned long);
15068 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15069                               vector bool long);
15070 vector double vec_splats (double);
15071 vector signed long vec_splats (signed long);
15072 vector unsigned long vec_splats (unsigned long);
15073 vector float vec_sqrt (vector float);
15074 vector double vec_sqrt (vector double);
15075 void vec_st (vector double, int, vector double *);
15076 void vec_st (vector double, int, double *);
15077 vector double vec_sub (vector double, vector double);
15078 vector double vec_trunc (vector double);
15079 vector double vec_xor (vector double, vector double);
15080 vector double vec_xor (vector double, vector bool long);
15081 vector double vec_xor (vector bool long, vector double);
15082 vector long vec_xor (vector long, vector long);
15083 vector long vec_xor (vector long, vector bool long);
15084 vector long vec_xor (vector bool long, vector long);
15085 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15086 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15087 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15088 int vec_all_eq (vector double, vector double);
15089 int vec_all_ge (vector double, vector double);
15090 int vec_all_gt (vector double, vector double);
15091 int vec_all_le (vector double, vector double);
15092 int vec_all_lt (vector double, vector double);
15093 int vec_all_nan (vector double);
15094 int vec_all_ne (vector double, vector double);
15095 int vec_all_nge (vector double, vector double);
15096 int vec_all_ngt (vector double, vector double);
15097 int vec_all_nle (vector double, vector double);
15098 int vec_all_nlt (vector double, vector double);
15099 int vec_all_numeric (vector double);
15100 int vec_any_eq (vector double, vector double);
15101 int vec_any_ge (vector double, vector double);
15102 int vec_any_gt (vector double, vector double);
15103 int vec_any_le (vector double, vector double);
15104 int vec_any_lt (vector double, vector double);
15105 int vec_any_nan (vector double);
15106 int vec_any_ne (vector double, vector double);
15107 int vec_any_nge (vector double, vector double);
15108 int vec_any_ngt (vector double, vector double);
15109 int vec_any_nle (vector double, vector double);
15110 int vec_any_nlt (vector double, vector double);
15111 int vec_any_numeric (vector double);
15113 vector double vec_vsx_ld (int, const vector double *);
15114 vector double vec_vsx_ld (int, const double *);
15115 vector float vec_vsx_ld (int, const vector float *);
15116 vector float vec_vsx_ld (int, const float *);
15117 vector bool int vec_vsx_ld (int, const vector bool int *);
15118 vector signed int vec_vsx_ld (int, const vector signed int *);
15119 vector signed int vec_vsx_ld (int, const int *);
15120 vector signed int vec_vsx_ld (int, const long *);
15121 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15122 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15123 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15124 vector bool short vec_vsx_ld (int, const vector bool short *);
15125 vector pixel vec_vsx_ld (int, const vector pixel *);
15126 vector signed short vec_vsx_ld (int, const vector signed short *);
15127 vector signed short vec_vsx_ld (int, const short *);
15128 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15129 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15130 vector bool char vec_vsx_ld (int, const vector bool char *);
15131 vector signed char vec_vsx_ld (int, const vector signed char *);
15132 vector signed char vec_vsx_ld (int, const signed char *);
15133 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15134 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15136 void vec_vsx_st (vector double, int, vector double *);
15137 void vec_vsx_st (vector double, int, double *);
15138 void vec_vsx_st (vector float, int, vector float *);
15139 void vec_vsx_st (vector float, int, float *);
15140 void vec_vsx_st (vector signed int, int, vector signed int *);
15141 void vec_vsx_st (vector signed int, int, int *);
15142 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15143 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15144 void vec_vsx_st (vector bool int, int, vector bool int *);
15145 void vec_vsx_st (vector bool int, int, unsigned int *);
15146 void vec_vsx_st (vector bool int, int, int *);
15147 void vec_vsx_st (vector signed short, int, vector signed short *);
15148 void vec_vsx_st (vector signed short, int, short *);
15149 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15150 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15151 void vec_vsx_st (vector bool short, int, vector bool short *);
15152 void vec_vsx_st (vector bool short, int, unsigned short *);
15153 void vec_vsx_st (vector pixel, int, vector pixel *);
15154 void vec_vsx_st (vector pixel, int, unsigned short *);
15155 void vec_vsx_st (vector pixel, int, short *);
15156 void vec_vsx_st (vector bool short, int, short *);
15157 void vec_vsx_st (vector signed char, int, vector signed char *);
15158 void vec_vsx_st (vector signed char, int, signed char *);
15159 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15160 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15161 void vec_vsx_st (vector bool char, int, vector bool char *);
15162 void vec_vsx_st (vector bool char, int, unsigned char *);
15163 void vec_vsx_st (vector bool char, int, signed char *);
15165 vector double vec_xxpermdi (vector double, vector double, int);
15166 vector float vec_xxpermdi (vector float, vector float, int);
15167 vector long long vec_xxpermdi (vector long long, vector long long, int);
15168 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15169                                         vector unsigned long long, int);
15170 vector int vec_xxpermdi (vector int, vector int, int);
15171 vector unsigned int vec_xxpermdi (vector unsigned int,
15172                                   vector unsigned int, int);
15173 vector short vec_xxpermdi (vector short, vector short, int);
15174 vector unsigned short vec_xxpermdi (vector unsigned short,
15175                                     vector unsigned short, int);
15176 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15177 vector unsigned char vec_xxpermdi (vector unsigned char,
15178                                    vector unsigned char, int);
15180 vector double vec_xxsldi (vector double, vector double, int);
15181 vector float vec_xxsldi (vector float, vector float, int);
15182 vector long long vec_xxsldi (vector long long, vector long long, int);
15183 vector unsigned long long vec_xxsldi (vector unsigned long long,
15184                                       vector unsigned long long, int);
15185 vector int vec_xxsldi (vector int, vector int, int);
15186 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15187 vector short vec_xxsldi (vector short, vector short, int);
15188 vector unsigned short vec_xxsldi (vector unsigned short,
15189                                   vector unsigned short, int);
15190 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15191 vector unsigned char vec_xxsldi (vector unsigned char,
15192                                  vector unsigned char, int);
15193 @end smallexample
15195 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15196 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15197 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
15198 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15199 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15201 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15202 instruction set is available, the following additional functions are
15203 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
15204 can use @var{vector long} instead of @var{vector long long},
15205 @var{vector bool long} instead of @var{vector bool long long}, and
15206 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15208 @smallexample
15209 vector long long vec_abs (vector long long);
15211 vector long long vec_add (vector long long, vector long long);
15212 vector unsigned long long vec_add (vector unsigned long long,
15213                                    vector unsigned long long);
15215 int vec_all_eq (vector long long, vector long long);
15216 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15217 int vec_all_ge (vector long long, vector long long);
15218 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15219 int vec_all_gt (vector long long, vector long long);
15220 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15221 int vec_all_le (vector long long, vector long long);
15222 int vec_all_le (vector unsigned long long, vector unsigned long long);
15223 int vec_all_lt (vector long long, vector long long);
15224 int vec_all_lt (vector unsigned long long, vector unsigned long long);
15225 int vec_all_ne (vector long long, vector long long);
15226 int vec_all_ne (vector unsigned long long, vector unsigned long long);
15228 int vec_any_eq (vector long long, vector long long);
15229 int vec_any_eq (vector unsigned long long, vector unsigned long long);
15230 int vec_any_ge (vector long long, vector long long);
15231 int vec_any_ge (vector unsigned long long, vector unsigned long long);
15232 int vec_any_gt (vector long long, vector long long);
15233 int vec_any_gt (vector unsigned long long, vector unsigned long long);
15234 int vec_any_le (vector long long, vector long long);
15235 int vec_any_le (vector unsigned long long, vector unsigned long long);
15236 int vec_any_lt (vector long long, vector long long);
15237 int vec_any_lt (vector unsigned long long, vector unsigned long long);
15238 int vec_any_ne (vector long long, vector long long);
15239 int vec_any_ne (vector unsigned long long, vector unsigned long long);
15241 vector long long vec_eqv (vector long long, vector long long);
15242 vector long long vec_eqv (vector bool long long, vector long long);
15243 vector long long vec_eqv (vector long long, vector bool long long);
15244 vector unsigned long long vec_eqv (vector unsigned long long,
15245                                    vector unsigned long long);
15246 vector unsigned long long vec_eqv (vector bool long long,
15247                                    vector unsigned long long);
15248 vector unsigned long long vec_eqv (vector unsigned long long,
15249                                    vector bool long long);
15250 vector int vec_eqv (vector int, vector int);
15251 vector int vec_eqv (vector bool int, vector int);
15252 vector int vec_eqv (vector int, vector bool int);
15253 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15254 vector unsigned int vec_eqv (vector bool unsigned int,
15255                              vector unsigned int);
15256 vector unsigned int vec_eqv (vector unsigned int,
15257                              vector bool unsigned int);
15258 vector short vec_eqv (vector short, vector short);
15259 vector short vec_eqv (vector bool short, vector short);
15260 vector short vec_eqv (vector short, vector bool short);
15261 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15262 vector unsigned short vec_eqv (vector bool unsigned short,
15263                                vector unsigned short);
15264 vector unsigned short vec_eqv (vector unsigned short,
15265                                vector bool unsigned short);
15266 vector signed char vec_eqv (vector signed char, vector signed char);
15267 vector signed char vec_eqv (vector bool signed char, vector signed char);
15268 vector signed char vec_eqv (vector signed char, vector bool signed char);
15269 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15270 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15271 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15273 vector long long vec_max (vector long long, vector long long);
15274 vector unsigned long long vec_max (vector unsigned long long,
15275                                    vector unsigned long long);
15277 vector signed int vec_mergee (vector signed int, vector signed int);
15278 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
15279 vector bool int vec_mergee (vector bool int, vector bool int);
15281 vector signed int vec_mergeo (vector signed int, vector signed int);
15282 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
15283 vector bool int vec_mergeo (vector bool int, vector bool int);
15285 vector long long vec_min (vector long long, vector long long);
15286 vector unsigned long long vec_min (vector unsigned long long,
15287                                    vector unsigned long long);
15289 vector long long vec_nand (vector long long, vector long long);
15290 vector long long vec_nand (vector bool long long, vector long long);
15291 vector long long vec_nand (vector long long, vector bool long long);
15292 vector unsigned long long vec_nand (vector unsigned long long,
15293                                     vector unsigned long long);
15294 vector unsigned long long vec_nand (vector bool long long,
15295                                    vector unsigned long long);
15296 vector unsigned long long vec_nand (vector unsigned long long,
15297                                     vector bool long long);
15298 vector int vec_nand (vector int, vector int);
15299 vector int vec_nand (vector bool int, vector int);
15300 vector int vec_nand (vector int, vector bool int);
15301 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15302 vector unsigned int vec_nand (vector bool unsigned int,
15303                               vector unsigned int);
15304 vector unsigned int vec_nand (vector unsigned int,
15305                               vector bool unsigned int);
15306 vector short vec_nand (vector short, vector short);
15307 vector short vec_nand (vector bool short, vector short);
15308 vector short vec_nand (vector short, vector bool short);
15309 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15310 vector unsigned short vec_nand (vector bool unsigned short,
15311                                 vector unsigned short);
15312 vector unsigned short vec_nand (vector unsigned short,
15313                                 vector bool unsigned short);
15314 vector signed char vec_nand (vector signed char, vector signed char);
15315 vector signed char vec_nand (vector bool signed char, vector signed char);
15316 vector signed char vec_nand (vector signed char, vector bool signed char);
15317 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15318 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15319 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15321 vector long long vec_orc (vector long long, vector long long);
15322 vector long long vec_orc (vector bool long long, vector long long);
15323 vector long long vec_orc (vector long long, vector bool long long);
15324 vector unsigned long long vec_orc (vector unsigned long long,
15325                                    vector unsigned long long);
15326 vector unsigned long long vec_orc (vector bool long long,
15327                                    vector unsigned long long);
15328 vector unsigned long long vec_orc (vector unsigned long long,
15329                                    vector bool long long);
15330 vector int vec_orc (vector int, vector int);
15331 vector int vec_orc (vector bool int, vector int);
15332 vector int vec_orc (vector int, vector bool int);
15333 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15334 vector unsigned int vec_orc (vector bool unsigned int,
15335                              vector unsigned int);
15336 vector unsigned int vec_orc (vector unsigned int,
15337                              vector bool unsigned int);
15338 vector short vec_orc (vector short, vector short);
15339 vector short vec_orc (vector bool short, vector short);
15340 vector short vec_orc (vector short, vector bool short);
15341 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15342 vector unsigned short vec_orc (vector bool unsigned short,
15343                                vector unsigned short);
15344 vector unsigned short vec_orc (vector unsigned short,
15345                                vector bool unsigned short);
15346 vector signed char vec_orc (vector signed char, vector signed char);
15347 vector signed char vec_orc (vector bool signed char, vector signed char);
15348 vector signed char vec_orc (vector signed char, vector bool signed char);
15349 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15350 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15351 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15353 vector int vec_pack (vector long long, vector long long);
15354 vector unsigned int vec_pack (vector unsigned long long,
15355                               vector unsigned long long);
15356 vector bool int vec_pack (vector bool long long, vector bool long long);
15358 vector int vec_packs (vector long long, vector long long);
15359 vector unsigned int vec_packs (vector unsigned long long,
15360                                vector unsigned long long);
15362 vector unsigned int vec_packsu (vector long long, vector long long);
15363 vector unsigned int vec_packsu (vector unsigned long long,
15364                                 vector unsigned long long);
15366 vector long long vec_rl (vector long long,
15367                          vector unsigned long long);
15368 vector long long vec_rl (vector unsigned long long,
15369                          vector unsigned long long);
15371 vector long long vec_sl (vector long long, vector unsigned long long);
15372 vector long long vec_sl (vector unsigned long long,
15373                          vector unsigned long long);
15375 vector long long vec_sr (vector long long, vector unsigned long long);
15376 vector unsigned long long char vec_sr (vector unsigned long long,
15377                                        vector unsigned long long);
15379 vector long long vec_sra (vector long long, vector unsigned long long);
15380 vector unsigned long long vec_sra (vector unsigned long long,
15381                                    vector unsigned long long);
15383 vector long long vec_sub (vector long long, vector long long);
15384 vector unsigned long long vec_sub (vector unsigned long long,
15385                                    vector unsigned long long);
15387 vector long long vec_unpackh (vector int);
15388 vector unsigned long long vec_unpackh (vector unsigned int);
15390 vector long long vec_unpackl (vector int);
15391 vector unsigned long long vec_unpackl (vector unsigned int);
15393 vector long long vec_vaddudm (vector long long, vector long long);
15394 vector long long vec_vaddudm (vector bool long long, vector long long);
15395 vector long long vec_vaddudm (vector long long, vector bool long long);
15396 vector unsigned long long vec_vaddudm (vector unsigned long long,
15397                                        vector unsigned long long);
15398 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15399                                        vector unsigned long long);
15400 vector unsigned long long vec_vaddudm (vector unsigned long long,
15401                                        vector bool unsigned long long);
15403 vector long long vec_vbpermq (vector signed char, vector signed char);
15404 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15406 vector long long vec_cntlz (vector long long);
15407 vector unsigned long long vec_cntlz (vector unsigned long long);
15408 vector int vec_cntlz (vector int);
15409 vector unsigned int vec_cntlz (vector int);
15410 vector short vec_cntlz (vector short);
15411 vector unsigned short vec_cntlz (vector unsigned short);
15412 vector signed char vec_cntlz (vector signed char);
15413 vector unsigned char vec_cntlz (vector unsigned char);
15415 vector long long vec_vclz (vector long long);
15416 vector unsigned long long vec_vclz (vector unsigned long long);
15417 vector int vec_vclz (vector int);
15418 vector unsigned int vec_vclz (vector int);
15419 vector short vec_vclz (vector short);
15420 vector unsigned short vec_vclz (vector unsigned short);
15421 vector signed char vec_vclz (vector signed char);
15422 vector unsigned char vec_vclz (vector unsigned char);
15424 vector signed char vec_vclzb (vector signed char);
15425 vector unsigned char vec_vclzb (vector unsigned char);
15427 vector long long vec_vclzd (vector long long);
15428 vector unsigned long long vec_vclzd (vector unsigned long long);
15430 vector short vec_vclzh (vector short);
15431 vector unsigned short vec_vclzh (vector unsigned short);
15433 vector int vec_vclzw (vector int);
15434 vector unsigned int vec_vclzw (vector int);
15436 vector signed char vec_vgbbd (vector signed char);
15437 vector unsigned char vec_vgbbd (vector unsigned char);
15439 vector long long vec_vmaxsd (vector long long, vector long long);
15441 vector unsigned long long vec_vmaxud (vector unsigned long long,
15442                                       unsigned vector long long);
15444 vector long long vec_vminsd (vector long long, vector long long);
15446 vector unsigned long long vec_vminud (vector long long,
15447                                       vector long long);
15449 vector int vec_vpksdss (vector long long, vector long long);
15450 vector unsigned int vec_vpksdss (vector long long, vector long long);
15452 vector unsigned int vec_vpkudus (vector unsigned long long,
15453                                  vector unsigned long long);
15455 vector int vec_vpkudum (vector long long, vector long long);
15456 vector unsigned int vec_vpkudum (vector unsigned long long,
15457                                  vector unsigned long long);
15458 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15460 vector long long vec_vpopcnt (vector long long);
15461 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15462 vector int vec_vpopcnt (vector int);
15463 vector unsigned int vec_vpopcnt (vector int);
15464 vector short vec_vpopcnt (vector short);
15465 vector unsigned short vec_vpopcnt (vector unsigned short);
15466 vector signed char vec_vpopcnt (vector signed char);
15467 vector unsigned char vec_vpopcnt (vector unsigned char);
15469 vector signed char vec_vpopcntb (vector signed char);
15470 vector unsigned char vec_vpopcntb (vector unsigned char);
15472 vector long long vec_vpopcntd (vector long long);
15473 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15475 vector short vec_vpopcnth (vector short);
15476 vector unsigned short vec_vpopcnth (vector unsigned short);
15478 vector int vec_vpopcntw (vector int);
15479 vector unsigned int vec_vpopcntw (vector int);
15481 vector long long vec_vrld (vector long long, vector unsigned long long);
15482 vector unsigned long long vec_vrld (vector unsigned long long,
15483                                     vector unsigned long long);
15485 vector long long vec_vsld (vector long long, vector unsigned long long);
15486 vector long long vec_vsld (vector unsigned long long,
15487                            vector unsigned long long);
15489 vector long long vec_vsrad (vector long long, vector unsigned long long);
15490 vector unsigned long long vec_vsrad (vector unsigned long long,
15491                                      vector unsigned long long);
15493 vector long long vec_vsrd (vector long long, vector unsigned long long);
15494 vector unsigned long long char vec_vsrd (vector unsigned long long,
15495                                          vector unsigned long long);
15497 vector long long vec_vsubudm (vector long long, vector long long);
15498 vector long long vec_vsubudm (vector bool long long, vector long long);
15499 vector long long vec_vsubudm (vector long long, vector bool long long);
15500 vector unsigned long long vec_vsubudm (vector unsigned long long,
15501                                        vector unsigned long long);
15502 vector unsigned long long vec_vsubudm (vector bool long long,
15503                                        vector unsigned long long);
15504 vector unsigned long long vec_vsubudm (vector unsigned long long,
15505                                        vector bool long long);
15507 vector long long vec_vupkhsw (vector int);
15508 vector unsigned long long vec_vupkhsw (vector unsigned int);
15510 vector long long vec_vupklsw (vector int);
15511 vector unsigned long long vec_vupklsw (vector int);
15512 @end smallexample
15514 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15515 instruction set is available, the following additional functions are
15516 available for 64-bit targets.  New vector types
15517 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
15518 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
15519 builtins.
15521 The normal vector extract, and set operations work on
15522 @var{vector __int128_t} and @var{vector __uint128_t} types,
15523 but the index value must be 0.
15525 @smallexample
15526 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15527 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15529 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
15530 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
15532 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
15533                                 vector __int128_t);
15534 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
15535                                  vector __uint128_t);
15537 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
15538                                 vector __int128_t);
15539 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
15540                                  vector __uint128_t);
15542 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
15543                                 vector __int128_t);
15544 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
15545                                  vector __uint128_t);
15547 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
15548                                 vector __int128_t);
15549 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
15550                                  vector __uint128_t);
15552 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
15553 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
15555 __int128_t vec_vsubuqm (__int128_t, __int128_t);
15556 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
15558 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
15559 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
15560 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
15561 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
15562 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
15563 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
15564 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
15565 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
15566 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
15567 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
15568 @end smallexample
15570 If the cryptographic instructions are enabled (@option{-mcrypto} or
15571 @option{-mcpu=power8}), the following builtins are enabled.
15573 @smallexample
15574 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
15576 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
15577                                                     vector unsigned long long);
15579 vector unsigned long long __builtin_crypto_vcipherlast
15580                                      (vector unsigned long long,
15581                                       vector unsigned long long);
15583 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
15584                                                      vector unsigned long long);
15586 vector unsigned long long __builtin_crypto_vncipherlast
15587                                      (vector unsigned long long,
15588                                       vector unsigned long long);
15590 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
15591                                                 vector unsigned char,
15592                                                 vector unsigned char);
15594 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
15595                                                  vector unsigned short,
15596                                                  vector unsigned short);
15598 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
15599                                                vector unsigned int,
15600                                                vector unsigned int);
15602 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
15603                                                      vector unsigned long long,
15604                                                      vector unsigned long long);
15606 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
15607                                                vector unsigned char);
15609 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15610                                                 vector unsigned short);
15612 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15613                                               vector unsigned int);
15615 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15616                                                     vector unsigned long long);
15618 vector unsigned long long __builtin_crypto_vshasigmad
15619                                (vector unsigned long long, int, int);
15621 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15622                                                  int, int);
15623 @end smallexample
15625 The second argument to the @var{__builtin_crypto_vshasigmad} and
15626 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15627 integer that is 0 or 1.  The third argument to these builtin functions
15628 must be a constant integer in the range of 0 to 15.
15630 @node PowerPC Hardware Transactional Memory Built-in Functions
15631 @subsection PowerPC Hardware Transactional Memory Built-in Functions
15632 GCC provides two interfaces for accessing the Hardware Transactional
15633 Memory (HTM) instructions available on some of the PowerPC family
15634 of processors (eg, POWER8).  The two interfaces come in a low level
15635 interface, consisting of built-in functions specific to PowerPC and a
15636 higher level interface consisting of inline functions that are common
15637 between PowerPC and S/390.
15639 @subsubsection PowerPC HTM Low Level Built-in Functions
15641 The following low level built-in functions are available with
15642 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
15643 They all generate the machine instruction that is part of the name.
15645 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
15646 the full 4-bit condition register value set by their associated hardware
15647 instruction.  The header file @code{htmintrin.h} defines some macros that can
15648 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
15649 returns a simple true or false value depending on whether a transaction was
15650 successfully started or not.  The arguments of the builtins match exactly the
15651 type and order of the associated hardware instruction's operands, except for
15652 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
15653 Refer to the ISA manual for a description of each instruction's operands.
15655 @smallexample
15656 unsigned int __builtin_tbegin (unsigned int)
15657 unsigned int __builtin_tend (unsigned int)
15659 unsigned int __builtin_tabort (unsigned int)
15660 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
15661 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
15662 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
15663 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
15665 unsigned int __builtin_tcheck (void)
15666 unsigned int __builtin_treclaim (unsigned int)
15667 unsigned int __builtin_trechkpt (void)
15668 unsigned int __builtin_tsr (unsigned int)
15669 @end smallexample
15671 In addition to the above HTM built-ins, we have added built-ins for
15672 some common extended mnemonics of the HTM instructions:
15674 @smallexample
15675 unsigned int __builtin_tendall (void)
15676 unsigned int __builtin_tresume (void)
15677 unsigned int __builtin_tsuspend (void)
15678 @end smallexample
15680 The following set of built-in functions are available to gain access
15681 to the HTM specific special purpose registers.
15683 @smallexample
15684 unsigned long __builtin_get_texasr (void)
15685 unsigned long __builtin_get_texasru (void)
15686 unsigned long __builtin_get_tfhar (void)
15687 unsigned long __builtin_get_tfiar (void)
15689 void __builtin_set_texasr (unsigned long);
15690 void __builtin_set_texasru (unsigned long);
15691 void __builtin_set_tfhar (unsigned long);
15692 void __builtin_set_tfiar (unsigned long);
15693 @end smallexample
15695 Example usage of these low level built-in functions may look like:
15697 @smallexample
15698 #include <htmintrin.h>
15700 int num_retries = 10;
15702 while (1)
15703   @{
15704     if (__builtin_tbegin (0))
15705       @{
15706         /* Transaction State Initiated.  */
15707         if (is_locked (lock))
15708           __builtin_tabort (0);
15709         ... transaction code...
15710         __builtin_tend (0);
15711         break;
15712       @}
15713     else
15714       @{
15715         /* Transaction State Failed.  Use locks if the transaction
15716            failure is "persistent" or we've tried too many times.  */
15717         if (num_retries-- <= 0
15718             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
15719           @{
15720             acquire_lock (lock);
15721             ... non transactional fallback path...
15722             release_lock (lock);
15723             break;
15724           @}
15725       @}
15726   @}
15727 @end smallexample
15729 One final built-in function has been added that returns the value of
15730 the 2-bit Transaction State field of the Machine Status Register (MSR)
15731 as stored in @code{CR0}.
15733 @smallexample
15734 unsigned long __builtin_ttest (void)
15735 @end smallexample
15737 This built-in can be used to determine the current transaction state
15738 using the following code example:
15740 @smallexample
15741 #include <htmintrin.h>
15743 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
15745 if (tx_state == _HTM_TRANSACTIONAL)
15746   @{
15747     /* Code to use in transactional state.  */
15748   @}
15749 else if (tx_state == _HTM_NONTRANSACTIONAL)
15750   @{
15751     /* Code to use in non-transactional state.  */
15752   @}
15753 else if (tx_state == _HTM_SUSPENDED)
15754   @{
15755     /* Code to use in transaction suspended state.  */
15756   @}
15757 @end smallexample
15759 @subsubsection PowerPC HTM High Level Inline Functions
15761 The following high level HTM interface is made available by including
15762 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
15763 where CPU is `power8' or later.  This interface is common between PowerPC
15764 and S/390, allowing users to write one HTM source implementation that
15765 can be compiled and executed on either system.
15767 @smallexample
15768 long __TM_simple_begin (void)
15769 long __TM_begin (void* const TM_buff)
15770 long __TM_end (void)
15771 void __TM_abort (void)
15772 void __TM_named_abort (unsigned char const code)
15773 void __TM_resume (void)
15774 void __TM_suspend (void)
15776 long __TM_is_user_abort (void* const TM_buff)
15777 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
15778 long __TM_is_illegal (void* const TM_buff)
15779 long __TM_is_footprint_exceeded (void* const TM_buff)
15780 long __TM_nesting_depth (void* const TM_buff)
15781 long __TM_is_nested_too_deep(void* const TM_buff)
15782 long __TM_is_conflict(void* const TM_buff)
15783 long __TM_is_failure_persistent(void* const TM_buff)
15784 long __TM_failure_address(void* const TM_buff)
15785 long long __TM_failure_code(void* const TM_buff)
15786 @end smallexample
15788 Using these common set of HTM inline functions, we can create
15789 a more portable version of the HTM example in the previous
15790 section that will work on either PowerPC or S/390:
15792 @smallexample
15793 #include <htmxlintrin.h>
15795 int num_retries = 10;
15796 TM_buff_type TM_buff;
15798 while (1)
15799   @{
15800     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
15801       @{
15802         /* Transaction State Initiated.  */
15803         if (is_locked (lock))
15804           __TM_abort ();
15805         ... transaction code...
15806         __TM_end ();
15807         break;
15808       @}
15809     else
15810       @{
15811         /* Transaction State Failed.  Use locks if the transaction
15812            failure is "persistent" or we've tried too many times.  */
15813         if (num_retries-- <= 0
15814             || __TM_is_failure_persistent (TM_buff))
15815           @{
15816             acquire_lock (lock);
15817             ... non transactional fallback path...
15818             release_lock (lock);
15819             break;
15820           @}
15821       @}
15822   @}
15823 @end smallexample
15825 @node RX Built-in Functions
15826 @subsection RX Built-in Functions
15827 GCC supports some of the RX instructions which cannot be expressed in
15828 the C programming language via the use of built-in functions.  The
15829 following functions are supported:
15831 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
15832 Generates the @code{brk} machine instruction.
15833 @end deftypefn
15835 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
15836 Generates the @code{clrpsw} machine instruction to clear the specified
15837 bit in the processor status word.
15838 @end deftypefn
15840 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
15841 Generates the @code{int} machine instruction to generate an interrupt
15842 with the specified value.
15843 @end deftypefn
15845 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
15846 Generates the @code{machi} machine instruction to add the result of
15847 multiplying the top 16 bits of the two arguments into the
15848 accumulator.
15849 @end deftypefn
15851 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
15852 Generates the @code{maclo} machine instruction to add the result of
15853 multiplying the bottom 16 bits of the two arguments into the
15854 accumulator.
15855 @end deftypefn
15857 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
15858 Generates the @code{mulhi} machine instruction to place the result of
15859 multiplying the top 16 bits of the two arguments into the
15860 accumulator.
15861 @end deftypefn
15863 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
15864 Generates the @code{mullo} machine instruction to place the result of
15865 multiplying the bottom 16 bits of the two arguments into the
15866 accumulator.
15867 @end deftypefn
15869 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
15870 Generates the @code{mvfachi} machine instruction to read the top
15871 32 bits of the accumulator.
15872 @end deftypefn
15874 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
15875 Generates the @code{mvfacmi} machine instruction to read the middle
15876 32 bits of the accumulator.
15877 @end deftypefn
15879 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
15880 Generates the @code{mvfc} machine instruction which reads the control
15881 register specified in its argument and returns its value.
15882 @end deftypefn
15884 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
15885 Generates the @code{mvtachi} machine instruction to set the top
15886 32 bits of the accumulator.
15887 @end deftypefn
15889 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
15890 Generates the @code{mvtaclo} machine instruction to set the bottom
15891 32 bits of the accumulator.
15892 @end deftypefn
15894 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
15895 Generates the @code{mvtc} machine instruction which sets control
15896 register number @code{reg} to @code{val}.
15897 @end deftypefn
15899 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
15900 Generates the @code{mvtipl} machine instruction set the interrupt
15901 priority level.
15902 @end deftypefn
15904 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
15905 Generates the @code{racw} machine instruction to round the accumulator
15906 according to the specified mode.
15907 @end deftypefn
15909 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
15910 Generates the @code{revw} machine instruction which swaps the bytes in
15911 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
15912 and also bits 16--23 occupy bits 24--31 and vice versa.
15913 @end deftypefn
15915 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
15916 Generates the @code{rmpa} machine instruction which initiates a
15917 repeated multiply and accumulate sequence.
15918 @end deftypefn
15920 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
15921 Generates the @code{round} machine instruction which returns the
15922 floating-point argument rounded according to the current rounding mode
15923 set in the floating-point status word register.
15924 @end deftypefn
15926 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
15927 Generates the @code{sat} machine instruction which returns the
15928 saturated value of the argument.
15929 @end deftypefn
15931 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
15932 Generates the @code{setpsw} machine instruction to set the specified
15933 bit in the processor status word.
15934 @end deftypefn
15936 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
15937 Generates the @code{wait} machine instruction.
15938 @end deftypefn
15940 @node S/390 System z Built-in Functions
15941 @subsection S/390 System z Built-in Functions
15942 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
15943 Generates the @code{tbegin} machine instruction starting a
15944 non-constraint hardware transaction.  If the parameter is non-NULL the
15945 memory area is used to store the transaction diagnostic buffer and
15946 will be passed as first operand to @code{tbegin}.  This buffer can be
15947 defined using the @code{struct __htm_tdb} C struct defined in
15948 @code{htmintrin.h} and must reside on a double-word boundary.  The
15949 second tbegin operand is set to @code{0xff0c}. This enables
15950 save/restore of all GPRs and disables aborts for FPR and AR
15951 manipulations inside the transaction body.  The condition code set by
15952 the tbegin instruction is returned as integer value.  The tbegin
15953 instruction by definition overwrites the content of all FPRs.  The
15954 compiler will generate code which saves and restores the FPRs.  For
15955 soft-float code it is recommended to used the @code{*_nofloat}
15956 variant.  In order to prevent a TDB from being written it is required
15957 to pass an constant zero value as parameter.  Passing the zero value
15958 through a variable is not sufficient.  Although modifications of
15959 access registers inside the transaction will not trigger an
15960 transaction abort it is not supported to actually modify them.  Access
15961 registers do not get saved when entering a transaction. They will have
15962 undefined state when reaching the abort code.
15963 @end deftypefn
15965 Macros for the possible return codes of tbegin are defined in the
15966 @code{htmintrin.h} header file:
15968 @table @code
15969 @item _HTM_TBEGIN_STARTED
15970 @code{tbegin} has been executed as part of normal processing.  The
15971 transaction body is supposed to be executed.
15972 @item _HTM_TBEGIN_INDETERMINATE
15973 The transaction was aborted due to an indeterminate condition which
15974 might be persistent.
15975 @item _HTM_TBEGIN_TRANSIENT
15976 The transaction aborted due to a transient failure.  The transaction
15977 should be re-executed in that case.
15978 @item _HTM_TBEGIN_PERSISTENT
15979 The transaction aborted due to a persistent failure.  Re-execution
15980 under same circumstances will not be productive.
15981 @end table
15983 @defmac _HTM_FIRST_USER_ABORT_CODE
15984 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
15985 specifies the first abort code which can be used for
15986 @code{__builtin_tabort}.  Values below this threshold are reserved for
15987 machine use.
15988 @end defmac
15990 @deftp {Data type} {struct __htm_tdb}
15991 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
15992 the structure of the transaction diagnostic block as specified in the
15993 Principles of Operation manual chapter 5-91.
15994 @end deftp
15996 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
15997 Same as @code{__builtin_tbegin} but without FPR saves and restores.
15998 Using this variant in code making use of FPRs will leave the FPRs in
15999 undefined state when entering the transaction abort handler code.
16000 @end deftypefn
16002 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16003 In addition to @code{__builtin_tbegin} a loop for transient failures
16004 is generated.  If tbegin returns a condition code of 2 the transaction
16005 will be retried as often as specified in the second argument.  The
16006 perform processor assist instruction is used to tell the CPU about the
16007 number of fails so far.
16008 @end deftypefn
16010 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16011 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16012 restores.  Using this variant in code making use of FPRs will leave
16013 the FPRs in undefined state when entering the transaction abort
16014 handler code.
16015 @end deftypefn
16017 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16018 Generates the @code{tbeginc} machine instruction starting a constraint
16019 hardware transaction.  The second operand is set to @code{0xff08}.
16020 @end deftypefn
16022 @deftypefn {Built-in Function} int __builtin_tend (void)
16023 Generates the @code{tend} machine instruction finishing a transaction
16024 and making the changes visible to other threads.  The condition code
16025 generated by tend is returned as integer value.
16026 @end deftypefn
16028 @deftypefn {Built-in Function} void __builtin_tabort (int)
16029 Generates the @code{tabort} machine instruction with the specified
16030 abort code.  Abort codes from 0 through 255 are reserved and will
16031 result in an error message.
16032 @end deftypefn
16034 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16035 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16036 integer parameter is loaded into rX and a value of zero is loaded into
16037 rY.  The integer parameter specifies the number of times the
16038 transaction repeatedly aborted.
16039 @end deftypefn
16041 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16042 Generates the @code{etnd} machine instruction.  The current nesting
16043 depth is returned as integer value.  For a nesting depth of 0 the code
16044 is not executed as part of an transaction.
16045 @end deftypefn
16047 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16049 Generates the @code{ntstg} machine instruction.  The second argument
16050 is written to the first arguments location.  The store operation will
16051 not be rolled-back in case of an transaction abort.
16052 @end deftypefn
16054 @node SH Built-in Functions
16055 @subsection SH Built-in Functions
16056 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16057 families of processors:
16059 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16060 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16061 used by system code that manages threads and execution contexts.  The compiler
16062 normally does not generate code that modifies the contents of @samp{GBR} and
16063 thus the value is preserved across function calls.  Changing the @samp{GBR}
16064 value in user code must be done with caution, since the compiler might use
16065 @samp{GBR} in order to access thread local variables.
16067 @end deftypefn
16069 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16070 Returns the value that is currently set in the @samp{GBR} register.
16071 Memory loads and stores that use the thread pointer as a base address are
16072 turned into @samp{GBR} based displacement loads and stores, if possible.
16073 For example:
16074 @smallexample
16075 struct my_tcb
16077    int a, b, c, d, e;
16080 int get_tcb_value (void)
16082   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16083   return ((my_tcb*)__builtin_thread_pointer ())->c;
16086 @end smallexample
16087 @end deftypefn
16089 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16090 Returns the value that is currently set in the @samp{FPSCR} register.
16091 @end deftypefn
16093 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16094 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16095 preserving the current values of the FR, SZ and PR bits.
16096 @end deftypefn
16098 @node SPARC VIS Built-in Functions
16099 @subsection SPARC VIS Built-in Functions
16101 GCC supports SIMD operations on the SPARC using both the generic vector
16102 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16103 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16104 switch, the VIS extension is exposed as the following built-in functions:
16106 @smallexample
16107 typedef int v1si __attribute__ ((vector_size (4)));
16108 typedef int v2si __attribute__ ((vector_size (8)));
16109 typedef short v4hi __attribute__ ((vector_size (8)));
16110 typedef short v2hi __attribute__ ((vector_size (4)));
16111 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16112 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16114 void __builtin_vis_write_gsr (int64_t);
16115 int64_t __builtin_vis_read_gsr (void);
16117 void * __builtin_vis_alignaddr (void *, long);
16118 void * __builtin_vis_alignaddrl (void *, long);
16119 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16120 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16121 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16122 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16124 v4hi __builtin_vis_fexpand (v4qi);
16126 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16127 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16128 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16129 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16130 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16131 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16132 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16134 v4qi __builtin_vis_fpack16 (v4hi);
16135 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16136 v2hi __builtin_vis_fpackfix (v2si);
16137 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16139 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16141 long __builtin_vis_edge8 (void *, void *);
16142 long __builtin_vis_edge8l (void *, void *);
16143 long __builtin_vis_edge16 (void *, void *);
16144 long __builtin_vis_edge16l (void *, void *);
16145 long __builtin_vis_edge32 (void *, void *);
16146 long __builtin_vis_edge32l (void *, void *);
16148 long __builtin_vis_fcmple16 (v4hi, v4hi);
16149 long __builtin_vis_fcmple32 (v2si, v2si);
16150 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16151 long __builtin_vis_fcmpne32 (v2si, v2si);
16152 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16153 long __builtin_vis_fcmpgt32 (v2si, v2si);
16154 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16155 long __builtin_vis_fcmpeq32 (v2si, v2si);
16157 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16158 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16159 v2si __builtin_vis_fpadd32 (v2si, v2si);
16160 v1si __builtin_vis_fpadd32s (v1si, v1si);
16161 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16162 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16163 v2si __builtin_vis_fpsub32 (v2si, v2si);
16164 v1si __builtin_vis_fpsub32s (v1si, v1si);
16166 long __builtin_vis_array8 (long, long);
16167 long __builtin_vis_array16 (long, long);
16168 long __builtin_vis_array32 (long, long);
16169 @end smallexample
16171 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16172 functions also become available:
16174 @smallexample
16175 long __builtin_vis_bmask (long, long);
16176 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16177 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16178 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16179 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16181 long __builtin_vis_edge8n (void *, void *);
16182 long __builtin_vis_edge8ln (void *, void *);
16183 long __builtin_vis_edge16n (void *, void *);
16184 long __builtin_vis_edge16ln (void *, void *);
16185 long __builtin_vis_edge32n (void *, void *);
16186 long __builtin_vis_edge32ln (void *, void *);
16187 @end smallexample
16189 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16190 functions also become available:
16192 @smallexample
16193 void __builtin_vis_cmask8 (long);
16194 void __builtin_vis_cmask16 (long);
16195 void __builtin_vis_cmask32 (long);
16197 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16199 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16200 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16201 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16202 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16203 v2si __builtin_vis_fsll16 (v2si, v2si);
16204 v2si __builtin_vis_fslas16 (v2si, v2si);
16205 v2si __builtin_vis_fsrl16 (v2si, v2si);
16206 v2si __builtin_vis_fsra16 (v2si, v2si);
16208 long __builtin_vis_pdistn (v8qi, v8qi);
16210 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16212 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16213 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16215 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16216 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16217 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16218 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16219 v2si __builtin_vis_fpadds32 (v2si, v2si);
16220 v1si __builtin_vis_fpadds32s (v1si, v1si);
16221 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16222 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16224 long __builtin_vis_fucmple8 (v8qi, v8qi);
16225 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16226 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16227 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16229 float __builtin_vis_fhadds (float, float);
16230 double __builtin_vis_fhaddd (double, double);
16231 float __builtin_vis_fhsubs (float, float);
16232 double __builtin_vis_fhsubd (double, double);
16233 float __builtin_vis_fnhadds (float, float);
16234 double __builtin_vis_fnhaddd (double, double);
16236 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16237 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16238 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16239 @end smallexample
16241 @node SPU Built-in Functions
16242 @subsection SPU Built-in Functions
16244 GCC provides extensions for the SPU processor as described in the
16245 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16246 found at @uref{http://cell.scei.co.jp/} or
16247 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
16248 implementation differs in several ways.
16250 @itemize @bullet
16252 @item
16253 The optional extension of specifying vector constants in parentheses is
16254 not supported.
16256 @item
16257 A vector initializer requires no cast if the vector constant is of the
16258 same type as the variable it is initializing.
16260 @item
16261 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16262 vector type is the default signedness of the base type.  The default
16263 varies depending on the operating system, so a portable program should
16264 always specify the signedness.
16266 @item
16267 By default, the keyword @code{__vector} is added. The macro
16268 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16269 undefined.
16271 @item
16272 GCC allows using a @code{typedef} name as the type specifier for a
16273 vector type.
16275 @item
16276 For C, overloaded functions are implemented with macros so the following
16277 does not work:
16279 @smallexample
16280   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16281 @end smallexample
16283 @noindent
16284 Since @code{spu_add} is a macro, the vector constant in the example
16285 is treated as four separate arguments.  Wrap the entire argument in
16286 parentheses for this to work.
16288 @item
16289 The extended version of @code{__builtin_expect} is not supported.
16291 @end itemize
16293 @emph{Note:} Only the interface described in the aforementioned
16294 specification is supported. Internally, GCC uses built-in functions to
16295 implement the required functionality, but these are not supported and
16296 are subject to change without notice.
16298 @node TI C6X Built-in Functions
16299 @subsection TI C6X Built-in Functions
16301 GCC provides intrinsics to access certain instructions of the TI C6X
16302 processors.  These intrinsics, listed below, are available after
16303 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
16304 to C6X instructions.
16306 @smallexample
16308 int _sadd (int, int)
16309 int _ssub (int, int)
16310 int _sadd2 (int, int)
16311 int _ssub2 (int, int)
16312 long long _mpy2 (int, int)
16313 long long _smpy2 (int, int)
16314 int _add4 (int, int)
16315 int _sub4 (int, int)
16316 int _saddu4 (int, int)
16318 int _smpy (int, int)
16319 int _smpyh (int, int)
16320 int _smpyhl (int, int)
16321 int _smpylh (int, int)
16323 int _sshl (int, int)
16324 int _subc (int, int)
16326 int _avg2 (int, int)
16327 int _avgu4 (int, int)
16329 int _clrr (int, int)
16330 int _extr (int, int)
16331 int _extru (int, int)
16332 int _abs (int)
16333 int _abs2 (int)
16335 @end smallexample
16337 @node TILE-Gx Built-in Functions
16338 @subsection TILE-Gx Built-in Functions
16340 GCC provides intrinsics to access every instruction of the TILE-Gx
16341 processor.  The intrinsics are of the form:
16343 @smallexample
16345 unsigned long long __insn_@var{op} (...)
16347 @end smallexample
16349 Where @var{op} is the name of the instruction.  Refer to the ISA manual
16350 for the complete list of instructions.
16352 GCC also provides intrinsics to directly access the network registers.
16353 The intrinsics are:
16355 @smallexample
16357 unsigned long long __tile_idn0_receive (void)
16358 unsigned long long __tile_idn1_receive (void)
16359 unsigned long long __tile_udn0_receive (void)
16360 unsigned long long __tile_udn1_receive (void)
16361 unsigned long long __tile_udn2_receive (void)
16362 unsigned long long __tile_udn3_receive (void)
16363 void __tile_idn_send (unsigned long long)
16364 void __tile_udn_send (unsigned long long)
16366 @end smallexample
16368 The intrinsic @code{void __tile_network_barrier (void)} is used to
16369 guarantee that no network operations before it are reordered with
16370 those after it.
16372 @node TILEPro Built-in Functions
16373 @subsection TILEPro Built-in Functions
16375 GCC provides intrinsics to access every instruction of the TILEPro
16376 processor.  The intrinsics are of the form:
16378 @smallexample
16380 unsigned __insn_@var{op} (...)
16382 @end smallexample
16384 @noindent
16385 where @var{op} is the name of the instruction.  Refer to the ISA manual
16386 for the complete list of instructions.
16388 GCC also provides intrinsics to directly access the network registers.
16389 The intrinsics are:
16391 @smallexample
16393 unsigned __tile_idn0_receive (void)
16394 unsigned __tile_idn1_receive (void)
16395 unsigned __tile_sn_receive (void)
16396 unsigned __tile_udn0_receive (void)
16397 unsigned __tile_udn1_receive (void)
16398 unsigned __tile_udn2_receive (void)
16399 unsigned __tile_udn3_receive (void)
16400 void __tile_idn_send (unsigned)
16401 void __tile_sn_send (unsigned)
16402 void __tile_udn_send (unsigned)
16404 @end smallexample
16406 The intrinsic @code{void __tile_network_barrier (void)} is used to
16407 guarantee that no network operations before it are reordered with
16408 those after it.
16410 @node x86 Built-in Functions
16411 @subsection x86 Built-in Functions
16413 These built-in functions are available for the x86-32 and x86-64 family
16414 of computers, depending on the command-line switches used.
16416 If you specify command-line switches such as @option{-msse},
16417 the compiler could use the extended instruction sets even if the built-ins
16418 are not used explicitly in the program.  For this reason, applications
16419 that perform run-time CPU detection must compile separate files for each
16420 supported architecture, using the appropriate flags.  In particular,
16421 the file containing the CPU detection code should be compiled without
16422 these options.
16424 The following machine modes are available for use with MMX built-in functions
16425 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
16426 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
16427 vector of eight 8-bit integers.  Some of the built-in functions operate on
16428 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
16430 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
16431 of two 32-bit floating-point values.
16433 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
16434 floating-point values.  Some instructions use a vector of four 32-bit
16435 integers, these use @code{V4SI}.  Finally, some instructions operate on an
16436 entire vector register, interpreting it as a 128-bit integer, these use mode
16437 @code{TI}.
16439 In 64-bit mode, the x86-64 family of processors uses additional built-in
16440 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
16441 floating point and @code{TC} 128-bit complex floating-point values.
16443 The following floating-point built-in functions are available in 64-bit
16444 mode.  All of them implement the function that is part of the name.
16446 @smallexample
16447 __float128 __builtin_fabsq (__float128)
16448 __float128 __builtin_copysignq (__float128, __float128)
16449 @end smallexample
16451 The following built-in function is always available.
16453 @table @code
16454 @item void __builtin_ia32_pause (void)
16455 Generates the @code{pause} machine instruction with a compiler memory
16456 barrier.
16457 @end table
16459 The following floating-point built-in functions are made available in the
16460 64-bit mode.
16462 @table @code
16463 @item __float128 __builtin_infq (void)
16464 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
16465 @findex __builtin_infq
16467 @item __float128 __builtin_huge_valq (void)
16468 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
16469 @findex __builtin_huge_valq
16470 @end table
16472 The following built-in functions are always available and can be used to
16473 check the target platform type.
16475 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
16476 This function runs the CPU detection code to check the type of CPU and the
16477 features supported.  This built-in function needs to be invoked along with the built-in functions
16478 to check CPU type and features, @code{__builtin_cpu_is} and
16479 @code{__builtin_cpu_supports}, only when used in a function that is
16480 executed before any constructors are called.  The CPU detection code is
16481 automatically executed in a very high priority constructor.
16483 For example, this function has to be used in @code{ifunc} resolvers that
16484 check for CPU type using the built-in functions @code{__builtin_cpu_is}
16485 and @code{__builtin_cpu_supports}, or in constructors on targets that
16486 don't support constructor priority.
16487 @smallexample
16489 static void (*resolve_memcpy (void)) (void)
16491   // ifunc resolvers fire before constructors, explicitly call the init
16492   // function.
16493   __builtin_cpu_init ();
16494   if (__builtin_cpu_supports ("ssse3"))
16495     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
16496   else
16497     return default_memcpy;
16500 void *memcpy (void *, const void *, size_t)
16501      __attribute__ ((ifunc ("resolve_memcpy")));
16502 @end smallexample
16504 @end deftypefn
16506 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
16507 This function returns a positive integer if the run-time CPU
16508 is of type @var{cpuname}
16509 and returns @code{0} otherwise. The following CPU names can be detected:
16511 @table @samp
16512 @item intel
16513 Intel CPU.
16515 @item atom
16516 Intel Atom CPU.
16518 @item core2
16519 Intel Core 2 CPU.
16521 @item corei7
16522 Intel Core i7 CPU.
16524 @item nehalem
16525 Intel Core i7 Nehalem CPU.
16527 @item westmere
16528 Intel Core i7 Westmere CPU.
16530 @item sandybridge
16531 Intel Core i7 Sandy Bridge CPU.
16533 @item amd
16534 AMD CPU.
16536 @item amdfam10h
16537 AMD Family 10h CPU.
16539 @item barcelona
16540 AMD Family 10h Barcelona CPU.
16542 @item shanghai
16543 AMD Family 10h Shanghai CPU.
16545 @item istanbul
16546 AMD Family 10h Istanbul CPU.
16548 @item btver1
16549 AMD Family 14h CPU.
16551 @item amdfam15h
16552 AMD Family 15h CPU.
16554 @item bdver1
16555 AMD Family 15h Bulldozer version 1.
16557 @item bdver2
16558 AMD Family 15h Bulldozer version 2.
16560 @item bdver3
16561 AMD Family 15h Bulldozer version 3.
16563 @item bdver4
16564 AMD Family 15h Bulldozer version 4.
16566 @item btver2
16567 AMD Family 16h CPU.
16568 @end table
16570 Here is an example:
16571 @smallexample
16572 if (__builtin_cpu_is ("corei7"))
16573   @{
16574      do_corei7 (); // Core i7 specific implementation.
16575   @}
16576 else
16577   @{
16578      do_generic (); // Generic implementation.
16579   @}
16580 @end smallexample
16581 @end deftypefn
16583 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
16584 This function returns a positive integer if the run-time CPU
16585 supports @var{feature}
16586 and returns @code{0} otherwise. The following features can be detected:
16588 @table @samp
16589 @item cmov
16590 CMOV instruction.
16591 @item mmx
16592 MMX instructions.
16593 @item popcnt
16594 POPCNT instruction.
16595 @item sse
16596 SSE instructions.
16597 @item sse2
16598 SSE2 instructions.
16599 @item sse3
16600 SSE3 instructions.
16601 @item ssse3
16602 SSSE3 instructions.
16603 @item sse4.1
16604 SSE4.1 instructions.
16605 @item sse4.2
16606 SSE4.2 instructions.
16607 @item avx
16608 AVX instructions.
16609 @item avx2
16610 AVX2 instructions.
16611 @item avx512f
16612 AVX512F instructions.
16613 @end table
16615 Here is an example:
16616 @smallexample
16617 if (__builtin_cpu_supports ("popcnt"))
16618   @{
16619      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
16620   @}
16621 else
16622   @{
16623      count = generic_countbits (n); //generic implementation.
16624   @}
16625 @end smallexample
16626 @end deftypefn
16629 The following built-in functions are made available by @option{-mmmx}.
16630 All of them generate the machine instruction that is part of the name.
16632 @smallexample
16633 v8qi __builtin_ia32_paddb (v8qi, v8qi)
16634 v4hi __builtin_ia32_paddw (v4hi, v4hi)
16635 v2si __builtin_ia32_paddd (v2si, v2si)
16636 v8qi __builtin_ia32_psubb (v8qi, v8qi)
16637 v4hi __builtin_ia32_psubw (v4hi, v4hi)
16638 v2si __builtin_ia32_psubd (v2si, v2si)
16639 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
16640 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
16641 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
16642 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
16643 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
16644 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
16645 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
16646 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
16647 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
16648 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
16649 di __builtin_ia32_pand (di, di)
16650 di __builtin_ia32_pandn (di,di)
16651 di __builtin_ia32_por (di, di)
16652 di __builtin_ia32_pxor (di, di)
16653 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
16654 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
16655 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
16656 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
16657 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
16658 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
16659 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
16660 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
16661 v2si __builtin_ia32_punpckhdq (v2si, v2si)
16662 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
16663 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
16664 v2si __builtin_ia32_punpckldq (v2si, v2si)
16665 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
16666 v4hi __builtin_ia32_packssdw (v2si, v2si)
16667 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
16669 v4hi __builtin_ia32_psllw (v4hi, v4hi)
16670 v2si __builtin_ia32_pslld (v2si, v2si)
16671 v1di __builtin_ia32_psllq (v1di, v1di)
16672 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
16673 v2si __builtin_ia32_psrld (v2si, v2si)
16674 v1di __builtin_ia32_psrlq (v1di, v1di)
16675 v4hi __builtin_ia32_psraw (v4hi, v4hi)
16676 v2si __builtin_ia32_psrad (v2si, v2si)
16677 v4hi __builtin_ia32_psllwi (v4hi, int)
16678 v2si __builtin_ia32_pslldi (v2si, int)
16679 v1di __builtin_ia32_psllqi (v1di, int)
16680 v4hi __builtin_ia32_psrlwi (v4hi, int)
16681 v2si __builtin_ia32_psrldi (v2si, int)
16682 v1di __builtin_ia32_psrlqi (v1di, int)
16683 v4hi __builtin_ia32_psrawi (v4hi, int)
16684 v2si __builtin_ia32_psradi (v2si, int)
16686 @end smallexample
16688 The following built-in functions are made available either with
16689 @option{-msse}, or with a combination of @option{-m3dnow} and
16690 @option{-march=athlon}.  All of them generate the machine
16691 instruction that is part of the name.
16693 @smallexample
16694 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
16695 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
16696 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
16697 v1di __builtin_ia32_psadbw (v8qi, v8qi)
16698 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
16699 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
16700 v8qi __builtin_ia32_pminub (v8qi, v8qi)
16701 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
16702 int __builtin_ia32_pmovmskb (v8qi)
16703 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
16704 void __builtin_ia32_movntq (di *, di)
16705 void __builtin_ia32_sfence (void)
16706 @end smallexample
16708 The following built-in functions are available when @option{-msse} is used.
16709 All of them generate the machine instruction that is part of the name.
16711 @smallexample
16712 int __builtin_ia32_comieq (v4sf, v4sf)
16713 int __builtin_ia32_comineq (v4sf, v4sf)
16714 int __builtin_ia32_comilt (v4sf, v4sf)
16715 int __builtin_ia32_comile (v4sf, v4sf)
16716 int __builtin_ia32_comigt (v4sf, v4sf)
16717 int __builtin_ia32_comige (v4sf, v4sf)
16718 int __builtin_ia32_ucomieq (v4sf, v4sf)
16719 int __builtin_ia32_ucomineq (v4sf, v4sf)
16720 int __builtin_ia32_ucomilt (v4sf, v4sf)
16721 int __builtin_ia32_ucomile (v4sf, v4sf)
16722 int __builtin_ia32_ucomigt (v4sf, v4sf)
16723 int __builtin_ia32_ucomige (v4sf, v4sf)
16724 v4sf __builtin_ia32_addps (v4sf, v4sf)
16725 v4sf __builtin_ia32_subps (v4sf, v4sf)
16726 v4sf __builtin_ia32_mulps (v4sf, v4sf)
16727 v4sf __builtin_ia32_divps (v4sf, v4sf)
16728 v4sf __builtin_ia32_addss (v4sf, v4sf)
16729 v4sf __builtin_ia32_subss (v4sf, v4sf)
16730 v4sf __builtin_ia32_mulss (v4sf, v4sf)
16731 v4sf __builtin_ia32_divss (v4sf, v4sf)
16732 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
16733 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
16734 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
16735 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
16736 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
16737 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
16738 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
16739 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
16740 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
16741 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
16742 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
16743 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
16744 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
16745 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
16746 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
16747 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
16748 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
16749 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
16750 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
16751 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
16752 v4sf __builtin_ia32_maxps (v4sf, v4sf)
16753 v4sf __builtin_ia32_maxss (v4sf, v4sf)
16754 v4sf __builtin_ia32_minps (v4sf, v4sf)
16755 v4sf __builtin_ia32_minss (v4sf, v4sf)
16756 v4sf __builtin_ia32_andps (v4sf, v4sf)
16757 v4sf __builtin_ia32_andnps (v4sf, v4sf)
16758 v4sf __builtin_ia32_orps (v4sf, v4sf)
16759 v4sf __builtin_ia32_xorps (v4sf, v4sf)
16760 v4sf __builtin_ia32_movss (v4sf, v4sf)
16761 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
16762 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
16763 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
16764 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
16765 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
16766 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
16767 v2si __builtin_ia32_cvtps2pi (v4sf)
16768 int __builtin_ia32_cvtss2si (v4sf)
16769 v2si __builtin_ia32_cvttps2pi (v4sf)
16770 int __builtin_ia32_cvttss2si (v4sf)
16771 v4sf __builtin_ia32_rcpps (v4sf)
16772 v4sf __builtin_ia32_rsqrtps (v4sf)
16773 v4sf __builtin_ia32_sqrtps (v4sf)
16774 v4sf __builtin_ia32_rcpss (v4sf)
16775 v4sf __builtin_ia32_rsqrtss (v4sf)
16776 v4sf __builtin_ia32_sqrtss (v4sf)
16777 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
16778 void __builtin_ia32_movntps (float *, v4sf)
16779 int __builtin_ia32_movmskps (v4sf)
16780 @end smallexample
16782 The following built-in functions are available when @option{-msse} is used.
16784 @table @code
16785 @item v4sf __builtin_ia32_loadups (float *)
16786 Generates the @code{movups} machine instruction as a load from memory.
16787 @item void __builtin_ia32_storeups (float *, v4sf)
16788 Generates the @code{movups} machine instruction as a store to memory.
16789 @item v4sf __builtin_ia32_loadss (float *)
16790 Generates the @code{movss} machine instruction as a load from memory.
16791 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
16792 Generates the @code{movhps} machine instruction as a load from memory.
16793 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
16794 Generates the @code{movlps} machine instruction as a load from memory
16795 @item void __builtin_ia32_storehps (v2sf *, v4sf)
16796 Generates the @code{movhps} machine instruction as a store to memory.
16797 @item void __builtin_ia32_storelps (v2sf *, v4sf)
16798 Generates the @code{movlps} machine instruction as a store to memory.
16799 @end table
16801 The following built-in functions are available when @option{-msse2} is used.
16802 All of them generate the machine instruction that is part of the name.
16804 @smallexample
16805 int __builtin_ia32_comisdeq (v2df, v2df)
16806 int __builtin_ia32_comisdlt (v2df, v2df)
16807 int __builtin_ia32_comisdle (v2df, v2df)
16808 int __builtin_ia32_comisdgt (v2df, v2df)
16809 int __builtin_ia32_comisdge (v2df, v2df)
16810 int __builtin_ia32_comisdneq (v2df, v2df)
16811 int __builtin_ia32_ucomisdeq (v2df, v2df)
16812 int __builtin_ia32_ucomisdlt (v2df, v2df)
16813 int __builtin_ia32_ucomisdle (v2df, v2df)
16814 int __builtin_ia32_ucomisdgt (v2df, v2df)
16815 int __builtin_ia32_ucomisdge (v2df, v2df)
16816 int __builtin_ia32_ucomisdneq (v2df, v2df)
16817 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
16818 v2df __builtin_ia32_cmpltpd (v2df, v2df)
16819 v2df __builtin_ia32_cmplepd (v2df, v2df)
16820 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
16821 v2df __builtin_ia32_cmpgepd (v2df, v2df)
16822 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
16823 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
16824 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
16825 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
16826 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
16827 v2df __builtin_ia32_cmpngepd (v2df, v2df)
16828 v2df __builtin_ia32_cmpordpd (v2df, v2df)
16829 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
16830 v2df __builtin_ia32_cmpltsd (v2df, v2df)
16831 v2df __builtin_ia32_cmplesd (v2df, v2df)
16832 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
16833 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
16834 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
16835 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
16836 v2df __builtin_ia32_cmpordsd (v2df, v2df)
16837 v2di __builtin_ia32_paddq (v2di, v2di)
16838 v2di __builtin_ia32_psubq (v2di, v2di)
16839 v2df __builtin_ia32_addpd (v2df, v2df)
16840 v2df __builtin_ia32_subpd (v2df, v2df)
16841 v2df __builtin_ia32_mulpd (v2df, v2df)
16842 v2df __builtin_ia32_divpd (v2df, v2df)
16843 v2df __builtin_ia32_addsd (v2df, v2df)
16844 v2df __builtin_ia32_subsd (v2df, v2df)
16845 v2df __builtin_ia32_mulsd (v2df, v2df)
16846 v2df __builtin_ia32_divsd (v2df, v2df)
16847 v2df __builtin_ia32_minpd (v2df, v2df)
16848 v2df __builtin_ia32_maxpd (v2df, v2df)
16849 v2df __builtin_ia32_minsd (v2df, v2df)
16850 v2df __builtin_ia32_maxsd (v2df, v2df)
16851 v2df __builtin_ia32_andpd (v2df, v2df)
16852 v2df __builtin_ia32_andnpd (v2df, v2df)
16853 v2df __builtin_ia32_orpd (v2df, v2df)
16854 v2df __builtin_ia32_xorpd (v2df, v2df)
16855 v2df __builtin_ia32_movsd (v2df, v2df)
16856 v2df __builtin_ia32_unpckhpd (v2df, v2df)
16857 v2df __builtin_ia32_unpcklpd (v2df, v2df)
16858 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
16859 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
16860 v4si __builtin_ia32_paddd128 (v4si, v4si)
16861 v2di __builtin_ia32_paddq128 (v2di, v2di)
16862 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
16863 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
16864 v4si __builtin_ia32_psubd128 (v4si, v4si)
16865 v2di __builtin_ia32_psubq128 (v2di, v2di)
16866 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
16867 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
16868 v2di __builtin_ia32_pand128 (v2di, v2di)
16869 v2di __builtin_ia32_pandn128 (v2di, v2di)
16870 v2di __builtin_ia32_por128 (v2di, v2di)
16871 v2di __builtin_ia32_pxor128 (v2di, v2di)
16872 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
16873 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
16874 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
16875 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
16876 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
16877 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
16878 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
16879 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
16880 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
16881 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
16882 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
16883 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
16884 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
16885 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
16886 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
16887 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
16888 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
16889 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
16890 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
16891 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
16892 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
16893 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
16894 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
16895 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
16896 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
16897 v2df __builtin_ia32_loadupd (double *)
16898 void __builtin_ia32_storeupd (double *, v2df)
16899 v2df __builtin_ia32_loadhpd (v2df, double const *)
16900 v2df __builtin_ia32_loadlpd (v2df, double const *)
16901 int __builtin_ia32_movmskpd (v2df)
16902 int __builtin_ia32_pmovmskb128 (v16qi)
16903 void __builtin_ia32_movnti (int *, int)
16904 void __builtin_ia32_movnti64 (long long int *, long long int)
16905 void __builtin_ia32_movntpd (double *, v2df)
16906 void __builtin_ia32_movntdq (v2df *, v2df)
16907 v4si __builtin_ia32_pshufd (v4si, int)
16908 v8hi __builtin_ia32_pshuflw (v8hi, int)
16909 v8hi __builtin_ia32_pshufhw (v8hi, int)
16910 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
16911 v2df __builtin_ia32_sqrtpd (v2df)
16912 v2df __builtin_ia32_sqrtsd (v2df)
16913 v2df __builtin_ia32_shufpd (v2df, v2df, int)
16914 v2df __builtin_ia32_cvtdq2pd (v4si)
16915 v4sf __builtin_ia32_cvtdq2ps (v4si)
16916 v4si __builtin_ia32_cvtpd2dq (v2df)
16917 v2si __builtin_ia32_cvtpd2pi (v2df)
16918 v4sf __builtin_ia32_cvtpd2ps (v2df)
16919 v4si __builtin_ia32_cvttpd2dq (v2df)
16920 v2si __builtin_ia32_cvttpd2pi (v2df)
16921 v2df __builtin_ia32_cvtpi2pd (v2si)
16922 int __builtin_ia32_cvtsd2si (v2df)
16923 int __builtin_ia32_cvttsd2si (v2df)
16924 long long __builtin_ia32_cvtsd2si64 (v2df)
16925 long long __builtin_ia32_cvttsd2si64 (v2df)
16926 v4si __builtin_ia32_cvtps2dq (v4sf)
16927 v2df __builtin_ia32_cvtps2pd (v4sf)
16928 v4si __builtin_ia32_cvttps2dq (v4sf)
16929 v2df __builtin_ia32_cvtsi2sd (v2df, int)
16930 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
16931 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
16932 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
16933 void __builtin_ia32_clflush (const void *)
16934 void __builtin_ia32_lfence (void)
16935 void __builtin_ia32_mfence (void)
16936 v16qi __builtin_ia32_loaddqu (const char *)
16937 void __builtin_ia32_storedqu (char *, v16qi)
16938 v1di __builtin_ia32_pmuludq (v2si, v2si)
16939 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
16940 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
16941 v4si __builtin_ia32_pslld128 (v4si, v4si)
16942 v2di __builtin_ia32_psllq128 (v2di, v2di)
16943 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
16944 v4si __builtin_ia32_psrld128 (v4si, v4si)
16945 v2di __builtin_ia32_psrlq128 (v2di, v2di)
16946 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
16947 v4si __builtin_ia32_psrad128 (v4si, v4si)
16948 v2di __builtin_ia32_pslldqi128 (v2di, int)
16949 v8hi __builtin_ia32_psllwi128 (v8hi, int)
16950 v4si __builtin_ia32_pslldi128 (v4si, int)
16951 v2di __builtin_ia32_psllqi128 (v2di, int)
16952 v2di __builtin_ia32_psrldqi128 (v2di, int)
16953 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
16954 v4si __builtin_ia32_psrldi128 (v4si, int)
16955 v2di __builtin_ia32_psrlqi128 (v2di, int)
16956 v8hi __builtin_ia32_psrawi128 (v8hi, int)
16957 v4si __builtin_ia32_psradi128 (v4si, int)
16958 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
16959 v2di __builtin_ia32_movq128 (v2di)
16960 @end smallexample
16962 The following built-in functions are available when @option{-msse3} is used.
16963 All of them generate the machine instruction that is part of the name.
16965 @smallexample
16966 v2df __builtin_ia32_addsubpd (v2df, v2df)
16967 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
16968 v2df __builtin_ia32_haddpd (v2df, v2df)
16969 v4sf __builtin_ia32_haddps (v4sf, v4sf)
16970 v2df __builtin_ia32_hsubpd (v2df, v2df)
16971 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
16972 v16qi __builtin_ia32_lddqu (char const *)
16973 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
16974 v4sf __builtin_ia32_movshdup (v4sf)
16975 v4sf __builtin_ia32_movsldup (v4sf)
16976 void __builtin_ia32_mwait (unsigned int, unsigned int)
16977 @end smallexample
16979 The following built-in functions are available when @option{-mssse3} is used.
16980 All of them generate the machine instruction that is part of the name.
16982 @smallexample
16983 v2si __builtin_ia32_phaddd (v2si, v2si)
16984 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
16985 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
16986 v2si __builtin_ia32_phsubd (v2si, v2si)
16987 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
16988 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
16989 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
16990 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
16991 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
16992 v8qi __builtin_ia32_psignb (v8qi, v8qi)
16993 v2si __builtin_ia32_psignd (v2si, v2si)
16994 v4hi __builtin_ia32_psignw (v4hi, v4hi)
16995 v1di __builtin_ia32_palignr (v1di, v1di, int)
16996 v8qi __builtin_ia32_pabsb (v8qi)
16997 v2si __builtin_ia32_pabsd (v2si)
16998 v4hi __builtin_ia32_pabsw (v4hi)
16999 @end smallexample
17001 The following built-in functions are available when @option{-mssse3} is used.
17002 All of them generate the machine instruction that is part of the name.
17004 @smallexample
17005 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17006 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17007 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17008 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17009 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17010 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17011 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17012 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17013 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17014 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17015 v4si __builtin_ia32_psignd128 (v4si, v4si)
17016 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17017 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17018 v16qi __builtin_ia32_pabsb128 (v16qi)
17019 v4si __builtin_ia32_pabsd128 (v4si)
17020 v8hi __builtin_ia32_pabsw128 (v8hi)
17021 @end smallexample
17023 The following built-in functions are available when @option{-msse4.1} is
17024 used.  All of them generate the machine instruction that is part of the
17025 name.
17027 @smallexample
17028 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17029 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17030 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17031 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17032 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17033 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17034 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17035 v2di __builtin_ia32_movntdqa (v2di *);
17036 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17037 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17038 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17039 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17040 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17041 v8hi __builtin_ia32_phminposuw128 (v8hi)
17042 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17043 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17044 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17045 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17046 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17047 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17048 v4si __builtin_ia32_pminud128 (v4si, v4si)
17049 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17050 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17051 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17052 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17053 v2di __builtin_ia32_pmovsxdq128 (v4si)
17054 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17055 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17056 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17057 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17058 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17059 v2di __builtin_ia32_pmovzxdq128 (v4si)
17060 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17061 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17062 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17063 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17064 int __builtin_ia32_ptestc128 (v2di, v2di)
17065 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17066 int __builtin_ia32_ptestz128 (v2di, v2di)
17067 v2df __builtin_ia32_roundpd (v2df, const int)
17068 v4sf __builtin_ia32_roundps (v4sf, const int)
17069 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17070 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17071 @end smallexample
17073 The following built-in functions are available when @option{-msse4.1} is
17074 used.
17076 @table @code
17077 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17078 Generates the @code{insertps} machine instruction.
17079 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17080 Generates the @code{pextrb} machine instruction.
17081 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17082 Generates the @code{pinsrb} machine instruction.
17083 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17084 Generates the @code{pinsrd} machine instruction.
17085 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
17086 Generates the @code{pinsrq} machine instruction in 64bit mode.
17087 @end table
17089 The following built-in functions are changed to generate new SSE4.1
17090 instructions when @option{-msse4.1} is used.
17092 @table @code
17093 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
17094 Generates the @code{extractps} machine instruction.
17095 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
17096 Generates the @code{pextrd} machine instruction.
17097 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
17098 Generates the @code{pextrq} machine instruction in 64bit mode.
17099 @end table
17101 The following built-in functions are available when @option{-msse4.2} is
17102 used.  All of them generate the machine instruction that is part of the
17103 name.
17105 @smallexample
17106 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
17107 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
17108 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
17109 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
17110 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
17111 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
17112 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
17113 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
17114 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
17115 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
17116 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
17117 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
17118 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
17119 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
17120 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
17121 @end smallexample
17123 The following built-in functions are available when @option{-msse4.2} is
17124 used.
17126 @table @code
17127 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
17128 Generates the @code{crc32b} machine instruction.
17129 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
17130 Generates the @code{crc32w} machine instruction.
17131 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
17132 Generates the @code{crc32l} machine instruction.
17133 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
17134 Generates the @code{crc32q} machine instruction.
17135 @end table
17137 The following built-in functions are changed to generate new SSE4.2
17138 instructions when @option{-msse4.2} is used.
17140 @table @code
17141 @item int __builtin_popcount (unsigned int)
17142 Generates the @code{popcntl} machine instruction.
17143 @item int __builtin_popcountl (unsigned long)
17144 Generates the @code{popcntl} or @code{popcntq} machine instruction,
17145 depending on the size of @code{unsigned long}.
17146 @item int __builtin_popcountll (unsigned long long)
17147 Generates the @code{popcntq} machine instruction.
17148 @end table
17150 The following built-in functions are available when @option{-mavx} is
17151 used. All of them generate the machine instruction that is part of the
17152 name.
17154 @smallexample
17155 v4df __builtin_ia32_addpd256 (v4df,v4df)
17156 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
17157 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
17158 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
17159 v4df __builtin_ia32_andnpd256 (v4df,v4df)
17160 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
17161 v4df __builtin_ia32_andpd256 (v4df,v4df)
17162 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
17163 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
17164 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
17165 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
17166 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
17167 v2df __builtin_ia32_cmppd (v2df,v2df,int)
17168 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
17169 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
17170 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
17171 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
17172 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
17173 v4df __builtin_ia32_cvtdq2pd256 (v4si)
17174 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
17175 v4si __builtin_ia32_cvtpd2dq256 (v4df)
17176 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
17177 v8si __builtin_ia32_cvtps2dq256 (v8sf)
17178 v4df __builtin_ia32_cvtps2pd256 (v4sf)
17179 v4si __builtin_ia32_cvttpd2dq256 (v4df)
17180 v8si __builtin_ia32_cvttps2dq256 (v8sf)
17181 v4df __builtin_ia32_divpd256 (v4df,v4df)
17182 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
17183 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
17184 v4df __builtin_ia32_haddpd256 (v4df,v4df)
17185 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
17186 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
17187 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
17188 v32qi __builtin_ia32_lddqu256 (pcchar)
17189 v32qi __builtin_ia32_loaddqu256 (pcchar)
17190 v4df __builtin_ia32_loadupd256 (pcdouble)
17191 v8sf __builtin_ia32_loadups256 (pcfloat)
17192 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
17193 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
17194 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
17195 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
17196 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
17197 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
17198 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
17199 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
17200 v4df __builtin_ia32_maxpd256 (v4df,v4df)
17201 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
17202 v4df __builtin_ia32_minpd256 (v4df,v4df)
17203 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
17204 v4df __builtin_ia32_movddup256 (v4df)
17205 int __builtin_ia32_movmskpd256 (v4df)
17206 int __builtin_ia32_movmskps256 (v8sf)
17207 v8sf __builtin_ia32_movshdup256 (v8sf)
17208 v8sf __builtin_ia32_movsldup256 (v8sf)
17209 v4df __builtin_ia32_mulpd256 (v4df,v4df)
17210 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
17211 v4df __builtin_ia32_orpd256 (v4df,v4df)
17212 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
17213 v2df __builtin_ia32_pd_pd256 (v4df)
17214 v4df __builtin_ia32_pd256_pd (v2df)
17215 v4sf __builtin_ia32_ps_ps256 (v8sf)
17216 v8sf __builtin_ia32_ps256_ps (v4sf)
17217 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
17218 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
17219 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
17220 v8sf __builtin_ia32_rcpps256 (v8sf)
17221 v4df __builtin_ia32_roundpd256 (v4df,int)
17222 v8sf __builtin_ia32_roundps256 (v8sf,int)
17223 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
17224 v8sf __builtin_ia32_rsqrtps256 (v8sf)
17225 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
17226 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
17227 v4si __builtin_ia32_si_si256 (v8si)
17228 v8si __builtin_ia32_si256_si (v4si)
17229 v4df __builtin_ia32_sqrtpd256 (v4df)
17230 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
17231 v8sf __builtin_ia32_sqrtps256 (v8sf)
17232 void __builtin_ia32_storedqu256 (pchar,v32qi)
17233 void __builtin_ia32_storeupd256 (pdouble,v4df)
17234 void __builtin_ia32_storeups256 (pfloat,v8sf)
17235 v4df __builtin_ia32_subpd256 (v4df,v4df)
17236 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
17237 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
17238 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
17239 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
17240 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
17241 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
17242 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
17243 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
17244 v4sf __builtin_ia32_vbroadcastss (pcfloat)
17245 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
17246 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
17247 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
17248 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
17249 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
17250 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
17251 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
17252 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
17253 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
17254 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
17255 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
17256 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
17257 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
17258 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
17259 v2df __builtin_ia32_vpermilpd (v2df,int)
17260 v4df __builtin_ia32_vpermilpd256 (v4df,int)
17261 v4sf __builtin_ia32_vpermilps (v4sf,int)
17262 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
17263 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
17264 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
17265 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
17266 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
17267 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
17268 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
17269 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
17270 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
17271 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
17272 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
17273 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
17274 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
17275 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
17276 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
17277 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
17278 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
17279 void __builtin_ia32_vzeroall (void)
17280 void __builtin_ia32_vzeroupper (void)
17281 v4df __builtin_ia32_xorpd256 (v4df,v4df)
17282 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
17283 @end smallexample
17285 The following built-in functions are available when @option{-mavx2} is
17286 used. All of them generate the machine instruction that is part of the
17287 name.
17289 @smallexample
17290 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
17291 v32qi __builtin_ia32_pabsb256 (v32qi)
17292 v16hi __builtin_ia32_pabsw256 (v16hi)
17293 v8si __builtin_ia32_pabsd256 (v8si)
17294 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
17295 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
17296 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
17297 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
17298 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
17299 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
17300 v8si __builtin_ia32_paddd256 (v8si,v8si)
17301 v4di __builtin_ia32_paddq256 (v4di,v4di)
17302 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
17303 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
17304 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
17305 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
17306 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
17307 v4di __builtin_ia32_andsi256 (v4di,v4di)
17308 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
17309 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
17310 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
17311 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
17312 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
17313 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
17314 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
17315 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
17316 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
17317 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
17318 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
17319 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
17320 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
17321 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
17322 v8si __builtin_ia32_phaddd256 (v8si,v8si)
17323 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
17324 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
17325 v8si __builtin_ia32_phsubd256 (v8si,v8si)
17326 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
17327 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
17328 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
17329 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
17330 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
17331 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
17332 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
17333 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
17334 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
17335 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
17336 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
17337 v8si __builtin_ia32_pminsd256 (v8si,v8si)
17338 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
17339 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
17340 v8si __builtin_ia32_pminud256 (v8si,v8si)
17341 int __builtin_ia32_pmovmskb256 (v32qi)
17342 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
17343 v8si __builtin_ia32_pmovsxbd256 (v16qi)
17344 v4di __builtin_ia32_pmovsxbq256 (v16qi)
17345 v8si __builtin_ia32_pmovsxwd256 (v8hi)
17346 v4di __builtin_ia32_pmovsxwq256 (v8hi)
17347 v4di __builtin_ia32_pmovsxdq256 (v4si)
17348 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
17349 v8si __builtin_ia32_pmovzxbd256 (v16qi)
17350 v4di __builtin_ia32_pmovzxbq256 (v16qi)
17351 v8si __builtin_ia32_pmovzxwd256 (v8hi)
17352 v4di __builtin_ia32_pmovzxwq256 (v8hi)
17353 v4di __builtin_ia32_pmovzxdq256 (v4si)
17354 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
17355 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
17356 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
17357 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
17358 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
17359 v8si __builtin_ia32_pmulld256 (v8si,v8si)
17360 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
17361 v4di __builtin_ia32_por256 (v4di,v4di)
17362 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
17363 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
17364 v8si __builtin_ia32_pshufd256 (v8si,int)
17365 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
17366 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
17367 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
17368 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
17369 v8si __builtin_ia32_psignd256 (v8si,v8si)
17370 v4di __builtin_ia32_pslldqi256 (v4di,int)
17371 v16hi __builtin_ia32_psllwi256 (16hi,int)
17372 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
17373 v8si __builtin_ia32_pslldi256 (v8si,int)
17374 v8si __builtin_ia32_pslld256(v8si,v4si)
17375 v4di __builtin_ia32_psllqi256 (v4di,int)
17376 v4di __builtin_ia32_psllq256(v4di,v2di)
17377 v16hi __builtin_ia32_psrawi256 (v16hi,int)
17378 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
17379 v8si __builtin_ia32_psradi256 (v8si,int)
17380 v8si __builtin_ia32_psrad256 (v8si,v4si)
17381 v4di __builtin_ia32_psrldqi256 (v4di, int)
17382 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
17383 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
17384 v8si __builtin_ia32_psrldi256 (v8si,int)
17385 v8si __builtin_ia32_psrld256 (v8si,v4si)
17386 v4di __builtin_ia32_psrlqi256 (v4di,int)
17387 v4di __builtin_ia32_psrlq256(v4di,v2di)
17388 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
17389 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
17390 v8si __builtin_ia32_psubd256 (v8si,v8si)
17391 v4di __builtin_ia32_psubq256 (v4di,v4di)
17392 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
17393 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
17394 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
17395 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
17396 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
17397 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
17398 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
17399 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
17400 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
17401 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
17402 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
17403 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
17404 v4di __builtin_ia32_pxor256 (v4di,v4di)
17405 v4di __builtin_ia32_movntdqa256 (pv4di)
17406 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
17407 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
17408 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
17409 v4di __builtin_ia32_vbroadcastsi256 (v2di)
17410 v4si __builtin_ia32_pblendd128 (v4si,v4si)
17411 v8si __builtin_ia32_pblendd256 (v8si,v8si)
17412 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
17413 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
17414 v8si __builtin_ia32_pbroadcastd256 (v4si)
17415 v4di __builtin_ia32_pbroadcastq256 (v2di)
17416 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
17417 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
17418 v4si __builtin_ia32_pbroadcastd128 (v4si)
17419 v2di __builtin_ia32_pbroadcastq128 (v2di)
17420 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
17421 v4df __builtin_ia32_permdf256 (v4df,int)
17422 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
17423 v4di __builtin_ia32_permdi256 (v4di,int)
17424 v4di __builtin_ia32_permti256 (v4di,v4di,int)
17425 v4di __builtin_ia32_extract128i256 (v4di,int)
17426 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
17427 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
17428 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
17429 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
17430 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
17431 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
17432 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
17433 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
17434 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
17435 v8si __builtin_ia32_psllv8si (v8si,v8si)
17436 v4si __builtin_ia32_psllv4si (v4si,v4si)
17437 v4di __builtin_ia32_psllv4di (v4di,v4di)
17438 v2di __builtin_ia32_psllv2di (v2di,v2di)
17439 v8si __builtin_ia32_psrav8si (v8si,v8si)
17440 v4si __builtin_ia32_psrav4si (v4si,v4si)
17441 v8si __builtin_ia32_psrlv8si (v8si,v8si)
17442 v4si __builtin_ia32_psrlv4si (v4si,v4si)
17443 v4di __builtin_ia32_psrlv4di (v4di,v4di)
17444 v2di __builtin_ia32_psrlv2di (v2di,v2di)
17445 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
17446 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
17447 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
17448 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
17449 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
17450 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
17451 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
17452 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
17453 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
17454 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
17455 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
17456 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
17457 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
17458 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
17459 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
17460 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
17461 @end smallexample
17463 The following built-in functions are available when @option{-maes} is
17464 used.  All of them generate the machine instruction that is part of the
17465 name.
17467 @smallexample
17468 v2di __builtin_ia32_aesenc128 (v2di, v2di)
17469 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
17470 v2di __builtin_ia32_aesdec128 (v2di, v2di)
17471 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
17472 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
17473 v2di __builtin_ia32_aesimc128 (v2di)
17474 @end smallexample
17476 The following built-in function is available when @option{-mpclmul} is
17477 used.
17479 @table @code
17480 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
17481 Generates the @code{pclmulqdq} machine instruction.
17482 @end table
17484 The following built-in function is available when @option{-mfsgsbase} is
17485 used.  All of them generate the machine instruction that is part of the
17486 name.
17488 @smallexample
17489 unsigned int __builtin_ia32_rdfsbase32 (void)
17490 unsigned long long __builtin_ia32_rdfsbase64 (void)
17491 unsigned int __builtin_ia32_rdgsbase32 (void)
17492 unsigned long long __builtin_ia32_rdgsbase64 (void)
17493 void _writefsbase_u32 (unsigned int)
17494 void _writefsbase_u64 (unsigned long long)
17495 void _writegsbase_u32 (unsigned int)
17496 void _writegsbase_u64 (unsigned long long)
17497 @end smallexample
17499 The following built-in function is available when @option{-mrdrnd} is
17500 used.  All of them generate the machine instruction that is part of the
17501 name.
17503 @smallexample
17504 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
17505 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
17506 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
17507 @end smallexample
17509 The following built-in functions are available when @option{-msse4a} is used.
17510 All of them generate the machine instruction that is part of the name.
17512 @smallexample
17513 void __builtin_ia32_movntsd (double *, v2df)
17514 void __builtin_ia32_movntss (float *, v4sf)
17515 v2di __builtin_ia32_extrq  (v2di, v16qi)
17516 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
17517 v2di __builtin_ia32_insertq (v2di, v2di)
17518 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
17519 @end smallexample
17521 The following built-in functions are available when @option{-mxop} is used.
17522 @smallexample
17523 v2df __builtin_ia32_vfrczpd (v2df)
17524 v4sf __builtin_ia32_vfrczps (v4sf)
17525 v2df __builtin_ia32_vfrczsd (v2df)
17526 v4sf __builtin_ia32_vfrczss (v4sf)
17527 v4df __builtin_ia32_vfrczpd256 (v4df)
17528 v8sf __builtin_ia32_vfrczps256 (v8sf)
17529 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
17530 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
17531 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
17532 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
17533 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
17534 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
17535 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
17536 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
17537 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
17538 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
17539 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
17540 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
17541 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
17542 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
17543 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17544 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
17545 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
17546 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
17547 v4si __builtin_ia32_vpcomequd (v4si, v4si)
17548 v2di __builtin_ia32_vpcomequq (v2di, v2di)
17549 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
17550 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17551 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
17552 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
17553 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
17554 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
17555 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
17556 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
17557 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
17558 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
17559 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
17560 v4si __builtin_ia32_vpcomged (v4si, v4si)
17561 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
17562 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
17563 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
17564 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
17565 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
17566 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
17567 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
17568 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
17569 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
17570 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
17571 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
17572 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
17573 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
17574 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
17575 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
17576 v4si __builtin_ia32_vpcomled (v4si, v4si)
17577 v2di __builtin_ia32_vpcomleq (v2di, v2di)
17578 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
17579 v4si __builtin_ia32_vpcomleud (v4si, v4si)
17580 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
17581 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
17582 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
17583 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
17584 v4si __builtin_ia32_vpcomltd (v4si, v4si)
17585 v2di __builtin_ia32_vpcomltq (v2di, v2di)
17586 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
17587 v4si __builtin_ia32_vpcomltud (v4si, v4si)
17588 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
17589 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
17590 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
17591 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
17592 v4si __builtin_ia32_vpcomned (v4si, v4si)
17593 v2di __builtin_ia32_vpcomneq (v2di, v2di)
17594 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
17595 v4si __builtin_ia32_vpcomneud (v4si, v4si)
17596 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
17597 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
17598 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
17599 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
17600 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
17601 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
17602 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
17603 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
17604 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
17605 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
17606 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
17607 v4si __builtin_ia32_vphaddbd (v16qi)
17608 v2di __builtin_ia32_vphaddbq (v16qi)
17609 v8hi __builtin_ia32_vphaddbw (v16qi)
17610 v2di __builtin_ia32_vphadddq (v4si)
17611 v4si __builtin_ia32_vphaddubd (v16qi)
17612 v2di __builtin_ia32_vphaddubq (v16qi)
17613 v8hi __builtin_ia32_vphaddubw (v16qi)
17614 v2di __builtin_ia32_vphaddudq (v4si)
17615 v4si __builtin_ia32_vphadduwd (v8hi)
17616 v2di __builtin_ia32_vphadduwq (v8hi)
17617 v4si __builtin_ia32_vphaddwd (v8hi)
17618 v2di __builtin_ia32_vphaddwq (v8hi)
17619 v8hi __builtin_ia32_vphsubbw (v16qi)
17620 v2di __builtin_ia32_vphsubdq (v4si)
17621 v4si __builtin_ia32_vphsubwd (v8hi)
17622 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
17623 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
17624 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
17625 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
17626 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
17627 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
17628 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
17629 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
17630 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
17631 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
17632 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
17633 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
17634 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
17635 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
17636 v4si __builtin_ia32_vprotd (v4si, v4si)
17637 v2di __builtin_ia32_vprotq (v2di, v2di)
17638 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
17639 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
17640 v4si __builtin_ia32_vpshad (v4si, v4si)
17641 v2di __builtin_ia32_vpshaq (v2di, v2di)
17642 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
17643 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
17644 v4si __builtin_ia32_vpshld (v4si, v4si)
17645 v2di __builtin_ia32_vpshlq (v2di, v2di)
17646 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
17647 @end smallexample
17649 The following built-in functions are available when @option{-mfma4} is used.
17650 All of them generate the machine instruction that is part of the name.
17652 @smallexample
17653 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
17654 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
17655 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
17656 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
17657 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
17658 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
17659 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
17660 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
17661 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
17662 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
17663 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
17664 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
17665 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
17666 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
17667 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
17668 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
17669 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
17670 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
17671 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
17672 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
17673 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
17674 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
17675 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
17676 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
17677 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
17678 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
17679 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
17680 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
17681 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
17682 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
17683 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
17684 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
17686 @end smallexample
17688 The following built-in functions are available when @option{-mlwp} is used.
17690 @smallexample
17691 void __builtin_ia32_llwpcb16 (void *);
17692 void __builtin_ia32_llwpcb32 (void *);
17693 void __builtin_ia32_llwpcb64 (void *);
17694 void * __builtin_ia32_llwpcb16 (void);
17695 void * __builtin_ia32_llwpcb32 (void);
17696 void * __builtin_ia32_llwpcb64 (void);
17697 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
17698 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
17699 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
17700 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
17701 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
17702 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
17703 @end smallexample
17705 The following built-in functions are available when @option{-mbmi} is used.
17706 All of them generate the machine instruction that is part of the name.
17707 @smallexample
17708 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
17709 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
17710 @end smallexample
17712 The following built-in functions are available when @option{-mbmi2} is used.
17713 All of them generate the machine instruction that is part of the name.
17714 @smallexample
17715 unsigned int _bzhi_u32 (unsigned int, unsigned int)
17716 unsigned int _pdep_u32 (unsigned int, unsigned int)
17717 unsigned int _pext_u32 (unsigned int, unsigned int)
17718 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
17719 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
17720 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
17721 @end smallexample
17723 The following built-in functions are available when @option{-mlzcnt} is used.
17724 All of them generate the machine instruction that is part of the name.
17725 @smallexample
17726 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
17727 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
17728 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
17729 @end smallexample
17731 The following built-in functions are available when @option{-mfxsr} is used.
17732 All of them generate the machine instruction that is part of the name.
17733 @smallexample
17734 void __builtin_ia32_fxsave (void *)
17735 void __builtin_ia32_fxrstor (void *)
17736 void __builtin_ia32_fxsave64 (void *)
17737 void __builtin_ia32_fxrstor64 (void *)
17738 @end smallexample
17740 The following built-in functions are available when @option{-mxsave} is used.
17741 All of them generate the machine instruction that is part of the name.
17742 @smallexample
17743 void __builtin_ia32_xsave (void *, long long)
17744 void __builtin_ia32_xrstor (void *, long long)
17745 void __builtin_ia32_xsave64 (void *, long long)
17746 void __builtin_ia32_xrstor64 (void *, long long)
17747 @end smallexample
17749 The following built-in functions are available when @option{-mxsaveopt} is used.
17750 All of them generate the machine instruction that is part of the name.
17751 @smallexample
17752 void __builtin_ia32_xsaveopt (void *, long long)
17753 void __builtin_ia32_xsaveopt64 (void *, long long)
17754 @end smallexample
17756 The following built-in functions are available when @option{-mtbm} is used.
17757 Both of them generate the immediate form of the bextr machine instruction.
17758 @smallexample
17759 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
17760 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
17761 @end smallexample
17764 The following built-in functions are available when @option{-m3dnow} is used.
17765 All of them generate the machine instruction that is part of the name.
17767 @smallexample
17768 void __builtin_ia32_femms (void)
17769 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
17770 v2si __builtin_ia32_pf2id (v2sf)
17771 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
17772 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
17773 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
17774 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
17775 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
17776 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
17777 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
17778 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
17779 v2sf __builtin_ia32_pfrcp (v2sf)
17780 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
17781 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
17782 v2sf __builtin_ia32_pfrsqrt (v2sf)
17783 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
17784 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
17785 v2sf __builtin_ia32_pi2fd (v2si)
17786 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
17787 @end smallexample
17789 The following built-in functions are available when both @option{-m3dnow}
17790 and @option{-march=athlon} are used.  All of them generate the machine
17791 instruction that is part of the name.
17793 @smallexample
17794 v2si __builtin_ia32_pf2iw (v2sf)
17795 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
17796 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
17797 v2sf __builtin_ia32_pi2fw (v2si)
17798 v2sf __builtin_ia32_pswapdsf (v2sf)
17799 v2si __builtin_ia32_pswapdsi (v2si)
17800 @end smallexample
17802 The following built-in functions are available when @option{-mrtm} is used
17803 They are used for restricted transactional memory. These are the internal
17804 low level functions. Normally the functions in 
17805 @ref{x86 transactional memory intrinsics} should be used instead.
17807 @smallexample
17808 int __builtin_ia32_xbegin ()
17809 void __builtin_ia32_xend ()
17810 void __builtin_ia32_xabort (status)
17811 int __builtin_ia32_xtest ()
17812 @end smallexample
17814 @node x86 transactional memory intrinsics
17815 @subsection x86 Transactional Memory Intrinsics
17817 These hardware transactional memory intrinsics for x86 allow you to use
17818 memory transactions with RTM (Restricted Transactional Memory).
17819 This support is enabled with the @option{-mrtm} option.
17820 For using HLE (Hardware Lock Elision) see 
17821 @ref{x86 specific memory model extensions for transactional memory} instead.
17823 A memory transaction commits all changes to memory in an atomic way,
17824 as visible to other threads. If the transaction fails it is rolled back
17825 and all side effects discarded.
17827 Generally there is no guarantee that a memory transaction ever succeeds
17828 and suitable fallback code always needs to be supplied.
17830 @deftypefn {RTM Function} {unsigned} _xbegin ()
17831 Start a RTM (Restricted Transactional Memory) transaction. 
17832 Returns @code{_XBEGIN_STARTED} when the transaction
17833 started successfully (note this is not 0, so the constant has to be 
17834 explicitly tested).  
17836 If the transaction aborts, all side-effects 
17837 are undone and an abort code encoded as a bit mask is returned.
17838 The following macros are defined:
17840 @table @code
17841 @item _XABORT_EXPLICIT
17842 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
17843 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
17844 @item _XABORT_RETRY
17845 Transaction retry is possible.
17846 @item _XABORT_CONFLICT
17847 Transaction abort due to a memory conflict with another thread.
17848 @item _XABORT_CAPACITY
17849 Transaction abort due to the transaction using too much memory.
17850 @item _XABORT_DEBUG
17851 Transaction abort due to a debug trap.
17852 @item _XABORT_NESTED
17853 Transaction abort in an inner nested transaction.
17854 @end table
17856 There is no guarantee
17857 any transaction ever succeeds, so there always needs to be a valid
17858 fallback path.
17859 @end deftypefn
17861 @deftypefn {RTM Function} {void} _xend ()
17862 Commit the current transaction. When no transaction is active this faults.
17863 All memory side-effects of the transaction become visible
17864 to other threads in an atomic manner.
17865 @end deftypefn
17867 @deftypefn {RTM Function} {int} _xtest ()
17868 Return a nonzero value if a transaction is currently active, otherwise 0.
17869 @end deftypefn
17871 @deftypefn {RTM Function} {void} _xabort (status)
17872 Abort the current transaction. When no transaction is active this is a no-op.
17873 The @var{status} is an 8-bit constant; its value is encoded in the return 
17874 value from @code{_xbegin}.
17875 @end deftypefn
17877 Here is an example showing handling for @code{_XABORT_RETRY}
17878 and a fallback path for other failures:
17880 @smallexample
17881 #include <immintrin.h>
17883 int n_tries, max_tries;
17884 unsigned status = _XABORT_EXPLICIT;
17887 for (n_tries = 0; n_tries < max_tries; n_tries++) 
17888   @{
17889     status = _xbegin ();
17890     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
17891       break;
17892   @}
17893 if (status == _XBEGIN_STARTED) 
17894   @{
17895     ... transaction code...
17896     _xend ();
17897   @} 
17898 else 
17899   @{
17900     ... non-transactional fallback path...
17901   @}
17902 @end smallexample
17904 @noindent
17905 Note that, in most cases, the transactional and non-transactional code
17906 must synchronize together to ensure consistency.
17908 @node Target Format Checks
17909 @section Format Checks Specific to Particular Target Machines
17911 For some target machines, GCC supports additional options to the
17912 format attribute
17913 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17915 @menu
17916 * Solaris Format Checks::
17917 * Darwin Format Checks::
17918 @end menu
17920 @node Solaris Format Checks
17921 @subsection Solaris Format Checks
17923 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17924 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
17925 conversions, and the two-argument @code{%b} conversion for displaying
17926 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
17928 @node Darwin Format Checks
17929 @subsection Darwin Format Checks
17931 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17932 attribute context.  Declarations made with such attribution are parsed for correct syntax
17933 and format argument types.  However, parsing of the format string itself is currently undefined
17934 and is not carried out by this version of the compiler.
17936 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17937 also be used as format arguments.  Note that the relevant headers are only likely to be
17938 available on Darwin (OSX) installations.  On such installations, the XCode and system
17939 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17940 associated functions.
17942 @node Pragmas
17943 @section Pragmas Accepted by GCC
17944 @cindex pragmas
17945 @cindex @code{#pragma}
17947 GCC supports several types of pragmas, primarily in order to compile
17948 code originally written for other compilers.  Note that in general
17949 we do not recommend the use of pragmas; @xref{Function Attributes},
17950 for further explanation.
17952 @menu
17953 * ARM Pragmas::
17954 * M32C Pragmas::
17955 * MeP Pragmas::
17956 * RS/6000 and PowerPC Pragmas::
17957 * Darwin Pragmas::
17958 * Solaris Pragmas::
17959 * Symbol-Renaming Pragmas::
17960 * Structure-Packing Pragmas::
17961 * Weak Pragmas::
17962 * Diagnostic Pragmas::
17963 * Visibility Pragmas::
17964 * Push/Pop Macro Pragmas::
17965 * Function Specific Option Pragmas::
17966 * Loop-Specific Pragmas::
17967 @end menu
17969 @node ARM Pragmas
17970 @subsection ARM Pragmas
17972 The ARM target defines pragmas for controlling the default addition of
17973 @code{long_call} and @code{short_call} attributes to functions.
17974 @xref{Function Attributes}, for information about the effects of these
17975 attributes.
17977 @table @code
17978 @item long_calls
17979 @cindex pragma, long_calls
17980 Set all subsequent functions to have the @code{long_call} attribute.
17982 @item no_long_calls
17983 @cindex pragma, no_long_calls
17984 Set all subsequent functions to have the @code{short_call} attribute.
17986 @item long_calls_off
17987 @cindex pragma, long_calls_off
17988 Do not affect the @code{long_call} or @code{short_call} attributes of
17989 subsequent functions.
17990 @end table
17992 @node M32C Pragmas
17993 @subsection M32C Pragmas
17995 @table @code
17996 @item GCC memregs @var{number}
17997 @cindex pragma, memregs
17998 Overrides the command-line option @code{-memregs=} for the current
17999 file.  Use with care!  This pragma must be before any function in the
18000 file, and mixing different memregs values in different objects may
18001 make them incompatible.  This pragma is useful when a
18002 performance-critical function uses a memreg for temporary values,
18003 as it may allow you to reduce the number of memregs used.
18005 @item ADDRESS @var{name} @var{address}
18006 @cindex pragma, address
18007 For any declared symbols matching @var{name}, this does three things
18008 to that symbol: it forces the symbol to be located at the given
18009 address (a number), it forces the symbol to be volatile, and it
18010 changes the symbol's scope to be static.  This pragma exists for
18011 compatibility with other compilers, but note that the common
18012 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18013 instead).  Example:
18015 @smallexample
18016 #pragma ADDRESS port3 0x103
18017 char port3;
18018 @end smallexample
18020 @end table
18022 @node MeP Pragmas
18023 @subsection MeP Pragmas
18025 @table @code
18027 @item custom io_volatile (on|off)
18028 @cindex pragma, custom io_volatile
18029 Overrides the command-line option @code{-mio-volatile} for the current
18030 file.  Note that for compatibility with future GCC releases, this
18031 option should only be used once before any @code{io} variables in each
18032 file.
18034 @item GCC coprocessor available @var{registers}
18035 @cindex pragma, coprocessor available
18036 Specifies which coprocessor registers are available to the register
18037 allocator.  @var{registers} may be a single register, register range
18038 separated by ellipses, or comma-separated list of those.  Example:
18040 @smallexample
18041 #pragma GCC coprocessor available $c0...$c10, $c28
18042 @end smallexample
18044 @item GCC coprocessor call_saved @var{registers}
18045 @cindex pragma, coprocessor call_saved
18046 Specifies which coprocessor registers are to be saved and restored by
18047 any function using them.  @var{registers} may be a single register,
18048 register range separated by ellipses, or comma-separated list of
18049 those.  Example:
18051 @smallexample
18052 #pragma GCC coprocessor call_saved $c4...$c6, $c31
18053 @end smallexample
18055 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
18056 @cindex pragma, coprocessor subclass
18057 Creates and defines a register class.  These register classes can be
18058 used by inline @code{asm} constructs.  @var{registers} may be a single
18059 register, register range separated by ellipses, or comma-separated
18060 list of those.  Example:
18062 @smallexample
18063 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
18065 asm ("cpfoo %0" : "=B" (x));
18066 @end smallexample
18068 @item GCC disinterrupt @var{name} , @var{name} @dots{}
18069 @cindex pragma, disinterrupt
18070 For the named functions, the compiler adds code to disable interrupts
18071 for the duration of those functions.  If any functions so named 
18072 are not encountered in the source, a warning is emitted that the pragma is
18073 not used.  Examples:
18075 @smallexample
18076 #pragma disinterrupt foo
18077 #pragma disinterrupt bar, grill
18078 int foo () @{ @dots{} @}
18079 @end smallexample
18081 @item GCC call @var{name} , @var{name} @dots{}
18082 @cindex pragma, call
18083 For the named functions, the compiler always uses a register-indirect
18084 call model when calling the named functions.  Examples:
18086 @smallexample
18087 extern int foo ();
18088 #pragma call foo
18089 @end smallexample
18091 @end table
18093 @node RS/6000 and PowerPC Pragmas
18094 @subsection RS/6000 and PowerPC Pragmas
18096 The RS/6000 and PowerPC targets define one pragma for controlling
18097 whether or not the @code{longcall} attribute is added to function
18098 declarations by default.  This pragma overrides the @option{-mlongcall}
18099 option, but not the @code{longcall} and @code{shortcall} attributes.
18100 @xref{RS/6000 and PowerPC Options}, for more information about when long
18101 calls are and are not necessary.
18103 @table @code
18104 @item longcall (1)
18105 @cindex pragma, longcall
18106 Apply the @code{longcall} attribute to all subsequent function
18107 declarations.
18109 @item longcall (0)
18110 Do not apply the @code{longcall} attribute to subsequent function
18111 declarations.
18112 @end table
18114 @c Describe h8300 pragmas here.
18115 @c Describe sh pragmas here.
18116 @c Describe v850 pragmas here.
18118 @node Darwin Pragmas
18119 @subsection Darwin Pragmas
18121 The following pragmas are available for all architectures running the
18122 Darwin operating system.  These are useful for compatibility with other
18123 Mac OS compilers.
18125 @table @code
18126 @item mark @var{tokens}@dots{}
18127 @cindex pragma, mark
18128 This pragma is accepted, but has no effect.
18130 @item options align=@var{alignment}
18131 @cindex pragma, options align
18132 This pragma sets the alignment of fields in structures.  The values of
18133 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
18134 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
18135 properly; to restore the previous setting, use @code{reset} for the
18136 @var{alignment}.
18138 @item segment @var{tokens}@dots{}
18139 @cindex pragma, segment
18140 This pragma is accepted, but has no effect.
18142 @item unused (@var{var} [, @var{var}]@dots{})
18143 @cindex pragma, unused
18144 This pragma declares variables to be possibly unused.  GCC does not
18145 produce warnings for the listed variables.  The effect is similar to
18146 that of the @code{unused} attribute, except that this pragma may appear
18147 anywhere within the variables' scopes.
18148 @end table
18150 @node Solaris Pragmas
18151 @subsection Solaris Pragmas
18153 The Solaris target supports @code{#pragma redefine_extname}
18154 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
18155 @code{#pragma} directives for compatibility with the system compiler.
18157 @table @code
18158 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
18159 @cindex pragma, align
18161 Increase the minimum alignment of each @var{variable} to @var{alignment}.
18162 This is the same as GCC's @code{aligned} attribute @pxref{Variable
18163 Attributes}).  Macro expansion occurs on the arguments to this pragma
18164 when compiling C and Objective-C@.  It does not currently occur when
18165 compiling C++, but this is a bug which may be fixed in a future
18166 release.
18168 @item fini (@var{function} [, @var{function}]...)
18169 @cindex pragma, fini
18171 This pragma causes each listed @var{function} to be called after
18172 main, or during shared module unloading, by adding a call to the
18173 @code{.fini} section.
18175 @item init (@var{function} [, @var{function}]...)
18176 @cindex pragma, init
18178 This pragma causes each listed @var{function} to be called during
18179 initialization (before @code{main}) or during shared module loading, by
18180 adding a call to the @code{.init} section.
18182 @end table
18184 @node Symbol-Renaming Pragmas
18185 @subsection Symbol-Renaming Pragmas
18187 GCC supports a @code{#pragma} directive that changes the name used in
18188 assembly for a given declaration. While this pragma is supported on all
18189 platforms, it is intended primarily to provide compatibility with the
18190 Solaris system headers. This effect can also be achieved using the asm
18191 labels extension (@pxref{Asm Labels}).
18193 @table @code
18194 @item redefine_extname @var{oldname} @var{newname}
18195 @cindex pragma, redefine_extname
18197 This pragma gives the C function @var{oldname} the assembly symbol
18198 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
18199 is defined if this pragma is available (currently on all platforms).
18200 @end table
18202 This pragma and the asm labels extension interact in a complicated
18203 manner.  Here are some corner cases you may want to be aware of:
18205 @enumerate
18206 @item This pragma silently applies only to declarations with external
18207 linkage.  Asm labels do not have this restriction.
18209 @item In C++, this pragma silently applies only to declarations with
18210 ``C'' linkage.  Again, asm labels do not have this restriction.
18212 @item If either of the ways of changing the assembly name of a
18213 declaration are applied to a declaration whose assembly name has
18214 already been determined (either by a previous use of one of these
18215 features, or because the compiler needed the assembly name in order to
18216 generate code), and the new name is different, a warning issues and
18217 the name does not change.
18219 @item The @var{oldname} used by @code{#pragma redefine_extname} is
18220 always the C-language name.
18221 @end enumerate
18223 @node Structure-Packing Pragmas
18224 @subsection Structure-Packing Pragmas
18226 For compatibility with Microsoft Windows compilers, GCC supports a
18227 set of @code{#pragma} directives that change the maximum alignment of
18228 members of structures (other than zero-width bit-fields), unions, and
18229 classes subsequently defined. The @var{n} value below always is required
18230 to be a small power of two and specifies the new alignment in bytes.
18232 @enumerate
18233 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
18234 @item @code{#pragma pack()} sets the alignment to the one that was in
18235 effect when compilation started (see also command-line option
18236 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
18237 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
18238 setting on an internal stack and then optionally sets the new alignment.
18239 @item @code{#pragma pack(pop)} restores the alignment setting to the one
18240 saved at the top of the internal stack (and removes that stack entry).
18241 Note that @code{#pragma pack([@var{n}])} does not influence this internal
18242 stack; thus it is possible to have @code{#pragma pack(push)} followed by
18243 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
18244 @code{#pragma pack(pop)}.
18245 @end enumerate
18247 Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct}
18248 @code{#pragma} which lays out a structure as the documented
18249 @code{__attribute__ ((ms_struct))}.
18250 @enumerate
18251 @item @code{#pragma ms_struct on} turns on the layout for structures
18252 declared.
18253 @item @code{#pragma ms_struct off} turns off the layout for structures
18254 declared.
18255 @item @code{#pragma ms_struct reset} goes back to the default layout.
18256 @end enumerate
18258 @node Weak Pragmas
18259 @subsection Weak Pragmas
18261 For compatibility with SVR4, GCC supports a set of @code{#pragma}
18262 directives for declaring symbols to be weak, and defining weak
18263 aliases.
18265 @table @code
18266 @item #pragma weak @var{symbol}
18267 @cindex pragma, weak
18268 This pragma declares @var{symbol} to be weak, as if the declaration
18269 had the attribute of the same name.  The pragma may appear before
18270 or after the declaration of @var{symbol}.  It is not an error for
18271 @var{symbol} to never be defined at all.
18273 @item #pragma weak @var{symbol1} = @var{symbol2}
18274 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
18275 It is an error if @var{symbol2} is not defined in the current
18276 translation unit.
18277 @end table
18279 @node Diagnostic Pragmas
18280 @subsection Diagnostic Pragmas
18282 GCC allows the user to selectively enable or disable certain types of
18283 diagnostics, and change the kind of the diagnostic.  For example, a
18284 project's policy might require that all sources compile with
18285 @option{-Werror} but certain files might have exceptions allowing
18286 specific types of warnings.  Or, a project might selectively enable
18287 diagnostics and treat them as errors depending on which preprocessor
18288 macros are defined.
18290 @table @code
18291 @item #pragma GCC diagnostic @var{kind} @var{option}
18292 @cindex pragma, diagnostic
18294 Modifies the disposition of a diagnostic.  Note that not all
18295 diagnostics are modifiable; at the moment only warnings (normally
18296 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
18297 Use @option{-fdiagnostics-show-option} to determine which diagnostics
18298 are controllable and which option controls them.
18300 @var{kind} is @samp{error} to treat this diagnostic as an error,
18301 @samp{warning} to treat it like a warning (even if @option{-Werror} is
18302 in effect), or @samp{ignored} if the diagnostic is to be ignored.
18303 @var{option} is a double quoted string that matches the command-line
18304 option.
18306 @smallexample
18307 #pragma GCC diagnostic warning "-Wformat"
18308 #pragma GCC diagnostic error "-Wformat"
18309 #pragma GCC diagnostic ignored "-Wformat"
18310 @end smallexample
18312 Note that these pragmas override any command-line options.  GCC keeps
18313 track of the location of each pragma, and issues diagnostics according
18314 to the state as of that point in the source file.  Thus, pragmas occurring
18315 after a line do not affect diagnostics caused by that line.
18317 @item #pragma GCC diagnostic push
18318 @itemx #pragma GCC diagnostic pop
18320 Causes GCC to remember the state of the diagnostics as of each
18321 @code{push}, and restore to that point at each @code{pop}.  If a
18322 @code{pop} has no matching @code{push}, the command-line options are
18323 restored.
18325 @smallexample
18326 #pragma GCC diagnostic error "-Wuninitialized"
18327   foo(a);                       /* error is given for this one */
18328 #pragma GCC diagnostic push
18329 #pragma GCC diagnostic ignored "-Wuninitialized"
18330   foo(b);                       /* no diagnostic for this one */
18331 #pragma GCC diagnostic pop
18332   foo(c);                       /* error is given for this one */
18333 #pragma GCC diagnostic pop
18334   foo(d);                       /* depends on command-line options */
18335 @end smallexample
18337 @end table
18339 GCC also offers a simple mechanism for printing messages during
18340 compilation.
18342 @table @code
18343 @item #pragma message @var{string}
18344 @cindex pragma, diagnostic
18346 Prints @var{string} as a compiler message on compilation.  The message
18347 is informational only, and is neither a compilation warning nor an error.
18349 @smallexample
18350 #pragma message "Compiling " __FILE__ "..."
18351 @end smallexample
18353 @var{string} may be parenthesized, and is printed with location
18354 information.  For example,
18356 @smallexample
18357 #define DO_PRAGMA(x) _Pragma (#x)
18358 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
18360 TODO(Remember to fix this)
18361 @end smallexample
18363 @noindent
18364 prints @samp{/tmp/file.c:4: note: #pragma message:
18365 TODO - Remember to fix this}.
18367 @end table
18369 @node Visibility Pragmas
18370 @subsection Visibility Pragmas
18372 @table @code
18373 @item #pragma GCC visibility push(@var{visibility})
18374 @itemx #pragma GCC visibility pop
18375 @cindex pragma, visibility
18377 This pragma allows the user to set the visibility for multiple
18378 declarations without having to give each a visibility attribute
18379 (@pxref{Function Attributes}).
18381 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
18382 declarations.  Class members and template specializations are not
18383 affected; if you want to override the visibility for a particular
18384 member or instantiation, you must use an attribute.
18386 @end table
18389 @node Push/Pop Macro Pragmas
18390 @subsection Push/Pop Macro Pragmas
18392 For compatibility with Microsoft Windows compilers, GCC supports
18393 @samp{#pragma push_macro(@var{"macro_name"})}
18394 and @samp{#pragma pop_macro(@var{"macro_name"})}.
18396 @table @code
18397 @item #pragma push_macro(@var{"macro_name"})
18398 @cindex pragma, push_macro
18399 This pragma saves the value of the macro named as @var{macro_name} to
18400 the top of the stack for this macro.
18402 @item #pragma pop_macro(@var{"macro_name"})
18403 @cindex pragma, pop_macro
18404 This pragma sets the value of the macro named as @var{macro_name} to
18405 the value on top of the stack for this macro. If the stack for
18406 @var{macro_name} is empty, the value of the macro remains unchanged.
18407 @end table
18409 For example:
18411 @smallexample
18412 #define X  1
18413 #pragma push_macro("X")
18414 #undef X
18415 #define X -1
18416 #pragma pop_macro("X")
18417 int x [X];
18418 @end smallexample
18420 @noindent
18421 In this example, the definition of X as 1 is saved by @code{#pragma
18422 push_macro} and restored by @code{#pragma pop_macro}.
18424 @node Function Specific Option Pragmas
18425 @subsection Function Specific Option Pragmas
18427 @table @code
18428 @item #pragma GCC target (@var{"string"}...)
18429 @cindex pragma GCC target
18431 This pragma allows you to set target specific options for functions
18432 defined later in the source file.  One or more strings can be
18433 specified.  Each function that is defined after this point is as
18434 if @code{attribute((target("STRING")))} was specified for that
18435 function.  The parenthesis around the options is optional.
18436 @xref{Function Attributes}, for more information about the
18437 @code{target} attribute and the attribute syntax.
18439 The @code{#pragma GCC target} pragma is presently implemented for
18440 x86, PowerPC, and Nios II targets only.
18441 @end table
18443 @table @code
18444 @item #pragma GCC optimize (@var{"string"}...)
18445 @cindex pragma GCC optimize
18447 This pragma allows you to set global optimization options for functions
18448 defined later in the source file.  One or more strings can be
18449 specified.  Each function that is defined after this point is as
18450 if @code{attribute((optimize("STRING")))} was specified for that
18451 function.  The parenthesis around the options is optional.
18452 @xref{Function Attributes}, for more information about the
18453 @code{optimize} attribute and the attribute syntax.
18454 @end table
18456 @table @code
18457 @item #pragma GCC push_options
18458 @itemx #pragma GCC pop_options
18459 @cindex pragma GCC push_options
18460 @cindex pragma GCC pop_options
18462 These pragmas maintain a stack of the current target and optimization
18463 options.  It is intended for include files where you temporarily want
18464 to switch to using a different @samp{#pragma GCC target} or
18465 @samp{#pragma GCC optimize} and then to pop back to the previous
18466 options.
18467 @end table
18469 @table @code
18470 @item #pragma GCC reset_options
18471 @cindex pragma GCC reset_options
18473 This pragma clears the current @code{#pragma GCC target} and
18474 @code{#pragma GCC optimize} to use the default switches as specified
18475 on the command line.
18476 @end table
18478 @node Loop-Specific Pragmas
18479 @subsection Loop-Specific Pragmas
18481 @table @code
18482 @item #pragma GCC ivdep
18483 @cindex pragma GCC ivdep
18484 @end table
18486 With this pragma, the programmer asserts that there are no loop-carried
18487 dependencies which would prevent consecutive iterations of
18488 the following loop from executing concurrently with SIMD
18489 (single instruction multiple data) instructions.
18491 For example, the compiler can only unconditionally vectorize the following
18492 loop with the pragma:
18494 @smallexample
18495 void foo (int n, int *a, int *b, int *c)
18497   int i, j;
18498 #pragma GCC ivdep
18499   for (i = 0; i < n; ++i)
18500     a[i] = b[i] + c[i];
18502 @end smallexample
18504 @noindent
18505 In this example, using the @code{restrict} qualifier had the same
18506 effect. In the following example, that would not be possible. Assume
18507 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
18508 that it can unconditionally vectorize the following loop:
18510 @smallexample
18511 void ignore_vec_dep (int *a, int k, int c, int m)
18513 #pragma GCC ivdep
18514   for (int i = 0; i < m; i++)
18515     a[i] = a[i + k] * c;
18517 @end smallexample
18520 @node Unnamed Fields
18521 @section Unnamed Structure and Union Fields
18522 @cindex @code{struct}
18523 @cindex @code{union}
18525 As permitted by ISO C11 and for compatibility with other compilers,
18526 GCC allows you to define
18527 a structure or union that contains, as fields, structures and unions
18528 without names.  For example:
18530 @smallexample
18531 struct @{
18532   int a;
18533   union @{
18534     int b;
18535     float c;
18536   @};
18537   int d;
18538 @} foo;
18539 @end smallexample
18541 @noindent
18542 In this example, you are able to access members of the unnamed
18543 union with code like @samp{foo.b}.  Note that only unnamed structs and
18544 unions are allowed, you may not have, for example, an unnamed
18545 @code{int}.
18547 You must never create such structures that cause ambiguous field definitions.
18548 For example, in this structure:
18550 @smallexample
18551 struct @{
18552   int a;
18553   struct @{
18554     int a;
18555   @};
18556 @} foo;
18557 @end smallexample
18559 @noindent
18560 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
18561 The compiler gives errors for such constructs.
18563 @opindex fms-extensions
18564 Unless @option{-fms-extensions} is used, the unnamed field must be a
18565 structure or union definition without a tag (for example, @samp{struct
18566 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
18567 also be a definition with a tag such as @samp{struct foo @{ int a;
18568 @};}, a reference to a previously defined structure or union such as
18569 @samp{struct foo;}, or a reference to a @code{typedef} name for a
18570 previously defined structure or union type.
18572 @opindex fplan9-extensions
18573 The option @option{-fplan9-extensions} enables
18574 @option{-fms-extensions} as well as two other extensions.  First, a
18575 pointer to a structure is automatically converted to a pointer to an
18576 anonymous field for assignments and function calls.  For example:
18578 @smallexample
18579 struct s1 @{ int a; @};
18580 struct s2 @{ struct s1; @};
18581 extern void f1 (struct s1 *);
18582 void f2 (struct s2 *p) @{ f1 (p); @}
18583 @end smallexample
18585 @noindent
18586 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
18587 converted into a pointer to the anonymous field.
18589 Second, when the type of an anonymous field is a @code{typedef} for a
18590 @code{struct} or @code{union}, code may refer to the field using the
18591 name of the @code{typedef}.
18593 @smallexample
18594 typedef struct @{ int a; @} s1;
18595 struct s2 @{ s1; @};
18596 s1 f1 (struct s2 *p) @{ return p->s1; @}
18597 @end smallexample
18599 These usages are only permitted when they are not ambiguous.
18601 @node Thread-Local
18602 @section Thread-Local Storage
18603 @cindex Thread-Local Storage
18604 @cindex @acronym{TLS}
18605 @cindex @code{__thread}
18607 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
18608 are allocated such that there is one instance of the variable per extant
18609 thread.  The runtime model GCC uses to implement this originates
18610 in the IA-64 processor-specific ABI, but has since been migrated
18611 to other processors as well.  It requires significant support from
18612 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
18613 system libraries (@file{libc.so} and @file{libpthread.so}), so it
18614 is not available everywhere.
18616 At the user level, the extension is visible with a new storage
18617 class keyword: @code{__thread}.  For example:
18619 @smallexample
18620 __thread int i;
18621 extern __thread struct state s;
18622 static __thread char *p;
18623 @end smallexample
18625 The @code{__thread} specifier may be used alone, with the @code{extern}
18626 or @code{static} specifiers, but with no other storage class specifier.
18627 When used with @code{extern} or @code{static}, @code{__thread} must appear
18628 immediately after the other storage class specifier.
18630 The @code{__thread} specifier may be applied to any global, file-scoped
18631 static, function-scoped static, or static data member of a class.  It may
18632 not be applied to block-scoped automatic or non-static data member.
18634 When the address-of operator is applied to a thread-local variable, it is
18635 evaluated at run time and returns the address of the current thread's
18636 instance of that variable.  An address so obtained may be used by any
18637 thread.  When a thread terminates, any pointers to thread-local variables
18638 in that thread become invalid.
18640 No static initialization may refer to the address of a thread-local variable.
18642 In C++, if an initializer is present for a thread-local variable, it must
18643 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
18644 standard.
18646 See @uref{http://www.akkadia.org/drepper/tls.pdf,
18647 ELF Handling For Thread-Local Storage} for a detailed explanation of
18648 the four thread-local storage addressing models, and how the runtime
18649 is expected to function.
18651 @menu
18652 * C99 Thread-Local Edits::
18653 * C++98 Thread-Local Edits::
18654 @end menu
18656 @node C99 Thread-Local Edits
18657 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
18659 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
18660 that document the exact semantics of the language extension.
18662 @itemize @bullet
18663 @item
18664 @cite{5.1.2  Execution environments}
18666 Add new text after paragraph 1
18668 @quotation
18669 Within either execution environment, a @dfn{thread} is a flow of
18670 control within a program.  It is implementation defined whether
18671 or not there may be more than one thread associated with a program.
18672 It is implementation defined how threads beyond the first are
18673 created, the name and type of the function called at thread
18674 startup, and how threads may be terminated.  However, objects
18675 with thread storage duration shall be initialized before thread
18676 startup.
18677 @end quotation
18679 @item
18680 @cite{6.2.4  Storage durations of objects}
18682 Add new text before paragraph 3
18684 @quotation
18685 An object whose identifier is declared with the storage-class
18686 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
18687 Its lifetime is the entire execution of the thread, and its
18688 stored value is initialized only once, prior to thread startup.
18689 @end quotation
18691 @item
18692 @cite{6.4.1  Keywords}
18694 Add @code{__thread}.
18696 @item
18697 @cite{6.7.1  Storage-class specifiers}
18699 Add @code{__thread} to the list of storage class specifiers in
18700 paragraph 1.
18702 Change paragraph 2 to
18704 @quotation
18705 With the exception of @code{__thread}, at most one storage-class
18706 specifier may be given [@dots{}].  The @code{__thread} specifier may
18707 be used alone, or immediately following @code{extern} or
18708 @code{static}.
18709 @end quotation
18711 Add new text after paragraph 6
18713 @quotation
18714 The declaration of an identifier for a variable that has
18715 block scope that specifies @code{__thread} shall also
18716 specify either @code{extern} or @code{static}.
18718 The @code{__thread} specifier shall be used only with
18719 variables.
18720 @end quotation
18721 @end itemize
18723 @node C++98 Thread-Local Edits
18724 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18726 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18727 that document the exact semantics of the language extension.
18729 @itemize @bullet
18730 @item
18731 @b{[intro.execution]}
18733 New text after paragraph 4
18735 @quotation
18736 A @dfn{thread} is a flow of control within the abstract machine.
18737 It is implementation defined whether or not there may be more than
18738 one thread.
18739 @end quotation
18741 New text after paragraph 7
18743 @quotation
18744 It is unspecified whether additional action must be taken to
18745 ensure when and whether side effects are visible to other threads.
18746 @end quotation
18748 @item
18749 @b{[lex.key]}
18751 Add @code{__thread}.
18753 @item
18754 @b{[basic.start.main]}
18756 Add after paragraph 5
18758 @quotation
18759 The thread that begins execution at the @code{main} function is called
18760 the @dfn{main thread}.  It is implementation defined how functions
18761 beginning threads other than the main thread are designated or typed.
18762 A function so designated, as well as the @code{main} function, is called
18763 a @dfn{thread startup function}.  It is implementation defined what
18764 happens if a thread startup function returns.  It is implementation
18765 defined what happens to other threads when any thread calls @code{exit}.
18766 @end quotation
18768 @item
18769 @b{[basic.start.init]}
18771 Add after paragraph 4
18773 @quotation
18774 The storage for an object of thread storage duration shall be
18775 statically initialized before the first statement of the thread startup
18776 function.  An object of thread storage duration shall not require
18777 dynamic initialization.
18778 @end quotation
18780 @item
18781 @b{[basic.start.term]}
18783 Add after paragraph 3
18785 @quotation
18786 The type of an object with thread storage duration shall not have a
18787 non-trivial destructor, nor shall it be an array type whose elements
18788 (directly or indirectly) have non-trivial destructors.
18789 @end quotation
18791 @item
18792 @b{[basic.stc]}
18794 Add ``thread storage duration'' to the list in paragraph 1.
18796 Change paragraph 2
18798 @quotation
18799 Thread, static, and automatic storage durations are associated with
18800 objects introduced by declarations [@dots{}].
18801 @end quotation
18803 Add @code{__thread} to the list of specifiers in paragraph 3.
18805 @item
18806 @b{[basic.stc.thread]}
18808 New section before @b{[basic.stc.static]}
18810 @quotation
18811 The keyword @code{__thread} applied to a non-local object gives the
18812 object thread storage duration.
18814 A local variable or class data member declared both @code{static}
18815 and @code{__thread} gives the variable or member thread storage
18816 duration.
18817 @end quotation
18819 @item
18820 @b{[basic.stc.static]}
18822 Change paragraph 1
18824 @quotation
18825 All objects that have neither thread storage duration, dynamic
18826 storage duration nor are local [@dots{}].
18827 @end quotation
18829 @item
18830 @b{[dcl.stc]}
18832 Add @code{__thread} to the list in paragraph 1.
18834 Change paragraph 1
18836 @quotation
18837 With the exception of @code{__thread}, at most one
18838 @var{storage-class-specifier} shall appear in a given
18839 @var{decl-specifier-seq}.  The @code{__thread} specifier may
18840 be used alone, or immediately following the @code{extern} or
18841 @code{static} specifiers.  [@dots{}]
18842 @end quotation
18844 Add after paragraph 5
18846 @quotation
18847 The @code{__thread} specifier can be applied only to the names of objects
18848 and to anonymous unions.
18849 @end quotation
18851 @item
18852 @b{[class.mem]}
18854 Add after paragraph 6
18856 @quotation
18857 Non-@code{static} members shall not be @code{__thread}.
18858 @end quotation
18859 @end itemize
18861 @node Binary constants
18862 @section Binary Constants using the @samp{0b} Prefix
18863 @cindex Binary constants using the @samp{0b} prefix
18865 Integer constants can be written as binary constants, consisting of a
18866 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18867 @samp{0B}.  This is particularly useful in environments that operate a
18868 lot on the bit level (like microcontrollers).
18870 The following statements are identical:
18872 @smallexample
18873 i =       42;
18874 i =     0x2a;
18875 i =      052;
18876 i = 0b101010;
18877 @end smallexample
18879 The type of these constants follows the same rules as for octal or
18880 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18881 can be applied.
18883 @node C++ Extensions
18884 @chapter Extensions to the C++ Language
18885 @cindex extensions, C++ language
18886 @cindex C++ language extensions
18888 The GNU compiler provides these extensions to the C++ language (and you
18889 can also use most of the C language extensions in your C++ programs).  If you
18890 want to write code that checks whether these features are available, you can
18891 test for the GNU compiler the same way as for C programs: check for a
18892 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
18893 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18894 Predefined Macros,cpp,The GNU C Preprocessor}).
18896 @menu
18897 * C++ Volatiles::       What constitutes an access to a volatile object.
18898 * Restricted Pointers:: C99 restricted pointers and references.
18899 * Vague Linkage::       Where G++ puts inlines, vtables and such.
18900 * C++ Interface::       You can use a single C++ header file for both
18901                         declarations and definitions.
18902 * Template Instantiation:: Methods for ensuring that exactly one copy of
18903                         each needed template instantiation is emitted.
18904 * Bound member functions:: You can extract a function pointer to the
18905                         method denoted by a @samp{->*} or @samp{.*} expression.
18906 * C++ Attributes::      Variable, function, and type attributes for C++ only.
18907 * Function Multiversioning::   Declaring multiple function versions.
18908 * Namespace Association:: Strong using-directives for namespace association.
18909 * Type Traits::         Compiler support for type traits
18910 * Java Exceptions::     Tweaking exception handling to work with Java.
18911 * Deprecated Features:: Things will disappear from G++.
18912 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18913 @end menu
18915 @node C++ Volatiles
18916 @section When is a Volatile C++ Object Accessed?
18917 @cindex accessing volatiles
18918 @cindex volatile read
18919 @cindex volatile write
18920 @cindex volatile access
18922 The C++ standard differs from the C standard in its treatment of
18923 volatile objects.  It fails to specify what constitutes a volatile
18924 access, except to say that C++ should behave in a similar manner to C
18925 with respect to volatiles, where possible.  However, the different
18926 lvalueness of expressions between C and C++ complicate the behavior.
18927 G++ behaves the same as GCC for volatile access, @xref{C
18928 Extensions,,Volatiles}, for a description of GCC's behavior.
18930 The C and C++ language specifications differ when an object is
18931 accessed in a void context:
18933 @smallexample
18934 volatile int *src = @var{somevalue};
18935 *src;
18936 @end smallexample
18938 The C++ standard specifies that such expressions do not undergo lvalue
18939 to rvalue conversion, and that the type of the dereferenced object may
18940 be incomplete.  The C++ standard does not specify explicitly that it
18941 is lvalue to rvalue conversion that is responsible for causing an
18942 access.  There is reason to believe that it is, because otherwise
18943 certain simple expressions become undefined.  However, because it
18944 would surprise most programmers, G++ treats dereferencing a pointer to
18945 volatile object of complete type as GCC would do for an equivalent
18946 type in C@.  When the object has incomplete type, G++ issues a
18947 warning; if you wish to force an error, you must force a conversion to
18948 rvalue with, for instance, a static cast.
18950 When using a reference to volatile, G++ does not treat equivalent
18951 expressions as accesses to volatiles, but instead issues a warning that
18952 no volatile is accessed.  The rationale for this is that otherwise it
18953 becomes difficult to determine where volatile access occur, and not
18954 possible to ignore the return value from functions returning volatile
18955 references.  Again, if you wish to force a read, cast the reference to
18956 an rvalue.
18958 G++ implements the same behavior as GCC does when assigning to a
18959 volatile object---there is no reread of the assigned-to object, the
18960 assigned rvalue is reused.  Note that in C++ assignment expressions
18961 are lvalues, and if used as an lvalue, the volatile object is
18962 referred to.  For instance, @var{vref} refers to @var{vobj}, as
18963 expected, in the following example:
18965 @smallexample
18966 volatile int vobj;
18967 volatile int &vref = vobj = @var{something};
18968 @end smallexample
18970 @node Restricted Pointers
18971 @section Restricting Pointer Aliasing
18972 @cindex restricted pointers
18973 @cindex restricted references
18974 @cindex restricted this pointer
18976 As with the C front end, G++ understands the C99 feature of restricted pointers,
18977 specified with the @code{__restrict__}, or @code{__restrict} type
18978 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
18979 language flag, @code{restrict} is not a keyword in C++.
18981 In addition to allowing restricted pointers, you can specify restricted
18982 references, which indicate that the reference is not aliased in the local
18983 context.
18985 @smallexample
18986 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18988   /* @r{@dots{}} */
18990 @end smallexample
18992 @noindent
18993 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18994 @var{rref} refers to a (different) unaliased integer.
18996 You may also specify whether a member function's @var{this} pointer is
18997 unaliased by using @code{__restrict__} as a member function qualifier.
18999 @smallexample
19000 void T::fn () __restrict__
19002   /* @r{@dots{}} */
19004 @end smallexample
19006 @noindent
19007 Within the body of @code{T::fn}, @var{this} has the effective
19008 definition @code{T *__restrict__ const this}.  Notice that the
19009 interpretation of a @code{__restrict__} member function qualifier is
19010 different to that of @code{const} or @code{volatile} qualifier, in that it
19011 is applied to the pointer rather than the object.  This is consistent with
19012 other compilers that implement restricted pointers.
19014 As with all outermost parameter qualifiers, @code{__restrict__} is
19015 ignored in function definition matching.  This means you only need to
19016 specify @code{__restrict__} in a function definition, rather than
19017 in a function prototype as well.
19019 @node Vague Linkage
19020 @section Vague Linkage
19021 @cindex vague linkage
19023 There are several constructs in C++ that require space in the object
19024 file but are not clearly tied to a single translation unit.  We say that
19025 these constructs have ``vague linkage''.  Typically such constructs are
19026 emitted wherever they are needed, though sometimes we can be more
19027 clever.
19029 @table @asis
19030 @item Inline Functions
19031 Inline functions are typically defined in a header file which can be
19032 included in many different compilations.  Hopefully they can usually be
19033 inlined, but sometimes an out-of-line copy is necessary, if the address
19034 of the function is taken or if inlining fails.  In general, we emit an
19035 out-of-line copy in all translation units where one is needed.  As an
19036 exception, we only emit inline virtual functions with the vtable, since
19037 it always requires a copy.
19039 Local static variables and string constants used in an inline function
19040 are also considered to have vague linkage, since they must be shared
19041 between all inlined and out-of-line instances of the function.
19043 @item VTables
19044 @cindex vtable
19045 C++ virtual functions are implemented in most compilers using a lookup
19046 table, known as a vtable.  The vtable contains pointers to the virtual
19047 functions provided by a class, and each object of the class contains a
19048 pointer to its vtable (or vtables, in some multiple-inheritance
19049 situations).  If the class declares any non-inline, non-pure virtual
19050 functions, the first one is chosen as the ``key method'' for the class,
19051 and the vtable is only emitted in the translation unit where the key
19052 method is defined.
19054 @emph{Note:} If the chosen key method is later defined as inline, the
19055 vtable is still emitted in every translation unit that defines it.
19056 Make sure that any inline virtuals are declared inline in the class
19057 body, even if they are not defined there.
19059 @item @code{type_info} objects
19060 @cindex @code{type_info}
19061 @cindex RTTI
19062 C++ requires information about types to be written out in order to
19063 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
19064 For polymorphic classes (classes with virtual functions), the @samp{type_info}
19065 object is written out along with the vtable so that @samp{dynamic_cast}
19066 can determine the dynamic type of a class object at run time.  For all
19067 other types, we write out the @samp{type_info} object when it is used: when
19068 applying @samp{typeid} to an expression, throwing an object, or
19069 referring to a type in a catch clause or exception specification.
19071 @item Template Instantiations
19072 Most everything in this section also applies to template instantiations,
19073 but there are other options as well.
19074 @xref{Template Instantiation,,Where's the Template?}.
19076 @end table
19078 When used with GNU ld version 2.8 or later on an ELF system such as
19079 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
19080 these constructs will be discarded at link time.  This is known as
19081 COMDAT support.
19083 On targets that don't support COMDAT, but do support weak symbols, GCC
19084 uses them.  This way one copy overrides all the others, but
19085 the unused copies still take up space in the executable.
19087 For targets that do not support either COMDAT or weak symbols,
19088 most entities with vague linkage are emitted as local symbols to
19089 avoid duplicate definition errors from the linker.  This does not happen
19090 for local statics in inlines, however, as having multiple copies
19091 almost certainly breaks things.
19093 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
19094 another way to control placement of these constructs.
19096 @node C++ Interface
19097 @section C++ Interface and Implementation Pragmas
19099 @cindex interface and implementation headers, C++
19100 @cindex C++ interface and implementation headers
19101 @cindex pragmas, interface and implementation
19103 @code{#pragma interface} and @code{#pragma implementation} provide the
19104 user with a way of explicitly directing the compiler to emit entities
19105 with vague linkage (and debugging information) in a particular
19106 translation unit.
19108 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
19109 by COMDAT support and the ``key method'' heuristic
19110 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
19111 program to grow due to unnecessary out-of-line copies of inline
19112 functions.
19114 @table @code
19115 @item #pragma interface
19116 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
19117 @kindex #pragma interface
19118 Use this directive in @emph{header files} that define object classes, to save
19119 space in most of the object files that use those classes.  Normally,
19120 local copies of certain information (backup copies of inline member
19121 functions, debugging information, and the internal tables that implement
19122 virtual functions) must be kept in each object file that includes class
19123 definitions.  You can use this pragma to avoid such duplication.  When a
19124 header file containing @samp{#pragma interface} is included in a
19125 compilation, this auxiliary information is not generated (unless
19126 the main input source file itself uses @samp{#pragma implementation}).
19127 Instead, the object files contain references to be resolved at link
19128 time.
19130 The second form of this directive is useful for the case where you have
19131 multiple headers with the same name in different directories.  If you
19132 use this form, you must specify the same string to @samp{#pragma
19133 implementation}.
19135 @item #pragma implementation
19136 @itemx #pragma implementation "@var{objects}.h"
19137 @kindex #pragma implementation
19138 Use this pragma in a @emph{main input file}, when you want full output from
19139 included header files to be generated (and made globally visible).  The
19140 included header file, in turn, should use @samp{#pragma interface}.
19141 Backup copies of inline member functions, debugging information, and the
19142 internal tables used to implement virtual functions are all generated in
19143 implementation files.
19145 @cindex implied @code{#pragma implementation}
19146 @cindex @code{#pragma implementation}, implied
19147 @cindex naming convention, implementation headers
19148 If you use @samp{#pragma implementation} with no argument, it applies to
19149 an include file with the same basename@footnote{A file's @dfn{basename}
19150 is the name stripped of all leading path information and of trailing
19151 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
19152 file.  For example, in @file{allclass.cc}, giving just
19153 @samp{#pragma implementation}
19154 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
19156 Use the string argument if you want a single implementation file to
19157 include code from multiple header files.  (You must also use
19158 @samp{#include} to include the header file; @samp{#pragma
19159 implementation} only specifies how to use the file---it doesn't actually
19160 include it.)
19162 There is no way to split up the contents of a single header file into
19163 multiple implementation files.
19164 @end table
19166 @cindex inlining and C++ pragmas
19167 @cindex C++ pragmas, effect on inlining
19168 @cindex pragmas in C++, effect on inlining
19169 @samp{#pragma implementation} and @samp{#pragma interface} also have an
19170 effect on function inlining.
19172 If you define a class in a header file marked with @samp{#pragma
19173 interface}, the effect on an inline function defined in that class is
19174 similar to an explicit @code{extern} declaration---the compiler emits
19175 no code at all to define an independent version of the function.  Its
19176 definition is used only for inlining with its callers.
19178 @opindex fno-implement-inlines
19179 Conversely, when you include the same header file in a main source file
19180 that declares it as @samp{#pragma implementation}, the compiler emits
19181 code for the function itself; this defines a version of the function
19182 that can be found via pointers (or by callers compiled without
19183 inlining).  If all calls to the function can be inlined, you can avoid
19184 emitting the function by compiling with @option{-fno-implement-inlines}.
19185 If any calls are not inlined, you will get linker errors.
19187 @node Template Instantiation
19188 @section Where's the Template?
19189 @cindex template instantiation
19191 C++ templates are the first language feature to require more
19192 intelligence from the environment than one usually finds on a UNIX
19193 system.  Somehow the compiler and linker have to make sure that each
19194 template instance occurs exactly once in the executable if it is needed,
19195 and not at all otherwise.  There are two basic approaches to this
19196 problem, which are referred to as the Borland model and the Cfront model.
19198 @table @asis
19199 @item Borland model
19200 Borland C++ solved the template instantiation problem by adding the code
19201 equivalent of common blocks to their linker; the compiler emits template
19202 instances in each translation unit that uses them, and the linker
19203 collapses them together.  The advantage of this model is that the linker
19204 only has to consider the object files themselves; there is no external
19205 complexity to worry about.  This disadvantage is that compilation time
19206 is increased because the template code is being compiled repeatedly.
19207 Code written for this model tends to include definitions of all
19208 templates in the header file, since they must be seen to be
19209 instantiated.
19211 @item Cfront model
19212 The AT&T C++ translator, Cfront, solved the template instantiation
19213 problem by creating the notion of a template repository, an
19214 automatically maintained place where template instances are stored.  A
19215 more modern version of the repository works as follows: As individual
19216 object files are built, the compiler places any template definitions and
19217 instantiations encountered in the repository.  At link time, the link
19218 wrapper adds in the objects in the repository and compiles any needed
19219 instances that were not previously emitted.  The advantages of this
19220 model are more optimal compilation speed and the ability to use the
19221 system linker; to implement the Borland model a compiler vendor also
19222 needs to replace the linker.  The disadvantages are vastly increased
19223 complexity, and thus potential for error; for some code this can be
19224 just as transparent, but in practice it can been very difficult to build
19225 multiple programs in one directory and one program in multiple
19226 directories.  Code written for this model tends to separate definitions
19227 of non-inline member templates into a separate file, which should be
19228 compiled separately.
19229 @end table
19231 When used with GNU ld version 2.8 or later on an ELF system such as
19232 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
19233 Borland model.  On other systems, G++ implements neither automatic
19234 model.
19236 You have the following options for dealing with template instantiations:
19238 @enumerate
19239 @item
19240 @opindex frepo
19241 Compile your template-using code with @option{-frepo}.  The compiler
19242 generates files with the extension @samp{.rpo} listing all of the
19243 template instantiations used in the corresponding object files that
19244 could be instantiated there; the link wrapper, @samp{collect2},
19245 then updates the @samp{.rpo} files to tell the compiler where to place
19246 those instantiations and rebuild any affected object files.  The
19247 link-time overhead is negligible after the first pass, as the compiler
19248 continues to place the instantiations in the same files.
19250 This is your best option for application code written for the Borland
19251 model, as it just works.  Code written for the Cfront model 
19252 needs to be modified so that the template definitions are available at
19253 one or more points of instantiation; usually this is as simple as adding
19254 @code{#include <tmethods.cc>} to the end of each template header.
19256 For library code, if you want the library to provide all of the template
19257 instantiations it needs, just try to link all of its object files
19258 together; the link will fail, but cause the instantiations to be
19259 generated as a side effect.  Be warned, however, that this may cause
19260 conflicts if multiple libraries try to provide the same instantiations.
19261 For greater control, use explicit instantiation as described in the next
19262 option.
19264 @item
19265 @opindex fno-implicit-templates
19266 Compile your code with @option{-fno-implicit-templates} to disable the
19267 implicit generation of template instances, and explicitly instantiate
19268 all the ones you use.  This approach requires more knowledge of exactly
19269 which instances you need than do the others, but it's less
19270 mysterious and allows greater control.  You can scatter the explicit
19271 instantiations throughout your program, perhaps putting them in the
19272 translation units where the instances are used or the translation units
19273 that define the templates themselves; you can put all of the explicit
19274 instantiations you need into one big file; or you can create small files
19275 like
19277 @smallexample
19278 #include "Foo.h"
19279 #include "Foo.cc"
19281 template class Foo<int>;
19282 template ostream& operator <<
19283                 (ostream&, const Foo<int>&);
19284 @end smallexample
19286 @noindent
19287 for each of the instances you need, and create a template instantiation
19288 library from those.
19290 If you are using Cfront-model code, you can probably get away with not
19291 using @option{-fno-implicit-templates} when compiling files that don't
19292 @samp{#include} the member template definitions.
19294 If you use one big file to do the instantiations, you may want to
19295 compile it without @option{-fno-implicit-templates} so you get all of the
19296 instances required by your explicit instantiations (but not by any
19297 other files) without having to specify them as well.
19299 The ISO C++ 2011 standard allows forward declaration of explicit
19300 instantiations (with @code{extern}). G++ supports explicit instantiation
19301 declarations in C++98 mode and has extended the template instantiation
19302 syntax to support instantiation of the compiler support data for a
19303 template class (i.e.@: the vtable) without instantiating any of its
19304 members (with @code{inline}), and instantiation of only the static data
19305 members of a template class, without the support data or member
19306 functions (with @code{static}):
19308 @smallexample
19309 extern template int max (int, int);
19310 inline template class Foo<int>;
19311 static template class Foo<int>;
19312 @end smallexample
19314 @item
19315 Do nothing.  Pretend G++ does implement automatic instantiation
19316 management.  Code written for the Borland model works fine, but
19317 each translation unit contains instances of each of the templates it
19318 uses.  In a large program, this can lead to an unacceptable amount of code
19319 duplication.
19320 @end enumerate
19322 @node Bound member functions
19323 @section Extracting the Function Pointer from a Bound Pointer to Member Function
19324 @cindex pmf
19325 @cindex pointer to member function
19326 @cindex bound pointer to member function
19328 In C++, pointer to member functions (PMFs) are implemented using a wide
19329 pointer of sorts to handle all the possible call mechanisms; the PMF
19330 needs to store information about how to adjust the @samp{this} pointer,
19331 and if the function pointed to is virtual, where to find the vtable, and
19332 where in the vtable to look for the member function.  If you are using
19333 PMFs in an inner loop, you should really reconsider that decision.  If
19334 that is not an option, you can extract the pointer to the function that
19335 would be called for a given object/PMF pair and call it directly inside
19336 the inner loop, to save a bit of time.
19338 Note that you still pay the penalty for the call through a
19339 function pointer; on most modern architectures, such a call defeats the
19340 branch prediction features of the CPU@.  This is also true of normal
19341 virtual function calls.
19343 The syntax for this extension is
19345 @smallexample
19346 extern A a;
19347 extern int (A::*fp)();
19348 typedef int (*fptr)(A *);
19350 fptr p = (fptr)(a.*fp);
19351 @end smallexample
19353 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
19354 no object is needed to obtain the address of the function.  They can be
19355 converted to function pointers directly:
19357 @smallexample
19358 fptr p1 = (fptr)(&A::foo);
19359 @end smallexample
19361 @opindex Wno-pmf-conversions
19362 You must specify @option{-Wno-pmf-conversions} to use this extension.
19364 @node C++ Attributes
19365 @section C++-Specific Variable, Function, and Type Attributes
19367 Some attributes only make sense for C++ programs.
19369 @table @code
19370 @item abi_tag ("@var{tag}", ...)
19371 @cindex @code{abi_tag} function attribute
19372 @cindex @code{abi_tag} variable attribute
19373 @cindex @code{abi_tag} type attribute
19374 The @code{abi_tag} attribute can be applied to a function, variable, or class
19375 declaration.  It modifies the mangled name of the entity to
19376 incorporate the tag name, in order to distinguish the function or
19377 class from an earlier version with a different ABI; perhaps the class
19378 has changed size, or the function has a different return type that is
19379 not encoded in the mangled name.
19381 The attribute can also be applied to an inline namespace, but does not
19382 affect the mangled name of the namespace; in this case it is only used
19383 for @option{-Wabi-tag} warnings and automatic tagging of functions and
19384 variables.  Tagging inline namespaces is generally preferable to
19385 tagging individual declarations, but the latter is sometimes
19386 necessary, such as when only certain members of a class need to be
19387 tagged.
19389 The argument can be a list of strings of arbitrary length.  The
19390 strings are sorted on output, so the order of the list is
19391 unimportant.
19393 A redeclaration of an entity must not add new ABI tags,
19394 since doing so would change the mangled name.
19396 The ABI tags apply to a name, so all instantiations and
19397 specializations of a template have the same tags.  The attribute will
19398 be ignored if applied to an explicit specialization or instantiation.
19400 The @option{-Wabi-tag} flag enables a warning about a class which does
19401 not have all the ABI tags used by its subobjects and virtual functions; for users with code
19402 that needs to coexist with an earlier ABI, using this option can help
19403 to find all affected types that need to be tagged.
19405 When a type involving an ABI tag is used as the type of a variable or
19406 return type of a function where that tag is not already present in the
19407 signature of the function, the tag is automatically applied to the
19408 variable or function.  @option{-Wabi-tag} also warns about this
19409 situation; this warning can be avoided by explicitly tagging the
19410 variable or function or moving it into a tagged inline namespace.
19412 @item init_priority (@var{priority})
19413 @cindex @code{init_priority} variable attribute
19415 In Standard C++, objects defined at namespace scope are guaranteed to be
19416 initialized in an order in strict accordance with that of their definitions
19417 @emph{in a given translation unit}.  No guarantee is made for initializations
19418 across translation units.  However, GNU C++ allows users to control the
19419 order of initialization of objects defined at namespace scope with the
19420 @code{init_priority} attribute by specifying a relative @var{priority},
19421 a constant integral expression currently bounded between 101 and 65535
19422 inclusive.  Lower numbers indicate a higher priority.
19424 In the following example, @code{A} would normally be created before
19425 @code{B}, but the @code{init_priority} attribute reverses that order:
19427 @smallexample
19428 Some_Class  A  __attribute__ ((init_priority (2000)));
19429 Some_Class  B  __attribute__ ((init_priority (543)));
19430 @end smallexample
19432 @noindent
19433 Note that the particular values of @var{priority} do not matter; only their
19434 relative ordering.
19436 @item java_interface
19437 @cindex @code{java_interface} type attribute
19439 This type attribute informs C++ that the class is a Java interface.  It may
19440 only be applied to classes declared within an @code{extern "Java"} block.
19441 Calls to methods declared in this interface are dispatched using GCJ's
19442 interface table mechanism, instead of regular virtual table dispatch.
19444 @item warn_unused
19445 @cindex @code{warn_unused} type attribute
19447 For C++ types with non-trivial constructors and/or destructors it is
19448 impossible for the compiler to determine whether a variable of this
19449 type is truly unused if it is not referenced. This type attribute
19450 informs the compiler that variables of this type should be warned
19451 about if they appear to be unused, just like variables of fundamental
19452 types.
19454 This attribute is appropriate for types which just represent a value,
19455 such as @code{std::string}; it is not appropriate for types which
19456 control a resource, such as @code{std::mutex}.
19458 This attribute is also accepted in C, but it is unnecessary because C
19459 does not have constructors or destructors.
19461 @end table
19463 See also @ref{Namespace Association}.
19465 @node Function Multiversioning
19466 @section Function Multiversioning
19467 @cindex function versions
19469 With the GNU C++ front end, for x86 targets, you may specify multiple
19470 versions of a function, where each function is specialized for a
19471 specific target feature.  At runtime, the appropriate version of the
19472 function is automatically executed depending on the characteristics of
19473 the execution platform.  Here is an example.
19475 @smallexample
19476 __attribute__ ((target ("default")))
19477 int foo ()
19479   // The default version of foo.
19480   return 0;
19483 __attribute__ ((target ("sse4.2")))
19484 int foo ()
19486   // foo version for SSE4.2
19487   return 1;
19490 __attribute__ ((target ("arch=atom")))
19491 int foo ()
19493   // foo version for the Intel ATOM processor
19494   return 2;
19497 __attribute__ ((target ("arch=amdfam10")))
19498 int foo ()
19500   // foo version for the AMD Family 0x10 processors.
19501   return 3;
19504 int main ()
19506   int (*p)() = &foo;
19507   assert ((*p) () == foo ());
19508   return 0;
19510 @end smallexample
19512 In the above example, four versions of function foo are created. The
19513 first version of foo with the target attribute "default" is the default
19514 version.  This version gets executed when no other target specific
19515 version qualifies for execution on a particular platform. A new version
19516 of foo is created by using the same function signature but with a
19517 different target string.  Function foo is called or a pointer to it is
19518 taken just like a regular function.  GCC takes care of doing the
19519 dispatching to call the right version at runtime.  Refer to the
19520 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
19521 Function Multiversioning} for more details.
19523 @node Namespace Association
19524 @section Namespace Association
19526 @strong{Caution:} The semantics of this extension are equivalent
19527 to C++ 2011 inline namespaces.  Users should use inline namespaces
19528 instead as this extension will be removed in future versions of G++.
19530 A using-directive with @code{__attribute ((strong))} is stronger
19531 than a normal using-directive in two ways:
19533 @itemize @bullet
19534 @item
19535 Templates from the used namespace can be specialized and explicitly
19536 instantiated as though they were members of the using namespace.
19538 @item
19539 The using namespace is considered an associated namespace of all
19540 templates in the used namespace for purposes of argument-dependent
19541 name lookup.
19542 @end itemize
19544 The used namespace must be nested within the using namespace so that
19545 normal unqualified lookup works properly.
19547 This is useful for composing a namespace transparently from
19548 implementation namespaces.  For example:
19550 @smallexample
19551 namespace std @{
19552   namespace debug @{
19553     template <class T> struct A @{ @};
19554   @}
19555   using namespace debug __attribute ((__strong__));
19556   template <> struct A<int> @{ @};   // @r{OK to specialize}
19558   template <class T> void f (A<T>);
19561 int main()
19563   f (std::A<float>());             // @r{lookup finds} std::f
19564   f (std::A<int>());
19566 @end smallexample
19568 @node Type Traits
19569 @section Type Traits
19571 The C++ front end implements syntactic extensions that allow
19572 compile-time determination of 
19573 various characteristics of a type (or of a
19574 pair of types).
19576 @table @code
19577 @item __has_nothrow_assign (type)
19578 If @code{type} is const qualified or is a reference type then the trait is
19579 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
19580 is true, else if @code{type} is a cv class or union type with copy assignment
19581 operators that are known not to throw an exception then the trait is true,
19582 else it is false.  Requires: @code{type} shall be a complete type,
19583 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19585 @item __has_nothrow_copy (type)
19586 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
19587 @code{type} is a cv class or union type with copy constructors that
19588 are known not to throw an exception then the trait is true, else it is false.
19589 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
19590 @code{void}, or an array of unknown bound.
19592 @item __has_nothrow_constructor (type)
19593 If @code{__has_trivial_constructor (type)} is true then the trait is
19594 true, else if @code{type} is a cv class or union type (or array
19595 thereof) with a default constructor that is known not to throw an
19596 exception then the trait is true, else it is false.  Requires:
19597 @code{type} shall be a complete type, (possibly cv-qualified)
19598 @code{void}, or an array of unknown bound.
19600 @item __has_trivial_assign (type)
19601 If @code{type} is const qualified or is a reference type then the trait is
19602 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
19603 true, else if @code{type} is a cv class or union type with a trivial
19604 copy assignment ([class.copy]) then the trait is true, else it is
19605 false.  Requires: @code{type} shall be a complete type, (possibly
19606 cv-qualified) @code{void}, or an array of unknown bound.
19608 @item __has_trivial_copy (type)
19609 If @code{__is_pod (type)} is true or @code{type} is a reference type
19610 then the trait is true, else if @code{type} is a cv class or union type
19611 with a trivial copy constructor ([class.copy]) then the trait
19612 is true, else it is false.  Requires: @code{type} shall be a complete
19613 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19615 @item __has_trivial_constructor (type)
19616 If @code{__is_pod (type)} is true then the trait is true, else if
19617 @code{type} is a cv class or union type (or array thereof) with a
19618 trivial default constructor ([class.ctor]) then the trait is true,
19619 else it is false.  Requires: @code{type} shall be a complete
19620 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19622 @item __has_trivial_destructor (type)
19623 If @code{__is_pod (type)} is true or @code{type} is a reference type then
19624 the trait is true, else if @code{type} is a cv class or union type (or
19625 array thereof) with a trivial destructor ([class.dtor]) then the trait
19626 is true, else it is false.  Requires: @code{type} shall be a complete
19627 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19629 @item __has_virtual_destructor (type)
19630 If @code{type} is a class type with a virtual destructor
19631 ([class.dtor]) then the trait is true, else it is false.  Requires:
19632 @code{type} shall be a complete type, (possibly cv-qualified)
19633 @code{void}, or an array of unknown bound.
19635 @item __is_abstract (type)
19636 If @code{type} is an abstract class ([class.abstract]) then the trait
19637 is true, else it is false.  Requires: @code{type} shall be a complete
19638 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19640 @item __is_base_of (base_type, derived_type)
19641 If @code{base_type} is a base class of @code{derived_type}
19642 ([class.derived]) then the trait is true, otherwise it is false.
19643 Top-level cv qualifications of @code{base_type} and
19644 @code{derived_type} are ignored.  For the purposes of this trait, a
19645 class type is considered is own base.  Requires: if @code{__is_class
19646 (base_type)} and @code{__is_class (derived_type)} are true and
19647 @code{base_type} and @code{derived_type} are not the same type
19648 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
19649 type.  Diagnostic is produced if this requirement is not met.
19651 @item __is_class (type)
19652 If @code{type} is a cv class type, and not a union type
19653 ([basic.compound]) the trait is true, else it is false.
19655 @item __is_empty (type)
19656 If @code{__is_class (type)} is false then the trait is false.
19657 Otherwise @code{type} is considered empty if and only if: @code{type}
19658 has no non-static data members, or all non-static data members, if
19659 any, are bit-fields of length 0, and @code{type} has no virtual
19660 members, and @code{type} has no virtual base classes, and @code{type}
19661 has no base classes @code{base_type} for which
19662 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
19663 be a complete type, (possibly cv-qualified) @code{void}, or an array
19664 of unknown bound.
19666 @item __is_enum (type)
19667 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
19668 true, else it is false.
19670 @item __is_literal_type (type)
19671 If @code{type} is a literal type ([basic.types]) the trait is
19672 true, else it is false.  Requires: @code{type} shall be a complete type,
19673 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19675 @item __is_pod (type)
19676 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
19677 else it is false.  Requires: @code{type} shall be a complete type,
19678 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19680 @item __is_polymorphic (type)
19681 If @code{type} is a polymorphic class ([class.virtual]) then the trait
19682 is true, else it is false.  Requires: @code{type} shall be a complete
19683 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19685 @item __is_standard_layout (type)
19686 If @code{type} is a standard-layout type ([basic.types]) the trait is
19687 true, else it is false.  Requires: @code{type} shall be a complete
19688 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19690 @item __is_trivial (type)
19691 If @code{type} is a trivial type ([basic.types]) the trait is
19692 true, else it is false.  Requires: @code{type} shall be a complete
19693 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19695 @item __is_union (type)
19696 If @code{type} is a cv union type ([basic.compound]) the trait is
19697 true, else it is false.
19699 @item __underlying_type (type)
19700 The underlying type of @code{type}.  Requires: @code{type} shall be
19701 an enumeration type ([dcl.enum]).
19703 @end table
19705 @node Java Exceptions
19706 @section Java Exceptions
19708 The Java language uses a slightly different exception handling model
19709 from C++.  Normally, GNU C++ automatically detects when you are
19710 writing C++ code that uses Java exceptions, and handle them
19711 appropriately.  However, if C++ code only needs to execute destructors
19712 when Java exceptions are thrown through it, GCC guesses incorrectly.
19713 Sample problematic code is:
19715 @smallexample
19716   struct S @{ ~S(); @};
19717   extern void bar();    // @r{is written in Java, and may throw exceptions}
19718   void foo()
19719   @{
19720     S s;
19721     bar();
19722   @}
19723 @end smallexample
19725 @noindent
19726 The usual effect of an incorrect guess is a link failure, complaining of
19727 a missing routine called @samp{__gxx_personality_v0}.
19729 You can inform the compiler that Java exceptions are to be used in a
19730 translation unit, irrespective of what it might think, by writing
19731 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
19732 @samp{#pragma} must appear before any functions that throw or catch
19733 exceptions, or run destructors when exceptions are thrown through them.
19735 You cannot mix Java and C++ exceptions in the same translation unit.  It
19736 is believed to be safe to throw a C++ exception from one file through
19737 another file compiled for the Java exception model, or vice versa, but
19738 there may be bugs in this area.
19740 @node Deprecated Features
19741 @section Deprecated Features
19743 In the past, the GNU C++ compiler was extended to experiment with new
19744 features, at a time when the C++ language was still evolving.  Now that
19745 the C++ standard is complete, some of those features are superseded by
19746 superior alternatives.  Using the old features might cause a warning in
19747 some cases that the feature will be dropped in the future.  In other
19748 cases, the feature might be gone already.
19750 While the list below is not exhaustive, it documents some of the options
19751 that are now deprecated:
19753 @table @code
19754 @item -fexternal-templates
19755 @itemx -falt-external-templates
19756 These are two of the many ways for G++ to implement template
19757 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
19758 defines how template definitions have to be organized across
19759 implementation units.  G++ has an implicit instantiation mechanism that
19760 should work just fine for standard-conforming code.
19762 @item -fstrict-prototype
19763 @itemx -fno-strict-prototype
19764 Previously it was possible to use an empty prototype parameter list to
19765 indicate an unspecified number of parameters (like C), rather than no
19766 parameters, as C++ demands.  This feature has been removed, except where
19767 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
19768 @end table
19770 G++ allows a virtual function returning @samp{void *} to be overridden
19771 by one returning a different pointer type.  This extension to the
19772 covariant return type rules is now deprecated and will be removed from a
19773 future version.
19775 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19776 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19777 and are now removed from G++.  Code using these operators should be
19778 modified to use @code{std::min} and @code{std::max} instead.
19780 The named return value extension has been deprecated, and is now
19781 removed from G++.
19783 The use of initializer lists with new expressions has been deprecated,
19784 and is now removed from G++.
19786 Floating and complex non-type template parameters have been deprecated,
19787 and are now removed from G++.
19789 The implicit typename extension has been deprecated and is now
19790 removed from G++.
19792 The use of default arguments in function pointers, function typedefs
19793 and other places where they are not permitted by the standard is
19794 deprecated and will be removed from a future version of G++.
19796 G++ allows floating-point literals to appear in integral constant expressions,
19797 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19798 This extension is deprecated and will be removed from a future version.
19800 G++ allows static data members of const floating-point type to be declared
19801 with an initializer in a class definition. The standard only allows
19802 initializers for static members of const integral types and const
19803 enumeration types so this extension has been deprecated and will be removed
19804 from a future version.
19806 @node Backwards Compatibility
19807 @section Backwards Compatibility
19808 @cindex Backwards Compatibility
19809 @cindex ARM [Annotated C++ Reference Manual]
19811 Now that there is a definitive ISO standard C++, G++ has a specification
19812 to adhere to.  The C++ language evolved over time, and features that
19813 used to be acceptable in previous drafts of the standard, such as the ARM
19814 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
19815 compilation of C++ written to such drafts, G++ contains some backwards
19816 compatibilities.  @emph{All such backwards compatibility features are
19817 liable to disappear in future versions of G++.} They should be considered
19818 deprecated.   @xref{Deprecated Features}.
19820 @table @code
19821 @item For scope
19822 If a variable is declared at for scope, it used to remain in scope until
19823 the end of the scope that contained the for statement (rather than just
19824 within the for scope).  G++ retains this, but issues a warning, if such a
19825 variable is accessed outside the for scope.
19827 @item Implicit C language
19828 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19829 scope to set the language.  On such systems, all header files are
19830 implicitly scoped inside a C language scope.  Also, an empty prototype
19831 @code{()} is treated as an unspecified number of arguments, rather
19832 than no arguments, as C++ demands.
19833 @end table
19835 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
19836 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr